Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri May 17, 2019 2:15 pm

Hi Support team,
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

PrintPro
 
Posts: 55
Joined: Tue Apr 16, 2019 6:17 pm

Mon May 20, 2019 8:18 am

Dear Christian,

Thank you for contacting us.
I noticed the issue that the page orientation "Landscape" didn't work if directly save to DOCX, HTML and SVG formats. I have submitted the issue to our Dev team for further investigation. If there is any update, we will inform you. Sorry for the inconvenience caused.

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Thu May 23, 2019 6:11 am

Hi,

After further investigation, the code you used to set the page orientation before didn't take effect. The reason is that it doesn't conform to the internal mechanism of setting the orientation in our Spire.PDF. The following code would make sense for the setting. Please use it instead.
Code: Select all
            PdfDocument doc = new PdfDocument();
            PdfPageSettings ps = new PdfPageSettings(PdfPageSize.A4, PdfPageOrientation.Landscape);
            PdfSection section = doc.Sections.Add(ps);
            section.PageSettings.Margins = new PdfMargins(0, 0, 0, 0);
            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));
            doc.SaveToFile("orientation.html", FileFormat.HTML);

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Thu May 23, 2019 1:44 pm

Hi Nancy,

changed the code - works like a charm :)

Thanks and KR

PrintPro
 
Posts: 55
Joined: Tue Apr 16, 2019 6:17 pm

Fri May 24, 2019 3:23 am

Hi,

Thanks for your feedback.
If there is anything we can do for you in the future, please do not hesitate to contact us.
Wish you all the best!

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Wed Sep 18, 2019 11:28 am

Hi,

Glad to inform that we just released Spire.PDF Pack(Hot Fix) Version:5.9.6 which supports setting the orientation using the code you reported originally. Welcome to download it from the following link.
Our website: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget: https://www.nuget.org/packages/Spire.PDF/5.9.6

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDF