Standardizing PDF Libraries for API Use
Tags: tutorial, webdev, javascript, api
Published: 2021-04-26 04:45:25

## Human Readable IDs enable consistent keys for data fields across multiple PDFs

When setting up a PDF template for the PDF filling API, Anvil automatically generates a unique field ID for each field on the PDF. When working with a library of PDF templates, tracking these unique field IDs across multiple PDFs can be cumbersome, so Anvil allows developers to assign a Human Readable ID, similar to a variable name, for each PDF field.

A big benefit of using a Human Readable ID is the ability to have consistent Human Readable IDs across multiple PDFs that ask for the same information. For example, say you have a library of 10 different PDFs, and each PDF asks for a Name and Address. You could manually track the auto-generated ID for each field on each PDF, resulting in 20 unique field IDs that need to be tracked. Or you can assign a Human Readable ID of `fullName` and `fullAddress` to every name and address field across all PDFs.

Now when making a request to the specific PDF template, you only need to construct a data payload with the Human Readable IDs and Anvil will automatically route it to the correct field.

```
{
    "fullName": {
        "firstName": "John",
        "lastName": "Doe"
    },
    "fullAddress": {
        "street1": "123 Main Street",
        "city": "San Francisco",
        "state": "CA",
        "zip": "95273"
    }
}
```
This data payload will work across all 10 PDF templates in Anvil, as long as the fields have the proper Human Readable ID assigned.

As an added benefit, reading a JSON payload constructed using Human Readable IDs makes debugging API requests much easier.

## How to assign a Human Readable ID
In the PDF template editor
1. Select the field
2. Add a Human Readable ID
The Human Readable ID must be unique within the PDF and we suggest using camelCase for all IDs.

![adding a human readable id](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/25gul0ei2enxhpj51g62.jpg)

## Why do you need Human Readable IDs?
For most paperwork processes there are multiple forms that need to be completed. To ensure that forms are properly associated with one another, the forms have a set of common fields that are consistent across each form.

Common pieces of information used to associate forms with one another include:
- Name
- Address
- Unique Customer Number
- Social Security Number ← clearly the best use for a sensitive piece of information is to have it on EVERY form

One quirk of how paper and PDF forms are created, is that they are updated over time, resulting in the “consistent” fields becoming inconsistent. Someone might change the formatting of the form, or change the labels for each field `Name` → `Full Name`, `Social Security Number` → `SSN`. All of these little inconsistencies make it a pain to pass the same information into multiple fields across different PDFs.

Anvil’s Human Readable IDs is a way for you to normalize between your own database and all of the PDFs you are generating with Anvil.

## Real world use cases for Human Readable IDs

Human Readable IDs are a popular feature for Anvil API developers. To date, we have seen developers use it for
- **New hire packets** - Job Application, W4, I9
- **Insurance Policy Packets** - Claims Forms, COI, Policy Information
- **Sales Contracts** - MSA, Purchase Orders, NDAs
- **Loans** - Applications, Supporting Forms, Closing Documents

Each of these cases require the same information, such as name and address, to be completed in multiple documents.

## Resources
To sign up for our free developer sandbox or learn more about our API, head over to our developer center at [www.useanvil.com/developers](https://www.useanvil.com/developers). There, you will find comprehensive documentation, simple tutorials, and client libraries to help you get started quickly and easily.

If you have questions, please do not hesitate to contact us at:
[developers@useanvil.com](mailto:developers@useanvil.com)