Skip navigation
Natasha Jaz
Currently Being Moderated

Error while Open and save pdf using Adobe library

Sep 8, 2012 5:43 AM

I m using adobe library to open and save PDF using VC++ MFC .

as given samples are working for me all are using console application to accomplish this task.

But when i tried to use same functions to open and save PDF from DOC/VIEW application it gives me an error.

it is a strange problem that I don't understand. If I compile the following code (Visual C++ 2000 Express Edition) I get an error message: "Unhandled exception at 0x0041183f in test.exe: 0xC0000005: Access violation reading location 0x00000004."

For your reference when I simply  create one function and one menu and called that function from menu.

Please see the code is given below.

 

The code is given below

 

void CPDF_MFCDoc::OnPdfOpen()

{

    // TODO: Add your command handler code here

    OpenPDF();

}

 

#define PDF_FNAME1  "C:/Test.pdf"

 

void OpenPDF()

{

     PDDoc pdDoc= NULL;

     ASErrorCode errCode = 0;

    

     DURING

        pdDoc1 = MyPDDocOpen(PDF_FNAME1);

    HANDLER

        errCode = ERRORCODE;

    END_HANDLER

}

 

It gives me an error as.

Unhandled exception at 0x004075b1 in PDF_MFC.exe: 0xC0000005: Access violation reading location 0x00000024.

 

But when same thing I was complied from console ,it works.

Working code is given below.

 

#define PDF_FNAME1  "C:/Test.pdf"

void MainProc(int argc, char **argv )

{

     PDDoc pdDoc= NULL,

     ASErrorCode errCode = 0;

     DURING

             pdDoc1 = MyPDDocOpen(PDF_FNAME1);

    

     HANDLER

        errCode = ERRORCODE;

    END_HANDLER

}

PDDoc MyPDDocOpen(char *fileName)

{

    ASFileSys asFileSys = ASGetDefaultFileSys();

 

    volatile ASPathName asPathName    = NULL;

    volatile PDDoc        pdDoc        = NULL;

 

    DURING

        /* Create asPathName from file.*/

 

        #if MAC_PLATFORM

        asPathName = GetMacPath(fileName);

        #else

        asPathName = ASFileSysCreatePathName(asFileSys, ASAtomFromString("Cstring"), fileName, 0);

        #endif

 

        /* Open pdDoc from asPathName.*/

        pdDoc = PDDocOpen(asPathName, NULL, NULL, true);

        fprintf(stdout, "Successfully opened %s\n", fileName);

 

    HANDLER

        fprintf(stderr, "Unable to open %s\n", fileName);

        pdDoc = NULL;

    END_HANDLER

 

    /* Release asPathName.*/

    if (asPathName)

        ASFileSysReleasePath(asFileSys, asPathName);

 

    return pdDoc;

}


 
Replies
  • Currently Being Moderated
    Sep 9, 2012 12:29 AM   in reply to Natasha Jaz

    As you are using the Adobe PDFLibrary, you have a support contract with either Adobe or Datalogics.  Contact them directly for support.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 10, 2012 12:55 AM   in reply to Natasha Jaz

    I think lrosenth has given you the best advice.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points