Some test text!

Search
Hamburger Icon

Appian / Guides / Overview

Template generation in Appian

Overview

Apryse's office template generation framework enables the dynamic generation of PDFs:

  • You provide a template in the form of an Office document (such as .docx)
  • You provide replacement data in JSON form
  • Apryse SDK will efficiently generate a PDF by merging the data with the template
  • Fully featured, with support for loops, conditionals, images, table generation, etc.
  • Use your preferred office editor to design attractive templates, and Apryse will take care of the rest
  • All logic is entirely contained within the SDK, with no external dependencies

Template Structure

If you have an Office document with template values that look like this:

{{sender.name}} // object structure

or

{{first_name}} // normal tag

You can insert values to replace those template placeholders. This can be done in various ways.

Filling a Template

The first is to set the templateDataValues parameter with a object that has keys that match the ones in the template and their associated value. They can be objects as seen in the placeholder key example above. Here is a sample of how this could look like in expression mode in Appian Designer:

a!localVariables(
  local!data: a!queryEntity(
    entity: cons!WT_DS_User,
    query: a!query(
      pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: -1
      )
    )
  ).data[1],
  a!headerContentLayout(
    header: {
      a!billboardLayout(
        backgroundMedia: a!documentImage(document: a!EXAMPLE_BILLBOARD_IMAGE()),
        backgroundColor: "#f0f0f0",
        marginBelow: "NONE",
        overlay: a!barOverlay(contents: {})
      )
    },
    contents: {
      webviewer(
        label: "WebViewer",
        labelPosition: "ABOVE",
        validations: {},
        height: "AUTO",
        key: null,
        url: null,
        appianDocId: 1249,
        documentFolder: null,
        userDisplayName: null,
        enabledElements: null,
        disabledElements: null,
        docAccessConnectedSystem: cons!WT_CS,
        loadAsPDF: null,
        enableAnnotations: null,
        notesInLeftPanel: null,
        darkMode: null,
        defaultLanguageCode: null,
        customCSSPath: null,
        fullAPI: null,
        enableRedaction: null,
        enableMeasurement: null,
        enableExtractPagesToAppian: null,
        newSavedDocumentIdValue: null,
        newSavedDocumentIdSaveInto: null,
        xfdfAnnotationDataValue: null,
        xfdfAnnotationDataSaveInto: null,
        enableDocumentGeneration: true,
        templateDataValue: {
          logo: local!data.firstName,
          date: local!data.firstName,
          sender: {
            name: local!data.firstName
          },
          dest: {
            title: "Mr.", /* hardcoded text value */
            given_name: local!data.firstName, /* value from variable */
            surname: local!data.lastName,
            address: "Earth"
          },
          client: {
            full_name: local!data.firstName,
            gender_posessive: "Male",
          },
          lease_problem: "none",
          land_location: "Earth",
        }
      )
    }
  )
)

Manually set values with modal

You can also enable the enableDocumentGeneration parameter to gain access to a modal that allows users to manually set those values. This is, however, limited to just text/numerical values.

Additional documentation

For more details, such as complex use cases like conditionals, loops, images and more visit our WebViewer guide on generating via template .

Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales