Steve Reeder
Steve Reeder

Reputation: 1022

NetSuite Advanced PDF - How to set <#ftl output_format = "HTML" />

I've built many many many Advanced PDFs in the past couple of years. There is one thing that always sticks...

This applies mainly to SuiteScript rendered PDF templates.

The PDFs error if the user fields include & or -- or any other unesdcaped string literal. The default output_format is undefined

I'm looking at FTL documentation and can set <#ftl output_format = "HTML" /> but no matter where I put this in the PDF template, it fails.

Is there a particular place I need to declare this in the template?

It's not feasible to globally replace "&" with "&" everywhere etc...

Upvotes: 0

Views: 1628

Answers (1)

Krypton
Krypton

Reputation: 5286

Not sure that this answers the exact question you're asking, but I don't think it's the output format that's your problem here. My understanding is that the output format refers to what's generated by the template - ie: the final render. The output format, in any case, should be XML, as that's what's consumed by the BFO tag library when you're creating PDFs.

I think the issue is that your XML itself is not valid when string literals contain XML control characters of "&", "<" or ">". To avoid this, when building your templates and adding strings with SuiteScript, you can use the N/xml module's xml.escape() method to wrap anything that could contain one of those characters.

Sorry if I'm off base with this, but hope it helps.

Upvotes: 1

Related Questions