Esempio n. 1
0
        /// <summary>
        /// The write plot.
        /// </summary>
        /// <param name="plot">
        /// The plot.
        /// </param>
        public void WritePlot(PlotFigure plot)
        {
            if (this.FileName == null)
            {
                return;
            }

            var directory = Path.GetDirectoryName(this.FileName);

            if (directory == null)
            {
                return;
            }

            var source = string.Format(
                "{0}_Plot{1}.pdf", Path.GetFileNameWithoutExtension(this.FileName), plot.FigureNumber);
            var sourceFullPath = Path.Combine(directory, source);

            PdfExporter.Export(plot.PlotModel, sourceFullPath, plot.Width, plot.Height);

            var p = this.WriteStartFigure(plot);

            MigraDoc.DocumentObjectModel.Shapes.Image pi = p.AddImage(sourceFullPath);
            pi.Width = Unit.FromCentimeter(15);

            this.WriteEndFigure(plot, p);
        }
Esempio n. 2
0
        /// <summary>
        /// Exports the specified model to a stream.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="stream">The output stream.</param>
        /// <param name="width">The width (points).</param>
        /// <param name="height">The height (points).</param>
        public static void Export(IPlotModel model, Stream stream, double width, double height)
        {
            var exporter = new PdfExporter {
                Width = width, Height = height, Background = model.Background
            };

            exporter.Export(model, stream);
        }
Esempio n. 3
0
 public void Export_Unicode()
 {
     var model = new PlotModel { Title = "Unicode support ☺", DefaultFont = "Arial" };
     model.Axes.Add(new LinearAxis { Title = "λ", Position = AxisPosition.Bottom });
     model.Axes.Add(new LinearAxis { Title = "Ж", Position = AxisPosition.Left });
     var exporter = new PdfExporter { Width = 400, Height = 400 };
     using (var stream = File.OpenWrite("Unicode.pdf"))
     {
         exporter.Export(model, stream);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Writes the specified plot.
        /// </summary>
        /// <param name="plot">The plot.</param>
        void IReportWriter.WritePlot(PlotFigure plot)
        {
            var temporaryPlotFileName = Guid.NewGuid() + ".pdf";

            this.temporaryPlotFiles.Add(temporaryPlotFileName);
            PdfExporter.Export(plot.PlotModel, temporaryPlotFileName, plot.Width, plot.Height);

            var p = this.WriteStartFigure(plot);

            MigraDoc.DocumentObjectModel.Shapes.Image pi = p.AddImage(temporaryPlotFileName);
            pi.Width = Unit.FromCentimeter(15);

            this.WriteEndFigure(plot, p);
        }
Esempio n. 5
0
 /// <summary>
 /// Exports the specified model to a stream.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="stream">The output stream.</param>
 /// <param name="width">The width (points).</param>
 /// <param name="height">The height (points).</param>
 public static void Export(IPlotModel model, Stream stream, double width, double height)
 {
     var exporter = new PdfExporter { Width = width, Height = height, Background = model.Background };
     exporter.Export(model, stream);
 }