PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jun 17, 2024 6:50 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: Fri Oct 05, 2012 1:59 am 
Offline

Joined: Fri Oct 05, 2012 1:35 am
Posts: 1
Hi,

I have discovered the following code in PdfPage.WriteObject(PdfWriter writer):

Code:
      // HACK: temporarily flip media box if Landscape
      PdfRectangle mediaBox = MediaBox;
      // TODO: Take /Rotate into account
      if (orientation == PageOrientation.Landscape)
        MediaBox = new PdfRectangle(mediaBox.X1, mediaBox.Y1, mediaBox.Y2, mediaBox.X2);


This causes a bug in our application when the input PDF contains:

Code:
/Type /Page
/Rotate 90
/MediaBox [ 0 0 595 842 ]
/CropBox [ 0 0 595 842 ]
 


but outputs as:
Code:
  /CropBox [0 0 595 842]
  /MediaBox [0 0 842 595]
  /Rotate 90
  /Type /Page


effectively cropping the page into a 595x595 square.

My current fix is to remove "Hack" code, can someone please advice any "unwanted side effects" out of this?

Thanks


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 08, 2012 7:39 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
PandaKiwi wrote:
My current fix is to remove "Hack" code, can someone please advice any "unwanted side effects" out of this?
If it works for you, leave it like that.

Maybe the MediaBox must also be flipped while reading the file. I can't tell without a deep dive into the source code.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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: Google [Bot] and 139 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:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group