Belge Oluştur (Birden Fazla)
PDF4me Belge Oluştur (Birden Fazla) birden fazla belgeyi tek bir şekilde görüntüler REST Çağrı. Tek bir kelime gönder. HTML, veya PDF şablon (Base64, URLveya ham HTML) artı bir dizi kayıt (JSON veya XMLmetin olarak, Base64 dosya veya URL). Bir değer döndürür. JSON Oluşturulan dosyaların listesi (her kayıt için bir giriş) Base64 içinde çıktıBelgeleri[].akışDosyasıYanıta bağlı olarak ya da tek bir ikili değer.
Kimliğinizi Doğrulama API Rica etmek
Her PDF4me REST Çağrınızda mutlaka sizin de bulunmanız gerekiyor. API anahtara girin 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/GenerateDocumentMultipleUç nokta adı şudur: GenerateDocumentMultiple (tekil) Belge), Olumsuz GenerateDocumentsMultiple.
Kaçırmamanız Gereken Önemli Bilgiler
çıktıBelgeleri[]dosya adı ve bir base64 akış dosyası (Bazen dosya içeriği, içerik, veya veriHer bir base64 dizesini çözerek dosyayı kaydedin.Docx, HTML, PDFSınırlı veri türleri şunlardır: Json, XMLÇıktı ekler xlsx Word için / PDF şablonlar.HTTP kurmak
Yöntem: POSTALAMAK
URL: https://api.pdf4me.com/api/v2/GenerateDocumentMultiple
İçerik Türü: uygulama/json
Yetkilendirme: Temel <sizin PDF4me API anahtar>
Göndermek IsAsync: true Vücutta. 200 geri dönebilir JSON ile çıktıBelgeleri[] veya tek bir ikili dosya. 202 bir döndürür Konum anket içeren başlık URL.
Farklılıklar ve Belge Oluşturma (Tekli)
| Başlık | Çoklu | Bekar |
|---|---|---|
| Endpoint | /api/v2/GenerateDocumentMultiple | /api/v2/GenerateDocumentSingle |
| templateFileType | Docx, HTML, PDF only | Also MailMerge, GoogleDocs |
| documentDataType | Json, XML only | Also Csv |
| outputType | PDF, Docx, xlsx (Word/PDF), HTML | No xlsx |
| Data shape | Typically array of records (one doc per row) | Usually one object |
| outputFileName | Integration-UI only (output naming) | Not in API body either |
Varyant matrisi (Postman ile ilgili)
Şablon (templateFileData)
| Kod | Kaynak | Postacı değeri | Ayrıca gerekli |
|---|---|---|---|
| T1 | Base64 | Base64 template (strip data:...;base64, prefix if present) | templateFileName |
| T2 | URL | HTTPS URL string | templateFileName |
| T3 | HTML code | Base64(UTF-8 HTML): Buffer.from(html, "utf8").toString("base64") | templateFileName, templateFileType: HTML |
Belge verileri
| Kod | Kaynak | API alanı | Postacı değeri |
|---|---|---|---|
| D1 | Text | documentDataText | JSON array (or XML with multiple records) |
| D2 | Base64 | documentDataFile | Base64 of the .json / .xml file |
| D3 | URL | documentDataFile | URL to the data file |
İkisinden birini kullanın. belgeVeriMetni veya belgeVeriDosyası (Kullanılmayan alanı atlayın).
şablonDosyaTipi → izin verilen çıktıTipi
şablonDosyaTürü | İzin verilmiş çıktıTürü |
|---|---|
Docx | PDF, Docx, xlsx |
PDF | PDF, Docx, xlsx |
HTML | HTML only |
API vücut alanları
Her zaman gönderildi
| Alan | Gerekli | Tip | Notlar |
|---|---|---|---|
templateFileType | Yes | string | Docx, HTML, PDF |
templateFileName | Yes | string | e.g. template.docx, template.html, template.pdf |
templateFileData | Yes | string | Base64 template, or template URL |
documentDataType | Yes | string | Json or XML (exact casing) |
outputType | Yes | string | PDF, Docx, xlsx, or HTML |
IsAsync | Yes | boolean | true |
Belge verileri (tek yol)
| Alan | Gerekli olduğu zamanlar | Tip | Notlar |
|---|---|---|---|
documentDataText | D1 | string | Valid JSON (JSON.parse) or XML-like for XML |
documentDataFile | D2 or D3 | string | Base64 data file or URL |
İsteğe bağlı
| Alan | Ne zaman | Varsayılan |
|---|---|---|
KeepPdfEditable | outputType is PDF | false |
Doğrulama kuralları
| Kontrol etmek | Detay |
|---|---|
| Template URL / base64 | Same rules as Single. |
| HTML code | Only when templateFileType is HTML. |
| JSON text | Must parse with JSON.parse. |
| XML text | Looser than Single (no strict tag check); send XML the template expects. |
| Data source | documentDataFile or documentDataText is required. |
Çoklu kayıt veri şekli
İçin JSONNesne dizisi kullanın (oluşturulan her belge için bir nesne):
[
]
İçin XMLTekrarlanan satırlar için şablonunuzun beklediği bir yapı kullanın (posta birleştirme ile aynı mantık). API sadece şunu kontrol eder JSON Ayrıştırma işlemleri; motor, kaç belge üretileceğini belirler.
API yanıt (Postacı)
Genellikle JSON formatında şu şekildedir:
{
"outputDocuments": [
{
"fileName": "document1.pdf",
"streamFile": "<base64>"
}
]
}
Alan adı şu şekilde de görünebilir: fileContent, content, veya dataHer birini çözün. Base64 Her dosyayı kaydetmek için kullanılan dize.
Örnek yükler
1. Word şablonu (base64) + JSON dizi (metin) → çoklu PDFs
{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "Json",
"documentDataText": "[{\"name\": \"Alice\", \"email\": \"[email protected]\"}, {\"name\": \"Bob\", \"email\": \"[email protected]\"}]",
"outputType": "PDF",
"KeepPdfEditable": false,
"IsAsync": true
}
2. Word şablonu (URL) + JSON veri (URL) → PDFs
{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "https://example.com/template.docx",
"documentDataType": "Json",
"documentDataFile": "https://example.com/customers.json",
"outputType": "PDF",
"IsAsync": true
}
3. Word şablonu (base64) + JSON dosya (base64) → Excel (xlsx)
{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "Json",
"documentDataFile": "W3sibmFtZSI6ICJBbGljZSJ9LCB7Im5hbWUiOiAiQm9iIn1d",
"outputType": "xlsx",
"IsAsync": true
}
(documentDataFile = base64'ü [{"name":"Alice"},{"name":"Bob"}].)
4. HTML şablon (base64) + JSON dizi (metin) → HTML
{
"templateFileType": "HTML",
"templateFileName": "template.html",
"templateFileData": "PCFET0NUWVBFIGh0bWw+...",
"documentDataType": "Json",
"documentDataText": "[{\"title\": \"Invoice 1\", \"heading\": \"Hello\", \"content\": \"A\"}, {\"title\": \"Invoice 2\", \"heading\": \"Hi\", \"content\": \"B\"}]",
"outputType": "HTML",
"IsAsync": true
}
5. PDF şablon (URL) + XML (metin) → birden fazla PDFs
{
"templateFileType": "PDF",
"templateFileName": "template.pdf",
"templateFileData": "https://example.com/template.pdf",
"documentDataType": "XML",
"documentDataText": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><records><record><name>Alice</name></record><record><name>Bob</name></record></records>",
"outputType": "PDF",
"KeepPdfEditable": true,
"IsAsync": true
}
6. Word şablonu (base64) + XML (URL) → Word (Docx)
{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "XML",
"documentDataFile": "https://example.com/data.xml",
"outputType": "Docx",
"IsAsync": true
}
Postacı tahsilat ipuçları
curl örneği
curl -X POST https://api.pdf4me.com/api/v2/GenerateDocumentMultiple \
-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",
"documentDataText": "[{\"name\":\"Alice\"},{\"name\":\"Bob\"}]",
"outputType": "PDF",
"IsAsync": true
}' \
--output response.json
Hızlı referans: varyanta göre gerekli ve isteğe bağlı olanlar
| Alan | T1+D1 | T2+D3 | T1+D2 | T3+D1 | PDF çıktısı |
|---|---|---|---|---|---|
templateFileType | Req | Req | Req | Req | Req |
templateFileName | Req | Req | Req | Req | Req |
templateFileData | Req (b64) | Req (URL) | Req (b64) | Req (b64) | Req |
documentDataType | Req | Req | Req | Req | Req |
outputType | Req | Req | Req | Req | Req |
documentDataText | Req | Omit | Omit | Req | Omit |
documentDataFile | Omit | Req | Req | Omit | Omit |
IsAsync | Req | Req | Req | Req | Req |
KeepPdfEditable | Opt | Opt | Opt | N/A* | Opt |
*Sadece şu durumlarda çıktıTürü dır PDF.