0

I'm using Delphi 2007. I'm getting 'Not implemented' exception when trying to call IPersistFile.Save() after loading document into Ole container. Problem exists for Acrobat Reader 10 and higher. The same code works for Acrobat Reader 9.

I was trying to find some solution on Adobe forum but without success. Maybe someone has the same problem before.

I'm using code like this:

procedure LoadAndSave();
var PF: IPersistFile;
    saveResult : integer;
    OleContainerDocument: TOleContainer;
    CreateInfo: TCreateInfo;
begin
  CreateInfo := ...
  OleContainerDocument.CreateObjectFromInfo(CreateInfo);

  OleContainerDocument.OleObjectInterface.QueryInterface(IPersistFile, PF);

  if PF <> nil then begin
    saveResult := PF.Save(StringToOleStr(FullFilePath), false);
    //In this place saveResult contains E_NOTIMPL error
  end
end;
Emil
  • 171
  • 1
  • 8
  • The error is pretty self explanatory. The OLE object that is implementing the `IPersistFile` interface does not implement saving a file. What is hard to understand about that? Not surprising for Acrobat, which has a history of restricting features like saving files. – Remy Lebeau May 16 '17 at 03:26
  • @RemyLebeau I understand, but I'm looking for some solution for this. How I can save document to not use IPersistFile.Save() method? I can check result code and then call some other method, but which one? – Emil May 16 '17 at 03:28
  • 1
    hard to answer that without seeing how you are accessing the document in the first place. – Remy Lebeau May 16 '17 at 03:43
  • 1
    In other words: could you make a simple [MCVE] displaying the problem? – Rudy Velthuis May 16 '17 at 09:22
  • 1
    @RemyLebeau: I never had any problems saving files with Acrobat Reader, no matter which version. So it is a little surprising that it doesn't allow saving using the interface. Could it be the .pdf that doesn't allow it? – Rudy Velthuis May 16 '17 at 09:24
  • @RudyVelthuis if that were the case, I would expect a different error than `E_NOTIMPL`. – Remy Lebeau May 16 '17 at 14:46
  • @Remy: yes, that is probably right. I still find it weird that it is not possible through IPersistent. – Rudy Velthuis May 16 '17 at 15:06
  • There are many IPersist* interfaces... an ActiveX container is supposed to try all of them. – Sheng Jiang 蒋晟 May 16 '17 at 16:36
  • @RemyLebeau I added some sample code. If you think that is necessary to paste whole working implementation please let me know what you need more to be able to help. Thanks – Emil May 18 '17 at 05:09
  • @Emil my guess is the object's `IPersistFile` only allows loading but not saving. You might need to ask Adobe about this. On a side note, your code has a memory leak. The pointer returned from `StringToOleStr()` must be freed manually using `SysFreeString()`. Otherwise, use `PWideChar(WideString(FullFilePath))` instead. – Remy Lebeau May 18 '17 at 05:21

0 Answers0