PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Aug 18, 2017 8:38 am

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
PostPosted: Fri Aug 05, 2016 6:47 pm 
Offline

Joined: Fri Aug 05, 2016 6:11 pm
Posts: 1
I encountered an assertion failure when I tried to encrypt some specific pdf file (sorry it's 500KiB with only one page and cannot be uploaded)

and I am using the pdf sharp source code (PDFsharp-1_50-beta3b.zip) to build my own PdfSharp.dll,

I noticed that this pdf triggers the following code in PdfDocument.cs

// HACK: Remove XRefTrailer
if (_trailer is PdfCrossReferenceStream) ----------------> condition got met
_trailer = new PdfTrailer((PdfCrossReferenceStream)_trailer);

Although I have no idea why we need this hack, it seems the failure can be fixed by adding the following codes:

----------------
iref = trailer.Elements.GetReference(Keys.Encrypt);
if (iref != null)
Elements.SetReference(Keys.Encrypt, trailer.Elements.GetReference(Keys.Encrypt));
----------------
in the function "public PdfTrailer(PdfCrossReferenceStream trailer)" in PdfTrailer.cs

Please help to confirm, thx


Top
 Profile  
 
PostPosted: Fri Aug 05, 2016 7:35 pm 
Offline
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 266
Location: CCAA
Hi!

My proposed fix for this issue can be found here:
http://stackoverflow.com/a/38593235/1015447

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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:  
Powered by phpBB® Forum Software © phpBB Group