public class

TemplateDocument

extends Object
implements AutoCloseable
java.lang.Object
   ↳ com.pdftron.pdf.TemplateDocument

Class Overview

The class TemplateDocument. Encapsulates a template document that can merged with data to generate any number of PDFs. TemplateDocument instances are created through the Convert class. See Convert.CreateOfficeTemplate.

Summary

Constants
int e_failure
int e_incomplete
int e_success
Public Constructors
TemplateDocument(long impl_ptr)
Public Methods
static TemplateDocument __Create(long impl)
long __GetHandle()
void cancelConversion()
Cancel the current template filling, forcing FillTemplateJson to return.
void close()
Frees the native memory of the object.
void destroy()
Frees the native memory of the object.
PDFDoc fillTemplateJson(String json)
Create a PDF by merging JSON data with this template document.
void fillTemplateJsonToOffice(String json, String output_path)
Create an office file by merging JSON data with this template document.
int getConversionStatus()
Get the state of the template filling process.
String getErrorString()
If the template filling finsihed with some kind of error, this returns the value of the error description; otherwise returns an empty string.
int getNumWarnings()
Return the number of warning strings generated during the template filling process.
String getTemplateKeysJson()
Get information about the template keys present in the template document.
String getWarningString(int index)
Retrieve warning strings that have been collected during the template filling process.
boolean isCancelled()
Has the template filling been cancelled?.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.AutoCloseable

Constants

public static final int e_failure

Constant Value: 2 (0x00000002)

public static final int e_incomplete

Constant Value: 1 (0x00000001)

public static final int e_success

Constant Value: 0 (0x00000000)

Public Constructors

public TemplateDocument (long impl_ptr)

Public Methods

public static TemplateDocument __Create (long impl)

public long __GetHandle ()

public void cancelConversion ()

Cancel the current template filling, forcing FillTemplateJson to return.

public void close ()

Frees the native memory of the object. This can be explicitly called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

public void destroy ()

Frees the native memory of the object. This can be explicitly called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

public PDFDoc fillTemplateJson (String json)

Create a PDF by merging JSON data with this template document.

Parameters
json -- A JSON dictionary mapping template keys to their replacement content
Returns
  • The PDFDoc from the template filling result

public void fillTemplateJsonToOffice (String json, String output_path)

Create an office file by merging JSON data with this template document. This function currently only supports DOCX input.

Parameters
json -- A JSON dictionary mapping template keys to their replacement content
output_path -- The path where the output file is written

public int getConversionStatus ()

Get the state of the template filling process.

public String getErrorString ()

If the template filling finsihed with some kind of error, this returns the value of the error description; otherwise returns an empty string.

Returns
  • The error description. Will be blank unless GetConversionStatus returns Failure

public int getNumWarnings ()

Return the number of warning strings generated during the template filling process. Warning: experimental interface; this method may be renamed or replaced with equivalent functionality in the future.

Returns
  • The number of stored warning strings

public String getTemplateKeysJson ()

Get information about the template keys present in the template document. Returns a JSON dictionary following this form: https://www.pdftron.com/api/web/Core.html#.TemplateSchema.

Returns
  • The template keys info JSON dictionary, serialized into a string

public String getWarningString (int index)

Retrieve warning strings that have been collected during the template filling process. Warning: experimental interface; this method may be renamed or replaced with equivalent functionality in the future.

Parameters
index -- the index of the string to be retrieved. Must be less than GetNumWarnings()
Returns
  • The value of the particular warning string

public boolean isCancelled ()

Has the template filling been cancelled?.

Returns
  • Returns true if CancelConversion has been called previously