|
| 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;"> <span style="color:black;">TC</span><span style="color:white;">PDF</span> </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'); |
0 commit comments