PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Rotate PDF Page

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
Sai Alluru



Joined: 02 Jan 2009
Posts: 4

PostPosted: Fri Jan 02, 2009 12:18 pm    Post subject: Rotate PDF Page Reply with quote

Hi,

I want to know how to rotate a pdf page say by 90, 180 and 270 degrees. I tried the following code but when I rotate and transform the resulting page is blank. If not rotated the page appears in the rectangle bounding box.

PdfDocument inputDocument = PdfReader.Open(filename, PdfDocumentOpenMode.Import);
PdfDocument outputDocument = new PdfDocument();
for (int idx = 0; idx < inputDocument.PageCount; idx++)
{
PdfPage page = inputDocument.Pages[idx];
PdfDocument singlePageDocument = new PdfDocument();
singlePageDocument.AddPage(page);
singlePageDocument.Save("C:\\NewTemp\\temp"+idx.ToString()+".pdf");
outputDocument.AddPage(new PdfPage());
page = outputDocument.Pages[idx];
page.Orientation = PdfSharp.PageOrientation.Landscape;
XGraphics gfx = XGraphics.FromPdfPage(page);
XPdfForm form = XPdfForm.FromFile("C:\\NewTemp\\temp"+idx.ToString()+".pdf");
gfx.RotateAtTransform(90, new XPoint(0, 0));
gfx.DrawImage(form,new XRect(140, 80, 50, 50 * Math.Sqrt(2)));
gfx.Save();
}
outputDocument.Save("C:\\NewTemp\\Rotated.pdf");

Let me know if there is a simple way to rotate a page.

Thanks,

Sai.
Back to top
View user's profile Send private message
billy anachronism



Joined: 08 Jan 2009
Posts: 8

PostPosted: Thu Jan 08, 2009 3:50 am    Post subject: Reply with quote

Hi Sai,

I just did:

PdfDocument inputDocument = PdfReader.Open(filename, PdfDocumentOpenMode.Import);

foreach (PdfPage page in inputDocument)
{
page.Rotate = 0;
page.Orientation = PdfSharp.PageOrientation.Portrait;
}

That worked for me. However, I'm also looking to resize the page and I haven't found an easy way to do that yet.
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Thu Jan 08, 2009 9:16 am    Post subject: Re: Rotate PDF Page Reply with quote

Hi!
Sai Alluru wrote:
I tried the following code but when I rotate and transform the resulting page is blank.

The turning point is (0, 0) - I guess you rotate the whole content away from the visible part of the page (RotateAtTransform) or use co-ordinates outside the visible area (DrawImage).
Try using the center of the page as turning point for the rotation.

Have you checked the XForms sample?
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com