Reputation: 845
I am trying to get HTML content to print in NetSuite's Advanced PDF/HTML Templates. Does anyone know if this is possible?
In this example, custbody_print_content
is a custom field. Its value is:
<h1>Tiger</h1>
The template source code looks like this:
<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">
<pdf>
<body>
${record.custbody_print_content}
</body>
</pdf>
I get this output:
<h1>Tiger</h1>
but I do not want the literal HTML. I want the interpreted HTML, like this:
I tried some of the built-ins that were mentioned in the comments, but I still do not get what I want. The picture below shows the template and the printout. The Zebra example has the desired result.
Upvotes: 0
Views: 1419
Reputation: 845
It looks like NetSuite escapes the html when it saves. This means that when you type this in the form's text box:
<b>Marmot</b>
NetSuite "escapes" it and saves it like this:
<b>Marmot</b>
So in the FreeMarker template, you need to unescape it. I could not find any built-in feature to do this, but I can use ?replace
. My current solution looks like this:
<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">
<pdf>
<body>
${record.custbody_print_content?replace('<br />', '')?replace('<', "\l")?replace('>', "\g")}
</body>
</pdf>
If anyone knows an easier way to do this, then let me know.
Upvotes: 0
Reputation: 15367
You can use the no_esc built-in. E.g
${record.custbody_print_content?no_esc}
Also I don't think this should make a difference but your xml is unusual in that it doesn't have a head element
Try getting rid of the extra space between the DOCTYPE and the <pdf>
element and add this before the <body>
opening tag
<head>
<link name="verdana" type="font" subtype="opentype" src="${nsfont.verdana}" src-bold="${nsfont.verdana_bold}" bytes="2"></link>
</head>
Upvotes: 2