if (pdfView.PDFDocument <> nil) then
if pdfView.PDFDocument.Active then
if pdfView.PDFDocument.Attachments.Count > 0 then
for i := 0 to pdfView.PDFDocument.Attachments.Count - 1 do
if (Pos('.xml',LowerCase(pdfView.PDFDocument.Attachments[I].Name)) > 0) or
(Pos('zugferd',LowerCase(pdfView.PDFDocument.Attachments[I].Name)) = 1) or
(Pos('factur-x',LowerCase(pdfView.PDFDocument.Attachments[I].Name)) = 1) then
try
aStr := TMemoryStream.Create;
try
pdfView.PDFDocument.Attachments[I].SaveToStream(aStr);
aStr.Seek(0,soFromBeginning);
case TXRechnungValidationHelper.GetXRechnungVersion(aStr) of
XRechnungVersion_230_UNCEFACT,
XRechnungVersion_30x_UNCEFACT,
XRechnungVersion_ReadingSupport_ZUGFeRDFacturX :
begin
zugferdCurrentInv2 := TInvoice.Create;
TXRechnungInvoiceAdapter.LoadFromStream(zugferdCurrentInv2,aStr,error);
end;
end;
finally
aStr.Free;
end;
break;
except
on E:
Exception do MessageDlg(E.Message+' '+e.ClassName, mtError, [mbOK], 0);
end;