diff --git a/src/ACadSharp.Pdf.Examples/PdfExporterExamples.cs b/src/ACadSharp.Pdf.Examples/PdfExporterExamples.cs new file mode 100644 index 0000000..4b23c75 --- /dev/null +++ b/src/ACadSharp.Pdf.Examples/PdfExporterExamples.cs @@ -0,0 +1,35 @@ +namespace ACadSharp.Pdf.Examples +{ + public static class PdfExporterExamples + { + /// + /// Example of how to print the model space in a pdf page. + /// + /// + /// + public static void AddModelSpace(CadDocument document, string pdfPath) + { + PdfExporter exporter = new PdfExporter(pdfPath); + + //Add the model space into the file, page size will be adapted to include all entities + exporter.AddModelSpace(document); + + exporter.Close(); + } + + /// + /// Example of how to add all paper layouts into the pdf document. + /// + /// + /// + public static void AddPaperLayout(CadDocument document, string pdfPath) + { + PdfExporter exporter = new PdfExporter(pdfPath); + + //Add all paper layouts in the pdf document + exporter.AddPaperLayouts(document); + + exporter.Close(); + } + } +} diff --git a/src/ACadSharp.Pdf.Examples/Program.cs b/src/ACadSharp.Pdf.Examples/Program.cs index 9db5b82..5b8bed7 100644 --- a/src/ACadSharp.Pdf.Examples/Program.cs +++ b/src/ACadSharp.Pdf.Examples/Program.cs @@ -5,21 +5,21 @@ namespace ACadSharp.Pdf.Examples { internal class Program { - private const string _folder = "..\\\\..\\\\..\\\\..\\\\..\\\\samples"; - private const string _outFolder = "..\\\\..\\\\..\\\\..\\\\..\\\\samples\\\\out"; + const string _file = "../../../../../samples/export_sample.dwg"; static void Main(string[] args) { - CadDocument doc = DwgReader.Read(Path.Combine(_folder, "export_sample.dwg"), NotificationHelper.LogConsoleNotification); + CadDocument doc = DwgReader.Read(_file, NotificationHelper.LogConsoleNotification); - string filename = Path.Combine(_folder, "export_sample_output.pdf"); + string filename = Path.ChangeExtension(_file, ".pdf"); PdfExporter exporter = new PdfExporter(filename); + exporter.Configuration.OnNotification += NotificationHelper.LogConsoleNotification; - //exporter.OnNotification += NotificationHelper.LogConsoleNotification; - + //Add the model space as a page exporter.Add(doc.ModelSpace); + //Save and close the pdf exporter.Close(); } }