Skip to content

Commit 0e0f5e5

Browse files
committed
Updated embedding files example
1 parent a141190 commit 0e0f5e5

File tree

4 files changed

+277
-3
lines changed

4 files changed

+277
-3
lines changed

PdfProcessing/GenerateDocument/DocumentGenerator.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,30 @@ private static RadFixedDocument CreateDocument()
100100

101101
DrawText(editor, maxWidth);
102102

103-
EmbedZugferdAddZugferdInvoice(document);
103+
string textFilePath = sampleDataPath + "sample text.txt";
104+
string textFileName = "Text file.txt";
105+
EmbedFileStream(document, textFilePath, textFileName);
106+
107+
string imageFilePath = sampleDataPath + "sample image.jpg";
108+
string imageFileName = "photo name.jpg";
109+
EmbedFileStream(document, textFilePath, textFileName);
110+
111+
string invoicePath = sampleDataPath + "zugferd-invoice.xml";
112+
AddZugferdInvoice(document, invoicePath);
104113

105114
return document;
106115
}
107116

108-
private static void EmbedZugferdAddZugferdInvoice(RadFixedDocument document)
117+
private static void EmbedFileStream(RadFixedDocument document, string filePath, string name)
118+
{
119+
RadFixedPage page = document.Pages.AddPage();
120+
byte[] textFile = File.ReadAllBytes(filePath);
121+
document.EmbeddedFiles.Add(name, textFile);
122+
}
123+
124+
private static void AddZugferdInvoice(RadFixedDocument document, string invoicePath)
109125
{
110-
byte[] bytes = File.ReadAllBytes(@"zugferd-invoice.xml");
126+
byte[] bytes = File.ReadAllBytes(invoicePath);
111127
//Only a single XML invoice attachment is allowed according to ZUGFeRD standard.
112128
document.EmbeddedFiles.AddZugferdInvoice(bytes);
113129
}
54.9 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a sample text document.
Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
<?xml version="1.0" encoding="UTF-8"?><rsm:CrossIndustryInvoice xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:a="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:10" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2+
<!--Created by PDFlib Cookbook program zugferd2_invoice_pdfa3b.java
3+
http://www.pdflib.com/pdflib-cookbook/-->
4+
<rsm:ExchangedDocumentContext>
5+
<ram:GuidelineSpecifiedDocumentContextParameter>
6+
<ram:ID>urn:cen.eu:en16931:2017#compliant#urn:zugferd.de:2p0:basic</ram:ID>
7+
</ram:GuidelineSpecifiedDocumentContextParameter>
8+
</rsm:ExchangedDocumentContext>
9+
<rsm:ExchangedDocument>
10+
<ram:ID>2019-03</ram:ID>
11+
<ram:TypeCode>380</ram:TypeCode>
12+
<ram:IssueDateTime>
13+
<udt:DateTimeString format="102">20190503</udt:DateTimeString>
14+
</ram:IssueDateTime>
15+
<ram:IncludedNote>
16+
<ram:Content>Created by PDFlib Cookbook program zugferd2_invoice_pdfa3b.java
17+
http://www.pdflib.com/pdflib-cookbook/</ram:Content>
18+
</ram:IncludedNote>
19+
</rsm:ExchangedDocument>
20+
<rsm:SupplyChainTradeTransaction>
21+
<ram:IncludedSupplyChainTradeLineItem>
22+
<ram:AssociatedDocumentLineDocument>
23+
<ram:LineID>1</ram:LineID>
24+
</ram:AssociatedDocumentLineDocument>
25+
<ram:SpecifiedTradeProduct>
26+
<ram:Name>Superdrachen</ram:Name>
27+
</ram:SpecifiedTradeProduct>
28+
<ram:SpecifiedLineTradeAgreement>
29+
<ram:NetPriceProductTradePrice>
30+
<ram:ChargeAmount>20.00</ram:ChargeAmount>
31+
</ram:NetPriceProductTradePrice>
32+
</ram:SpecifiedLineTradeAgreement>
33+
<ram:SpecifiedLineTradeDelivery>
34+
<ram:BilledQuantity unitCode="C62">2.0000</ram:BilledQuantity>
35+
</ram:SpecifiedLineTradeDelivery>
36+
<ram:SpecifiedLineTradeSettlement>
37+
<ram:ApplicableTradeTax>
38+
<ram:TypeCode>VAT</ram:TypeCode>
39+
<ram:CategoryCode>S</ram:CategoryCode>
40+
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
41+
</ram:ApplicableTradeTax>
42+
<ram:SpecifiedTradeSettlementLineMonetarySummation>
43+
<ram:LineTotalAmount>40.00</ram:LineTotalAmount>
44+
</ram:SpecifiedTradeSettlementLineMonetarySummation>
45+
</ram:SpecifiedLineTradeSettlement>
46+
</ram:IncludedSupplyChainTradeLineItem>
47+
<ram:IncludedSupplyChainTradeLineItem>
48+
<ram:AssociatedDocumentLineDocument>
49+
<ram:LineID>2</ram:LineID>
50+
</ram:AssociatedDocumentLineDocument>
51+
<ram:SpecifiedTradeProduct>
52+
<ram:Name>Turbo Flyer</ram:Name>
53+
</ram:SpecifiedTradeProduct>
54+
<ram:SpecifiedLineTradeAgreement>
55+
<ram:NetPriceProductTradePrice>
56+
<ram:ChargeAmount>40.00</ram:ChargeAmount>
57+
</ram:NetPriceProductTradePrice>
58+
</ram:SpecifiedLineTradeAgreement>
59+
<ram:SpecifiedLineTradeDelivery>
60+
<ram:BilledQuantity unitCode="C62">5.0000</ram:BilledQuantity>
61+
</ram:SpecifiedLineTradeDelivery>
62+
<ram:SpecifiedLineTradeSettlement>
63+
<ram:ApplicableTradeTax>
64+
<ram:TypeCode>VAT</ram:TypeCode>
65+
<ram:CategoryCode>S</ram:CategoryCode>
66+
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
67+
</ram:ApplicableTradeTax>
68+
<ram:SpecifiedTradeSettlementLineMonetarySummation>
69+
<ram:LineTotalAmount>200.00</ram:LineTotalAmount>
70+
</ram:SpecifiedTradeSettlementLineMonetarySummation>
71+
</ram:SpecifiedLineTradeSettlement>
72+
</ram:IncludedSupplyChainTradeLineItem>
73+
<ram:IncludedSupplyChainTradeLineItem>
74+
<ram:AssociatedDocumentLineDocument>
75+
<ram:LineID>3</ram:LineID>
76+
</ram:AssociatedDocumentLineDocument>
77+
<ram:SpecifiedTradeProduct>
78+
<ram:Name>Sturzflug-Geier</ram:Name>
79+
</ram:SpecifiedTradeProduct>
80+
<ram:SpecifiedLineTradeAgreement>
81+
<ram:NetPriceProductTradePrice>
82+
<ram:ChargeAmount>180.00</ram:ChargeAmount>
83+
</ram:NetPriceProductTradePrice>
84+
</ram:SpecifiedLineTradeAgreement>
85+
<ram:SpecifiedLineTradeDelivery>
86+
<ram:BilledQuantity unitCode="C62">1.0000</ram:BilledQuantity>
87+
</ram:SpecifiedLineTradeDelivery>
88+
<ram:SpecifiedLineTradeSettlement>
89+
<ram:ApplicableTradeTax>
90+
<ram:TypeCode>VAT</ram:TypeCode>
91+
<ram:CategoryCode>S</ram:CategoryCode>
92+
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
93+
</ram:ApplicableTradeTax>
94+
<ram:SpecifiedTradeSettlementLineMonetarySummation>
95+
<ram:LineTotalAmount>180.00</ram:LineTotalAmount>
96+
</ram:SpecifiedTradeSettlementLineMonetarySummation>
97+
</ram:SpecifiedLineTradeSettlement>
98+
</ram:IncludedSupplyChainTradeLineItem>
99+
<ram:IncludedSupplyChainTradeLineItem>
100+
<ram:AssociatedDocumentLineDocument>
101+
<ram:LineID>4</ram:LineID>
102+
</ram:AssociatedDocumentLineDocument>
103+
<ram:SpecifiedTradeProduct>
104+
<ram:Name>Eisvogel</ram:Name>
105+
</ram:SpecifiedTradeProduct>
106+
<ram:SpecifiedLineTradeAgreement>
107+
<ram:NetPriceProductTradePrice>
108+
<ram:ChargeAmount>50.00</ram:ChargeAmount>
109+
</ram:NetPriceProductTradePrice>
110+
</ram:SpecifiedLineTradeAgreement>
111+
<ram:SpecifiedLineTradeDelivery>
112+
<ram:BilledQuantity unitCode="C62">3.0000</ram:BilledQuantity>
113+
</ram:SpecifiedLineTradeDelivery>
114+
<ram:SpecifiedLineTradeSettlement>
115+
<ram:ApplicableTradeTax>
116+
<ram:TypeCode>VAT</ram:TypeCode>
117+
<ram:CategoryCode>S</ram:CategoryCode>
118+
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
119+
</ram:ApplicableTradeTax>
120+
<ram:SpecifiedTradeSettlementLineMonetarySummation>
121+
<ram:LineTotalAmount>150.00</ram:LineTotalAmount>
122+
</ram:SpecifiedTradeSettlementLineMonetarySummation>
123+
</ram:SpecifiedLineTradeSettlement>
124+
</ram:IncludedSupplyChainTradeLineItem>
125+
<ram:IncludedSupplyChainTradeLineItem>
126+
<ram:AssociatedDocumentLineDocument>
127+
<ram:LineID>5</ram:LineID>
128+
</ram:AssociatedDocumentLineDocument>
129+
<ram:SpecifiedTradeProduct>
130+
<ram:Name>Storch</ram:Name>
131+
</ram:SpecifiedTradeProduct>
132+
<ram:SpecifiedLineTradeAgreement>
133+
<ram:NetPriceProductTradePrice>
134+
<ram:ChargeAmount>20.00</ram:ChargeAmount>
135+
</ram:NetPriceProductTradePrice>
136+
</ram:SpecifiedLineTradeAgreement>
137+
<ram:SpecifiedLineTradeDelivery>
138+
<ram:BilledQuantity unitCode="C62">10.0000</ram:BilledQuantity>
139+
</ram:SpecifiedLineTradeDelivery>
140+
<ram:SpecifiedLineTradeSettlement>
141+
<ram:ApplicableTradeTax>
142+
<ram:TypeCode>VAT</ram:TypeCode>
143+
<ram:CategoryCode>S</ram:CategoryCode>
144+
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
145+
</ram:ApplicableTradeTax>
146+
<ram:SpecifiedTradeSettlementLineMonetarySummation>
147+
<ram:LineTotalAmount>200.00</ram:LineTotalAmount>
148+
</ram:SpecifiedTradeSettlementLineMonetarySummation>
149+
</ram:SpecifiedLineTradeSettlement>
150+
</ram:IncludedSupplyChainTradeLineItem>
151+
<ram:IncludedSupplyChainTradeLineItem>
152+
<ram:AssociatedDocumentLineDocument>
153+
<ram:LineID>6</ram:LineID>
154+
</ram:AssociatedDocumentLineDocument>
155+
<ram:SpecifiedTradeProduct>
156+
<ram:Name>Adler</ram:Name>
157+
</ram:SpecifiedTradeProduct>
158+
<ram:SpecifiedLineTradeAgreement>
159+
<ram:NetPriceProductTradePrice>
160+
<ram:ChargeAmount>75.00</ram:ChargeAmount>
161+
</ram:NetPriceProductTradePrice>
162+
</ram:SpecifiedLineTradeAgreement>
163+
<ram:SpecifiedLineTradeDelivery>
164+
<ram:BilledQuantity unitCode="C62">1.0000</ram:BilledQuantity>
165+
</ram:SpecifiedLineTradeDelivery>
166+
<ram:SpecifiedLineTradeSettlement>
167+
<ram:ApplicableTradeTax>
168+
<ram:TypeCode>VAT</ram:TypeCode>
169+
<ram:CategoryCode>S</ram:CategoryCode>
170+
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
171+
</ram:ApplicableTradeTax>
172+
<ram:SpecifiedTradeSettlementLineMonetarySummation>
173+
<ram:LineTotalAmount>75.00</ram:LineTotalAmount>
174+
</ram:SpecifiedTradeSettlementLineMonetarySummation>
175+
</ram:SpecifiedLineTradeSettlement>
176+
</ram:IncludedSupplyChainTradeLineItem>
177+
<ram:IncludedSupplyChainTradeLineItem>
178+
<ram:AssociatedDocumentLineDocument>
179+
<ram:LineID>7</ram:LineID>
180+
</ram:AssociatedDocumentLineDocument>
181+
<ram:SpecifiedTradeProduct>
182+
<ram:Name>Kostenlose Zugabe</ram:Name>
183+
</ram:SpecifiedTradeProduct>
184+
<ram:SpecifiedLineTradeAgreement>
185+
<ram:NetPriceProductTradePrice>
186+
<ram:ChargeAmount>0.00</ram:ChargeAmount>
187+
</ram:NetPriceProductTradePrice>
188+
</ram:SpecifiedLineTradeAgreement>
189+
<ram:SpecifiedLineTradeDelivery>
190+
<ram:BilledQuantity unitCode="C62">1.0000</ram:BilledQuantity>
191+
</ram:SpecifiedLineTradeDelivery>
192+
<ram:SpecifiedLineTradeSettlement>
193+
<ram:ApplicableTradeTax>
194+
<ram:TypeCode>VAT</ram:TypeCode>
195+
<ram:CategoryCode>S</ram:CategoryCode>
196+
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
197+
</ram:ApplicableTradeTax>
198+
<ram:SpecifiedTradeSettlementLineMonetarySummation>
199+
<ram:LineTotalAmount>0.00</ram:LineTotalAmount>
200+
</ram:SpecifiedTradeSettlementLineMonetarySummation>
201+
</ram:SpecifiedLineTradeSettlement>
202+
</ram:IncludedSupplyChainTradeLineItem>
203+
<ram:ApplicableHeaderTradeAgreement>
204+
<ram:SellerTradeParty>
205+
<ram:Name>Kraxi GmbH</ram:Name>
206+
<ram:PostalTradeAddress>
207+
<ram:PostcodeCode>12345</ram:PostcodeCode>
208+
<ram:LineOne>Flugzeugallee 17</ram:LineOne>
209+
<ram:CityName>Papierfeld</ram:CityName>
210+
<ram:CountryID>DE</ram:CountryID>
211+
</ram:PostalTradeAddress>
212+
<ram:SpecifiedTaxRegistration>
213+
<ram:ID schemeID="VA">DE123456789</ram:ID>
214+
</ram:SpecifiedTaxRegistration>
215+
</ram:SellerTradeParty>
216+
<ram:BuyerTradeParty>
217+
<ram:Name>Papierflieger-Vertriebs-GmbH</ram:Name>
218+
<ram:PostalTradeAddress>
219+
<ram:PostcodeCode>34567</ram:PostcodeCode>
220+
<ram:LineOne>Rabattstr. 25</ram:LineOne>
221+
<ram:CityName>Osterhausen</ram:CityName>
222+
<ram:CountryID>DE</ram:CountryID>
223+
</ram:PostalTradeAddress>
224+
</ram:BuyerTradeParty>
225+
</ram:ApplicableHeaderTradeAgreement>
226+
<ram:ApplicableHeaderTradeDelivery>
227+
<ram:ActualDeliverySupplyChainEvent>
228+
<ram:OccurrenceDateTime>
229+
<udt:DateTimeString format="102">20190503</udt:DateTimeString>
230+
</ram:OccurrenceDateTime>
231+
</ram:ActualDeliverySupplyChainEvent>
232+
</ram:ApplicableHeaderTradeDelivery>
233+
<ram:ApplicableHeaderTradeSettlement>
234+
<ram:PaymentReference>2019-03</ram:PaymentReference>
235+
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
236+
<ram:ApplicableTradeTax>
237+
<ram:CalculatedAmount>160.55</ram:CalculatedAmount>
238+
<ram:TypeCode>VAT</ram:TypeCode>
239+
<ram:BasisAmount>845.00</ram:BasisAmount>
240+
<ram:CategoryCode>S</ram:CategoryCode>
241+
<ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
242+
</ram:ApplicableTradeTax>
243+
<ram:SpecifiedTradePaymentTerms>
244+
<ram:DueDateDateTime>
245+
<udt:DateTimeString format="102">20190602</udt:DateTimeString>
246+
</ram:DueDateDateTime>
247+
</ram:SpecifiedTradePaymentTerms>
248+
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
249+
<ram:LineTotalAmount>845.00</ram:LineTotalAmount>
250+
<ram:TaxBasisTotalAmount>845.00</ram:TaxBasisTotalAmount>
251+
<ram:TaxTotalAmount currencyID="EUR">160.55</ram:TaxTotalAmount>
252+
<ram:GrandTotalAmount>1005.55</ram:GrandTotalAmount>
253+
<ram:DuePayableAmount>1005.55</ram:DuePayableAmount>
254+
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
255+
</ram:ApplicableHeaderTradeSettlement>
256+
</rsm:SupplyChainTradeTransaction>
257+
</rsm:CrossIndustryInvoice>

0 commit comments

Comments
 (0)