Show / Hide Table of Contents

# Class TemplateDocument

Encapsulates a template document that can merged with data to generate any number of PDFs.

##### Inheritance

object
TemplateDocument

##### Implements

IDisposable

##### Inherited Members

object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()

###### Namespace: pdftron.PDF

###### Assembly: PDFNet.dll

##### Syntax

    public sealed class TemplateDocument : IDisposable

### Methods

#### CancelConversion()

Cancel the current template filling, forcing FillTemplateJson to return.

##### Declaration

    public void CancelConversion()

#### Dispose()

##### Declaration

    public override sealed void Dispose()

#### Dispose(bool)

##### Declaration

    [HandleProcessCorruptedStateExceptions]
    protected void Dispose(bool A_0)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | A_0 |

#### FillTemplateJson(string)

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

##### Declaration

    public PDFDoc FillTemplateJson(string json)

##### Parameters

Type | Name | Description
--- | --- | ---
string | json | A JSON dictionary mapping template keys to their replacement content.

##### Returns

Type | Description
--- | ---
PDFDoc | The PDFDoc from the template filling result.

#### FillTemplateJsonToOffice(string, string)

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

##### Declaration

    public void FillTemplateJsonToOffice(string json, string output_path)

##### Parameters

Type | Name | Description
--- | --- | ---
string | json | A JSON dictionary mapping template keys to their replacement content.
string | output_path | The path where the output file is written.

#### FillTemplateJsonToOfficeWithFilter(string, Filter)

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

##### Declaration

    public void FillTemplateJsonToOfficeWithFilter(string json, Filter output_stream)

##### Parameters

Type | Name | Description
--- | --- | ---
string | json | A JSON dictionary mapping template keys to their replacement content.
Filter | output_stream | An output stream.

#### ~TemplateDocument()

##### Declaration

    protected ~TemplateDocument()

#### GetConversionStatus()

Get the state of the template filling process.

##### Declaration

    public TemplateDocumentResult GetConversionStatus()

##### Returns

Type | Description
--- | ---
TemplateDocumentResult |

#### GetErrorString()

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

##### Declaration

    public string GetErrorString()

##### Returns

Type | Description
--- | ---
string | The error description. Will be blank unless GetConversionStatus returns Failure.

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

##### Declaration

    public int GetNumWarnings()

##### Returns

Type | Description
--- | ---
int | The number of stored warning strings.

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

##### Declaration

    public string GetTemplateKeysJson()

##### Returns

Type | Description
--- | ---
string | The template keys info JSON dictionary, serialized into a string.

#### GetWarningString(int)

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.

##### Declaration

    public string GetWarningString(int index)

##### Parameters

Type | Name | Description
--- | --- | ---
int | index | The index of the string to be retrieved. Must be less than GetNumWarnings().

##### Returns

Type | Description
--- | ---
string | The value of the particular warning string.

#### IsCancelled()

Has the template filling been cancelled?.

##### Declaration

    public bool IsCancelled()

##### Returns

Type | Description
--- | ---
bool | Returns true if CancelConversion has been called previously.

### Implements

IDisposable