PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Mar 29, 2024 3:56 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue May 19, 2009 4:29 am 
Offline

Joined: Wed Jan 14, 2009 2:10 am
Posts: 7
Location: London, United Kingdom
Bug raised, also discussed by another user at http://forum.pdfsharp.net/viewtopic.php?t=610&highlight=rotate&mforum=pdfsharp.

Scenario:

I have a Portrait PDF, with either no Rotation value set, or it is set to 0.

I rotate by 90 degrees, giving me a Rotation from 0 to 90, the content is 90 degrees to the right, but the page is still portrait (wrong).

I rotate the result by another 90, a rotation from 90 to 180. Now the content is upside down in portrait (correct).

I rotate the result by another 90, a rotation from 180 to 270. Now the content is on its side in landscape (correct).

I rotate the result by another 90, a rotation from 270 to 0. Now the content is standing in portrait (correct).

I rotate the result by another by 90 degrees, giving me a Rotation from 0 to 90, the content is 90 degrees to the right, but the page is still portrait (wrong).

This sequence can be reversed if I make the 0>90 manually landscape, thus making all the subsequent rotations wrong way round (with content clipped of the side of the page).

I have tried when going back to zero, to subtract the existing rotation, i.e., rather than jump from 270 to 0, rotate by -270 to rotate back anti-clockwise, but this has no effect.

Its worth noting that the content is rotated correctly each time, only the page orientation is coming up wrong (at least when loaded back into Adobe Reader).

Any thoughts?


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 09, 2012 2:34 am 
Offline

Joined: Fri Mar 09, 2012 2:05 am
Posts: 1
Not sure if you ever found a solution for this, or if perhaps it has been corrected in a more recent version (it also seems to exist in the version that I am running, file Version 1.31.1789.0)... I seem to have found a work-around. It is only slightly tested, but seems to work for me with initial testing... It's as if the page orientation doesn't get set correctly when the rotation is 0 or 180. Here's the code I use:

Code:
for (int i = 0; i < doc.PageCount; i++)
{
   var cr = doc.Pages[i].Rotate;
   doc.Pages[i].Rotate = (cr + r) % 360;
   switch (doc.Pages[i].Rotate)
   {
      case 90:
      case 270:
         break;
      case 0:
      case 180:
         doc.Pages[i].Orientation = doc.Pages[i].Orientation == PdfSharp.PageOrientation.Portrait ? PdfSharp.PageOrientation.Landscape : PdfSharp.PageOrientation.Portrait;
         break;
   }
}


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 50 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group