Skip to content

Commit ca5b6de

Browse files
authored
Merge pull request #812 from tecnickcom/factur
Factur
2 parents 76debf1 + 383714c commit ca5b6de

File tree

8 files changed

+379
-9
lines changed

8 files changed

+379
-9
lines changed

CHANGELOG.TXT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
6.10.0 (2025-05-27)
2+
- Embedded files support (Factur-X 1.07 / ZUGFeRD 2.3) #789
3+
14
6.9.5 (2025-05-27)
25
- Automatically add destinations from HTML code #804
36
- Wrong default value when $table_el['old_cell_padding'] is missing #807

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.9.5
1+
6.10.0

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"barcodes"
1313
],
1414
"homepage": "http://www.tcpdf.org/",
15-
"version": "6.9.4",
15+
"version": "6.10.0",
1616
"license": "LGPL-3.0-or-later",
1717
"authors": [
1818
{

examples/example_068.php

Lines changed: 312 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,312 @@
1+
<?php
2+
3+
/**
4+
* Example 068 for TCPDF library
5+
*
6+
* @description Creates an example PDF/A-3b document using TCPDF
7+
* @author Nicola Asuni - Tecnick.com LTD <[email protected]>
8+
* @license LGPL-3.0
9+
*/
10+
11+
/**
12+
* Creates an example PDF/A-3b with embedded file (Factur-X 1.07 - ZUGFeRD 2.3)
13+
*
14+
* @abstract TCPDF - Example: PDF/A-3b with embedded file (Factur-X 1.07 - ZUGFeRD 2.3)
15+
* @author Nicola Asuni
16+
* @since 2021-03-26
17+
* @group A-3b
18+
* @group pdf
19+
*/
20+
21+
// Include the main TCPDF library (search for installation path).
22+
require_once('tcpdf_include.php');
23+
24+
// create new PDF document
25+
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, 3);
26+
27+
// set document information
28+
$pdf->setCreator(PDF_CREATOR);
29+
$pdf->setAuthor('Nicola Asuni');
30+
$pdf->setTitle('TCPDF Example 068');
31+
$pdf->setSubject('TCPDF Tutorial');
32+
$pdf->setKeywords('TCPDF, PDF, example, test, guide');
33+
34+
// set default header data
35+
$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 068', PDF_HEADER_STRING);
36+
37+
// set header and footer fonts
38+
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
39+
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
40+
41+
// set default monospaced font
42+
$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED);
43+
44+
// set margins
45+
$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
46+
$pdf->setHeaderMargin(PDF_MARGIN_HEADER);
47+
$pdf->setFooterMargin(PDF_MARGIN_FOOTER);
48+
49+
// set auto page breaks
50+
$pdf->setAutoPageBreak(true, PDF_MARGIN_BOTTOM);
51+
52+
// set image scale factor
53+
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
54+
55+
// set some language-dependent strings (optional)
56+
if (@file_exists(__DIR__ . '/lang/eng.php')) {
57+
require_once __DIR__ . '/lang/eng.php';
58+
59+
$pdf->setLanguageArray($l);
60+
}
61+
62+
// ---------------------------------------------------------
63+
64+
// set default font subsetting mode
65+
$pdf->setFontSubsetting(true);
66+
67+
// Set font
68+
$pdf->setFont('helvetica', '', 14, '', true);
69+
70+
// Add a page
71+
// This method has several options, check the source code documentation for more information.
72+
$pdf->AddPage();
73+
74+
// Set some content to print
75+
$html = <<<HTML
76+
<h1>Example of <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a> document in <span style="background-color:#99ccff;color:black;"> PDF/A-3b </span> mode.</h1>
77+
<i>This document conforms to the standard <b>Factur-X 1.07 / ZUGFeRD 2.3</b>.</i>
78+
<p>Please check the source code documentation and other examples for further information (<a href="http://www.tcpdf.org">http://www.tcpdf.org</a>).</p>
79+
HTML;
80+
81+
$invoiceXml = <<<XML
82+
<?xml version='1.0' encoding='UTF-8' ?>
83+
<rsm:CrossIndustryInvoice xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
84+
<rsm:ExchangedDocumentContext>
85+
<ram:BusinessProcessSpecifiedDocumentContextParameter>
86+
<ram:ID>Baurechnung</ram:ID>
87+
</ram:BusinessProcessSpecifiedDocumentContextParameter>
88+
<ram:GuidelineSpecifiedDocumentContextParameter>
89+
<ram:ID>urn:cen.eu:en16931:2017</ram:ID>
90+
</ram:GuidelineSpecifiedDocumentContextParameter>
91+
</rsm:ExchangedDocumentContext>
92+
<rsm:ExchangedDocument>
93+
<ram:ID>181301674</ram:ID>
94+
<ram:TypeCode>204</ram:TypeCode>
95+
<ram:IssueDateTime>
96+
<udt:DateTimeString format="102">20241115</udt:DateTimeString>
97+
</ram:IssueDateTime>
98+
<ram:IncludedNote>
99+
<ram:Content>Rapport-Nr.: 42389 vom 01.11.2024
100+
101+
Im 2. OG BT1 Besprechungsraum eine Beamerhalterung an die Decke montiert. Dafür eine Deckenplatte ausgesägt. Beamerhalterung zur Montage auseinander gebaut. Ein Stromkabel für den Beamer, ein HDMI Kabel und ein VGA Kabel durch die Halterung gezogen. Beamerhalterung wieder zusammengebaut und Beamer montiert. Beamer verkabelt und ausgerichtet. Decke geschlossen.</ram:Content>
102+
</ram:IncludedNote>
103+
</rsm:ExchangedDocument>
104+
<rsm:SupplyChainTradeTransaction>
105+
<ram:IncludedSupplyChainTradeLineItem>
106+
<ram:AssociatedDocumentLineDocument>
107+
<ram:LineID>01</ram:LineID>
108+
<ram:IncludedNote>
109+
<ram:Content>01 Beamermontage
110+
Für die doppelte Verlegung, falls erforderlich.</ram:Content>
111+
</ram:IncludedNote>
112+
</ram:AssociatedDocumentLineDocument>
113+
<ram:SpecifiedTradeProduct>
114+
<ram:Name>TGA Obermonteur/Monteur</ram:Name>
115+
</ram:SpecifiedTradeProduct>
116+
<ram:SpecifiedLineTradeAgreement>
117+
<ram:GrossPriceProductTradePrice>
118+
<ram:ChargeAmount>43.2</ram:ChargeAmount>
119+
</ram:GrossPriceProductTradePrice>
120+
<ram:NetPriceProductTradePrice>
121+
<ram:ChargeAmount>43.2</ram:ChargeAmount>
122+
</ram:NetPriceProductTradePrice>
123+
</ram:SpecifiedLineTradeAgreement>
124+
<ram:SpecifiedLineTradeDelivery>
125+
<ram:BilledQuantity unitCode="HUR">3</ram:BilledQuantity>
126+
</ram:SpecifiedLineTradeDelivery>
127+
<ram:SpecifiedLineTradeSettlement>
128+
<ram:ApplicableTradeTax>
129+
<ram:TypeCode>VAT</ram:TypeCode>
130+
<ram:CategoryCode>S</ram:CategoryCode>
131+
<ram:RateApplicablePercent>19</ram:RateApplicablePercent>
132+
</ram:ApplicableTradeTax>
133+
<ram:SpecifiedTradeSettlementLineMonetarySummation>
134+
<ram:LineTotalAmount>129.6</ram:LineTotalAmount>
135+
</ram:SpecifiedTradeSettlementLineMonetarySummation>
136+
</ram:SpecifiedLineTradeSettlement>
137+
</ram:IncludedSupplyChainTradeLineItem>
138+
<ram:IncludedSupplyChainTradeLineItem>
139+
<ram:AssociatedDocumentLineDocument>
140+
<ram:LineID>02</ram:LineID>
141+
<ram:IncludedNote>
142+
<ram:Content>02 Außerhalb Angebot</ram:Content>
143+
</ram:IncludedNote>
144+
</ram:AssociatedDocumentLineDocument>
145+
<ram:SpecifiedTradeProduct>
146+
<ram:Name>Beamer-Deckenhalterung</ram:Name>
147+
</ram:SpecifiedTradeProduct>
148+
<ram:SpecifiedLineTradeAgreement>
149+
<ram:GrossPriceProductTradePrice>
150+
<ram:ChargeAmount>122.5</ram:ChargeAmount>
151+
</ram:GrossPriceProductTradePrice>
152+
<ram:NetPriceProductTradePrice>
153+
<ram:ChargeAmount>122.5</ram:ChargeAmount>
154+
</ram:NetPriceProductTradePrice>
155+
</ram:SpecifiedLineTradeAgreement>
156+
<ram:SpecifiedLineTradeDelivery>
157+
<ram:BilledQuantity unitCode="H87">1</ram:BilledQuantity>
158+
</ram:SpecifiedLineTradeDelivery>
159+
<ram:SpecifiedLineTradeSettlement>
160+
<ram:ApplicableTradeTax>
161+
<ram:TypeCode>VAT</ram:TypeCode>
162+
<ram:CategoryCode>S</ram:CategoryCode>
163+
<ram:RateApplicablePercent>19</ram:RateApplicablePercent>
164+
</ram:ApplicableTradeTax>
165+
<ram:SpecifiedTradeSettlementLineMonetarySummation>
166+
<ram:LineTotalAmount>122.5</ram:LineTotalAmount>
167+
</ram:SpecifiedTradeSettlementLineMonetarySummation>
168+
</ram:SpecifiedLineTradeSettlement>
169+
</ram:IncludedSupplyChainTradeLineItem>
170+
<ram:ApplicableHeaderTradeAgreement>
171+
<ram:BuyerReference>Liselotte Müller-Lüdenscheidt</ram:BuyerReference>
172+
<ram:SellerTradeParty>
173+
<ram:ID>549910</ram:ID>
174+
<ram:Name>ELEKTRON Industrieservice GmbH</ram:Name>
175+
<ram:Description>Geschäftsführer Egon Schrempp Amtsgericht Stuttgart HRB 1234</ram:Description>
176+
<ram:PostalTradeAddress>
177+
<ram:PostcodeCode>74465</ram:PostcodeCode>
178+
<ram:LineOne>Erfurter Strasse 13</ram:LineOne>
179+
<ram:CityName>Demoort</ram:CityName>
180+
<ram:CountryID>DE</ram:CountryID>
181+
</ram:PostalTradeAddress>
182+
<ram:SpecifiedTaxRegistration>
183+
<ram:ID schemeID="VA">DE136695976</ram:ID>
184+
</ram:SpecifiedTaxRegistration>
185+
</ram:SellerTradeParty>
186+
<ram:BuyerTradeParty>
187+
<ram:ID>16259</ram:ID>
188+
<ram:Name>ConsultingService GmbH</ram:Name>
189+
<ram:PostalTradeAddress>
190+
<ram:PostcodeCode>76138</ram:PostcodeCode>
191+
<ram:LineOne>Musterstr. 18</ram:LineOne>
192+
<ram:CityName>Karlsruhe</ram:CityName>
193+
<ram:CountryID>DE</ram:CountryID>
194+
</ram:PostalTradeAddress>
195+
</ram:BuyerTradeParty>
196+
<ram:SellerOrderReferencedDocument>
197+
<ram:IssuerAssignedID>per Mail vom 01.09.2024</ram:IssuerAssignedID>
198+
</ram:SellerOrderReferencedDocument>
199+
<ram:AdditionalReferencedDocument>
200+
<ram:IssuerAssignedID>13130162</ram:IssuerAssignedID>
201+
<ram:URIID>#ef=Aufmass.png</ram:URIID>
202+
<ram:TypeCode>916</ram:TypeCode>
203+
</ram:AdditionalReferencedDocument>
204+
<ram:AdditionalReferencedDocument>
205+
<ram:IssuerAssignedID>42389</ram:IssuerAssignedID>
206+
<ram:URIID>#ef=ElektronRapport_neu-red.pdf</ram:URIID>
207+
<ram:TypeCode>916</ram:TypeCode>
208+
</ram:AdditionalReferencedDocument>
209+
<ram:SpecifiedProcuringProject>
210+
<ram:ID>13130162</ram:ID>
211+
<ram:Name>Projekt</ram:Name>
212+
</ram:SpecifiedProcuringProject>
213+
</ram:ApplicableHeaderTradeAgreement>
214+
<ram:ApplicableHeaderTradeDelivery>
215+
<ram:ActualDeliverySupplyChainEvent>
216+
<ram:OccurrenceDateTime>
217+
<udt:DateTimeString format="102">20241101</udt:DateTimeString>
218+
</ram:OccurrenceDateTime>
219+
</ram:ActualDeliverySupplyChainEvent>
220+
</ram:ApplicableHeaderTradeDelivery>
221+
<ram:ApplicableHeaderTradeSettlement>
222+
<ram:PaymentReference>Rechnung 181301674</ram:PaymentReference>
223+
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
224+
<ram:SpecifiedTradeSettlementPaymentMeans>
225+
<ram:TypeCode>58</ram:TypeCode>
226+
<ram:PayeePartyCreditorFinancialAccount>
227+
<ram:IBANID>DE91100000000123456789</ram:IBANID>
228+
</ram:PayeePartyCreditorFinancialAccount>
229+
</ram:SpecifiedTradeSettlementPaymentMeans>
230+
<ram:ApplicableTradeTax>
231+
<ram:CalculatedAmount>47.9</ram:CalculatedAmount>
232+
<ram:TypeCode>VAT</ram:TypeCode>
233+
<ram:BasisAmount>252.1</ram:BasisAmount>
234+
<ram:CategoryCode>S</ram:CategoryCode>
235+
<ram:RateApplicablePercent>19</ram:RateApplicablePercent>
236+
</ram:ApplicableTradeTax>
237+
<ram:SpecifiedTradePaymentTerms>
238+
<ram:Description>Zahlbar sofort rein netto</ram:Description>
239+
</ram:SpecifiedTradePaymentTerms>
240+
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
241+
<ram:LineTotalAmount>252.1</ram:LineTotalAmount>
242+
<ram:ChargeTotalAmount>0</ram:ChargeTotalAmount>
243+
<ram:AllowanceTotalAmount>0</ram:AllowanceTotalAmount>
244+
<ram:TaxBasisTotalAmount>252.1</ram:TaxBasisTotalAmount>
245+
<ram:TaxTotalAmount currencyID="EUR">47.9</ram:TaxTotalAmount>
246+
<ram:GrandTotalAmount>300</ram:GrandTotalAmount>
247+
<ram:TotalPrepaidAmount>0</ram:TotalPrepaidAmount>
248+
<ram:DuePayableAmount>300</ram:DuePayableAmount>
249+
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
250+
<ram:ReceivableSpecifiedTradeAccountingAccount>
251+
<ram:ID>420</ram:ID>
252+
</ram:ReceivableSpecifiedTradeAccountingAccount>
253+
</ram:ApplicableHeaderTradeSettlement>
254+
</rsm:SupplyChainTradeTransaction>
255+
</rsm:CrossIndustryInvoice>
256+
XML;
257+
258+
// Print text using writeHTMLCell()
259+
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
260+
261+
$pdf->EmbedFileFromString('factur-x.xml', $invoiceXml);
262+
263+
$pdf->setExtraXMPRDF(
264+
'<rdf:Description xmlns:fx="urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#" rdf:about="">
265+
<fx:DocumentType>INVOICE</fx:DocumentType>
266+
<fx:DocumentFileName>factur-x.xml</fx:DocumentFileName>
267+
<fx:Version>1.0</fx:Version>
268+
<fx:ConformanceLevel>EN 16931</fx:ConformanceLevel>
269+
</rdf:Description>');
270+
271+
$pdf->setExtraXMPPdfaextension(
272+
'<rdf:li rdf:parseType="Resource">
273+
<pdfaSchema:schema>Factur-X PDFA Extension Schema</pdfaSchema:schema>
274+
<pdfaSchema:namespaceURI>urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>
275+
<pdfaSchema:prefix>fx</pdfaSchema:prefix>
276+
<pdfaSchema:property>
277+
<rdf:Seq>
278+
<rdf:li rdf:parseType="Resource">
279+
<pdfaProperty:name>DocumentFileName</pdfaProperty:name>
280+
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
281+
<pdfaProperty:category>external</pdfaProperty:category>
282+
<pdfaProperty:description>The name of the embedded XML document</pdfaProperty:description>
283+
</rdf:li>
284+
<rdf:li rdf:parseType="Resource">
285+
<pdfaProperty:name>DocumentType</pdfaProperty:name>
286+
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
287+
<pdfaProperty:category>external</pdfaProperty:category>
288+
<pdfaProperty:description>The type of the hybrid document in capital letters, e.g. INVOICE or ORDER</pdfaProperty:description>
289+
</rdf:li>
290+
<rdf:li rdf:parseType="Resource">
291+
<pdfaProperty:name>Version</pdfaProperty:name>
292+
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
293+
<pdfaProperty:category>external</pdfaProperty:category>
294+
<pdfaProperty:description>The actual version of the standard applying to the embedded XML document</pdfaProperty:description>
295+
</rdf:li>
296+
<rdf:li rdf:parseType="Resource">
297+
<pdfaProperty:name>ConformanceLevel</pdfaProperty:name>
298+
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
299+
<pdfaProperty:category>external</pdfaProperty:category>
300+
<pdfaProperty:description>The conformance level of the embedded XML document</pdfaProperty:description>
301+
</rdf:li>
302+
</rdf:Seq>
303+
</pdfaSchema:property>
304+
</rdf:li>'
305+
);
306+
307+
308+
// ---------------------------------------------------------
309+
310+
// Close and output PDF document
311+
// This method has several options, check the source code documentation for more information.
312+
$pdf->Output('example_068.pdf', 'I');

examples/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<li>PDF/A-3b (ISO 19005-3:2012) document: [<a href="example_065.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
8888
<li>Using WriteHTMLCell: [<a href="example_066.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
8989
<li>Shorthand border styles including !important: [<a href="example_067.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
90+
<li>PDF/A-3b with embedded file (Factur-X 1.07 - ZUGFeRD 2.3): [<a href="example_068.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
9091
</ol>
9192

9293
<h2>Barcodes</h2>

include/tcpdf_static.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class TCPDF_STATIC {
5555
* Current TCPDF version.
5656
* @private static
5757
*/
58-
private static $tcpdf_version = '6.9.5';
58+
private static $tcpdf_version = '6.10.0';
5959

6060
/**
6161
* String alias for total number of pages.

0 commit comments

Comments
 (0)