Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Closing already opened document while opening another document

New Here ,
Jan 31, 2017 Jan 31, 2017

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!

TOPICS
Acrobat SDK and JavaScript
420
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 31, 2017 Jan 31, 2017

AVAppGetActiveDoc might return NULL. Doesn't mean no document is open.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 31, 2017 Jan 31, 2017

So, what is the possible alternative/solution for this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 01, 2017 Feb 01, 2017
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines