Template PDF API สำหรับ document contracts ที่เสถียร
เรนเดอร์ PDF จาก template_id ที่เสถียรและ data array เมื่อ layout ที่ใช้ซ้ำควรถูกดูแลครั้งเดียวและนำไปใช้ซ้ำโดย ERP, OMS, WMS หรือ SaaS callers
/api/v1/template-render เรนเดอร์ PDF ที่ใช้ซ้ำโดยส่ง template_id ที่เสถียรและ business data array แทนการให้ caller ทุกตัวอธิบาย pages, coordinates และ layout elements ในทุก request
ควรใช้ API นี้เมื่อใด
- layout เอกสารถูกอนุมัติแล้วและใช้ซ้ำโดย caller หรือ jobs หลายตัว
- callers ควรส่ง business data ไม่ใช่ coordinate-level layout JSON
- คุณต้องการ invoice, packing list, shipping label หรือ custom template output
- คุณต้องการให้ active template revisions ถูกควบคุมนอก caller
สิ่งที่ไม่ได้ทดแทน
- คุณยังออกแบบ layout อยู่ ใช้ JSON Render จนกว่า coordinates และ fields จะเสถียร
- คุณต้องการ arbitrary HTML-to-PDF conversion
- คุณต้องการ e-invoice PDF/A-3b packaging พร้อม CII XML ที่ฝังอยู่
ควรเรียก endpoint ใด
/api/v1/template-render
Template Render คือ path หลักสำหรับเวิร์กโฟลว์นี้.
/api/v1/pdf/render
ใช้เมื่อเวิร์กโฟลว์ต้องการ API path ที่เกี่ยวข้อง สัญญาเทมเพลต หรือการค้นหา capability.
Minimal request
POST /api/v1/template-render - เรนเดอร์ invoice หนึ่งใบจากเทมเพลต
{
"template_id": "invoice",
"data": [
{
"invoice_number": "INV-2026-001",
"date_of_issue": "2026-05-29",
"date_due": "2026-06-28",
"issuer_name": "Acme Cloud Inc.",
"issuer_address": "88 Harbor Rd, Long Beach, CA",
"bill_to_name": "Receiver Inc.",
"bill_to_address": "123 Main St, Los Angeles, CA",
"subtotal": "$100.00",
"total": "$100.00",
"amount_due": "$100.00",
"items": [
{
"description": "Service A",
"qty": 1,
"unit_price": "$100.00",
"amount": "$100.00"
}
]
}
]
}
gPdf จัดการอะไร
- template lookup ด้วย template_id ที่เสถียร
- การเรนเดอร์ data item แต่ละรายการกับ active template
- การรวม rendered pages เป็น PDF เดียวภายในขีดจำกัด public endpoint
- พฤติกรรม authentication, request ID และ error envelope ร่วมกัน
ระบบของคุณรับผิดชอบอะไร
- template selection, field mapping, business data และ caller authorization
- template publication workflow, change communication และ test coverage
- chunking, queueing และ retries เมื่อเรนเดอร์เอกสารจำนวนมาก
Production checklist
- ปฏิบัติกับ template_id เป็น opaque stable contract
- validate data fields ก่อนเรียก Template Render
- เก็บ golden-PDF tests สำหรับ active template และ representative data
- แบ่ง batch ขนาดใหญ่ตาม public Template Render limits
- log template_id, request ID และ business object IDs เพื่อ traceability
ขอบเขตของ claim
- Template Render ไม่ใช่ design tool ด้วยตัวเอง templates ต้องถูก publish แล้ว
- gPdf ไม่ infer business data ที่หายไปจาก template
- Template Render ไม่แทน E-Invoice Render endpoint
Template Render คือ contract layer สำหรับ production
JSON Render เหมาะมากระหว่างออกแบบ layout ส่วน Template Render คือ layer ที่ใช้หลัง layout กลายเป็น contract แล้ว caller ส่ง template_id และ data; active template เป็นเจ้าของโครงสร้างเอกสาร
วิธีนี้ทำให้ caller เล็กลง และทำให้ template changes review, test และ roll out ได้ง่ายขึ้น
FAQ
- ควรใช้ Template Render แทน JSON Render เมื่อใด
- ใช้ Template Render หลัง layout ได้รับอนุมัติและ caller ควรส่งเฉพาะ business data
- template_id เสถียรหรือไม่
- เสถียร เอกสาร Template API อธิบาย template_id ว่าเป็น identifier ที่ caller ใช้งานและเสถียร
- request เดียวเรนเดอร์ data items หลายรายการได้หรือไม่
- ได้ Template Render รับ data array ภายใน public endpoint limits
- Template Render สร้าง e-invoices ได้หรือไม่
- ไม่ได้ Factur-X และ ZUGFeRD PDF/A-3b packaging ใช้ E-Invoice Render endpoint