private PdfPage Add(PdfDocument pdf, Core2D.Project.XContainer container) { // Create A3 page size with Landscape orientation. PdfPage pdfPage = pdf.AddPage(); pdfPage.Size = PageSize.A3; pdfPage.Orientation = PageOrientation.Landscape; using (XGraphics gfx = XGraphics.FromPdfPage(pdfPage)) { // Calculate x and y page scale factors. double scaleX = pdfPage.Width.Value / container.Template.Width; double scaleY = pdfPage.Height.Value / container.Template.Height; double scale = Math.Min(scaleX, scaleY); // Set scaling function. _scaleToPage = (value) => value * scale; // Draw container template contents to pdf graphics. if (container.Template.Background.A > 0) { Fill(gfx, 0, 0, pdfPage.Width.Value / scale, pdfPage.Height.Value / scale, container.Template.Background); } // Draw template contents to pdf graphics. Draw(gfx, container.Template, 0.0, 0.0, container.Data.Properties, container.Data.Record); // Draw page contents to pdf graphics. Draw(gfx, container, 0.0, 0.0, container.Data.Properties, container.Data.Record); } return(pdfPage); }
/// <inheritdoc/> void Core2D.Interfaces.IProjectExporter.Save(string path, Core2D.Project.XContainer container) { using (var pdf = new PdfDocument()) { Add(pdf, container); pdf.Save(path); } }
/// <inheritdoc/> void Core2D.Interfaces.IProjectExporter.Save(string path, Core2D.Project.XContainer container) { _outputPath = System.IO.Path.GetDirectoryName(path); var dxf = new DxfDocument(DxfVersion.AutoCad2010); Add(dxf, container); dxf.Save(path); ClearCache(isZooming: false); }
private void Add(DxfDocument dxf, Core2D.Project.XContainer container) { if (container.Template != null) { _pageWidth = container.Template.Width; _pageHeight = container.Template.Height; Draw(dxf, container.Template, container.Data.Properties, container.Data.Record); } else { throw new NullReferenceException("Container template must be set."); } Draw(dxf, container, container.Data.Properties, container.Data.Record); }
/// <inheritdoc/> public override void Draw(object dc, Core2D.Project.XContainer container, ImmutableArray <Core2D.Data.XProperty> db, Core2D.Data.Database.XRecord r) { var dxf = dc as DxfDocument; foreach (var layer in container.Layers) { var dxfLayer = new Layer(layer.Name) { IsVisible = layer.IsVisible }; dxf.Layers.Add(dxfLayer); _currentLayer = dxfLayer; Draw(dc, layer, db, r); } }