new TemplateDocument()
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.
Extends
Members
-
<static> Result
-
Type:
- number
Properties:
Name Type Description e_Success
number e_Incomplete
number e_Failure
number
Methods
-
cancelConversion()
-
Cancel the current template filling, forcing FillTemplateJson to return.
Returns:
- Type
- Promise.<void>
-
destroy()
-
Destructor
- Inherited From:
Returns:
- Type
- Promise.<void>
-
fillTemplateJson(json)
-
Create a PDF by merging JSON data with this template document.
Parameters:
Name Type Description json
string - A JSON dictionary mapping template keys to their replacement content. Returns:
A promise that resolves to the PDFDoc from the template filling result.- Type
- Promise.<PDFNet.PDFDoc>
-
fillTemplateJsonToOffice(json, output_path)
-
Create an office file by merging JSON data with this template document. This function currently only supports DOCX input.
Parameters:
Name Type Description json
string - A JSON dictionary mapping template keys to their replacement content. output_path
string - The path where the output file is written. Returns:
- Type
- Promise.<void>
-
getConversionStatus()
-
Get the state of the template filling process.
Returns:
A promise that resolves to .- Type
- Promise.<number>
Example
Return value enum: <pre> PDFNet.TemplateDocument.Result = { e_Success : 0 e_Incomplete : 1 e_Failure : 2 } </pre>
-
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:
A promise that resolves to the error description. Will be blank unless GetConversionStatus returns Failure.- Type
- Promise.<string>
-
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:
A promise that resolves to the number of stored warning strings.- Type
- Promise.<number>
-
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:
A promise that resolves to the template keys info JSON dictionary, serialized into a string.- Type
- Promise.<string>
-
getWarningString(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:
Name Type Description index
number - the index of the string to be retrieved. Must be less than GetNumWarnings(). Returns:
A promise that resolves to the value of the particular warning string.- Type
- Promise.<string>
-
isCancelled()
-
Has the template filling been cancelled?.
Returns:
A promise that resolves to returns true if CancelConversion has been called previously.- Type
- Promise.<boolean>
-
takeOwnership()
-
Take the ownership of this object, so that PDFNet.runWithCleanup won't destroy this object.
- Inherited From:
Returns:
- Type
- void