Skip to content

addImage PNG fails >= 2.4.0 #3359

Open
Open
@cobbrg

Description

@cobbrg

The following code exports a good PNG image to PDF in jsPDF version 2.3.1 and below. In version 2.4.0 and 2.5.0, the image is not displayed and Acrobat Reader reports "An error exists on this page". The image is displayed with a black background when viewed in the Edge PDF viewer (previously transparent).

where imageCanvas is an HTMLCanvasElement and pdf is a jsPDF

let img = imageCanvas.toDataURL("image/png", 1.0);
pdf.addImage(img, 'PNG', 20, 20, 560, 300);
pdf.save('testPNG.pdf');

JPEG and WEBP show an image when using 2.4.0 and 2.5.0, but the JPEG background is black and the WEBP image looks like an 8-bit conversion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions