Summary: Constants | Ctors | Methods | Inherited Methods | [Expand All]
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.
void | fillTemplateJsonToOfficeWithFilter(String json, Filter out_filter) 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
boolean | equals(Object arg0)
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()
From interface java.lang.AutoCloseable
abstract void | close()

## 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.

##### Throws

PDFNetException |

#### 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.

##### Throws

PDFNetException |

#### 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.

##### Throws

PDFNetException |

#### 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.

##### Throws

PDFNetException |

#### 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.

##### Throws

PDFNetException |

#### public void fillTemplateJsonToOfficeWithFilter (String json, Filter out_filter)

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.
out_filter | An output filter where the office file will be written.

##### Throws

PDFNetException |

#### public int getConversionStatus ()

Get the state of the template filling process.

##### Throws

PDFNetException |

#### 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.

##### Throws

PDFNetException |

#### 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.

##### Throws

PDFNetException |

#### 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.

##### Throws

PDFNetException |

#### 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.

##### Throws

PDFNetException |

#### public boolean isCancelled ()

Has the template filling been cancelled?.

##### Returns

- Returns true if CancelConversion has been called previously.

##### Throws

PDFNetException |