jsPDF: fromHTML plugin incompatible with Adobe Acrobat Reader
Hi,
I know that the fromHTML plugin (viewable at /jsPDF-master/examples/basic.html
) is still in beta, so I’m not expecting for it to be perfect. However, the second page of the PDF is consistently giving us this error message in Adobe Acrobat Reader:
An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem.
The <header>
and <footer>
, if they exist, are present on page 2 and onward, but everything else is blank. In other words, for Adobe Acrobat Reader on both Mac and PC, the first page of a fromHTML-generated-PDF renders correctly and the rest are white and empty.
This problem occurs when opening the repo demo PDF in Adobe Acrobat Reader, so I’m confident that the issue is greater than a simple inability on my end to implement it correctly. Importantly, all other PDF readers render the PDF just fine. It looks to be specific to Adobe’s method of PDF syntax specifications. Any ideas what the problem might be, or when we can get this fixed? I LOVE jsPDF and if this bug didn’t exist then we could use it on a fairly extensive project.
Thanks!
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (5 by maintainers)
Commits related to this issue
- from_html pdf rendering fix - Fix issue with Adobe Acrobat Reader per jutunen suggestion in #570 - Fix double breakline with BR tag. — committed to lydialim/jsPDF by lydialim 7 years ago
Wow, okay. I updated my version of
jspdf.debug.js
to set the penultimate argument tonull
. It looks like this:That did the trick!!
Thanks so much @jutunen. You’re clearly a subject matter expert at this PDF stuff. @MrRio hasn’t built a demo of the
fromHTML
feature that’s longer than 1 page, so he hasn’t come across this issue yet in Adobe Acrobat Reader, but you’ve nailed a core but that will need to be fixed.In the meanwhile I’m going to use this patched version for our purposes. It’s functioning great.
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf
PDF reference page 406 tells us that Td operator does not have any operand for color.
For some reason on this line the color operand is assigned:
this.pdf.internal.write(“q”, “BT 0 g”, this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), style.color, “Td”);
You could try to remove the style.color parameter.