Hello,
(wPDF, v.4.31, used as DCU, not as DLL + Delphi 6)
Currently, I am programming the creation of ZUGFeRD invoices (it means that I attach ZUGFeRD-invoice.xml file to PDF/A-3 file).
1) But the resulting PDF file is not accepted by both of ZUGFeRD validation portals that I know (one and two).
The error of validation is: MIME-Type of attached file is empty.
In the PDF-file created by wPDF (v.4.31), there are no MIME-Types!!! The Typ = 'text/xml' - parameter of the method .AddFileAttachment is ignored.
2) Additionally, there is another unclear aspect: the result of .AddFileAttachment - call is always FALSE without OnError-Event
Here are some links to the files in my Dropbox
My Project
- Position of missed "/Subtype" (=MIME) PDF-Tag in PDF-Source of created by wPDF file (.PNG)
- Created ZUGFeRD invoice PDF-File (.PDF)
- Validation - Report (.PDF)
- My delphi project (Delphi 6) (.ZIP)
- Attached ZUGFeRD XML-File (.XML)
Example-Invoice from ZUGFeRD documentation. This PDF-File is correct.
- PDF-Tags (.PNG)
- Example PDF-File (.PDF)
- Validation - Report (.PDF)
procedure TMainForm.btnCreatePDFClick(Sender: TObject);
var
sEXEPath : string;
sXMLFullPath : string;
sPDFFullPath : string;
pdf : TWPPDFPrinter;
bAttachedOK : boolean;
begin
sEXEPath:=ExtractFilePath(Application.ExeName)+'';
sXMLFullPath:=sEXEPath+'DATA\ZUGFeRD-invoice.xml';
sPDFFullPath:=sEXEPath+'OUTPUT\RE_'+FormatDateTime('dd_mm_yyyy___hh_nn_ss',Now())+'.pdf';
pdf:=TWPPDFPrinter.Create(nil);
try
//wPDF4 License
WPDF_Start('*****************', <<<< to be replaced
'*****************'); <<<< to be replaced
pdf.FileName := sPDFFullPath;
pdf.PDFAMode := wpdfaLevel3B;
pdf.PageMode := wpUseThumbs;
pdf.FontMode := wpEmbedType3;
//Tests of pdf-output
//--- pdf.EncodeStreamMethod := wpEncodeNone;
//--- pdf.CompressStreamMethod := wpCompressRunlength; //for plain text
pdf.BeginDoc();
try
//Add XML-Attachment
bAttachedOK := pdf.AddFileAttachment(
ExtractFileName(sXMLFullPath), // Shown name
'ZUGFeRD invoice in XML format', // Description
sXMLFullPath, // FileName
'text/xml', // MimeType
0 // Modified Date
);
if bAttachedOK then
ShowMessage('AddFileAttachment: OK')
else
ShowMessage('AddFileAttachment: ERROR'); // <<<< :-( every time this message, but why?
//Add Page with Text
pdf.StartPage(800, 1000, 72, 72, 0);
pdf.Canvas.Font.Name := 'Arial';
pdf.Canvas.Font.Size := 20;
pdf.Canvas.TextOut(10, 10, 'ZUGFeRD-Test (see XML attachment)');
pdf.EndPage();
finally
pdf.EndDoc();
end;
finally
FreeAndNil(pdf);
end;
ShowMessage('PDF file created'+#13#10+
sPDFFullPath);
end;
Alles anzeigen