yWorks / svg2pdf.js

A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts
MIT License
646 stars 96 forks source link

Acrobat Always Asks to Save Changes to "unmodified" File on Close of PDF #225

Open jamesbley-rhythm opened 1 year ago

jamesbley-rhythm commented 1 year ago

I have the following problem: See this playground.

If you download the PDF and open it in Acrobat Reader, make no changes, then close the PDF, Acrobat will ask if you want to Save the File.

I expected this to happen: I didn't make any changes to the PDF, I expected Acrobat not to ask me to save the file on close.

I tried this: The above svg2pdf playground and our own use of this to create pdfs from svg.

But this is what happened instead: Both result in the same issue.

yGuy commented 1 year ago

To me this sounds more like a bug in jspdf. Or actually in Acrobat Reader. If the program does not edit the file, who could have modified the file and how, anyway?

I don't have Acrobat Reader installed, here. Does this also happen with an empty SVG or even if you omit the call to svg2pdf altogether? There aren't that many calls that go into jspdf when the svg is empty so this might be "easy" to debug with an almost empty pdf.

jamesbley-rhythm commented 1 year ago

According to my development team, if they create a pdf using jspdf only, Acrobat Reader does not issue the same "save changes to modified file" prompt. But if they use svgtopdf using an svg, then they get the "save changes" prompt.

My guess is that acrobat reader does not like what it's seeing in the .pdf file and is "modifying" it to its liking as it's loaded. Almost like it's "converting" it when it's opened. This is how it's becoming "modified".

Using the "playground" link above, I cleared out the text and this resulted in an empty svg. I downloaded it and still get the prompt to save the file when I close it from acrobat reader. I tried this on both chrome and edge, to be sure the browser wasn't adding anything.

jamesbley-rhythm commented 1 year ago

Attaching 2 pdf files. Both originate from "playground" link above. I removed the "text" node and "viewbox" attribute and had it generate a pdf. "svg2pdf_blank_before_adobe_save.pdf" is what was downloaded directly. "svg2pdf_blank_after_adobe_save.pdf" is what the file was after adobe acrobat reader asked me to save it. svg2pdf_blank_before_adobe_save.pdf svg2pdf_blank_after_adobe_save.pdf

yGuy commented 1 year ago

We should probably compare the output of the empty jspdf export with the "empty svg" case. The file saved by Acrobat Reader is very different from the "before" file (different file version to begin with). We'll probably need to bisect the instructions that are issued when we write the empty SVG to find out which ones Acrobat does not "like".

HackbrettXXX commented 11 months ago

Using jspdf 2.5 instead of 2.0 seems to resolve the issue, can you confirm @jamesbley-rhythm?