Quantcast
Channel: Adobe Community: Message List - Acrobat SDK
Viewing all articles
Browse latest Browse all 10848

insert png image into pdf

$
0
0

I found width and height of png image.

 

But when i m calling AddImageSnip() after that it shown message "Out of Memory".

 

While i select jpg file and i found width and height of jpg file after that i m calling AddImageSnip() function then the image inserted into pdf successfully.

 

Why this fuction is not working for png format ?

 

Can any one tell me How to set value of PDEImageMatrix and what are the parameter passing to this PDEImageCreate() function for png image file......?

 

 

PDEImage volatile pdeImage = NULL;

                    PDEImageAttrs pdeImageAttrs;

                    PDEColorSpace pdeColorSpace;

                    ASFixedMatrix imageMatrix;

 

                    memset(&pdeImageAttrs, 0, sizeof(PDEImageAttrs));

                    pdeImageAttrs.flags = kPDEImageExternal;

                    pdeImageAttrs.width = width;

                    pdeImageAttrs.height = height;

                    pdeImageAttrs.bitsPerComponent = 8;

 

                    imageMatrix.a = ASInt16ToFixed(width);

                    imageMatrix.d = ASInt16ToFixed(height);

                    imageMatrix.b = imageMatrix.c = fixedZero;

                    imageMatrix.h = fixedZero;

                    imageMatrix.v = fixedZero;

 

                    pdeColorSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB"));

 

                    PDEFilterArray filterArray;

                    PDEFilterSpec filterSpec;

                    memset (&filterSpec, 0, sizeof (PDEFilterSpec));

                    filterSpec.name = ASAtomFromString ("DCTDecode");//FlateDecode //DCTDecode

                    filterArray.numFilters = 1;

                    filterArray.spec[0] = filterSpec;

                    ASTFilePos size =  ASFileGetEOF(asFile);

                    DURING

                              pdeImage = PDEImageCreate (&pdeImageAttrs, sizeof(pdeImageAttrs), &imageMatrix,

                                                                                                    kPDEImageEncodedDat a , pdeColorSpace, NULL,&filterArray,

                                                                                                    asStm, NULL, ASFileGetEOF(asFile));

                    HANDLER

                              iErrorCode = ASGetExceptionErrorCode();

                    END_HANDLER

 

 

                    if (0 == iErrorCode)

                    {

                              PDPage pdPage;

                              PDEContent pdeContent;

                              PDDoc doc=NULL;

                              if(!createpdf)

                              {

                                        AVDoc avDoc = AVAppGetActiveDoc();

                                        doc = AVDocGetPDDoc(avDoc);

                                        pdPage = PDDocAcquirePage (doc, 0);

                              }

                              else

                              {

                                        doc=PDDocCreate();

                                        ASFixedRect mediaBox = {ASInt32ToFixed(0), ASInt32ToFixed(0), ASInt32ToFixed(width), ASInt32ToFixed(height)};   

                                        pdPage = PDDocCreatePage(doc, PDBeforeFirstPage, mediaBox);

                              }

                              if(pdPage == NULL)

                                        return NULL;

                              pdeContent = PDPageAcquirePDEContent (pdPage, gExtensionID);

                              ASInt32 initialNumElements  = PDEContentGetNumElems(pdeContent);

                              PDEImage existingImage;

                              if(initialNumElements > 0)

                              {

                                        existingImage = (PDEImage) PDEContentGetElem(pdeContent, 0);

                                        ASUns32 encodedLenP;

                                        ASBool isEncoded = PDEImageDataIsEncoded(existingImage,&encodedLenP);

                              }

 

                              DURING

                                        PDEElement pdeElement=(PDEElement)pdeImage;.

                                        PDEContentAddElem (pdeContent, kPDEAfterLast, pdeElement );

                              HANDLER

                                        iErrorCode = ASGetExceptionErrorCode();

                              END_HANDLER

 

                              ASInt32 finalNumElements  = PDEContentGetNumElems(pdeContent);

                              ASBool sucess = PDPageSetPDEContent (pdPage, gExtensionID);

                              PDPageReleasePDEContent (pdPage, gExtensionID);

 

 

This code is correct for jpg but this is not working for png.

 

Can any one tell me why it is not working for png ?


Viewing all articles
Browse latest Browse all 10848

Trending Articles