Copy link to clipboard
Copied
Hello,
I have created a plugin which I can access from my external program.
Plugin adds a menu item to the acrobat.
Open document is one of the function of my plugin.
Workflow 1:
1. My external IAC program passes the document path to plugin and hits the menu item.
2. Now, plugin opens the document from the received path.
Workflow 2:
Now, I navigated to my external program. This time, acrobat windows has been minimized.
Again if my external program hits the menu item with different document path this time, it does not close the previous document.
To overcome this behavior, I used AVDocClose(avDoc, false) method.
But it seems it only works when Acrobat window is NOT minimized.
How can I achieve my goal?
My code snippet:
ACCB1 void ACCB2 OpenDocument()
{
AVDoc avDoc = AVAppGetActiveDoc();
PDDoc pdDoc = AVDocGetPDDoc(avDoc);
AVDocClose(avDoc, false);
char filePath[256];
GetPrivateProfileString("OpenFile", "filePath", "", filePath, 256, iniFilePath);
ASAtom pathType = ASAtomFromString("Cstring");
//Create an ASText object
ASText titleText = ASTextNew();
ASTextSetPDText(titleText, "This PDF was opened by using the Acrobat SDK");
//Create an ASPathName object
ASFileSys fileSys = ASGetDefaultFileSysForPath(pathType, filePath);
ASPathName pathName = ASFileSysCreatePathName(fileSys, pathType, filePath, NULL);
//Open the PDF file
AVDoc myDoc = AVDocOpenFromFile(pathName, fileSys,NULL);
//Do some clean up
ASFileSysReleasePath(fileSys, pathName);
ASTextDestroy(titleText);
}
Many Thanks!
Copy link to clipboard
Copied
AVAppGetActiveDoc might return NULL. Doesn't mean no document is open.
Copy link to clipboard
Copied
So, what is the possible alternative/solution for this?
Copy link to clipboard
Copied
Well, I don't understand what you want to do. If the user has opened a document by double clicking, do you want to close it? If the user has opened two documents, which one do you want to close? Surely you only want to close a document if your plug-in opened it. If so, remember the AVDoc but be SURE to register for AVDocDidClose notifications or you will crash.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now