/// EDIT
1 creditFill PDF Form API
Fill PDF forms by field name. Unknown fields are reported, never silently dropped.
/// Quick answer
Fill PDF Form sets each field you name to the value you give it, by field name — any name in your request that doesn't match a real field on the form comes back in unmatched instead of being silently ignored, and strict: true turns an unmatched field into a 422 instead. Checkboxes accept true, false, "Yes" or "Off". Set flatten: true to make the filled values permanent (non-editable) in the same call.
How does the Fill PDF Form API work?
One HTTP request from any language. Every ASHDOCS endpoint uses the same X-API-Key header.
curl -X POST https://www.ashdocs.com/api/v2/tools/pdf-form-fill \
-H "X-API-Key: ash_live_..." \
-F "file=@form.pdf" \
-F 'fields={"full_name":"Ada Lovelace"}' \
-F 'flatten=true' \
-F 'strict=false'import requests
r = requests.post(
"https://www.ashdocs.com/api/v2/tools/pdf-form-fill",
headers={"X-API-Key": "ash_live_..."},
files=[("file", open("form.pdf", "rb"))],
data={"fields": '{"full_name":"Ada Lovelace"}', "flatten": 'true', "strict": 'false'},
)
job = r.json()
print(job["status"], job.get("url"))import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("file", new Blob([await readFile("form.pdf")]), "form.pdf");
form.append("fields", "{\"full_name\":\"Ada Lovelace\"}");
form.append("flatten", "true");
form.append("strict", "false");
const res = await fetch("https://www.ashdocs.com/api/v2/tools/pdf-form-fill", {
method: "POST",
headers: { "X-API-Key": "ash_live_..." },
body: form,
});
const job = await res.json();
console.log(job.status, job.url);using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "ash_live_...");
using var form = new MultipartFormDataContent();
form.Add(new ByteArrayContent(await File.ReadAllBytesAsync("form.pdf")), "file", "form.pdf");
form.Add(new StringContent("{\"full_name\":\"Ada Lovelace\"}"), "fields");
form.Add(new StringContent("true"), "flatten");
form.Add(new StringContent("false"), "strict");
var res = await client.PostAsync("https://www.ashdocs.com/api/v2/tools/pdf-form-fill", form);
var job = await res.Content.ReadAsStringAsync();
Console.WriteLine(job);import java.io.ByteArrayOutputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
public class Sample {
static final String BOUNDARY = "AshdocsBoundary7MA4YWxkTrZu0gW";
public static void main(String[] args) throws Exception {
ByteArrayOutputStream body = new ByteArrayOutputStream();
addFile(body, "file", "form.pdf");
addField(body, "fields", "{\"full_name\":\"Ada Lovelace\"}");
addField(body, "flatten", "true");
addField(body, "strict", "false");
body.write(("--" + BOUNDARY + "--\r\n").getBytes(StandardCharsets.UTF_8));
HttpRequest req = HttpRequest.newBuilder(URI.create("https://www.ashdocs.com/api/v2/tools/pdf-form-fill"))
.header("X-API-Key", "ash_live_...")
.header("Content-Type", "multipart/form-data; boundary=" + BOUNDARY)
.POST(HttpRequest.BodyPublishers.ofByteArray(body.toByteArray()))
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.body());
}
static void addFile(ByteArrayOutputStream body, String name, String path) throws Exception {
body.write(("--" + BOUNDARY + "\r\nContent-Disposition: form-data; name=\"" + name + "\"; filename=\""
+ Path.of(path).getFileName() + "\"\r\nContent-Type: application/octet-stream\r\n\r\n").getBytes(StandardCharsets.UTF_8));
body.write(Files.readAllBytes(Path.of(path)));
body.write("\r\n".getBytes(StandardCharsets.UTF_8));
}
static void addField(ByteArrayOutputStream body, String name, String value) throws Exception {
body.write(("--" + BOUNDARY + "\r\nContent-Disposition: form-data; name=\"" + name + "\"\r\n\r\n"
+ value + "\r\n").getBytes(StandardCharsets.UTF_8));
}
}#include <stdio.h>
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
if (!curl) return 1;
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "X-API-Key: ash_live_...");
curl_mime *mime = curl_mime_init(curl);
curl_mimepart *part;
part = curl_mime_addpart(mime);
curl_mime_name(part, "file");
curl_mime_filedata(part, "form.pdf");
part = curl_mime_addpart(mime);
curl_mime_name(part, "fields");
curl_mime_data(part, "{\"full_name\":\"Ada Lovelace\"}", CURL_ZERO_TERMINATED);
part = curl_mime_addpart(mime);
curl_mime_name(part, "flatten");
curl_mime_data(part, "true", CURL_ZERO_TERMINATED);
part = curl_mime_addpart(mime);
curl_mime_name(part, "strict");
curl_mime_data(part, "false", CURL_ZERO_TERMINATED);
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
curl_easy_setopt(curl, CURLOPT_URL, "https://www.ashdocs.com/api/v2/tools/pdf-form-fill");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
CURLcode rc = curl_easy_perform(curl);
printf("\n");
curl_mime_free(mime);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return rc == CURLE_OK ? 0 : 1;
}Common use cases
- →Auto-filling a contract from CRM data
- →Generating a filled application PDF per applicant
- →Batch-filling the same template for many recipients
RELATED TOOLS
PDF Form Fields API — read every fillable field
Name, type, page, rect, value, options, required, read-only — per widget, one call.
Create PDF Form API — add fillable fields to any PDF
Place fields by exact coordinates, or anchor them to text already on the page.
Flatten PDF Form API
Make filled-in fields and annotations permanent, non-editable page content.