PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Sep 26, 2021 2:57 am

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: Tue Jul 20, 2021 5:21 pm 
Offline

Joined: Tue Jul 20, 2021 5:17 pm
Posts: 3
I am generating .pdfs using PdfSharp in C#. However, each time I generate a new document (in memory), write the same graphics, and save it to disk, the resulting .pdf documents are not byte equivalent.

Are there some properties I could set such that every time I do this, there is no change in the bytes in the file? I basically want to detect a _real_ change (as in, I different XGraphics were written) vs no change.

EDIT:

It appears that the cause of my issue is with the '/FontName/' and '/BaseFont/' lines.

Examples from file 1:
/BaseFont/GVLFRZ+Verdana
/FontName/PQKDZC+Verdana

Same lines in file 2:
/BaseFont/LRPOEC+Verdana,Italic
/FontName/KTKFNL+Verdana,Italic

I'm generating them with the lines:

XFont heading2 = new XFont("Verdana", 18, XFontStyle.Regular);
XFont heading3 = new XFont("Verdana", 16, XFontStyle.Bold);


Last edited by Ehryk on Tue Jul 20, 2021 10:26 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 20, 2021 10:05 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 660
Location: CCAA
No. At least not yet.

Some IDs are generated each time and creation date/time also changes. So you need a comparison that takes care of these differences.

Maybe use 3ed-party software to render bitmaps from the PDF and compare the bitmaps for visual differences.

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


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 20, 2021 10:29 pm 
Offline

Joined: Tue Jul 20, 2021 5:17 pm
Posts: 3
See my edit. I have accounted for document.Info.CreationDate and document.Info.ModificationDate.

Is there a way I can control the prefix on the font families, or have it not output in the saved document? Worst case I could strip them out with regex I suppose.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 21, 2021 6:24 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 660
Location: CCAA
Ehryk wrote:
Is there a way I can control the prefix on the font families, or have it not output in the saved document?
PDFsharp is open source.
Feel free to add a flag to "PdfDocument.Options" and share your changes with us.

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


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 21, 2021 6:00 pm 
Offline

Joined: Tue Jul 20, 2021 5:17 pm
Posts: 3
TH-Soft wrote:
Ehryk wrote:
Is there a way I can control the prefix on the font families, or have it not output in the saved document?
PDFsharp is open source.
Feel free to add a flag to "PdfDocument.Options" and share your changes with us.


Is this the correct source repository? https://github.com/empira/PDFsharp


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 22, 2021 9:25 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 660
Location: CCAA
Ehryk wrote:
Is this the correct source repository? https://github.com/empira/PDFsharp
Yes.
And please only make changes "on topic" when creating a pull request.

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


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: Google [Bot] and 32 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