Rellene un PDF Forma
PDF4me Rellene un formulario PDF rellena los campos de AcroForm en un PDF plantilla con valores de una JSON objeto en uno solo REST llamar. Enviar la plantilla como Base64 o un público URL, envíe los valores del campo como una cadena matriz de datosy recibir el formulario PDF como bytes binarios (200) o mediante una consulta de encabezado Location. URL (202). Alternar Conservar PDF editable para entregar un formulario reeditable o un registro estático plano.
Autenticando su API Pedido
Cada PDF4me REST La llamada debe incluir su API clave en el Authorization Encabezado como autenticación básica. Obtenga o cambie su clave desde el panel de desarrollador.
Punto final
/api/v2/FillPdfFormhttps://api.pdf4me.com/api/v2/FillPdfFormDatos importantes que no debes perderte
matriz de datos es una CADENA, no un objetoJSON.stringify({...}) antes de publicar. El envío de un objeto anidado devuelve un error de deserialización.IsAsync: true el API puede responder 202 y un encabezado Location. GET eso URL (misma autorización) hasta que devuelva 200 con el PDF binario. Estándar PDF4me patrón asíncrono (pdf4meAsyncRequest).HTTP configuración
Método: CORREO
URL: https://api.pdf4me.com/api/v2/FillPdfForm
Tipo de contenido: aplicación/json
Autorización: Básico <tu PDF4me API clave>
Enviar IsAsync: true en el cuerpo. 200 devuelve el lleno PDF como bytes binarios. 202 devuelve un Ubicación encabezado con una encuesta URL; GET eso URL con el mismo encabezado de autorización hasta que devuelva 200 con el PDF binario (misma convención que pdf4meAsyncRequest).
Matriz de variantes (relevante para Postman)
Tres variantes de entrada cubren todas las llamadas de Postman / curl / SDK. Elija la variante que coincida con su PDF Plantilla y datos de formulario en tiempo real.
| Variante | Plantilla PDF (plantillaDocContent) | campos del formulario | Campos API obligatorios |
|---|---|---|---|
| A | Base64 PDF | JSON object → stringify → dataArray | All rows in the JSON-form table below. |
| B | Public PDF URL | JSON object → stringify → dataArray | Same as A; templateDocContent is the URL string. |
| C | Base64 PDF | Base64-encoded JSON file → decode → stringify into dataArray | Same as A; build dataArray from the decoded JSON. |
API campos corporales
Siempre enviado
| Campo | Requerido | Tipo | Predeterminado / notas |
|---|---|---|---|
templateDocName | Yes* | string | Filename of the template, e.g. template.pdf. Derived from the source URL filename or defaulted to template.pdf. Used for downstream output naming. |
templateDocContent | Yes | string | Base64-encoded PDF (no data: prefix) OR a publicly reachable https URL to the PDF. |
KeepPdfEditable | No | boolean | Default false. Set true to keep AcroForm fields editable in the output PDF; false flattens the form into static text. |
IsAsync | Yes | boolean | Default true. Toggles the 200 / 202 + Location async pattern. |
*Nombre del documento de plantilla Siempre debe configurarse en la solicitud; elija un nombre de archivo adecuado para que los nombres de archivo de salida sean claros en el proceso posterior.
Cuando se introduce un formulario JSON
| Campo | Requerido | Tipo | Notas |
|---|---|---|---|
dataArray | Yes | string | JSON.stringify({ ... }). Keys = AcroForm field names; values = strings to fill. |
inputDataType | Yes | string | Always "json" for this path. |
outputType | Yes | string | Always "pdf". |
Reglas de datos del formulario (JSON camino)
| Regla | Detalle |
|---|---|
| Shape | Single object: {"fieldName": "value", ...}. |
| Not allowed | Empty array, or an array of multiple objects. |
| Base64 form input | Decode the UTF-8 JSON file, then JSON.stringify into dataArray. In Postman: put the decoded-then-stringified result directly into dataArray. |
| Data URL | Strip the data:...;base64, prefix if present (applies to the PDF Base64 in templateDocContent). |
Cargas útiles de ejemplo
Variante A. PDF Base64 + formulario JSON
{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
matriz de datos debe ser una cadena, no un anidado JSON objeto:
"dataArray": "{"firstname":"John","lastname":"Doe"}"
Variante B. URL del PDF + formulario JSON
{
"templateDocName": "application-form.pdf",
"templateDocContent": "https://example.com/forms/application-form.pdf",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
Variante C. PDF Base64 + formulario a partir de JSON base64
Marcador de posición en el repositorio: eyJmaXJzdG5hbWUiOiJKb2huIn0= → {"firstname":"John"}.
Equivalente API cuerpo después de decodificar el formulario JSON:
{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"dataArray": "{\"firstname\": \"John\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
Opcional. Mantener el formulario editable.
{
"templateDocName": "application-form.pdf",
"templateDocContent": "https://example.com/forms/application-form.pdf",
"dataArray": "{\"firstname\": \"John\", \"lastname\": \"Doe\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": true,
"IsAsync": true
}
Consejos para el cobro de carteros
Ejemplo de curl
curl -X POST https://api.pdf4me.com/api/v2/FillPdfForm \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"templateDocName": "application-form.pdf",
"templateDocContent": "https://example.com/forms/application-form.pdf",
"dataArray": "{\"firstname\":\"John\",\"lastname\":\"Doe\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}' \
--output filled-form.pdf
Referencia rápida: obligatorio vs. opcional (Postman)
| Campo | A (PDF b64) | B (URL del PDF) | C (formato b64 → JSON) |
|---|---|---|---|
templateDocName | Required | Required | Required |
templateDocContent | Required (b64) | Required (URL) | Required (b64) |
dataArray | Required | Required | Required (from decoded JSON) |
inputDataType | Required (json) | Required (json) | Required (json) |
outputType | Required (pdf) | Required (pdf) | Required (pdf) |
IsAsync | Required (true) | Required (true) | Required (true) |
KeepPdfEditable | Optional | Optional | Optional |