Error Messages in Advanced Templates
There are two main reasons you might see error messages when working with advanced templates. You may get an error related to the virtual record generated when saving a template, or you may also see error messages when you preview, save or print a template.
Virtual Record when Saving Template
When a template is saved, the printing process creates a virtual record to make sure that the template can be printed. If your template uses a substring function, the temporary string might not have enough characters for the function to work properly. In this case you may see an error message similar to the following:
The template can't be saved due to the following errors: Exception during template merging. java.lang.StringIndexOutOfBoundsException: String index out of range: 9
For example, this line works when you're printing the record, but not when you're saving the template, because the temporary string isn't long enough:
${item.taxcode?substring(4,9)}
To ensure that the template saves correctly, add an if statement to verify the length of the string.
<#if (item.taxcode?length > 9)> ${item.taxcode?substring(4,9)}
</#if>
Errors when Previewing, Saving or Printing Templates
When you preview or save an advanced template, if the preview can't be shown, or if the template can't be saved, you'll see an error message. The message displays the line and the column where the error occurred.
Also, when a PDF document doesn't print and fails with an error, the error message includes the template name, line, and column where the error occurred. Click Detail… to see more information about the error encountered. Administrators can use this information to fix the issue with the template.
For PDF creation, there is a size limitation of 100MB for XML file input. If the file size exceeds 100MB, printing results in an error.