PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Dec 07, 2018 7:02 pm 
Offline

Joined: Fri Dec 07, 2018 6:40 pm
Posts: 3
I'm running into an odd problem. With certain documents, following saving them with PdfSharp, when I try to open them in Adobe Reader, I get the following error message: "There was an error processing a page. A number is out of range."

The simplest version of the code that reproduces this error is as follows:
Code:
using (var pdfDoc = PdfSharp.Pdf.IO.PdfReader.Open(sourcePath, PdfDocumentOpenMode.Modify))
{
  pdfDoc.Save(destPath);
}


The above code runs without any exceptions being thrown so I have no idea that anything went wrong until I actually try to open the new file.

Unfortunately I can't share the documents since they have personal information on them, but the commonality seems to be that they were previously signed using DocuSign. I've tried to create a file that causes the error, but I've been unable to do so.

I know that without access to the original documents, it's unlikely that anyone could definitively say what's happening, but does anyone have any advice as to how I could troubleshoot this issue?


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 21, 2018 8:21 pm 
Offline

Joined: Fri Dec 07, 2018 6:40 pm
Posts: 3
I've narrowed down the issue by inspecting the difference between the underlying raw data in the file before and after the save. It appears that the issue relates somehow to this block of code in PDFSharp:

https://github.com/empira/PDFsharp/blob ... ge.cs#L613

Basically, the following gets inserted into the page on save:

Code:
/Group
<<
/CS/DeviceRGB
/S/Transparency
>>


This appears to somehow be conflicting with other content in the page because if I manually remove that entry, I can at least open and see the contents of the page (though I do get the following error message upon attempting to open it with Adobe Reader "An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem.")

I've been reading through the PDF spec to try to figure out what's wrong, but I haven't been able to find anything useful.

Does anyone have any ideas on what might be going on or how I might be able to troubleshoot this issue?


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 22, 2018 8:42 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
Judging from the PDFsharp code, that group should not be added when you set
Code:
PdfDocument.Options.ColorMode = PdfColorMode.Undefined

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


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 09, 2019 2:53 pm 
Offline

Joined: Fri Dec 07, 2018 6:40 pm
Posts: 3
Thanks for the suggestion.

I tried setting the PdfColorMode to Undefined and I confirmed that the setting was properly applied in the new document, but I continued to run into the same error, so looks like I was incorrect in the root cause.

Back to the drawing board, I guess.


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

All times are UTC


Who is online

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