AndreRenaud / PDFGen

Simple C PDF Writer/Generation library
The Unlicense
504 stars 120 forks source link

PDF Error: -22 - PNG has unsupported color type: 6 #149

Closed LinArcX closed 6 months ago

LinArcX commented 6 months ago

try to download this png file(black and white): https://icons8.com/icons/set/person

or even google fonts: https://fonts.google.com/icons?icon.size=24&icon.color=%235f6368&icon.query=person

And load it: pdf_add_image_file(pdf, NULL, x-10, y-30, 10, 10, "data/person.png");

Compilation is fine. but when I run it, I receive this error: PDF Error: -22 - PNG has unsupported color type: 6

AndreRenaud commented 6 months ago

Unfortunately PDFGen doesn't support alpha channels in images. The simplest option is to flatten the image down to having a white background. If you have imagemagick installed, you can do this with:

convert person.png  -background white -flatten flatten.png

Then you can put flatten.png into your PDF without issue.