Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Preview Mix MigraDoc And PdfSharp #2

Open
godshades opened this issue Jan 31, 2020 · 0 comments
Open

Preview Mix MigraDoc And PdfSharp #2

godshades opened this issue Jan 31, 2020 · 0 comments

Comments

@godshades
Copy link

godshades commented Jan 31, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant