Skip to content

Preview Mix MigraDoc And PdfSharp #2

@godshades

Description

@godshades

Hi, I want combine both sample for preview the mix pdf
https://github.com/empira/MigraDoc-samples/tree/master/samples/wpf/MixMigraDocAndPdfSharp
https://github.com/empira/MigraDoc-samples/tree/master/samples/wpf/DocumentViewer

But when preview, it only show data from Migradoc
Here is my code:

PdfDocument pdfDocument = new PdfDocument();
PdfPage page = pdfDocument.AddPage();
page.Size = PdfSharp.PageSize.A4;
page.Orientation = PdfSharp.PageOrientation.Landscape;

XGraphics gfx = XGraphics.FromPdfPage(page);

XFont fontH1 = new XFont("Arial", 18, XFontStyle.Bold);
XFont font = new XFont("Arial", 12);
XFont fontItalic = new XFont("Arial", 12, XFontStyle.BoldItalic);
double ls = font.GetHeight();
// Draw some text
gfx.DrawString("Create PDF on the fly with PDFsharp",
fontH1, XBrushes.Black, x, x);

Document doc = new Document();
var sec = doc.AddSection();
sec.PageSetup.Orientation = Orientation.Landscape;
sec.PageSetup.PageFormat = PageFormat.A4;

var para = sec.AddParagraph();
para.Format.Alignment = ParagraphAlignment.Justify;
para.Format.Borders.Color = Colors.AliceBlue;
para.AddText("Migradoc");

var docRenderer = new DocumentRenderer(doc);
docRenderer.PrepareDocument();
docRenderer.RenderObject(gfx, XUnit.FromCentimeter(5), XUnit.FromCentimeter(10), "12cm", para);

var ddl = DdlWriter.WriteToString(doc);

Preview.Ddl = ddl

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions