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;
}
North America
Europe, Middle East and Africa
Asia Pacific