"invalid floating-point operation" in WriteToFile  SOLVED

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
HDemo
User
Posts: 7
Joined: Mon Dec 05, 2016 12:11 pm

"invalid floating-point operation" in WriteToFile

Post by HDemo »

Hello,
I'm trying to embed an XML file into a PDF. Unfortunately, I get an 'invalid floating-point Operation" in class "EInvalid OP" with the "IPXC_Document-> WriteToFile".

It seems to me, the internally in the
PDFXCoreAPI.x86.dll
, which I registered, an object is not initialized or something is missing to me.

The following is the source code:

Code: Select all

var
  PXC_InstCore : PDFXCoreAPI_TLB.TPXC_Inst;
  pDoc : PDFXCoreAPI_TLB.IPXC_Document;
  pFS : PDFXCoreAPI_TLB.IPXC_FileSpec;
  pTree : PDFXCoreAPI_TLB.IPXC_NameTree;
  pdf : PDFXCoreAPI_TLB.IPXS_PDFVariant;
  pEFS : PDFXCoreAPI_TLB.IPXC_EmbeddedFileStream;
  pPXS_Inst : PDFXCoreAPI_TLB.IPXS_Inst;
  sfilePath : String;
  sfileName : String;
  atom : Cardinal; //Integer;

  sSerialKey : string;
  aXmlFileName , aPdfFilename : WideString ;
begin
  PXC_InstCore := PDFXCoreAPI_TLB.TPXC_Inst.Create(nil);
    Try
       PXC_InstCore.Init(PWideChar(sSerialKey));
       pDoc := PXC_InstCore.OpenDocumentFromFile(PWideChar(aPdfFilename ) ,nil,nil,0,0);
        pTree := pDoc.GetNameTree('EmbeddedFiles');
        sfilePath := aXmlFileName;
        sfileName := ExtractFilename(aXmlFileName);
        pFS := pDoc.CreateEmbeddFile(PWideChar(sfileName ) );
        pFS.Get_EmbeddedFile(pEFS);
        pEFS.UpdateFromFile2(PWideChar(sFilePath),nil,nil);
        pPXS_Inst := PDFXCoreAPI_TLB.IPXS_Inst(PXC_InstCore.GetExtension(PWideChar('PXS')));
        pFS.Get_PDFObject(pdf);
        if Assigned(pPXS_Inst) then
        begin
          atom := pPXS_Inst.StrToAtom(PWideChar('Alternative'));
          pFS.Set_AFRelationship(atom);
        end;
        pTree.Add(sFileName,pdf);
        pDoc.WriteToFile(  PWideChar(aPdfFilename)  ,nil,0);  <-- here i get the exception
        pDoc.Close(0);
    finally
        PXC_InstCore.Finalize;
        PXC_InstCore.Free
    end;
end;
Kinds regards

Holger Demoulin
HDemo
User
Posts: 7
Joined: Mon Dec 05, 2016 12:11 pm

Re: "invalid floating-point operation" in WriteToFile

Post by HDemo »

It looks like this is the problem with the passing of the serial key.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: "invalid floating-point operation" in WriteToFile

Post by Tracker Supp-Stefan »

Hello Holger,

I have passed this to a colleague from the dev team who can answer, but he is finishing up another task at the moment so he can not reply straight away. We will see to post a reply here within a few hours.

Regards,
Stefan
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: "invalid floating-point operation" in WriteToFile  SOLVED

Post by Sasha - Tracker Dev Team »

Hello HDemo,

Please look at this topic and use the method described there in your code:
https://forum.pdf-xchange.com/ ... 81#p103581

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
HDemo
User
Posts: 7
Joined: Mon Dec 05, 2016 12:11 pm

Re: "invalid floating-point operation" in WriteToFile

Post by HDemo »

Thank you, it's working

issue can be closed :-)
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: "invalid floating-point operation" in WriteToFile

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply