Product teams should be thinking differently about documents.Read blog post.
Anvil Logo

Fill PDFs with Java

A simple API for filling out PDFs from your app. Set up a PDF template and use Java to pass data into the form.
Hero Image

Write Java, receive PDF

Have existing PDF forms? Simply upload them to Anvil to create templates. With our RESTful endpoint, you'll be ready to receive data over API and fill your PDF.

It’s that simple. Take your structured data, develop against it with Java, make the request, and save the response.

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");

Try it now

SOC2 logo
GDPR logo
HIPAA logo
EIDAS logo

Sign up for a live demo

Request a 30-minute live demo today and we'll get in touch shortly. During the meeting our Sales team will help you find the right solution, including:
  • Simplifying data gathering
  • Streamlining document preparation
  • Requesting e-signatures
  • Building and scaling your business
Want to try Anvil first?Sign up for free
Want to try Anvil first?Sign up for free