3 Replies Latest reply: Nov 21, 2013 2:17 AM by amit12121989 RSS

    how to insert png to pdf?

    cheng845 Community Member

      I have readed the pdf reference 1.6,i want to insert png to pdf.

      i konw that the png consits of alpha and RGB,

      31 0 obj
      <</BitsPerComponent 8/ColorSpace/DeviceRGB/Filter/DCTDecode/Height 154/Length 8781/Name/X/SMask 30 0 R/Subtype/Image/Type/XObject/Width 154>>stream

      I know that 30 0 obj is alpha data after encompressed,buf i don't  konw the stream object in 31 0 obj, how to get the stream data from png?

        • 1. Re: how to insert png to pdf?
          lrosenth Adobe Employee

          You need to decode the PNG format to get just the raw pixels.  Then separate the alpha pixels from the rest and write both objects.


          Also, DCTDecode is fro JPEG.  You'd probably want FlateDecode for PNG.

          • 2. Re: how to insert png to pdf?

            I have get the alpha piexels and raw pixel(RGB) using the libpng to decode png format, but i don't know that what's  the content of 31 0 obj stream.

            I use the adobe acrobat to insert a png to pdf.

            the result:


            24 0 obj

            <</Contents 43 0 R/CropBox[0.0 0.0 612.0 792.0]/Group 39 0 R/ID 40 0 R/MediaBox[0.0 0.0 612.0 792.0]/PZ 1.0/Parent 14 0 R/Resources<</ColorSpace<</CS0 33 0 R>>/Font<</C0_0 38 0 R>>/ProcSet[/PDF/Text/ImageC]/XObject<</Im0 44 0 R>>>>/Rotate 0/Type/Page>>


            44 0 obj

            <</BitsPerComponent 8/ColorSpace/DeviceRGB/Filter/DCTDecode/Height 154/Length 8792/Name/X/SMask 45 0 R/Subtype/Image/Type/XObject/Width 154>>stream




            45 0 obj
            <</BitsPerComponent 8/ColorSpace/DeviceGray/Filter/FlateDecode/Height 154/Length 6157/Name/X/Subtype/Image/Type/XObject/Width 154>>stream



            I know that the stream data of 45 0 obj is alpha data  after compressed,but i don't know what's format the stream data of 44 0 obj  and how to get it from a png.

            • 3. Re: how to insert png to pdf?

              What are the values of image matrix for png image file ?


              imageMatrix.a = ASInt16ToFixed(width);

                                  imageMatrix.d = ASInt16ToFixed(height);

                                  imageMatrix.b = imageMatrix.c = fixedZero;

                                  imageMatrix.h = fixedZero;

                                  imageMatrix.v = fixedZero;



              Is it correct for png ?