when using page orientation "Landscape" in combination with sections - all none pdf exports (DOCX, HTML,SVG,...) are wrong.
Workaround (but no solution due to performance reason) is: Save the document as pdf - then saveToFile() works for all other formats correct.
- Code: Select all
//DOC
PdfDocument doc = new PdfDocument();
PdfSection section = doc.Sections.Add();
section.PageSettings.Margins = new PdfMargins(0, 0, 0, 0);
section.PageSettings.Size = PdfPageSize.A4;
section.PageSettings.Orientation = PdfPageOrientation.Landscape; //LANDSCAPE !!!
//NEW PAGE
PdfNewPage page = section.Pages.Add();
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
PdfFontBase fontFamily = new PdfTrueTypeFont(new Font("Arial", 15), true);
page.Canvas.DrawString("SUPPOSED TO BE TOP LEFT", fontFamily, brush,new PointF(10,20));
//Just remove below comment and orientation works in all other formats
//doc.SaveToFile("orientation.pdf");
doc.SaveToFile("orientation.docx", FileFormat.DOCX);
regards Christian