public async Task <IActionResult> ExporterPdf() { // IExporter exporter11 = new ExcelExporter(); IExportListFileByTemplate exporter = new PdfExporter(); var result = await exporter.ExportListByTemplate(Path.Combine("wwwroot", "test.pdf"), new List <StudentPdf>() { new StudentPdf { Name = "MR.A", Age = 18, Remarks = "我叫MR.A,今年18岁", Birthday = DateTime.Now }, new StudentPdf { Name = "MR.B", Age = 19, Remarks = "我叫MR.B,今年19岁", Birthday = DateTime.Now }, new StudentPdf { Name = "MR.C", Age = 20, Remarks = "我叫MR.C,今年20岁", Birthday = DateTime.Now } }).ConfigureAwait(false); return(File("test.pdf", "application/pdf", result.FileName)); }
// [ref] ${OxyPlot_HOME}/NET45/Examples/ExampleBrowser/ExampleBrowser.exe. static void runWorldPopulation() { var plotModel = new PlotModel(); plotModel.Title = "World population by continent"; var pieSeries1 = new PieSeries(); pieSeries1.InsideLabelPosition = 0.8; pieSeries1.StrokeThickness = 2; pieSeries1.Slices.Add(new PieSlice("Africa", 15.0)); pieSeries1.Slices.Add(new PieSlice("Americas", 13.0)); pieSeries1.Slices.Add(new PieSlice("Asia", 60.0)); pieSeries1.Slices.Add(new PieSlice("Europe", 11.0)); pieSeries1.Slices.Add(new PieSlice("Oceania", 1.0)); plotModel.Series.Add(pieSeries1); // String output_filename = "../data/visualization/oxyplot/pieseries_world_population.pdf"; using (var stream = File.Create(output_filename)) { PdfExporter.Export(plotModel, stream, 600, 400); } }
//Зберігає графік в форматі pdf private void pdfToolStripMenuItem_Click(object sender, EventArgs e) { //if there is no graph drawn show error message if ((Graph.graphList != null) && (!Graph.graphList.Any())) { string message = rm.GetString("NoGraph"); string title = rm.GetString("Error"); MessageBox.Show(message, title); } else { SaveFileDialog saveFile = new SaveFileDialog(); string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); //desktop path saveFile.InitialDirectory = desktop; saveFile.Filter = "Pdf Files(*.pdf) |*.pdf;"; saveFile.Title = rm.GetString("SaveImg"); saveFile.FileName = "graph"; saveFile.AddExtension = true; saveFile.DefaultExt = "pdf"; saveFile.FilterIndex = 2; saveFile.RestoreDirectory = true; if (saveFile.ShowDialog() == DialogResult.OK) { var pdfExporter = new PdfExporter { Width = 600, Height = 400, Background = OxyColors.White }; pdfExporter.ExportToFile(myModel, saveFile.FileName); } } }
public async Task GetPdf(DataSourceRequest dataSourceRequest, bool allPages, bool useExcelGeneration) { if (allPages) { dataSourceRequest.PageSize = 0; dataSourceRequest.Skip = 0; // for virtualization } IQueryable <WeatherForecast> queriableData = await MyDataService.GetForecasts(); var pdfExporter = new PdfExporter(); byte[] fileData = null; if (useExcelGeneration) { fileData = await pdfExporter.ExportWithRadSpreadProcessing(queriableData, dataSourceRequest); } else { fileData = await pdfExporter.ExportWithRadPdfProcessing(queriableData, dataSourceRequest); } string base64File = Convert.ToBase64String(fileData); //you can write the generated file to the file system to troubleshoot downloading issues //System.IO.File.WriteAllBytes("C:\\temp\\test.pdf", fileData); await jsRuntime.InvokeVoidAsync("saveFile", base64File, "application/pdf", "TelerikGridExport.pdf"); }
public async Task ExportReceipt_Test() { var tplPath = Path.Combine(Directory.GetCurrentDirectory(), "TestFiles", "ExportTemplates", "receipt.cshtml"); var tpl = File.ReadAllText(tplPath); var exporter = new PdfExporter(); var filePath = Path.Combine(Directory.GetCurrentDirectory(), nameof(ExportReceipt_Test) + ".pdf"); if (File.Exists(filePath)) { File.Delete(filePath); } //此处使用默认模板导出 var result = await exporter.ExportByTemplate(filePath, new ReceiptInfo() { Amount = 22939.43M, Grade = "2019秋", IdNo = "43062619890622xxxx", Name = "张三", Payee = "湖南心莱信息科技有限公司", PaymentMethod = "微信支付", Profession = "运动训练", Remark = "学费", TradeStatus = "已完成", TradeTime = DateTime.Now, UppercaseAmount = "贰万贰仟玖佰叁拾玖圆肆角叁分", Code = "19071800001" }, tpl); result.ShouldNotBeNull(); File.Exists(filePath).ShouldBeTrue(); }
///------------------------------------------ OXYPLOT save pdf FUNCTION ------------------------------------------------------- public async Task save_oxyplot() { try { var model2 = (DataContext as MainViewModel).MazePosModel; string current_time = DateTime.Now.ToString("dd-MM-yyyy_hh-mm-ss"); string plot_save_name = "OxyPlot_" + current_time + ".pdf"; var oxy_file = await mainFolder.CreateFileAsync(plot_save_name, CreationCollisionOption.GenerateUniqueName); var oxy_outputStream = await oxy_file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite); using (Stream stream = oxy_outputStream.AsStream()) { var pdfExporter = new PdfExporter { Width = 600, Height = 600 }; pdfExporter.Export(model2, stream); } func_plot_saved_success = true; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Save Oxyplot error" + ex.Message); } }
private void ExportPlotAsPdf(PlotView plotView, PlotModel plotModel) { SaveFileDialog saveFileDialog = new SaveFileDialog { Title = "Export to PDF", Filter = "PDF Files (*.pdf)|*.pdf" }; if (saveFileDialog.ShowDialog() == true) { try { using (var stream = File.Create(saveFileDialog.FileName)) { double width = 600.0; // Fix the width, but determine the height double height = width * (plotView.ActualHeight / plotView.ActualWidth); PdfExporter.Export(plotModel, stream, width, height); } } catch (Exception ex) { _mainViewModel.NotifyUserMessaged("Unable to export to a PDF file. " + ex.Message, UserMessageType.Error); } } }
private void SaveGraphButton_Click(object sender, RoutedEventArgs e) { SaveFileDialog dlg = new SaveFileDialog() { Filter = "Portable Network Graphics (*.png)|*.png|Portable Document Format (*.pdf)|*.pdf|Scalable Vector Graphics (*.svg)|*.svg", RestoreDirectory = true }; if (dlg.ShowDialog() == true) { if (File.Exists(dlg.FileName)) { try { File.Delete(dlg.FileName); } catch (IOException) { MessageBox.Show("Cannot access the file " + dlg.FileName + " because it is being used by another process.", Application.Current.MainWindow.Title, MessageBoxButton.OK, MessageBoxImage.Warning); } } switch (dlg.FileName.Substring(dlg.FileName.LastIndexOf('.'))) { case ".png": PngExporter pngExporter = new PngExporter(); using (FileStream fileStream = File.OpenWrite(dlg.FileName)) { pngExporter.Export(MainPlotView.Model, fileStream); } break; case ".pdf": PdfExporter pdfExporter = new PdfExporter(); using (FileStream fileStream = File.OpenWrite(dlg.FileName)) { pdfExporter.Export(MainPlotView.Model, fileStream); } break; case ".svg": OxyPlot.SvgExporter svgExporter = new OxyPlot.SvgExporter(); using (FileStream fileStream = File.OpenWrite(dlg.FileName)) { svgExporter.Export(MainPlotView.Model, fileStream); } break; default: break; } } }
public void ExportToFiles() { _app.Dispatcher.Invoke(() => { foreach (var keyValuePair in _tabControls) { var tabControl = keyValuePair.Value; var tabItems = tabControl.Items.OfType <TabItem>(); foreach (var tabItem in tabItems) { switch (tabItem.Content) { case PlotView plotView: { var fileName = $"{tabItem.Header as string}" + ".pdf"; using var stream = new FileStream(Path.Combine(_capitalGainReportSaver.SavingFolder, fileName), FileMode.Append, FileAccess.Write, FileShare.None); var pdfExporter = new PdfExporter { Width = tabControl.ActualWidth, Height = tabControl.ActualHeight }; pdfExporter.Export(plotView.Model, stream); break; } } } } }); }
public void saveChart(List <Individual> individuals) { var line1 = new OxyPlot.Series.LineSeries { Title = $"Y", Color = OxyColors.Blue, StrokeThickness = 1, MarkerSize = 2, MarkerType = MarkerType.Circle }; for (int i = 0; i < individuals.Count; i++) { line1.Points.Add(new DataPoint(i + 1, individuals[i].FunctionResult)); } var model = new PlotModel { Title = $"wykres wartosci funkcji w zaleznosci od epok", }; model.Series.Add(line1); var chartName = Directory.GetCurrentDirectory() + "\\results\\chart" + DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss") + ".pdf"; using (var stream = File.Create(chartName)) { var pdfExporter = new PdfExporter { Width = 600, Height = 400 }; pdfExporter.Export(model, stream); }; }
public void ExportPDF() { string pasta; string caminho; pasta = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; if (!Directory.Exists(Path.Combine(pasta, "ErgoMobile", "Exported", "temp"))) { Directory.CreateDirectory(Path.Combine(pasta, "ErgoMobile", "Exported", "temp")); } for (int i = 0; i < respostas.Lista.Count; i++) { char c = (char)(41 + i); caminho = Path.Combine(pasta, "ErgoMobile", "Exported", "temp", (i + 1) + c + ".pdf"); using (var stream = File.Create(caminho)) { //595 842 298 421 var pdfExporter = new PdfExporter { Width = 595, Height = 842 }; pdfExporter.Export(CreateCategoryModel(i), stream); stream.Close(); stream.Dispose(); } WriteAbout(i); } }
/// <summary> /// Saves the plot as a .png and returns the URL. /// </summary> /// <returns>The URL</returns> public string DrawPlot() { BarSeries.ItemsSource = Categories.Values.Select(x => new OxyPlot.Series.BarItem(x)); using (var stream = File.Create($"mopsdata//{ID}barplot.pdf")) { var pdfExporter = new PdfExporter { Width = 800, Height = 400 }; pdfExporter.Export(viewerChart, stream); } using (var prc = new System.Diagnostics.Process()) { prc.StartInfo.FileName = "convert"; prc.StartInfo.Arguments = $"-set density 300 \"mopsdata//{ID}barplot.pdf\" \"//var//www//html//StreamCharts//{ID}barplot.png\""; prc.Start(); prc.WaitForExit(); } var dir = new DirectoryInfo("mopsdata//"); var files = dir.GetFiles().Where(x => x.Name.Contains($"{ID}barplot")); foreach (var f in files) { f.Delete(); } return($"{Program.Config["ServerAddress"]}/StreamCharts/{ID.Replace(" ", "%20")}barplot.png?rand={StaticBase.ran.Next(0, 999999999)}"); }
public void ExportPdf() { string text = this.Filename; if (string.IsNullOrEmpty(text)) { text = this.Title; } SaveFileDialog saveFileDialog = new SaveFileDialog { Filter = this.SavePdfFileTypes, FileName = System.IO.Path.GetFileNameWithoutExtension(text), RestoreDirectory = true }; bool? flag = saveFileDialog.ShowDialog(); string fileName = saveFileDialog.FileName; if (!flag.Value || string.IsNullOrEmpty(fileName)) { return; } EditorRenderer._logger.Trace("Exporting PDF document: " + fileName); HtmlTemplate htmlTemplate = this.HtmlTemplate; htmlTemplate.UseBaseRelativeImageWorkaround = true; string content = htmlTemplate.GenerateHtmlTemplate(false); PdfExporter pdfExporter = new PdfExporter(fileName, content) { IncludeCssBackground = this._settings.IO_Pdf_IncludeBackground, EnableOutlineGeneration = this._settings.IO_Pdf_EnableOutlineGeneration }; pdfExporter.ExportPdf(); }
protected void PrintThrouputGraph(Dictionary <DateTime, double> data, string fileName, int timeResolutionInSeconds) { var stringBuffer = new StringBuilder(); var model = new PlotModel { Title = "AWS throuput in time (items finished/second)" }; var timeAxis = new DateTimeAxis { StringFormat = "hh:mm:ss" }; model.Axes.Add(timeAxis); var series = new LineSeries(); foreach (var log in data.OrderBy(l => l.Key)) { stringBuffer.AppendFormat("{0},{1}{2}", log.Value / timeResolutionInSeconds, log.Key, Environment.NewLine); series.Points.Add(new DataPoint(DateTimeAxis.ToDouble(log.Key), log.Value / timeResolutionInSeconds)); } model.Series.Add(series); using (var stream = File.Create(fileName)) { var pdfExporter = new PdfExporter { Width = 600, Height = 400 }; pdfExporter.Export(model, stream); } }
private void SavePlot_Click(object sender, RoutedEventArgs e) { var dlg = new SaveFileDialog(); dlg.Filter = ".svg files|*.svg|.png files|*.png|.pdf files|*.pdf|.xaml files|*.xaml"; dlg.DefaultExt = ".svg"; if (dlg.ShowDialog(this).Value) { var ext = Path.GetExtension(dlg.FileName).ToLower(); switch (ext) { case ".png": plot1.SaveBitmap(dlg.FileName); break; case ".svg": var rc = new ShapesRenderContext(null); var svg = vm.Model.ToSvg(plot1.ActualWidth, plot1.ActualHeight, false, rc); File.WriteAllText(dlg.FileName, svg); break; case ".pdf": PdfExporter.Export(vm.Model, dlg.FileName, plot1.ActualWidth, plot1.ActualHeight); break; case ".xaml": plot1.SaveXaml(dlg.FileName); break; } OpenContainingFolder(dlg.FileName); } }
static void Main(string[] args) { var pm = new PlotModel { Title = "Test" }; pm.Axes.Add(new LinearAxis { Title = "Bottom", Position = AxisPosition.Bottom, AxisTitleDistance = 10 }); pm.Axes.Add(new LinearAxis { Title = "Left", Position = AxisPosition.Left }); pm.Series.Add(new FunctionSeries(Math.Sin, 0, 10, 0.01)); var e = new PdfExporter(); e.Width = 800; e.Height = 500; e.Background = OxyColors.LightBlue; var path = "test.pdf"; using (var stream = File.Create(path)) e.Export(pm, stream); // Process.Start(path); }
public void ExportPDF() { const string DestinationDirectory = @"c:\variandeveloper"; if (!Directory.Exists(DestinationDirectory)) { Directory.CreateDirectory(DestinationDirectory); } // A4 const double Width = 297 / 25.4 * 72; const double Height = 210 / 25.4 * 72; if (plotModel == null) { return; } var path = Path.Combine(DestinationDirectory, StringHelper.CreateValidFileName("test", ".pdf")); using (var s = File.Create(path)) { try { PdfExporter.Export(plotModel, s, Width, Height); } catch (Exception ex) { //Debug.Assert.Fail(ex.Message); } } //Debug.Assert.IsTrue(File.Exists(path)); }
public void ExportPlotAsPdf(string filePath) { using (var stream = File.Create(filePath)) { PdfExporter.Export(PlotModel, stream, 600, 400); } }
public void Export_AllExamplesInExampleLibrary_CheckThatAllFilesExist() { var destinationDirectory = Path.Combine(TestContext.CurrentContext.WorkDirectory, "PdfExporterTests_ExampleLibrary"); if (!Directory.Exists(destinationDirectory)) { Directory.CreateDirectory(destinationDirectory); } // A4 const double Width = 297 / 25.4 * 72; const double Height = 210 / 25.4 * 72; foreach (var example in Examples.GetList()) { void ExportModelAndCheckFileExists(PlotModel model, string fileName) { if (model == null) { return; } var path = Path.Combine(destinationDirectory, FileNameUtilities.CreateValidFileName(fileName, ".pdf")); using (var s = File.Create(path)) { PdfExporter.Export(model, s, Width, Height); } Assert.IsTrue(File.Exists(path)); } ExportModelAndCheckFileExists(example.PlotModel, $"{example.Category} - {example.Title}"); } }
/// <summary> /// Exports the plot to a .pdf file. /// </summary> public void ExportToPdf(string path, double width = 800, double height = 600) { using (var s = File.Create(path)) { PdfExporter.Export(Model, s, width, height); } }
/// <summary> /// Zapisuje wykres do PDFu /// </summary> private void SaveToPdf() { string filePath = string.Empty; SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "PNG Files (*.png)|*.png|PDF Files (*.pdf)|*.pdf "; if (saveFileDialog.ShowDialog() == true) { filePath = saveFileDialog.FileName; if (filePath.Contains("pdf")) { using (var stream = File.Create(filePath)) { string tmp = ChartViewModel.PlotModel.Title; tmp = tmp.Replace("ł", "l"); tmp = tmp.Replace("ś", "s"); ChartViewModel.PlotModel.Title = tmp; PdfExporter.Export(ChartViewModel.PlotModel, stream, 600, 400); } } else { using (var stream = File.Create(filePath)) { PngExporter.Export(ChartViewModel.PlotModel, stream, 750, 550, OxyColor.FromArgb(250, 250, 250, 250)); } } } }
public static void Main() { var db = new FurnitureFactoryDbContext(); Utils.IUserInterfaceHandlerIO io = new ConsoleUserInterfaceIO(); var mongodata = new MongoDbData(DatabaseName, io); mongodata.Import(db); // Task 1. Load excel from zip LoadSalesReports(SourceSalesReportsArchiveFilePath); new MaterialsXmlImporter().Import(); new ProductionDetailsXmlImporter().Import(); new RoomsXmlMongoImporter().Import(io); PdfExporter pdfExporter = new PdfExporter(db); pdfExporter.GeneratePdf(); // Task 4.1 var jsonReporter = new JsonProductsReporter(db); jsonReporter.GetJsonReport().Load(); // Task 4.2 //var mySqlImporter = new SalesReportsMySqlImporter(io); //mySqlImporter.Save(); //// Task 3. Generate Xml Report in Xml-Exports folder var productXmlReport = new ProductsXmlFileExporter(db); productXmlReport.GetXmlReport(); var ordersXmlReport = new OrdersXmlFileExporter(db); ordersXmlReport.GetXmlReport(); }
public void SaveToPdf(string fileName, double x, double y) { using (var stream = File.Create(fileName)) { PdfExporter.Export(model, stream, x, y); } }
private void CreatePlotPdf_Click(object sender, RoutedEventArgs e) { var selectedItem = HistogramComboBox.SelectedItem; if (selectedItem == null) { MessageBox.Show("Select a plot type to export!"); return; } var plotName = selectedItem as string; //var fileDirectory = Directory.GetParent(tsvResultsFilePath).ToString(); var fileDirectory = ""; var fileName = String.Concat(plotName, ".pdf"); // update font sizes to exported PDF's size double tmpW = plotViewStat.Width; double tmpH = plotViewStat.Height; plotViewStat.Width = 1000; plotViewStat.Height = 700; plotViewStat.UpdateLayout(); using (Stream writePDF = File.Create(Path.Combine(fileDirectory, fileName))) { PdfExporter.Export(plotViewStat.Model, writePDF, 1000, 700); } plotViewStat.Width = tmpW; plotViewStat.Height = tmpH; MessageBox.Show("PDF Created at " + Path.Combine(fileDirectory, fileName) + "!"); }
public void Export_AllExamplesInExampleLibrary_CheckThatAllFilesExist() { const string DestinationDirectory = "PdfExporterTests_ExampleLibrary"; if (!Directory.Exists(DestinationDirectory)) { Directory.CreateDirectory(DestinationDirectory); } // A4 const double Width = 297 / 25.4 * 72; const double Height = 210 / 25.4 * 72; foreach (var example in Examples.GetList()) { if (example.PlotModel == null) { continue; } var path = Path.Combine(DestinationDirectory, FileNameUtilities.CreateValidFileName(example.Category + " - " + example.Title, ".pdf")); using (var s = File.Create(path)) { PdfExporter.Export(example.PlotModel, s, Width, Height); } Assert.IsTrue(File.Exists(path)); } }
private void CreatePlotPdf_Click(object sender, RoutedEventArgs e) { var selectedItem = plotsListBox.SelectedItem; if (selectedItem == null) { MessageBox.Show("Select a plot type to export!"); return; } if (!filteredListOfPsms.Any()) { MessageBox.Show("No PSMs are loaded!"); return; } var plotName = selectedItem as string; PlotModelStat plot = new PlotModelStat(plotName, filteredListOfPsms); var fileDirectory = Directory.GetParent(tsvResultsFilePath).ToString(); var fileName = String.Concat(plotName, ".pdf"); using (Stream writePDF = File.Create(Path.Combine(fileDirectory, fileName))) { PdfExporter.Export(plot.Model, writePDF, 1000, 700); } MessageBox.Show("PDF Created at " + Path.Combine(fileDirectory, fileName) + "!"); }
public async Task <bool> HandleSuccessfulReqeustAsync(HttpContext context, object body, Type type, string tplPath) { var contentType = ""; string filename = DateTime.Now.ToString("yyyyMMddHHmmss"); byte[] result = null; switch (context.Request.Headers["Magicodes-Type"]) { case HttpContentMediaType.XLSXHttpContentMediaType: filename += ".xlsx"; var dt = ToDataTable(body?.ToString()); contentType = HttpContentMediaType.XLSXHttpContentMediaType; var exporter = new ExcelExporter(); result = await exporter.ExportAsByteArray(dt, type); break; case HttpContentMediaType.PDFHttpContentMediaType: filename += ".pdf"; contentType = HttpContentMediaType.PDFHttpContentMediaType; IExportFileByTemplate pdfexporter = new PdfExporter(); var tpl = await File.ReadAllTextAsync(tplPath); var obj = JsonConvert.DeserializeObject(body.ToString(), type); result = await pdfexporter.ExportBytesByTemplate(obj, tpl, type); break; case HttpContentMediaType.HTMLHttpContentMediaType: filename += ".html"; contentType = HttpContentMediaType.HTMLHttpContentMediaType; IExportFileByTemplate htmlexporter = new HtmlExporter(); result = await htmlexporter.ExportBytesByTemplate(JsonConvert.DeserializeObject(body.ToString(), type), await File.ReadAllTextAsync(tplPath), type); break; case HttpContentMediaType.DOCXHttpContentMediaType: filename += ".docx"; contentType = HttpContentMediaType.DOCXHttpContentMediaType; IExportFileByTemplate docxexporter = new WordExporter(); result = await docxexporter.ExportBytesByTemplate(JsonConvert.DeserializeObject(body.ToString(), type), await File.ReadAllTextAsync(tplPath), type); break; } if (contentType != "") { context.Response.Headers.Add("Content-Disposition", $"attachment;filename={filename}"); context.Response.ContentType = contentType; if (result != null) { await context.Response.Body.WriteAsync(result, 0, result.Length); } } else { return(false); } return(true); }
public void Export() { using (var stream = File.Create("Plot.pdf")) { var pdfExporter = new PdfExporter { Width = 600, Height = 400 }; pdfExporter.Export(_plotModel, stream); } }
private void button_Click(object sender, RoutedEventArgs e) { var context = new WayneCarCorpsContext(); var pdfExporter = new PdfExporter(new EfRepository <Sale>(context)); pdfExporter.CreatePdfTable(); }
private static void CreatePdfExporter(FileStream stream, out PdfExporter pdfExporter, out GraphicsConfig config) { pdfExporter = new PdfExporter(stream); pdfExporter.EmbedFonts = true; config = (GraphicsConfig)GraphicsConfig.WhiteBackgroundCorrectForBackColor.Clone(); config.DisplayLineTypeElementShapes = true; config.TryDrawingTextAsText = true; }
public void Export_SomeExamplesInExampleLibrary_CheckThatAllFilesExist() { var exporter = new PdfExporter { Width = 297 / 25.4f * 72, Height = 210 / 25.4f * 72 }; var directory = Path.Combine(this.outputDirectory, "ExampleLibrary"); ExportTest.Export_FirstExampleOfEachExampleGroup_CheckThatAllFilesExist(exporter, directory, ".pdf"); }
/// <summary> /// Экпорт диаграммы в один из типов /// </summary> /// <param name="type">Тип для экспорта</param> public void ExportDiagram(ExportType type) { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Filter = type + " файлы (*." + type + ")|*." + type; bool? result = saveDialog.ShowDialog(); if (result == true) switch (type) { case ExportType.pdf: PdfExporter pdfExporter = new PdfExporter(); pdfExporter.Export(DiagramNetwork, saveDialog.FileName); break; case ExportType.svg: SvgExporter svgExporter = new SvgExporter(); svgExporter.Export(DiagramNetwork, saveDialog.FileName); break; } }
public static void Main() { DataExporter exporter = null; // Lets export the data to Excel file exporter = new ExcelExporter(); exporter.ExportFormatedData(); Console.WriteLine(); // Lets export the data to PDF file exporter = new PdfExporter(); exporter.ExportFormatedData(); Console.WriteLine(); // Lets export the data to Word file exporter = new WordExporter(); exporter.ExportFormatedData(); }
public void Export(string outfile) { //string outfile = sfd.FileName;//= Path.GetFileNameWithoutExtension(Path.GetFullPath(filename)); Stream stream; BoundsCalculator boundsCalculator = new BoundsCalculator(); boundsCalculator.GetBounds(model); Bounds3D bounds = boundsCalculator.Bounds; PaperSize paperSize = PaperSizes.GetPaperSize(PaperKind.Letter); // Lengths in inches. float pageWidth = (float)paperSize.Width / 100f; float pageHeight = (float)paperSize.Height / 100f; float margin = 0.5f; // Scale and transform such that its fits max width/height // and the top left middle of the cad drawing will match the // top middle of the pdf page. // The transform transforms to pdf pixels. Matrix4D to2DTransform = DxfUtil.GetScaleTransform( bounds.Corner1, bounds.Corner2, new Point3D(bounds.Center.X, bounds.Corner2.Y, 0d), new Point3D(new Vector3D(margin, margin, 0d) * PdfExporter.InchToPixel), new Point3D(new Vector3D(pageWidth - margin, pageHeight - margin, 0d) * PdfExporter.InchToPixel), new Point3D(new Vector3D(pageWidth / 2d, pageHeight - margin, 0d) * PdfExporter.InchToPixel) ); using (stream = File.Create(outfile)) { PdfExporter pdfGraphics = new PdfExporter(stream); pdfGraphics.DrawPage( model, GraphicsConfig.WhiteBackgroundCorrectForBackColor, to2DTransform, paperSize ); pdfGraphics.EndDocument(); } }