Saltar al contenido principal

Rellene un PDF Forma

Lo que hace este punto final

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.

Entradas de blog relacionadas
Aún no hay ninguna entrada de blog sobre esta función; estará disponible próximamente.
Mientras tanto, echa un vistazo al blog de PDF4me para encontrar tutoriales y flujos de trabajo para todas las plataformas.
Visita el blog

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

CORREO/api/v2/FillPdfForm

Datos importantes que no debes perderte

matriz de datos es una CADENA, no un objeto
El API espera una cadena JSON. Siempre envuelva la carga útil de su formulario en JSON.stringify({...}) antes de publicar. El envío de un objeto anidado devuelve un error de deserialización.
Las claves deben coincidir exactamente con los nombres de los campos de AcroForm.
Los nombres de los campos distinguen entre mayúsculas y minúsculas. Inspeccione la plantilla con Adobe Acrobat. Preparar formulario o bien, llame primero al punto final Extraer datos del formulario para obtener una lista limpia de todos los campos rellenables.
Async devuelve 202 + encabezado Location
Con 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.

VariantePlantilla PDF (plantillaDocContent)campos del formularioCampos API obligatorios
ABase64 PDFJSON object → stringify → dataArrayAll rows in the JSON-form table below.
BPublic PDF URLJSON object → stringify → dataArraySame as A; templateDocContent is the URL string.
CBase64 PDFBase64-encoded JSON file → decode → stringify into dataArraySame as A; build dataArray from the decoded JSON.

API campos corporales

Siempre enviado

CampoRequeridoTipoPredeterminado / notas
templateDocNameYes*stringFilename of the template, e.g. template.pdf. Derived from the source URL filename or defaulted to template.pdf. Used for downstream output naming.
templateDocContentYesstringBase64-encoded PDF (no data: prefix) OR a publicly reachable https URL to the PDF.
KeepPdfEditableNobooleanDefault false. Set true to keep AcroForm fields editable in the output PDF; false flattens the form into static text.
IsAsyncYesbooleanDefault 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

CampoRequeridoTipoNotas
dataArrayYesstringJSON.stringify({ ... }). Keys = AcroForm field names; values = strings to fill.
inputDataTypeYesstringAlways "json" for this path.
outputTypeYesstringAlways "pdf".

Reglas de datos del formulario (JSON camino)

ReglaDetalle
ShapeSingle object: {"fieldName": "value", ...}.
Not allowedEmpty array, or an array of multiple objects.
Base64 form inputDecode the UTF-8 JSON file, then JSON.stringify into dataArray. In Postman: put the decoded-then-stringified result directly into dataArray.
Data URLStrip 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...",
"dataArray": "{\"firstname\": \"John\", \"lastname\": \"Doe\", \"email\": \"[email protected]\"}",
"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",
"dataArray": "{\"firstname\": \"John\", \"lastname\": \"Doe\", \"email\": \"[email protected]\"}",
"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

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON. Copy one of the variant payloads above.
Response
Save as .pdf when status is 200 and the body is binary. If 202, GET the Location URL with the same Authorization until 200.
Field names
Must exactly match AcroForm names in the template. Use the Extract Form Data endpoint or a PDF editor if you are unsure.

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)

CampoA (PDF b64)B (URL del PDF)C (formato b64 → JSON)
templateDocNameRequiredRequiredRequired
templateDocContentRequired (b64)Required (URL)Required (b64)
dataArrayRequiredRequiredRequired (from decoded JSON)
inputDataTypeRequired (json)Required (json)Required (json)
outputTypeRequired (pdf)Required (pdf)Required (pdf)
IsAsyncRequired (true)Required (true)Required (true)
KeepPdfEditableOptionalOptionalOptional

Ejemplos de código

Preguntas frecuentes

Why must dataArray be a stringified JSON, not a nested object?+
The API contract defines dataArray as a string field. The engine parses the string server-side. Sending a nested object returns a deserialization error. Always wrap your form values with JSON.stringify before posting.
What happens when KeepPdfEditable is true?+
The output PDF retains its AcroForm field definitions so the recipient can re-edit values in any PDF viewer. KeepPdfEditable false (the default) flattens the form into static text, useful for delivering a locked record of what was submitted.
How do I know the exact AcroForm field names?+
Open the template in Adobe Acrobat (Prepare Form), use any PDF editor with field inspection, or call the PDF4me Extract Form Data endpoint first. Keys in your dataArray JSON must match those names exactly, including case.
When should I use Variant B (PDF URL) over Variant A (Base64)?+
Use Variant B when the template is already hosted at a publicly reachable HTTPS URL. It avoids the Base64 size bloat (~33%) and is the simplest path for templates pinned in S3, CDN, or your own static asset host. Use Variant A when the template is private or local.
How does the async flow work?+
Send IsAsync true. If the API returns 200, the PDF binary is in the body. If it returns 202, read the Location response header for a poll URL. GET that URL with the same Authorization header. Continue polling (commonly 10s intervals up to 15 retries) until it returns 200 with the PDF.
Can I send an array of multiple form-data objects?+
No. The REST contract requires a single object inside dataArray (after JSON.stringify). To fill many forms, call the endpoint once per form.
My PDF Base64 has a data: prefix. Do I strip it?+
Yes. The API expects raw Base64 in templateDocContent. Strip any data:application/pdf;base64, prefix before posting.
How do I get back something other than PDF?+
You cannot. outputType is fixed to pdf for this endpoint. To rasterize the filled PDF into PNG / JPEG, chain a downstream PDF4me Convert PDF to Image call.

Acciones relacionadas

La misma tarea en otras plataformas.

Obtén ayuda