We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Rotate PDF pages.

Hi there,

Is there a way to rotate pages in an existing PDF. I am using
PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(inFile);

Where inFile is a FileStream.

Let’s say I have five pages, 2 landscape and 3 portrait, would like to go rotate the 2 landscape pages to portrait and save the pdf. Is this possible, if not what is the work around, we don't have control over the PDF creation.

thanks,

Ravi



3 Replies

SS Sri Subhashini M Syncfusion Team November 10, 2008 01:30 PM UTC

Hi,

Thank you for choosing Syncfusion product.

If your intention is to change the orientation of an existing PDF document, it can be achieved by importing existing document pages into new document and we can change the Orientation for a single page by using the class Orientation.

Kindly look into the sample code snippet,

PdfLoadedDocument ldoc = new PdfLoadedDocument(@"..\..\Data\pdf.pdf");

// Create a new document class object.
PdfDocument doc = new PdfDocument();

doc.ImportPageRange(ldoc, 0, ldoc.Pages.Count - 1);
//lets only rotate the 1st page
PdfPage page = doc.Pages[0];

page.Section.PageSettings.Orientation = PdfPageOrientation.Portrait;

doc.Save("Sample.pdf");


Please do find the sample from the below specified location and let me know if this helps,

http://www.syncfusion.com/support/user/uploads/Pdf_Window_77594_ee50fb5e.zip

Regards,
Suba





RR Ravi Ravichandran November 10, 2008 05:45 PM UTC

Thanks Suba, it helped.

>Hi,

Thank you for choosing Syncfusion product.

If your intention is to change the orientation of an existing PDF document, it can be achieved by importing existing document pages into new document and we can change the Orientation for a single page by using the class Orientation.

Kindly look into the sample code snippet,

PdfLoadedDocument ldoc = new PdfLoadedDocument(@"..\..\Data\pdf.pdf");

// Create a new document class object.
PdfDocument doc = new PdfDocument();

doc.ImportPageRange(ldoc, 0, ldoc.Pages.Count - 1);
//lets only rotate the 1st page
PdfPage page = doc.Pages[0];

page.Section.PageSettings.Orientation = PdfPageOrientation.Portrait;

doc.Save("Sample.pdf");


Please do find the sample from the below specified location and let me know if this helps,

http://www.syncfusion.com/support/user/uploads/Pdf_Window_77594_ee50fb5e.zip

Regards,
Suba







SS Sri Subhashini M Syncfusion Team November 13, 2008 10:53 AM UTC

Hi Ravi,

Glad to know that the issue has been resolved.

Please let me know if you need any information.

Regards,
Suba


Loader.
Live Chat Icon For mobile
Up arrow icon