Search code examples
javascripthtmlpdfjspdfadobe-reader

generated pdf file from jsPDF library , does not open in adobe reader


I have a html page. There are two images on this page. both images are base64 encoded. I am printing images on html as

<img src='data:image/png;base64,<?php echo $img ?>' />

I set css properties position, left and right to bring one image over other image.

Now I am using jsPDF to generate pdf file of a section of the page where these 2 images are present.

generated pdf files from jsPDF works fine if I open it on FireFox , chrome or Document Viewer (ubuntu machine) but if I try to open this pdf file on a windows machine with Adobe reader then Adobe reader throws an error: There was an error processing a page. There was a problem reading this document (110) PDF error

If any one has any suggestion then kindly let me know.


Solution

  • I had a similar issue using the fromHTML plugin, apparently the code puts out the text color resulting in it placing "rgb(0, 0, 0)" in places it should not.

    The github recomended changing jspdf.dist.js in the line:

    this.pdf.internal.write("q", "BT 0 g", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), style.color, "Td");
    

    changing the "style.color" to "null" solved my issue.

    this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), null, "Td");