I have a plugin which is making changes to a PDF file. Once all the changes are done, I am using PDDocSave to attempt to save the file to a path on the local disk C:\, however the save does not complete successfully and instead gives the error:
"The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder."
The intersting this is that the pathname that I provided to the PDDocSave method IS a different file name and a differnent folder name than the originally opened file.
• I checked to make sure that I am releasing all acquired objects. I went line by line through 565 lines of code cross checking with the PDF reference to make sure that I cleaned up anything that needed cleaning before the save.
• The folder permissions on the target folder are not read only, I am the owner of the folder, and have full permissions to the folder.
• Security on the source document has been completely removed and the source folder is not read only.
• Acrobat X Pro is not configured for enhanced security, therefore is not starting in Protected Mode.
• Several ASAtom objects and CoSObjs are created in the code, however their scope is local to the method in which they are run and therefore are no longer valid when the document saves.
Here are the major points of the code which I believe may be relevant in helping to troubleshoot this error:
AVDoc currentAVDoc = AVAppGetActiveDoc();
PDDoc currentPDDoc = AVDocGetPDDoc (currentAVDoc); ...
PDDocSave(currentPDDoc, PDSaveFull | PDSaveLinearized, filePathName, ASGetDefaultFileSys(), NULL, NULL);
ASPathName openFilePath = ASFileAcquirePathName(openFile); ...
page = PDDocAcquirePage(currentPDDoc, i); ...
ASPathName filePathToOpen = ASFileSysCreatePathName(NULL, pathType, filePathToGetSizeOf, 0); ...
ASFileSysReleasePath(NULL, filePathToOpen); ...
PDPageRelease(page); ...
ASFileSysReleasePath(fileSysToUse, openFilePath);
PDDocClose(currentPDDoc); ...
ASPathName filePathName = ASFileSysCreatePathName(NULL, ASAtomFromString("CString"), replacedSavePath.c_str(), 0); AVDocClose(currentAVDoc, true); So that is where I am. The document does not save. Instead I get the error about being read-only or in use. Anyone have an idea whats happening?
PDDocSave(currentPDDoc, PDSaveFull | PDSaveLinearized, filePathName, ASGetDefaultFileSys(), NULL, NULL);
I also tried saving the file a little bit differently using PDSaveCopy as shown:
PDDocSave(currentPDDoc, PDSaveFull | PDSaveCopy | PDSaveLinearized | PDSaveCollectGarbage, filePathName, ASGetDefaultFileSys(), NULL, NULL); But now I get the error: "Cannot write to this file. Please save the document with a different name or in a different folder."
The commands you list seem a bit out of order - there are two calls to
PDDocSave(), one of them before I see the declaration of the path name.
Because we don't know what's going on between those commands, it's
impossible to diagnose your problem remotely.
You are new to plug-in programming, so I would approach this by eliminating
(or commenting out) anything that can potentially modify the PDF file, so
that you just have the calls to get the PDDoc, and then to save that PDDoc
at a different location. Does that work? If not, fix it - if it does work,
add things piece by piece and see where things stop working.
Are you sure you can write to the filename/directory you've selected? Have
you tried a different directory?
Plug-in programming for Acrobat is hard, and there is no way around making
all the mistakes in the world and learning from them ![]()
Karl Heinz Kremer
PDF Acrobatics Without a Net
Hello,
May be that won't help you, but in our Company, Users have the same error message when they open a PDF on the Internet with IE8 64 bits and then try to save it on their PC.
Everything works fine if they use IE 8 32 bits... it only happens if they launch the 64 bits version of IE 8 on W7.
I'm not sure what you're doing exactly, but if your pluging is using IE 8 64 bits, may be you should try IE 8 32 bits instead.
Good luck
North America
Europe, Middle East and Africa
Asia Pacific