How to insert transparent PNG in PDF?

萝らか妹 提交于 2019-12-05 02:06:45

@Bobrovsky

Here is an example: http://pd4ml.com/i/pd4ml18130.pdf

To be more accurate: you cannot embed a PNG absolutely with no manipulations with it. You would need to split a PNG to sections: IDAT (image data) goes to PDF as byte stream unchanged, PLTE (palette) - to colorspace definition, iCCP optionally goes to color profile object.

An object dictionary may look like that:

<<
/Filter /FlateDecode
/Type /XObject
/Subtype /Image
/BitsPerComponent 8
/Length 1277
/Height 250
/Width 250
/DecodeParms <<
    /BitsPerComponent 8
    /Predictor 15
    /Columns 250
    /Colors 1
>>
/ColorSpace [/Indexed /DeviceRGB 1 <1989d1ffffff>]
>>
stream
... IDAT bytes ...

Most probably you didn't decode PNG images.

PNGs are not directly supported in PDF. I mean they are not supported in way JPEGs are supported.

You have to produce raw uncompressed raster bytes from PNGs before embedding them into PDF. You may encode the raster bytes with Flate or LZW encoder if you wish.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!