Creating PDF template

Advantages of using PDF templates:

  • Can produce PDF files.

Disadvantages in comparison with Text templates:

  • Produce bigger documents.
  • More difficulties in maintaining the templates in time.
  • More time needed in the creation of the document (especially when the PDF optimization configuration parameter is enabled )

You can create PDF template forms with several applications:

Every PDF form field name needs to be unique, you can't set the same property value to several form fields.

Preliminaries

Register the Metadata group definition at Administration > Metadata.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.10//EN"
                                 "http://www.openkm.com/dtd/property-groups-3.10.dtd">
<property-groups>
  <property-group label="Sample Template" name="okg:tpl">
    <input label="Name" name="okp:tpl.name"/>
    <input label="Birth Date" name="okp:tpl.birth_date" type="date"/>
    <select label="Language" name="okp:tpl.language" type="simple">
      <option label="Java" value="java"/>
      <option label="Python" value="python"/>
      <option label="PHP" value="php" />
    </select>
    <checkbox label="Important" name="okp:tpl.important"/>
  </property-group>
</property-groups>

In order to make a relation between the template form field and the property group, you have to name them following a naming convention: replace ":" and "." by "_". Here you can see the matching between both fields:

Metadata field nameTemplate field nameTemplate field value

okp:tpl.name

okp_tpl_name

${okp_tpl_name!}

okp:tpl.birth_date

okp_tpl_birth_date

${okp_tpl_birth_date!}

okp:tpl.language

okp_tpl_language

${okp_tpl_language!}

okp:tpl.important

okp_tpl_important

${okp_tpl_important!}

Creating the template

We encourage using Acrobat Pro or Master PDF Editor to avoid problems.

 This is a sample template created with Master PDF Editor:

Date format

OpenKM uses FreeMarker inside, so you can take advantage of the FreeMarker formatting flexibilities. For example you can set date format by this way:

${okp_tpl_birth_date?string("yyyy-MM-dd")}

Learn more about FreeMarker formatting at Built-in Reference.  

Configuring sample

  • Upload tpl.pdf file at /okm:templates/documents
  • Register metadata definition okg:tpl at Administration > Metadata 
  • Enable metadata from profiles at Administration > Profiles 
  • Add metadata group okg:tpl to tpl.pdf file.