Not sure what I am doing wrong. It appears as though I've followed the PDF Reference and documentation correctly, but I am getting this error when my plugin trys to save my PDF file to a new location (dont want to overwrite the original).
Here is the sample code. I hope what I am doing wrong is easy to fix.
PDDocClose(currentPDDoc);
ASPathName filePathName = ASFileSysCreatePathName(NULL, ASAtomFromString("CString"), replacedSavePath.c_str(), 0); PDDocSave(currentPDDoc, PDSaveIncremental | PDSaveLinearized, filePathName, ASGetDefaultFileSys(), NULL, NULL);
Hi,
The first thing I notice is that you have closed the currentPDDoc before you try and save it. I think you need to save it before you close it.
I also not that you are saving linearized, this means that you need to make sure that any 'acquire' functions that you have called have been release, for example
PDDocAcquirePage() or PDBeadAcquirePage(). - see documentation for more information.
Hope this helps
Malcolm
You can do an incremental save when you save to a new location - there is
nothing to add the new information to. You need to call the function with
PDSaveFull.
You may not have acquired any objects explicitly, but chances are that if
your plugin is doing anything useful, you have acquired something through
some of the methods you called. Make sure that you know what the side
effects of every API function you call are, and then release whatever is
still acquired before you save the document.
Karl Heinz Kremer
PDF Acrobatics Without a Net
Ahh the problem was that the file was secured with a password. The documentation mentions:
Known Exceptions
Raises
pdErrOpNotPermitted if saving is not permitted. Saving is permitted if either edit or editNotes (see PDPerms) is allowed, or you are doing a full save and saveAs
is allowed.
So I looked for that exception in the docs and it said:
pdErrOpNotPermitted
security does not allow content copying or extraction. These operations should be permitted when the document’s
master password is used.
So for anyone getting this error, try removing security from the file first.
North America
Europe, Middle East and Africa
Asia Pacific