Anvil Logo
Products
Industries
Resources
Developers

Generate PDFs with Java

A simple API for generating PDFs within your app. Write Java to send HTML & CSS or Markdown to Anvil, get back a PDF.
Beyond Giant hero assetGiant hero assetDesktop hero assetMobile hero assetTablet hero asset

Perfectly formatted PDFs

Create dynamic and variable length PDFs with adjustments based on your content. Each page is perfectly scaled to a standard 8.5” x11” paper size.


Java to PDF

Use Java to lay out and generate your PDF for a 100% pixel perfect document.

public class PDFGenerateSimpleExample {
     
    public static void main(String[] args) {
        ObjectMapper mapper = new ObjectMapper();

        ObjectNode payload = mapper.createObjectNode();
        payload.put("html", "<h1 class='header-one'>What is Lorem Ipsum?</h1> <p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the <strong>1500s</strong>, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>");
        payload.put("css", "body { font-size: 14px; color: #171717; } .header-one { text-decoration: underline; }");

        // your Anvil API_KEY
        RestClient client = new RestClient(API_KEY);
        HttpResponse<byte[]> response = client.generatePdf(mapper.writeValueAsString(payload));

        Files.write(Paths.get("output/generate-html-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 team will help you find the right solution, including:
  • Simplifying data gathering
  • Streamlining document preparation
  • Requesting e-signatures
  • Building and scaling your business
Ready to experience document workflow automation?Sign up for free
Ready to experience document workflow automation?Sign up for free