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
, which I registered, an object is not initialized or something is missing to me.PDFXCoreAPI.x86.dll
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;
Holger Demoulin