Belge Oluştur (Tekli)
PDF4me Belge Oluştur (Tekli) Şablonları (Word, ...) birleştirerek tek bir belge oluşturur. HTML, veya PDF) veri yüküyle (JSON, XML, veya CSV) birinde REST Çağrı. Şablon şu olabilir: Base64halka açık bir URLveya ham HTMLVeriler satır içi metin olabilir, bir Base64-kodlanmış bir dosya veya bir URLOluşturulan görüntüyü döndürür. PDF, Docx, veya HTML ikili olarak (200) veya bir aracılığıyla Location-başlık anketi URL (202).
Kimliğinizi Doğrulama API Rica etmek
Her PDF4me REST Çağrınızda mutlaka sizin de bulunmanız gerekiyor. API anahtara Authorization Başlıkta Temel kimlik doğrulama (Basic auth) belirtilmiştir. Anahtarınızı geliştirici kontrol panelinden alın veya değiştirin.
Uç nokta
/api/v2/GenerateDocumentSingleKaçırmamanız Gereken Önemli Bilgiler
belgeVeriMetni veya belgeVeriDosyasıbelgeVeriMetni satır içi için JSON / XML / CSV. Kullanmak belgeVeriDosyası bir için Base64-kodlanmış veri dosyası veya herkese açık bir URL.PDF veya DocxHTML kabul eder HTML yalnızca PDF kabul edilir. PDF Sadece bu kadar. Büyük/küçük harf duyarlılığı önemlidir.IsAsync: true o API 202 yanıtı ve bir Location başlığı içerebilir. GET O URL (aynı Yetkilendirme) işlenmiş dosya ile 200'e kadar (standart) pdf4meAsyncRequest model).HTTP kurmak
Yöntem: POSTALAMAK
URL: https://api.pdf4me.com/api/v2/GenerateDocumentSingle
İçerik Türü: uygulama/json
Yetkilendirme: Temel <sizin PDF4me API anahtar>
Göndermek IsAsync: true Vücutta. 200 Oluşturulan dosya baytlarını döndürür. 202 bir döndürür Konum anket içeren başlık URL; GET O URL 200'e kadar aynı Yetkilendirme başlığıyla.
Varyant matrisi (Postman ile ilgili)
Bir şablon varyantı (T1 / T2 / T3) ve bir veri varyantı (D1 / D2 / D3) seçin. Altı kombinasyon her çağrıyı kapsar.
Şablon (templateFileData)
| Kod | Kaynak | Postacının değeri şablonDosyaVerileri | Ayrıca gerekli |
|---|---|---|---|
| T1 | Base64 | Base64 template file (strip data:...;base64, prefix if present) | templateFileName |
| T2 | URL | Full HTTPS URL string (not downloaded by the API request body) | templateFileName |
| T3 | HTML code | Base64-encoded UTF-8 HTML: Buffer.from(html, "utf8").toString("base64") | templateFileName, templateFileType: HTML |
Belge verileri (iki seçenekten biri) API alanlar)
| Kod | Kaynak | API alanı | Postacı değeri |
|---|---|---|---|
| D1 | Text | documentDataText | Raw JSON / XML / CSV string |
| D2 | Base64 | documentDataFile | Base64 of the data file (strip data-URL prefix if present) |
| D3 | URL | documentDataFile | Full HTTPS URL to .json / .xml / .csv |
Kural: tam olarak bir tane belgeVeriMetni veya belgeVeriDosyası Ayarlanmalıdır. Kullanılmayan alanı gövdeden çıkarın.
Yaygın kombinasyonlar
| # | Şablon | Veri | Tipik kullanım |
|---|---|---|---|
| 1 | T1 Docx base64 | D1 JSON text | Word mail-merge to PDF |
| 2 | T2 Docx URL | D3 JSON URL | Hosted template + hosted data |
| 3 | T3 HTML | D1 JSON text | HTML mustache rendered to HTML / PDF |
| 4 | T1 PDF form | D2 JSON base64 | PDF template + encoded data file |
| 5 | T2 MailMerge URL | D1 XML text | Word merge fields + inline XML |
şablonDosyaTipi → izin verilen çıktıTipi
şablonDosyaTürü | İzin verilmiş çıktıTürü | Notlar |
|---|---|---|
Docx | PDF, Docx | PDF4me Word template |
MailMerge | PDF, Docx | Mail merge Word |
GoogleDocs | PDF, Docx | Google Docs export style |
HTML | HTML only | Mustache in HTML |
PDF | PDF only | PDF form / template |
API vücut alanları
Her zaman gönderildi
| Alan | Gerekli | Tip | Notlar |
|---|---|---|---|
templateFileType | Yes | string | Docx, HTML, PDF, MailMerge, GoogleDocs |
templateFileName | Yes | string | With extension, e.g. template.docx, template.html, template.pdf |
templateFileData | Yes | string | Base64 template, or template URL string |
documentDataType | Yes | string | Json, XML, or Csv (exact casing) |
outputType | Yes | string | PDF, Docx, or HTML (see allowed-output table above) |
IsAsync | Yes | boolean | true |
Belge verileri (tek yol)
| Alan | Gerekli olduğu zamanlar | Tip | Notlar |
|---|---|---|---|
documentDataText | D1 (text) | string | Valid JSON when documentDataType is Json; XML must look like XML; CSV non-empty |
documentDataFile | D2 or D3 | string | Base64 data file or URL to data file |
İsteğe bağlı
| Alan | Ne zaman | Varsayılan |
|---|---|---|
KeepPdfEditable | outputType is PDF | false |
documentDataFile | D1 text path is used | Omitted |
documentDataText | D2 or D3 path is used | Omitted |
Doğrulama kuralları
| Kontrol etmek | Detay |
|---|---|
| Template URL | Non-empty, valid URL. |
| Template base64 | Non-empty after optional data-URL strip. |
| HTML code | Only when templateFileType is HTML. Empty is rejected. Auto-wraps <html> if missing. |
| JSON text | Must parse successfully with JSON.parse. |
| XML text | Must start with < and contain >. |
| CSV text | Non-empty after trim. |
| Either data source | documentDataFile or documentDataText is required. |
Yer tutucu örnekler
| Öğe | Örnek |
|---|---|
| Template URL (Docx) | https://example.com/template.docx |
| Template name | template.docx / template.html / template.pdf |
| Data URL (JSON) | https://example.com/data.json |
| Data file name | data.json |
| JSON text | {"name": "John Doe", "email": "[email protected]", "items": [{"product": "Widget", "price": 29.99}]} |
| XML text | <?xml version="1.0"?><root><name>John Doe</name></root> |
| CSV text | name,email\nJohn Doe,[email protected] |
| HTML template | <!DOCTYPE html>...{{title}}... |
Örnek yükler
1. Word şablonu (base64) + JSON metin → PDF
{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "Json",
"documentDataText": "{\"name\": \"John Doe\", \"email\": \"[email protected]\", \"items\": [{\"product\": \"Widget\", \"price\": 29.99}]}",
"outputType": "PDF",
"KeepPdfEditable": false,
"IsAsync": true
}
2. Word şablonu (URL) + JSON veri (URL) → PDF
{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "https://example.com/template.docx",
"documentDataType": "Json",
"documentDataFile": "https://example.com/data.json",
"outputType": "PDF",
"KeepPdfEditable": false,
"IsAsync": true
}
3. Word şablonu (base64) + JSON Veri (base64) → Word çıktısı
documentDataFile base64 formatındaki verileri tutar. JSON Dosya baytları (ayrıştırılmış nesne değil).
{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "Json",
"documentDataFile": "eyJuYW1lIjogIkpvaG4gRG9lIn0=",
"outputType": "Docx",
"IsAsync": true
}
4. HTML şablon (base64'ten) HTML dosya) + JSON metin → HTML
Ham madde için HTML Postman'de aynı veri paketini gönderin. n8n düğüm şunları yapardı: base64 kodlu HTML içinde templateFileData.
{
"templateFileType": "HTML",
"templateFileName": "template.html",
"templateFileData": "PCFET0NUWVBFIGh0bWw+...",
"documentDataType": "Json",
"documentDataText": "{\"title\": \"Invoice\", \"heading\": \"Hello\", \"content\": \"World\"}",
"outputType": "HTML",
"IsAsync": true
}
5. Posta birleştirme (URL) + XML metin → PDF
{
"templateFileType": "MailMerge",
"templateFileName": "template.docx",
"templateFileData": "https://example.com/template.docx",
"documentDataType": "XML",
"documentDataText": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><name>John Doe</name><email>[email protected]</email></root>",
"outputType": "PDF",
"IsAsync": true
}
6. PDF Form şablonu (base64) + CSV metin → PDF (düzenlenebilir)
{
"templateFileType": "PDF",
"templateFileName": "template.pdf",
"templateFileData": "JVBERi0xLjQKJcfsj6IK...",
"documentDataType": "Csv",
"outputType": "PDF",
"KeepPdfEditable": true,
"IsAsync": true
}
7. Google Dokümanlar stili (base64) + JSON URL → Docx
{
"templateFileType": "GoogleDocs",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "Json",
"documentDataFile": "https://example.com/data.json",
"outputType": "Docx",
"IsAsync": true
}
Postacı tahsilat ipuçları
curl örneği
curl -X POST https://api.pdf4me.com/api/v2/GenerateDocumentSingle \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "https://example.com/template.docx",
"documentDataType": "Json",
"documentDataFile": "https://example.com/data.json",
"outputType": "PDF",
"KeepPdfEditable": false,
"IsAsync": true
}' \
--output generated.pdf
Hızlı referans: varyanta göre gerekli ve isteğe bağlı olanlar
| Alan | T1+D1 | T2+D3 | T1+D2 | T3+D1 | Herhangi bir PDF çıktısı |
|---|---|---|---|---|---|
templateFileType | Req | Req | Req | Req | Req |
templateFileName | Req | Req | Req | Req | Req |
templateFileData | Req (b64) | Req (URL) | Req (b64) | Req (b64 HTML) | Req |
documentDataType | Req | Req | Req | Req | Req |
outputType | Req | Req | Req | Req | Req |
documentDataText | Req | Omit | Omit | Req | Omit |
documentDataFile | Omit | Req (URL) | Req (b64) | Omit | Omit |
IsAsync | Req | Req | Req | Req | Req |
KeepPdfEditable | Opt | Opt | Opt | N/A* | Opt if PDF |
*KeepPdfEditable yalnızca şu durumlarda geçerlidir çıktıTürü dır PDF; API aksi takdirde yanlış sonuçlar doğurur.