PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Dec 14, 2019 9:44 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu Jul 31, 2014 11:11 am 
Offline

Joined: Thu Jul 31, 2014 7:55 am
Posts: 4
Hello,

I am experiencing an issue with a specific PDF file supplied by a customer. My application merges multiple PDF file together using the following code:

Code:
using (PdfDocument objLoopedPDF = openPDFDocument(p_memDocument))
{
   // Iterate pages
   for (int i = 0; i < objLoopedPDF.PageCount; i++)
   {
      if (objLoopedPDF.Pages[i].Contents != null)
      {
         // ...and add it to the output document.
         PdfPage objNewPage = m_objMergedPdf.AddPage(objLoopedPDF.Pages[i]);
      }
   }
}


If the source PDF has a page with Rotate set to 180 this appears to be 'copied' across to the objNewPage object via the AddPage() method. However, when viewed in a PDF viewer the page appears upside down.

I can address this by setting the Rotate property to 0 following the AddPage() method call but I'm not sure of the consequences and don't really see why I should have to. Is this a bug?

I am using version 1.32.2608.0.

Any help would be appreciated.

Regards,
Martyn


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 04, 2014 9:02 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3013
Location: Cologne, Germany
WICSDEV wrote:
Is this a bug?
I don't know.
We need an SSCCE to investigate this.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 04, 2014 9:23 am 
Offline

Joined: Thu Jul 31, 2014 7:55 am
Posts: 4
Hi Thomas,

Unfortunately, the affected document contains medically sensitive information and our IG Policy prevents me from releasing it. Similarly, I'm unable to produce a non-sensitive version to attach as I'm unsure how the client in question is getting these documents.

From what I've described, is it possible for a PDF document to be:

1. scanned upside down
2. identified as upside down by the scanning software
3. Marked as rotate=180 so a viewer displays it correctly

If this is technically possible, is it then feasible that for some reason the AddPage() method is rotating the image and retaining the rotate=180 property or taking the source page as is (ie, already rotated) and retaining the rotate property?

Thanks,
Martyn


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 18, 2015 12:48 pm 
Offline

Joined: Thu Jul 31, 2014 7:55 am
Posts: 4
Hi

I applied the 'fix' that I suggested previously, ie: set the Rotate property to 0 after the AddPage method and this fixed the issue for the affected customer. Unfortunately, a different customer has now presented another PDF file that when merged ends up with pages upside down.

Doc1 is 4 pages and page 2 and 4 have a rotate value of 180 (the others are 0).
Doc2 is 12 pages and all of them are set to rotate 180

When merged using PDFSharp the resulting 16 page document has page 2 and 4 upside down. Both appear correct when viewed outside of the application, ie: Adobe Viewer etc.

The only difference I can find is that Doc1 is version 1.3 and Doc2 is version 1.4 - this may be a red herring though.

Any help would be appreciated - unfortunately, as before I cannot share the documents as they are medically sensitive. I am unable to generate any non-sensitive documents that are affected.

Thanks,
Martyn


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 18, 2015 3:40 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 508
Location: CCAA
There is a known problem with pages that have Rotate = 90 (I tried to fix it, but it is complicated - sorry for the inconvenience).
IIRC there is no problem with pages that have Rotate = 180.

So maybe the quick and dirty workaround will be: set 90 to 0, leave 180 and 0 as they are (I'm not sure about 270).
Multiples are allowed IIRC, so take Rotate modulo 360 before your switch statement.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 18, 2015 3:48 pm 
Offline

Joined: Thu Jul 31, 2014 7:55 am
Posts: 4
Hi Thomas

Thanks for the quick reply but I don't have any issues with 90 and 270 - only 180 degrees.

I did try setting all Rotate values to 90 and the resulting document had pages 2 and 4 pointing left and the others pointing right - it's almost as if the 2 affected pages cannot be overridden or always add 180 to whatever value is set.

If all 180's were acting the same I could address the issue, but I have 2 documents where the same rotate value is being handled differently.

My instinct is that this is either related to the PDF version or in some way caused by the 12 page document having all pages set to 180. Is there a document level Rotate value - or just a per page one?

Any further assistance would be appreciated.

Thanks
Martyn


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 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