I am able to insert JPG image into a PDF document with DCTDecode
filter. I think the all parameters should be the same for PNG
image too, except the filter which should be FlateDecode
. However, when I try to insert PNG
with the same parameters, the PNG image is not visible in he PDF document.
UPDATE: I came to conclusion that the PDF file should include
1 0 obj <<
/Type /XObject
/Subtype /Image
/Width 512
/Height 512
/BitsPerComponent 8
/ColorSpace /DeviceRGB
/SMask 9 0 R
/Length 134753
/Filter /FlateDecode
>>
stream
PNG_RAW DATA
endstream
endobj
9 0 obj <<
/Type /XObject
/Subtype /Image
/Width 512
/Height 512
/BitsPerComponent 8
/ColorSpace /DeviceGray
/Length 12087
/Filter /FlateDecode
>>
stream
ALPHA_PIXELS
endstream
endobj
BUT how can I separate the PNG
raw data and the alpha pixels
via ImageMagick
? In other words, what ImageMagick
command can produce PDF_RAW_DATA
and ALPHA_PIXELS
for insertion into the pdf file.
Click on the "Edit" tab, then select "Background" and choose "Edit Background" from the drop-down menu. Now a window pops up, and you need to click the Pencil-like icon to edit the background. Then you can customize the background. Select 0% in the "Opacity" option.
It's easy — simply go to Adobe Acrobat online services from any web browser and navigate to the convert JPG to PDF page. Click the Select A File button or drag and drop the image file into the drop zone to upload. You can upload a variety of image types to convert to a PDF, including a: PNG.
@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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With