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

Re: Convert PDF-Page Thumbnail to PNG or JPEG

$
0
0

Looking into the Documentation, i found an example am working on:

ACCB1  void   ACCB2   Trimmbox::createImage(QString filename){

     // get a PDF open in front.

            

                              

                // enumerate from PDF conversion handlers to find the JPEG handler.

                 AVConversionEnumFromPDFConverters(myAVConversionFromPDFEnumProc,  NULL); //GetJPEGHandler();

 

                // save the rtf file to the snippetRunner's output files folder.

                volatile ASPathName  OutPath ;

                OutPath =  ASFileSysCreatePathName  (ASGetDefaultFileSys(),  ASAtomFromString( "Cstring" ),  "D:\testingfile.jpg", 0);

                if (OutPath==NULL) {

                                AVAlertNote( "Cannot open an output file." );

                                return ;

               }

              

                // do conversion

                 // Create the setting cabinet and provide the settings.

                AVConversionStatus  status=AVConversionConvertFromPDFWithHandler(RightHandler,

                                                                                NULL,kAVConversionNoFlags, mycurrentPDDoc, OutPath,  ASGetDefaultFileSys(),NULL);

 

                // check the returned status and show message

                if (status ==  kAVConversionSuccess)

                                AVAlertNote( "The JPEG file was saved in SnippetRunner output folder." );

                else   if (status ==  kAVConversionFailed)

                                AVAlertNote( "The JPEG file conversion failed." );

                else   if (status ==  kAVConversionSuccessAsync)

                                AVAlertNote( "The conversion will continue asynchronously." );

                else   if (status ==  kAVConversionCancelled)

                                AVAlertNote( "The conversion was cancelled." );

 

                //pathname freigeben

               if (OutPath){

                     ASFileSysReleasePath(ASGetDefaultFileSys(), OutPath);

               }

}

 

  ACCB1  ASBool   ACCB2  myAVConversionFromPDFEnumProc(AVConversionFromPDFHandler  handler,AVConversionEnumProcData  data)

{

                AVFileFilterRec  filter = handler->convFilter;

                ASUns16  numFileExt = filter.numFileDescs;

              

                // go through the conversion handlers to find a handler for rtf extention files.

                for  (ASInt32  i = 0; i < numFileExt; i++)

               {

                                if  (strlen(handler->convFilter.fileDescs[i].extension)>0)

                               {

                                                // found it, fill in the handler and return false to stop going on.

                                                if (!strcmp(handler->convFilter.fileDescs[i].extension, "JPEG" )) {

                                                               RightHandler = handler;

                                                                return   false ;

                                               }

                               }

               }

                return   true ;

}

 

But i keep getting "The JPEG file conversion failed.". What could be wrong?


Viewing all articles
Browse latest Browse all 10848

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>