PDF genereren
POST /api/v1/generate-pdf — upload een Peppol BIS 3.0 XML-bestand en ontvang een binaire PDF-download.
PDF genereren
POST /api/v1/generate-pdfAccepteert een multipart/form-data-verzoek met een Peppol BIS 3.0 XML-bestand en geeft een binaire PDF-download terug.
Verzoek
Headers
| Header | Waarde | Verplicht |
|---|---|---|
Authorization | Bearer <jouw_api_sleutel> | Ja |
Formuliervelden
| Veld | Type | Verplicht | Beschrijving |
|---|---|---|---|
file | bestand | Ja | Peppol BIS 3.0 XML-bestand om te converteren |
config | string | Nee | JSON-object met generatieopties (zie hieronder) |
Het config-veld moet als JSON-string worden meegegeven. Als het ontbreekt, wordt standaard {"locale":"en"} gebruikt.
Configuratieopties
{
"locale": "nl",
"preset": "accountant",
"fields": { ... }
}| Veld | Type | Standaard | Beschrijving |
|---|---|---|---|
locale | string | en | Localecode voor labelvertaling. Ondersteund: en, nl, fr |
preset | string | — | Voorgedefinieerde veldmapping. Één van accountant of administration. Wederzijds exclusief met fields |
fields | object | — | Gedetailleerde veldcontrole. Wederzijds exclusief met preset |
Presets
| Preset | Beschrijving |
|---|---|
accountant | Velden relevant voor boekhouddoeleinden |
administration | Velden relevant voor administratieve doeleinden |
Velden
Gebruik fields om afzonderlijke Peppol BIS 3.0-gegevensvelden in de gegenereerde PDF te tonen of te verbergen. Elke sleutel komt overeen met een Peppol-element en accepteert een boolean (true om op te nemen, false om uit te sluiten). Geneste objecten bieden gedetailleerde controle over subvelden.
Documentheader
| Veld | BT / BG | Beschrijving |
|---|---|---|
CustomizationID | BT-24 | Specificatie-identifier |
ProfileID | BT-23 | Bedrijfsprocestype |
ID | BT-1 | Factuurnummer |
IssueDate | BT-2 | Factuurdatum |
DueDate | BT-9 | Vervaldatum betaling |
InvoiceTypeCode | BT-3 | Factuurtype (bijv. 380) |
Note | BT-22 | Factuurnotitie |
TaxPointDate | BT-7 | Datum btw-punt |
DocumentCurrencyCode | BT-5 | Factuurvalutacode |
TaxCurrencyCode | BT-6 | Btw-boekhoudingsvalutacode |
AccountingCost | BT-19 | Boekhoudingsreferentie koper |
BuyerReference | BT-10 | Koperreferentie |
PaymentTerms | BT-20 | Betalingsvoorwaarden |
Documentreferenties
| Veld | BT / BG | Beschrijving |
|---|---|---|
BillingReference | BG-3 | Verwijzingen naar voorgaande facturen |
DespatchDocumentReference | BT-16 | Leveringsadviesreferentie |
ReceiptDocumentReference | BT-15 | Ontvangstadviesreferentie |
OriginatorDocumentReference | BT-17 | Offerte- of lotreferentie |
ContractDocumentReference | BT-12 | Contractreferentie |
AdditionalDocumentReference | BG-24 | Aanvullende ondersteunende documenten |
ProjectReference | BT-11 | Projectreferentie |
InvoicePeriod
BG-14 — Factuurperiode
InvoicePeriod accepteert false of een object met subvelden:
| Subveld | BT | Beschrijving |
|---|---|---|
StartDate | BT-73 | Startdatum factuurperiode |
EndDate | BT-74 | Einddatum factuurperiode |
DescriptionCode | BT-8 | Datum btw-puntcode |
OrderReference
OrderReference accepteert false of een object:
| Subveld | BT | Beschrijving |
|---|---|---|
ID | BT-13 | Inkooporderreferentie |
SalesOrderID | BT-14 | Verkooporderreferentie |
Partijen
AccountingSupplierParty / AccountingCustomerParty
BG-4 — Verkoper / BG-7 — Koper
AccountingSupplierParty (BG-4 — Verkoper) en AccountingCustomerParty (BG-7 — Koper) accepteren elk false of een object met een Party-subobject met de volgende velden:
| Subveld | BT | Beschrijving |
|---|---|---|
EndpointID | BT-34 / BT-49 | Elektronisch adres (incl. schema) |
PartyIdentification | BT-29 / BT-46 | Identificator(s) (incl. schema) |
PartyName | BT-27 / BT-44 | Naam / handelsnaam |
PostalAddress | — | false of object — zie subvelden hieronder |
PartyTaxScheme | BT-31 / BT-48 | Btw-identificator / belastingregistratie |
PartyLegalEntity | — | false of object — zie subvelden hieronder |
Contact | BG-6 / BG-9 | false of object — zie subvelden hieronder |
Subvelden PostalAddress:
| Subveld | Beschrijving |
|---|---|
StreetName | Straatnaam |
AdditionalStreetName | Aanvullende straatnaam |
CityName | Plaatsnaam |
PostalZone | Postcode |
CountrySubentity | Provincie of regio |
AddressLine.Line | Extra adresregel |
Country.IdentificationCode | Landcode |
Subvelden PartyLegalEntity:
| Subveld | BT | Beschrijving |
|---|---|---|
RegistrationName | BT-27 / BT-44 | Wettelijke handelsnaam |
CompanyID | BT-30 / BT-47 | Wettelijke registratie-identifier |
CompanyLegalForm | BT-33 (alleen verkoper) | Aanvullende wettelijke informatie |
Subvelden Contact:
| Subveld | Beschrijving |
|---|---|
Name | Contactnaam |
Telephone | Telefoonnummer |
ElectronicMail | E-mailadres |
PayeeParty
BG-10 — Begunstigde
PayeeParty accepteert false of een object:
| Subveld | BT | Beschrijving |
|---|---|---|
PartyIdentification | BT-60 | Begunstigde-identifier (incl. schema) |
PartyName | BT-59 | Naam begunstigde |
PartyLegalEntity | BT-61 | Wettelijke registratie-identifier begunstigde |
TaxRepresentativeParty
BG-11 — Btw-vertegenwoordiger verkoper
TaxRepresentativeParty accepteert false of een object:
| Subveld | BT | Beschrijving |
|---|---|---|
PartyName | BT-62 | Naam btw-vertegenwoordiger verkoper |
PostalAddress | — | false of object — zelfde subvelden als PostalAddress hierboven |
PartyTaxScheme | — | false of object — zie subvelden hieronder |
Subvelden PartyTaxScheme:
| Subveld | BT | Beschrijving |
|---|---|---|
CompanyID | BT-63 | Btw-identificator btw-vertegenwoordiger verkoper |
TaxScheme | — | Object met ID (boolean) |
Levering
Delivery
BG-13 — Leveringsinformatie
Delivery accepteert false of een object:
| Subveld | BT | Beschrijving |
|---|---|---|
ActualDeliveryDate | BT-72 | Werkelijke leveringsdatum |
DeliveryParty | BT-70 | Naam afleverende partij |
DeliveryLocation | BG-15 | false of object — zie subvelden hieronder |
Subvelden DeliveryLocation:
| Subveld | BT | Beschrijving |
|---|---|---|
ID | BT-71 | Locatie-identifier afleveradres (incl. schema BT-71-1) |
Address | — | false of object — zelfde subvelden als PostalAddress hierboven |
Betaling
PaymentMeans
BG-16 — Betaalinstructies
PaymentMeans accepteert false of een object:
| Subveld | BT | Beschrijving |
|---|---|---|
PaymentMeansCode | BT-81 | Betalingsmiddelcode (incl. BT-82 naam) |
PaymentID | BT-83 | Betalingskenmerk |
PayeeFinancialAccount | BG-17 | Overboeking (IBAN, banknaam, enz.) |
CardAccount | BG-18 | Kaartbetalingsinformatie |
PaymentMandate | BG-19 | Automatische incasso (mandaatreferentie, belaste rekening) |
AllowanceCharge
BG-20 — Kortingen op documentniveau / BG-21 — Toeslagen op documentniveau
AllowanceCharge accepteert false of een object:
| Subveld | BT | Beschrijving |
|---|---|---|
AllowanceChargeReasonCode | BT-98/BT-140 | Redenscode |
AllowanceChargeReason | BT-97/BT-139 | Redenstekst |
MultiplierFactorNumeric | BT-94/BT-138 | Percentage |
Amount | BT-92/BT-137 | Bedrag |
BaseAmount | BT-93/BT-138 | Basisbedrag |
TaxCategory | — | false of object — zie subvelden hieronder |
Subvelden TaxCategory:
| Subveld | BT | Beschrijving |
|---|---|---|
ID | BT-95/BT-102 | Btw-categoriecode |
Percent | BT-96/BT-103 | Btw-tarief |
TaxScheme | — | Object met ID (boolean) |
Belasting en totalen
TaxTotal
BG-22 — Btw-uitsplitsing
TaxTotal accepteert false of een object:
| Subveld | BT | Beschrijving |
|---|---|---|
TaxAmount | BT-110/BT-111 | Totaal btw-bedrag factuur |
TaxSubtotal | BG-23 | false of object — zie subvelden hieronder |
Subvelden TaxSubtotal (BG-23 — Btw-uitsplitsingsrij):
| Subveld | BT | Beschrijving |
|---|---|---|
TaxableAmount | BT-116 | Belastbaar bedrag btw-categorie |
TaxAmount | BT-117 | Btw-bedrag btw-categorie |
TaxCategory | — | false of object — zie subvelden hieronder |
Subvelden TaxSubtotal.TaxCategory:
| Subveld | BT | Beschrijving |
|---|---|---|
ID | BT-118 | Btw-categoriecode |
Percent | BT-119 | Btw-tarief categorie |
TaxExemptionReasonCode | BT-121 | Code reden btw-vrijstelling |
TaxExemptionReason | BT-120 | Redentekst btw-vrijstelling |
TaxScheme | — | Object met ID (boolean) |
LegalMonetaryTotal
BG-22 — Documenttotalen
LegalMonetaryTotal accepteert false of een object:
| Subveld | BT | Beschrijving |
|---|---|---|
LineExtensionAmount | BT-106 | Som van nettobedragen factuurregels |
AllowanceTotalAmount | BT-107 | Som van kortingen op documentniveau |
ChargeTotalAmount | BT-108 | Som van toeslagen op documentniveau |
TaxExclusiveAmount | BT-109 | Factuurtotaal excl. btw |
TaxInclusiveAmount | BT-112 | Factuurtotaal incl. btw |
PrepaidAmount | BT-113 | Vooruitbetaald bedrag |
PayableRoundingAmount | BT-114 | Afrondingsbedrag |
PayableAmount | BT-115 | Te betalen bedrag |
Factuurregels
InvoiceLine
BG-25 — Factuurregel
InvoiceLine accepteert false of een object:
| Subveld | BT | Beschrijving |
|---|---|---|
ID | BT-126 | Factuurregelidentificator |
Note | BT-127 | Factuurregelnotitie |
InvoicedQuantity | BT-129 / BT-130 | Gefactureerde hoeveelheid / maateenheid |
LineExtensionAmount | BT-131 | Nettobedrag factuurregel |
AccountingCost | BT-133 | Boekhoudingsreferentie koper voor factuurregel |
InvoicePeriod | BG-26 | false of object — zie subvelden hieronder |
OrderLineReference | — | false of object — zie subvelden hieronder |
DocumentReference | — | false of object — zie subvelden hieronder |
AllowanceCharge | BG-27 / BG-28 | false of object — zie subvelden hieronder |
Item | BG-31 | false of object — zie subvelden hieronder |
Price | BG-29 | false of object — zie subvelden hieronder |
Subvelden InvoicePeriod (BG-26 — Factuurregelperiode):
| Subveld | BT | Beschrijving |
|---|---|---|
StartDate | BT-134 | Startdatum factuurregelperiode |
EndDate | BT-135 | Einddatum factuurregelperiode |
Subvelden OrderLineReference:
| Subveld | BT | Beschrijving |
|---|---|---|
LineID | BT-132 | Referentie inkooporderregel |
Subvelden DocumentReference:
| Subveld | BT | Beschrijving |
|---|---|---|
ID | BT-128 | Object-identifier factuurregel (incl. schema) |
DocumentTypeCode | — | Documenttypecode |
Subvelden AllowanceCharge (BG-27 / BG-28 — Kortingen en toeslagen factuurregel):
| Subveld | BT | Beschrijving |
|---|---|---|
ChargeIndicator | — | true voor toeslag, false voor korting |
AllowanceChargeReasonCode | BT-140 / BT-145 | Redenscode |
AllowanceChargeReason | BT-139 / BT-144 | Redenstekst |
MultiplierFactorNumeric | BT-138 / BT-143 | Percentage |
Amount | BT-136 / BT-141 | Bedrag |
BaseAmount | — | Basisbedrag |
Subvelden Item (BG-31 — Artikelinformatie):
| Subveld | BT | Beschrijving |
|---|---|---|
Name | BT-153 | Artikelnaam |
Description | BT-154 | Artikelomschrijving |
SellersItemIdentification.ID | BT-155 | Verkopersidentificator artikel |
BuyersItemIdentification.ID | BT-156 | Kopersidentificator artikel |
StandardItemIdentification.ID | BT-157 | Standaardidentificator artikel (incl. schema BT-157-1) |
OriginCountry.IdentificationCode | BT-159 | Land van oorsprong artikel |
CommodityClassification | BT-158 | Classificatie-identifier artikel |
ClassifiedTaxCategory | BG-30 | false of object — zie subvelden hieronder |
AdditionalItemProperty | BG-32 | Artikelkenmerken (naam/waarde-paren) |
Subvelden ClassifiedTaxCategory (BG-30 — Btw-informatie factuurregel):
| Subveld | BT | Beschrijving |
|---|---|---|
ID | BT-151 | Btw-categoriecode gefactureerd artikel |
Percent | BT-152 | Btw-tarief gefactureerd artikel |
TaxScheme | — | Object met ID (boolean) |
Subvelden Price (BG-29 — Prijsdetails):
| Subveld | BT | Beschrijving |
|---|---|---|
PriceAmount | BT-146 | Nettoprijsbedrag artikel |
BaseQuantity | BT-149 / BT-150 | Basishoeveelheid prijs / maateenheid |
AllowanceCharge | — | false of object — zie subvelden hieronder |
Subvelden Price.AllowanceCharge:
| Subveld | BT | Beschrijving |
|---|---|---|
ChargeIndicator | — | Moet false zijn (korting) |
Amount | BT-147 | Prijskorting artikel |
BaseAmount | BT-148 | Brutoprijsbedrag artikel |
Respons
200 — Geslaagd
Geeft een binaire PDF-download terug.
Content-Type: application/pdf400 — Ongeldig verzoek
{
"error": "string"
}Wordt geretourneerd als het bestand ontbreekt, de XML ongeldig is of het documenttype niet wordt ondersteund.
401 — Niet geautoriseerd
{
"error": "string"
}Wordt geretourneerd als de API-sleutel ontbreekt of ongeldig is.
Voorbeelden
Basis — PDF downloaden
curl -X POST "https://api.peppolpdf.eu/api/v1/generate-pdf" \
-H "Authorization: Bearer JOUW_API_SLEUTEL" \
-F "file=@factuur.xml" \
-o factuur.pdfimport fs from "fs";
const form = new FormData();
form.append("file", new Blob([fs.readFileSync("factuur.xml")], { type: "application/xml" }), "factuur.xml");
form.append("config", JSON.stringify({ locale: "nl" }));
const res = await fetch("https://api.peppolpdf.eu/api/v1/generate-pdf", {
method: "POST",
headers: { "Authorization": `Bearer ${process.env.PEPPOLPDF_API_KEY!}` },
body: form,
});
if (!res.ok) {
const { error } = await res.json();
throw new Error(error);
}
fs.writeFileSync("factuur.pdf", Buffer.from(await res.arrayBuffer()));import os
import requests
with open("factuur.xml", "rb") as f:
response = requests.post(
"https://api.peppolpdf.eu/api/v1/generate-pdf",
headers={"Authorization": f"Bearer {os.environ['PEPPOLPDF_API_KEY']}"},
files={"file": ("factuur.xml", f, "application/xml")},
)
response.raise_for_status()
with open("factuur.pdf", "wb") as f:
f.write(response.content)<?php
$curl = curl_init('https://api.peppolpdf.eu/api/v1/generate-pdf');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('PEPPOLPDF_API_KEY')],
CURLOPT_POSTFIELDS => [
'file' => new CURLFile('factuur.xml', 'application/xml', 'factuur.xml'),
],
]);
$pdf = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($httpCode !== 200) {
throw new RuntimeException('API fout: ' . $pdf);
}
file_put_contents('factuur.pdf', $pdf);package main
import (
"bytes"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
file, _ := os.Open("factuur.xml")
defer file.Close()
var body bytes.Buffer
writer := multipart.NewWriter(&body)
part, _ := writer.CreateFormFile("file", "factuur.xml")
io.Copy(part, file)
writer.Close()
req, _ := http.NewRequest(http.MethodPost, "https://api.peppolpdf.eu/api/v1/generate-pdf", &body)
req.Header.Set("Authorization", "Bearer " + os.Getenv("PEPPOLPDF_API_KEY"))
req.Header.Set("Content-Type", writer.FormDataContentType())
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
out, _ := os.Create("factuur.pdf")
defer out.Close()
io.Copy(out, resp.Body)
}using var fileStream = File.OpenRead("factuur.xml");
using var content = new MultipartFormDataContent
{
{ new StreamContent(fileStream), "file", "factuur.xml" },
};
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + Environment.GetEnvironmentVariable("PEPPOLPDF_API_KEY"));
var response = await client.PostAsync("https://api.peppolpdf.eu/api/v1/generate-pdf", content);
response.EnsureSuccessStatusCode();
var pdf = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("factuur.pdf", pdf);import okhttp3.*;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
var client = new OkHttpClient();
var body = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("file", "factuur.xml",
RequestBody.create(new File("factuur.xml"), MediaType.parse("application/xml")))
.build();
var request = new Request.Builder()
.url("https://api.peppolpdf.eu/api/v1/generate-pdf")
.addHeader("Authorization", "Bearer " + System.getenv("PEPPOLPDF_API_KEY"))
.post(body)
.build();
try (var response = client.newCall(request).execute()) {
if (!response.isSuccessful()) throw new IOException("API fout: " + response);
Files.write(Path.of("factuur.pdf"), response.body().bytes());
}Met locale en preset
curl -X POST "https://api.peppolpdf.eu/api/v1/generate-pdf" \
-H "Authorization: Bearer JOUW_API_SLEUTEL" \
-F "file=@factuur.xml" \
-F 'config={"preset":"administration","locale":"nl"}' \
-o factuur.pdfimport fs from "fs";
const form = new FormData();
form.append("file", new Blob([fs.readFileSync("factuur.xml")], { type: "application/xml" }), "factuur.xml");
form.append("config", JSON.stringify({ preset: "administration", locale: "nl" }));
const res = await fetch("https://api.peppolpdf.eu/api/v1/generate-pdf", {
method: "POST",
headers: { "Authorization": `Bearer ${process.env.PEPPOLPDF_API_KEY!}` },
body: form,
});
if (!res.ok) {
const { error } = await res.json();
throw new Error(error);
}
fs.writeFileSync("factuur.pdf", Buffer.from(await res.arrayBuffer()));import os
import json
import requests
with open("factuur.xml", "rb") as f:
response = requests.post(
"https://api.peppolpdf.eu/api/v1/generate-pdf",
headers={"Authorization": f"Bearer {os.environ['PEPPOLPDF_API_KEY']}"},
files={"file": ("factuur.xml", f, "application/xml")},
data={"config": json.dumps({"preset": "administration", "locale": "nl"})},
)
response.raise_for_status()
with open("factuur.pdf", "wb") as f:
f.write(response.content)<?php
$curl = curl_init('https://api.peppolpdf.eu/api/v1/generate-pdf');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('PEPPOLPDF_API_KEY')],
CURLOPT_POSTFIELDS => [
'file' => new CURLFile('factuur.xml', 'application/xml', 'factuur.xml'),
'config' => json_encode(['preset' => 'all', 'locale' => 'nl']),
],
]);
$pdf = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($httpCode !== 200) {
throw new RuntimeException('API fout: ' . $pdf);
}
file_put_contents('factuur.pdf', $pdf);package main
import (
"bytes"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
file, _ := os.Open("factuur.xml")
defer file.Close()
var body bytes.Buffer
writer := multipart.NewWriter(&body)
part, _ := writer.CreateFormFile("file", "factuur.xml")
io.Copy(part, file)
writer.WriteField("config", `{"preset":"administration","locale":"nl"}`)
writer.Close()
req, _ := http.NewRequest(http.MethodPost, "https://api.peppolpdf.eu/api/v1/generate-pdf", &body)
req.Header.Set("Authorization", "Bearer " + os.Getenv("PEPPOLPDF_API_KEY"))
req.Header.Set("Content-Type", writer.FormDataContentType())
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
out, _ := os.Create("factuur.pdf")
defer out.Close()
io.Copy(out, resp.Body)
}using var fileStream = File.OpenRead("factuur.xml");
using var content = new MultipartFormDataContent
{
{ new StreamContent(fileStream), "file", "factuur.xml" },
{ new StringContent("""{ \"preset\":\"administration\",\"locale\":\"nl\"}"""), "config" },
};
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + Environment.GetEnvironmentVariable("PEPPOLPDF_API_KEY"));
var response = await client.PostAsync("https://api.peppolpdf.eu/api/v1/generate-pdf", content);
response.EnsureSuccessStatusCode();
var pdf = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("factuur.pdf", pdf);import okhttp3.*;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
var client = new OkHttpClient();
var body = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("file", "factuur.xml",
RequestBody.create(new File("factuur.xml"), MediaType.parse("application/xml")))
.addFormDataPart("config", "{\"preset\":\"administration\",\"locale\":\"nl\"}")
.build();
var request = new Request.Builder()
.url("https://api.peppolpdf.eu/api/v1/generate-pdf")
.addHeader("Authorization", "Bearer " + System.getenv("PEPPOLPDF_API_KEY"))
.post(body)
.build();
try (var response = client.newCall(request).execute()) {
if (!response.isSuccessful()) throw new IOException("API fout: " + response);
Files.write(Path.of("factuur.pdf"), response.body().bytes());
}Met gedetailleerde veldcontrole
curl -X POST "https://api.peppolpdf.eu/api/v1/generate-pdf" \
-H "Authorization: Bearer JOUW_API_SLEUTEL" \
-F "file=@factuur.xml" \
-F 'config={"locale":"nl","fields":{"ID":true,"IssueDate":true,"DueDate":true,"LegalMonetaryTotal":true,"InvoiceLine":true}}' \
-o factuur.pdfimport fs from "fs";
const config = {
locale: "nl",
fields: {
ID: true,
IssueDate: true,
DueDate: true,
AccountingSupplierParty: {
Party: { PartyName: true, PostalAddress: true, PartyTaxScheme: true },
},
AccountingCustomerParty: {
Party: { PartyName: true, PostalAddress: true },
},
LegalMonetaryTotal: true,
InvoiceLine: true,
},
};
const form = new FormData();
form.append("file", new Blob([fs.readFileSync("factuur.xml")], { type: "application/xml" }), "factuur.xml");
form.append("config", JSON.stringify(config));
const res = await fetch("https://api.peppolpdf.eu/api/v1/generate-pdf", {
method: "POST",
headers: { "Authorization": `Bearer ${process.env.PEPPOLPDF_API_KEY!}` },
body: form,
});
if (!res.ok) {
const { error } = await res.json();
throw new Error(error);
}
fs.writeFileSync("factuur.pdf", Buffer.from(await res.arrayBuffer()));import os
import json
import requests
config = {
"locale": "nl",
"fields": {
"ID": True,
"IssueDate": True,
"DueDate": True,
"AccountingSupplierParty": {
"Party": {"PartyName": True, "PostalAddress": True, "PartyTaxScheme": True}
},
"AccountingCustomerParty": {
"Party": {"PartyName": True, "PostalAddress": True}
},
"LegalMonetaryTotal": True,
"InvoiceLine": True,
},
}
with open("factuur.xml", "rb") as f:
response = requests.post(
"https://api.peppolpdf.eu/api/v1/generate-pdf",
headers={"Authorization": f"Bearer {os.environ['PEPPOLPDF_API_KEY']}"},
files={"file": ("factuur.xml", f, "application/xml")},
data={"config": json.dumps(config)},
)
response.raise_for_status()
with open("factuur.pdf", "wb") as f:
f.write(response.content)<?php
$config = [
'locale' => 'nl',
'fields' => [
'ID' => true,
'IssueDate' => true,
'DueDate' => true,
'AccountingSupplierParty' => [
'Party' => ['PartyName' => true, 'PostalAddress' => true, 'PartyTaxScheme' => true],
],
'AccountingCustomerParty' => [
'Party' => ['PartyName' => true, 'PostalAddress' => true],
],
'LegalMonetaryTotal' => true,
'InvoiceLine' => true,
],
];
$curl = curl_init('https://api.peppolpdf.eu/api/v1/generate-pdf');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('PEPPOLPDF_API_KEY')],
CURLOPT_POSTFIELDS => [
'file' => new CURLFile('factuur.xml', 'application/xml', 'factuur.xml'),
'config' => json_encode($config),
],
]);
$pdf = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($httpCode !== 200) {
throw new RuntimeException('API fout: ' . $pdf);
}
file_put_contents('factuur.pdf', $pdf);package main
import (
"bytes"
"encoding/json"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
config, _ := json.Marshal(map[string]any{
"locale": "nl",
"fields": map[string]any{
"ID": true, "IssueDate": true, "DueDate": true,
"LegalMonetaryTotal": true, "InvoiceLine": true,
},
})
file, _ := os.Open("factuur.xml")
defer file.Close()
var body bytes.Buffer
writer := multipart.NewWriter(&body)
part, _ := writer.CreateFormFile("file", "factuur.xml")
io.Copy(part, file)
writer.WriteField("config", string(config))
writer.Close()
req, _ := http.NewRequest(http.MethodPost, "https://api.peppolpdf.eu/api/v1/generate-pdf", &body)
req.Header.Set("Authorization", "Bearer " + os.Getenv("PEPPOLPDF_API_KEY"))
req.Header.Set("Content-Type", writer.FormDataContentType())
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
out, _ := os.Create("factuur.pdf")
defer out.Close()
io.Copy(out, resp.Body)
}var config = new {
locale = "nl",
fields = new {
ID = true, IssueDate = true, DueDate = true,
AccountingSupplierParty = new { Party = new { PartyName = true, PostalAddress = true, PartyTaxScheme = true } },
AccountingCustomerParty = new { Party = new { PartyName = true, PostalAddress = true } },
LegalMonetaryTotal = true,
InvoiceLine = true,
},
};
using var fileStream = File.OpenRead("factuur.xml");
using var content = new MultipartFormDataContent
{
{ new StreamContent(fileStream), "file", "factuur.xml" },
{ new StringContent(JsonSerializer.Serialize(config)), "config" },
};
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + Environment.GetEnvironmentVariable("PEPPOLPDF_API_KEY"));
var response = await client.PostAsync("https://api.peppolpdf.eu/api/v1/generate-pdf", content);
response.EnsureSuccessStatusCode();
var pdf = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("factuur.pdf", pdf);import okhttp3.*;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
var config = """
{"locale":"nl","fields":{"ID":true,"IssueDate":true,
"DueDate":true,"LegalMonetaryTotal":true,"InvoiceLine":true}}
""";
var client = new OkHttpClient();
var body = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("file", "factuur.xml",
RequestBody.create(new File("factuur.xml"), MediaType.parse("application/xml")))
.addFormDataPart("config", config)
.build();
var request = new Request.Builder()
.url("https://api.peppolpdf.eu/api/v1/generate-pdf")
.addHeader("Authorization", "Bearer " + System.getenv("PEPPOLPDF_API_KEY"))
.post(body)
.build();
try (var response = client.newCall(request).execute()) {
if (!response.isSuccessful()) throw new IOException("API fout: " + response);
Files.write(Path.of("factuur.pdf"), response.body().bytes());
}