Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Basic examples #13

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading