import fs from 'fs'
import Anvil from '@anvilco/anvil'
const pdfTemplateID = 'kA6Da9CuGqUtc6QiBDRR'
const apiKey = '7j2JuUWmN4fGjBxsCltWaybHOEy3UEtt'
const exampleData = {
"title": "My PDF Title",
"fontSize": 10,
"textColor": "#CC0000",
"data": {
"someFieldId": "Hello World!"
}
}
const anvilClient = new Anvil({ apiKey })
const {
statusCode,
data
} = await anvilClient.fillPDF(pdfTemplateID, exampleData)
console.log(statusCode) // => 200
// Data will be the filled PDF raw bytes
fs.writeFileSync('output.pdf', data, { encoding: null })
import fs from 'fs'
import Anvil from '@anvilco/anvil'
const pdfTemplateID = 'kA6Da9CuGqUtc6QiBDRR'
const apiKey = '7j2JuUWmN4fGjBxsCltWaybHOEy3UEtt'
const exampleData = {
"title": "My PDF Title",
"fontSize": 10,
"textColor": "#CC0000",
"data": {
"someFieldId": "Hello World!"
}
}
const anvilClient = new Anvil({ apiKey })
const {
statusCode,
data
} = await anvilClient.fillPDF(pdfTemplateID, exampleData)
console.log(statusCode) // => 200
// Data will be the filled PDF raw bytes
fs.writeFileSync('output.pdf', data, { encoding: null })
class FillPDF: RunnableBaseExample {
private Anvil.Payloads.Request.FillPdf GetFillData() {
return new Anvil.Payloads.Request.FillPdf {
Title = "My PDF Title",
FontSize = 10,
TextColor = "#333333",
Data = new Dictionary < string, dynamic > () {
{ "shortText", "HELLOOW"},
{ "date", "2022-07-08" },
{ "name", new Dictionary < string, object > () {
{ "firstName", "Robin" },
{ "mi", "W" },
{ "lastName", "Smith" }
}
},
{ "email", "testy@example.com" }
}
};
}
public override async Task Run(string apiKey) {
var pdfTemplateEid = "f9eQzbUgCCRVDrd4gt8b";
var payload = GetFillData();
var client = new RestClient(apiKey);
var wasWritten = await client.FillPdf(pdfTemplateEid, payload, "./output/fill-output.pdf");
}
}
class PDFFillSimpleExample {
public static void main(String[] args) {
ObjectMapper mapper = new ObjectMapper();
// JSON object
ObjectNode dataObj = mapper.createObjectNode();
dataObj.put("shortText", "HELLO");
dataObj.put("date", "2022-07-08");
ObjectNode payload = mapper.createObjectNode();
payload.put("title", "My PDF Title");
payload.put("fontSize", 10);
payload.put("textColor", "#333333");
payload.putPOJO("data", dataObj);
String payloadStr = mapper.writeValueAsString(payload);
String pdfTemplateEid = "B5Loz3C7GVortDmn4p2P";
// your Anvil API_KEY
RestClient client = new RestClient(API_KEY);
HttpResponse<byte[]> response = client.fillPdf(pdfTemplateEid, payloadStr);
Files.write(Paths.get("output/fill-output.pdf"), response.body());
System.out.println("Fill PDF finished");
}
}
PDF_TEMPLATE_EID = "f9eQzbUgCCRVDrd4gt8b"
FILL_DATA = {
"title": "My PDF Title",
"fontSize": 10,
"textColor": "#CC0000",
"data": {
"someFieldId": "Hello World!"
}
}
def main():
anvil = Anvil(api_key=API_KEY)
print("Making fill request...")
with open(FILE_OUTPUT, "wb") as f:
f.write(res)
Anvil is more than a PDF tool. We specialize in helping product teams build custom paperwork solutions using these building blocks: PDF services, E-signatures, and Webforms.
Anvil Workflows tie all these building blocks together, automating your paperwork and saving your team time and resources.
Book a demo below to discuss solution to your unique use case.
Anvil uses digital certificates, specifically the industry-standard Public Key Infrastructure (PKI) framework, for identity verification in document signing. This involves creating a pair of certificates – public and private. Read more