PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
pdf encryption assertion failure https://forum.pdfsharp.net/viewtopic.php?f=3&t=3414 |
Page 1 of 1 |
Author: | berrywhite [ Fri Aug 05, 2016 6:47 pm ] |
Post subject: | pdf encryption assertion failure |
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 |
Author: | TH-Soft [ Fri Aug 05, 2016 7:35 pm ] |
Post subject: | Re: pdf encryption assertion failure |
Hi! My proposed fix for this issue can be found here: http://stackoverflow.com/a/38593235/1015447 |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |