PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Is there a way to ensure byte equivalence? https://forum.pdfsharp.net/viewtopic.php?f=2&t=4275 |
Page 1 of 1 |
Author: | Ehryk [ Tue Jul 20, 2021 5:21 pm ] |
Post subject: | Is there a way to ensure byte equivalence? |
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); |
Author: | TH-Soft [ Tue Jul 20, 2021 10:05 pm ] |
Post subject: | Re: Is there a way to ensure byte equivalence? |
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. |
Author: | Ehryk [ Tue Jul 20, 2021 10:29 pm ] |
Post subject: | Re: Is there a way to ensure byte equivalence? |
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. |
Author: | TH-Soft [ Wed Jul 21, 2021 6:24 am ] |
Post subject: | Re: Is there a way to ensure byte equivalence? |
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. |
Author: | Ehryk [ Wed Jul 21, 2021 6:00 pm ] |
Post subject: | Re: Is there a way to ensure byte equivalence? |
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 |
Author: | TH-Soft [ Thu Jul 22, 2021 9:25 am ] |
Post subject: | Re: Is there a way to ensure byte equivalence? |
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. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |