Skip to content

Unable to add base64 png images to JSPDF Javascript #1483

@baluMallisetty

Description

@baluMallisetty
function save_pdf() {
 var doc = new jsPDF();  
 var imgSampleData ='data:image/png;base64,/9j/4AAQSkZJRgABAAEA8ADwAAD/2w...';
 doc.addImage(btoa(imgSampleData), 'PNG', 15, 40, 175, 75);
 doc.save('MCR.pdf');
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.debug.js"></script>

image
https://drive.google.com/file/d/0BzRwV-8m4H86VHpFS1VFVFU4OWs/view

I have attached entire base64 String of whole image. This Base64 works fine and able to see images if I use any online conversion tool.

Attachement base64 png string
Please use the attached string in jspdf code imagedata and Also please copy and paste the Base64 string to browser which seems to work fine.

What could be the reason why JSPDF unable to parse this type of base64 strings and other online PNG base64 to image converters seems to parse the String Successfully?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions