Referencing a richtext field in an Advanced PDF te...
# ask-stanley-ai
a
Referencing a richtext field in an Advanced PDF template causes XML parsing errors when it encounters a tag with an attribute whose name contains dashes, like <i data-my-attribute="thingy">Some text here</i> How do I prevent the error from making the PDF render fail?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that the issue you're encountering is due to the XML parser not being able to handle certain characters in the rich text field. This is a common issue when dealing with XML and HTML content. To prevent the error from making the PDF render fail, you can use the Freemarker's escape mechanisms. Freemarker has a built-in function for escaping XML, which can be used to escape the problematic characters in your rich text field. Here is an example of how you can use it:
Copy code
freemarker
${yourRichTextField?xml}
This will escape all the problematic characters in the
yourRichTextField
field. However, be aware that this method is deprecated because it can lead to double escaping, especially since the standard rendering by NetSuite actually does its own escaping. Another approach is to manually replace the problematic characters. For example, if the problematic character is '&', you can replace it with '&' in the PDF template:
Copy code
freemarker
${yourRichTextField?replace("&","&")}
This will replace all occurrences of '&' with '&' in the
yourRichTextField
field. Remember that you need to be careful with this approach, as you don't want to replace every character, only the ones being used as values. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.821534157
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.806300938
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.804094136
Please provide your feedback on this answer.
Thank you for your feedback
a
This doesn't concern any of the characters escaped by the ?xml built-in.
Also, using ?xml causes the valid tags to print out literally instead of being parsed. We want them to parse.