Skip to content

Commit

Permalink
Merge pull request #13 from DomCR/basic-examples
Browse files Browse the repository at this point in the history
Basic examples
  • Loading branch information
DomCR authored Nov 4, 2024
2 parents de57fc4 + 6fab474 commit d99640c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
35 changes: 35 additions & 0 deletions src/ACadSharp.Pdf.Examples/PdfExporterExamples.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace ACadSharp.Pdf.Examples
{
public static class PdfExporterExamples
{
/// <summary>
/// Example of how to print the model space in a pdf page.
/// </summary>
/// <param name="document"></param>
/// <param name="pdfPath"></param>
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();
}

/// <summary>
/// Example of how to add all paper layouts into the pdf document.
/// </summary>
/// <param name="document"></param>
/// <param name="pdfPath"></param>
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();
}
}
}
12 changes: 6 additions & 6 deletions src/ACadSharp.Pdf.Examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down

0 comments on commit d99640c

Please # to comment.