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:

sh

1{{sender.name}} // object structure

or

sh

1{{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:

sh

1a!localVariables(
2 local!data: a!queryEntity(
3 entity: cons!WT_DS_User,
4 query: a!query(
5 pagingInfo: a!pagingInfo(
6 startIndex: 1,
7 batchSize: -1
8 )
9 )
10 ).data[1],
11 a!headerContentLayout(
12 header: {
13 a!billboardLayout(
14 backgroundMedia: a!documentImage(document: a!EXAMPLE_BILLBOARD_IMAGE()),
15 backgroundColor: "#f0f0f0",
16 marginBelow: "NONE",
17 overlay: a!barOverlay(contents: {})
18 )
19 },
20 contents: {
21 webviewer(
22 label: "WebViewer",
23 labelPosition: "ABOVE",
24 validations: {},
25 height: "AUTO",
26 key: null,
27 url: null,
28 appianDocId: 1249,
29 documentFolder: null,
30 userDisplayName: null,
31 enabledElements: null,
32 disabledElements: null,
33 docAccessConnectedSystem: cons!WT_CS,
34 loadAsPDF: null,
35 enableAnnotations: null,
36 notesInLeftPanel: null,
37 darkMode: null,
38 defaultLanguageCode: null,
39 customCSSPath: null,
40 fullAPI: null,
41 enableRedaction: null,
42 enableMeasurement: null,
43 enableExtractPagesToAppian: null,
44 newSavedDocumentIdValue: null,
45 newSavedDocumentIdSaveInto: null,
46 xfdfAnnotationDataValue: null,
47 xfdfAnnotationDataSaveInto: null,
48 enableDocumentGeneration: true,
49 templateDataValue: {
50 logo: local!data.firstName,
51 date: local!data.firstName,
52 sender: {
53 name: local!data.firstName
54 },
55 dest: {
56 title: "Mr.", /* hardcoded text value */
57 given_name: local!data.firstName, /* value from variable */
58 surname: local!data.lastName,
59 address: "Earth"
60 },
61 client: {
62 full_name: local!data.firstName,
63 gender_posessive: "Male",
64 },
65 lease_problem: "none",
66 land_location: "Earth",
67 }
68 )
69 }
70 )
71)

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.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales