Skip to content

PDF

Template type (numeric) Supports automatic variable detection
3

Text variables

Text variables are defined as PDF form text fields.

After inserting the text field into your document, set its name within the properties menu to the Document Rails variable name.

Image variables

Image variables are implemented using PDF form image fields.

Open the properties menu on any image form field and set the name to the Document Rails variable name.

Image field name mangling

In some cases, _af_image may be appended to your image form name.

This is expected, Document Rails handles those images during the printing process by trimming the suffix to resolve the real field name.

Examples

import { createTemplate, TemplateType } from "@vaultie/document-rails";

const response = await createTemplate(
    client,
    accessToken,
    organizationId,
    {
        // Select the .pdf template type.
        template_type: TemplateType.Pdf,

        // PDF template file.
        file: new Blob([await readFile("./template.pdf")]),

        // Template variables present within the uploaded file.
        //
        // For PDF templates, `template_vars` field is required.
        template_vars: [
            { name: "first_name", type: TemplateVarType.String },
            { name: "last_name", type: TemplateVarType.String },
            { name: "profile_photo", type: TemplateVarType.Image },
        ]
    }
);