I'm moving this to a new separate topic, as this is really not related to the original question, ref: https://forum.pdf-xchange.com/viewtopic.php?f=66&t=35186#p150385
From what I understand when the e.document.preSaveOptimizedData ends, the temporary (optimized) file is saved to (overwritten, if exists) DestFileName (then temporary one is deleted). For this, DestFileName must not exist or be opened / locked.
The issue I am facing is that I cannot really write my edits to the temporary (optimized) file, "TempOptimizedDoc.SrcInfo.FileName", as it is locked....Also you may use the TempOptimizedDoc.SrcInfo.File to read/write it...
Note: I'm not linearizing the file via your SDK / IPXC methods - I'm using a 3rd party library.
I can linearize a file from the file system (read, linearize, write) - meaning the file must not be locked. That's why I asked for "e.document.afterSave" - to linearize when no longer locked by PDFX.
I can also linearize from memory (buffer). To linearize from memory I can use IPXC_Document.WriteTo(IStream) - this works. Then I can either write back to a buffer (IStream) or write to a file.
Writing to a buffer is a no-go, since there's no IPXC_Document.ReadFrom(IStream) - having such a method would solve it.
After buffer linearization I could write to a different temporary file, but since TempOptimizedDoc is read-only I cannot change it to my linearized file (and let your code simply save/move it to where it needs to go: DestFileName).
So, I'm stuck again.
Or, I do not understand what you meant by "you may use the TempOptimizedDoc.SrcInfo.File to read/write it".
-žarko