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.

Sat Apr 16, 2016 11:16 pm

Page orientation is not being saved in the objects in PdfDocument.Pages. I have set each page to landscape when I create them. The instance of PdfPages that is returned has the landscape orientation, however I then use a for each loops to iterate though the Pages collection to add a header and a footer. The problem is that when I try to add new content to the canvas, its size as reverted back to portrait so my origin point is about 300 pixels above the page. This is very frustration. Any help would be very appreciated.

[email protected]
 
Posts: 6
Joined: Sat Apr 16, 2016 11:06 pm

Mon Apr 18, 2016 7:06 am

Hi,

Thanks for your posting.
I did a testing according to your issue describe but didn't reproduce your issue and the page Orientation still was ok after adding header and footer. To help us check your issue and work out a solution for you soon, please share all your code.
Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Mon Apr 18, 2016 1:03 pm

These seems to be the only relevant code.

This is what I had when I was having problems.
Code: Select all
        PdfDocument document = new PdfDocument();
        PdfPageBase page = document.Pages.Add(PdfPageSize.A4, margin, PdfPageRotateAngle.RotateAngle0, PdfPageOrientation.Landscape);


To fix it I did this
Code: Select all
            PdfDocument document = new PdfDocument
            {
                PageSettings =
                {
                    Orientation = PdfPageOrientation.Landscape,
                    Rotate = PdfPageRotateAngle.RotateAngle0,
                    Size = PdfPageSize.A4
                }
            };

            PdfPageBase page = document.Pages.Add();

[email protected]
 
Posts: 6
Joined: Sat Apr 16, 2016 11:06 pm

Tue Apr 19, 2016 2:15 am

Hi,

Thanks for sharing further information.
Did you mean that your issue was resolved by adjusting to the second part code?
If I misunderstand it and your issue still exists, please share your all code includes the code how to add header and footer then causing the Page Orientation issue.

Thank you.
Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Tue Apr 19, 2016 1:06 pm

Yes that is correct the changes in second code box fixed my problem.

[email protected]
 
Posts: 6
Joined: Sat Apr 16, 2016 11:06 pm

Wed Apr 20, 2016 2:31 am

Hi,

Thanks for your clarification.
Welcome to write to us again if you have further problems.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF