Currently custom adobe plugin should copy pdf content if pdf document was updated but not saved in Adobe Reader/Acrobat otherwise it continues using original file location. It was tested on different files. This works fine with almost all files except one.
From properties of this file I see that this is Adobe LiveCycle Forms 8.2 document with PDF Version 1.7 (Acrobat 8.x).
This file works fine with this plugin installed on Reader XI, Reader IX and Adobe Acrobat Pro DC. But when I use Adobe Acrobat Reader DC it crashes.
Source code:
ASInt32 docFlags = PDDocGetFlags(pdDoc);
if ((docFlags & PDDocNeedsSave) != 0) //check if document need to save
{
IntPtr pTempFile = Marshal::StringToHGlobalAnsi(strTempFile);
ASPathName asTempPath = ASFileSysCreatePathName(NULL, ASAtomFromString("Cstring"), pTempFile.ToPointer(), NULL);
PDDocCopyParamsRec copyParams;
memset(©Params, 0, sizeof(PDDocCopyParamsRec));
copyParams.size = sizeof(PDDocCopyParamsRec);
copyParams.fileSys = ASGetDefaultFileSys();
copyParams.newPath = asTempPath;
copyParams.saveChanges = true;
PDDocCopyToFile(pdDoc, ©Params); // <-- crashes here
Marshal::FreeHGlobal(pTempFile);
ASFileSysReleasePath(NULL, asTempPath);
}
In Adobe Acrobat Reader and Acrobat Pro DC this file is not possible to update (for Acrobat warning message appears, from Reader this file not editable) but docFlags are defined for this doc as need to save. This is not so bad if only plugin not crashes on line PDDocCopyToFile(pdDoc, ©Params).
Also I noticed that if I change copyParams.saveChanges to false it works fine but it copies file without not saved changes. This is unacceptable.
Exception message is "External component has thrown an exception." and type of exception - System.Runtime.InteropServices.SEHException.
Previously in plugin was used SDK older than 9 version, so I updated SDK to DC version - this didn't help. Then I used other available in downloads versions of SDK X and XI - the same result.
Is it a bug or I'm doing something wrong? Are the any workarounds? Are there any ideas?
Thank you.