PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Dec 03, 2021 1:22 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 Jul 27, 2018 6:30 pm 

Joined: Sat Jul 29, 2017 11:53 am
Posts: 11
Hello there,

it was very important for me to note you about a PDF file being harmed after being encrypted with any password since v.1.50 beta 5 and onward.
The issue is that some of the background color on the page was changed after the encryption.
Although the unicode character issue in properties has been fixed for file encryptions in v.1.50 beta 5 - it feels that some files are being encrypted badly as the background color on these file may be changed as I described above.
It's important for me to note that the file was generated by SSRS 2008 which includes some background images.

The background change issue on the file was not present on v.1.50 beta 4 and also not on v.1.32...

i would like to send you the file itself for you to have tests on it, but I will send it to you privately as the file may contain copyrighted content. Please let me have your e-mail (G-mail is preffered) for me to provide you a link to access the file for tests.

I found the issue on FormatStringLiteral on the file PdfEncoders.cs.
I'm afraid to say that before the fix for the unicode properties - the background color issue was not present.
After reverting the PdfEncoders.cs file to 1.50 beta 4 version only - I found the issue not presented anymore.
Unfortunately, I believe that some data on the file is changed incorrectly and this is why the issue occurs once file is encrypted.

Update 2
I applied the fix I previously did 1 year ago and the issue was not present anymore..
I have made the following changes:
- Use PdfEncoders.cs from version 1.50 beta 4.
- Add of enum: PdfStringFlags.BigEndianUnicode = 0x07.
- Add of Symbol.BigEndianUnicodeString which creates PDFString using (PdfStringFlags.BigEndianUnicode).
- Add of Symbol.BigEndianUnicodeHexString which creates PDFString using (PdfStringFlags.BigEndianUnicode | PdfStringFlags.HexLiteral).
- Replace of "return _symbol = Symbol.UnicodeString;" with "return _symbol = Symbol.BigEndianUnicodeString;" on Phase 2 for UTF-16BE.
- for Hex cases - replace of "return _symbol = Symbol.UnicodeHexString;" with "return _symbol = Symbol.BigEndianUnicodeHexString;".
- Add of enums: "Symbol.BigEndianUnicodeString" after "Symbol.UnicodeString" and "Symbol.BigEndianUnicodeHexString" after "Symbol.UnicodeHexString".
- Add of enum "PdfStringEncoding.BigEndianUnicode = PdfStringFlags.BigEndianUnicode" in PdfString.cs.
- Replace of "_flags = PdfStringFlags.Unicode;" with "_flags = PdfStringFlags.BigEndianUnicode | PdfStringFlags.HexLiteral;" on constructor of PdfString.
- Add of "case PdfStringEncoding.BigEndianUnicode: break;" on constructor of PdfString.

Thank you.

Last edited by ta221 on Mon Mar 09, 2020 1:06 pm, edited 1 time in total.

Reply with quote  
PostPosted: Mon Mar 09, 2020 7:39 am 

Joined: Sat Jul 29, 2017 11:53 am
Posts: 11
Hello, I'm afraid to tell that files like I mentioned above are damaged permanently upon encryption.
Please reconsider to resolve this as other libraries like iTextSharp encrypts the files and content properly and then files are opened and viewed properly.
I was able to resolve that issue where there is a potential of damage to file content by applying specific changes to source code.

Thank you.

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: No registered users and 2 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