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
Hope this helps
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
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:
So I looked for that exception in the docs and it said:
pdErrOpNotPermittedThis operation is not permitted. Acrobat
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.