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.
Unfortunately, activation email could not send to your email. Please try again.

Rotate pages in an existing PDF

Thread ID:

Created:

Updated:

Platform:

Replies:

94248 Apr 30,2010 03:57 PM Mar 23,2015 04:31 AM Windows Forms 3
loading
Tags: PDF
Karlie Shah
Asked On April 30, 2010 03:57 PM

How do I rotate a page in an existing PDF without having to recreate the PDF? I would just like to load it using PdfLoadedDocument, rotate and page and resave the document.
Thanks,
Karlie

Sundaram R [Syncfusion]
Replied On May 4, 2010 03:18 AM

Hi Karlie,

Thanks for using Syncfusion products.

Syncfusion.PDF.base assembly’s Type PdfLoadedDocument does not have any Page Rotation related properties.

However, there exist a workaround for your rotate feature, which is as follows, Please find whether this is helpful for your need,

Load the PDF file into object of type PdfLoadedDocument and then create an object of type PdfDocument from it. Here, every PdfPage in the PdfPages collection of PdfDocument resides with in the object of type PdfSection.
Here in type PdfSection, the PdfPages collection within them can be subjected for rotation, with its PageSettings property. The file with the changes can be saved back to the same location.

Please find the code snippet for your help,


//The File location
public const string saveUrl = "E:/Resources/Sample.pdf";

//The Page number, which has to be rotated
public const int pageNumber = 10;

//Load the existing PDF document from the drive
PdfLoadedDocument loadedPdf = new PdfLoadedDocument(openUrl);

//Convert PdfLoadedDocument to PdfDocument object
PdfDocument pdfDoc = PdfDocument.Merge(null, loadedPdf) as PdfDocument;

//Apply necessary rotation operation to required page(s).
pdfDoc.Sections[pageNumber].PageSettings.Rotate = PdfPageRotateAngle.RotateAngle90;

//Resave the document
pdfDoc.Save(openUrl);

If you have any further queries, please contact us.

Thanks,
Sundaram R.

Eric Rosenblum
Replied On March 20, 2015 06:52 PM

Hi Karlie,

Thanks for using Syncfusion products.

Syncfusion.PDF.base assembly’s Type PdfLoadedDocument does not have any Page Rotation related properties.

However, there exist a workaround for your rotate feature, which is as follows, Please find whether this is helpful for your need,

Load the PDF file into object of type PdfLoadedDocument and then create an object of type PdfDocument from it. Here, every PdfPage in the PdfPages collection of PdfDocument resides with in the object of type PdfSection.
Here in type PdfSection, the PdfPages collection within them can be subjected for rotation, with its PageSettings property. The file with the changes can be saved back to the same location.

Please find the code snippet for your help,


//The File location
public const string saveUrl = "E:/Resources/Sample.pdf";

//The Page number, which has to be rotated
public const int pageNumber = 10;

//Load the existing PDF document from the drive
PdfLoadedDocument loadedPdf = new PdfLoadedDocument(openUrl);

//Convert PdfLoadedDocument to PdfDocument object
PdfDocument pdfDoc = PdfDocument.Merge(null, loadedPdf) as PdfDocument;

//Apply necessary rotation operation to required page(s).
pdfDoc.Sections[pageNumber].PageSettings.Rotate = PdfPageRotateAngle.RotateAngle90;

//Resave the document
pdfDoc.Save(openUrl);

If you have any further queries, please contact us.

Thanks,
Sundaram R.

PdfDocument pdfDoc = PdfDocument.Merge(null, loadedPdf) as PdfDocument;

System.ArgumentNullException: Value cannot be null.
Parameter name: key



Karthik Krishnaraj [Syncfusion]
Replied On March 23, 2015 04:31 AM

Hi Karlie,

Thank you for your patience,

I am afraid that I couldn’t able to reproduce the issue, I have attached a simple sample and the output pdf file in the below link. Can you please check with this and let me know your current product version, this will help us to find the actual root cause for the issue.

Sample Link:

http://www.syncfusion.com/downloads/support/directtrac/135426/WindowsFormsApplication19551566329.zip

Output File:

http://www.syncfusion.com/downloads/support/directtrac/135426/Output1714935674.zip

Thanks,

Karthik.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;