Jspdf: PNG Color Issue

Created on 10 May 2016  路  12Comments  路  Source: MrRio/jsPDF

Hello -

So jsPDF is working wonderfully. However when I use addImage to add a .png image to the pdf, I am getting inconsistent results in terms of the color of the .png being added. This is how I am adding it:

doc.addImage(newimgData, 'png', 0.7, 3.4, updatedImgwidth, updatedImgheight);

This is what should be coming through:

screen shot 2016-05-10 at 4 55 11 pm

However, this is what gets added to the pdf:

screen shot 2016-05-10 at 4 54 54 pm

Notice how the blue turns to black? All kinds of incorrect colors. Anyone have any ways to fix this?

Bug addimage.js

Most helpful comment

It's seems to be in relation with this topic .
But still no online solution...

All 12 comments

I'm having a similar issue. It was working properly maybe a month ago, but now there's incorrect coloring.

It's seems to be in relation with this topic .
But still no online solution...

I have a maybe related issue:
I have a PNG dataURI that I add to the pdf. It is a simple color gradient that I created in a canvas previously.
In the pdf, some colors are corrupted.

https://jsfiddle.net/jayfmbpk/5/

The same happens if I generate the dataURI as JPG and add it as JPG.

Any Ideas?

Hi
I'm facing the same issue when I use addImage to add PNG. In my original PNG there is no gAMA chunk, but jsPDF is introducing gAMA chunk while adding it to PDF. Request you to kindly expedite this issue at the earliest opportunity.

Thanks a lot.
Regards,
Anitha

Another case when the colour is not respected: http://jsfiddle.net/hvs91vpq/61/

Assuming you don't need the transparency that PNG provides:

  • Use canvas-background to apply a white background;
  • Change addImage to use JPG — voila!

Hi! Faced same issue...
@MrRio , @BiggA94 maybe someone of you guys can take a look please..

@jeneg use pdfkit as it is far better with a similar API.

Faced same issue too. Finally find pdfmake can replace jsPDF.So,hope it can help some one!

Does somebody have an example image?

The thing is, that jspdf converts the png file to a jpg. So actually there is no adding of a gAMA-Chunk to the PNG. But I guess, the conversion without respecting the gAMA-Chunk results into an improper JPG-Filee.

Duplicate of #762

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

0721Betty picture 0721Betty  路  4Comments

glaier picture glaier  路  3Comments

MaxCodeDE picture MaxCodeDE  路  4Comments

BarathArivazhagan picture BarathArivazhagan  路  4Comments

allenksun picture allenksun  路  3Comments