Do i need to first convert the html to XML and the...
# suitescript
m
Do i need to first convert the html to XML and then use renderAsPdf??
w
no, to generate an xml to pdf it has to have the BF elements required to generate the xml as pdf.
d
Yes, but you'll have to manually convert it to xml by replacing all the not supported tags
m
Any where I can find documentation on which tags aren’t supported?
d
I wrote the following function and it worked for me:
Copy code
export function removeHtmlTags(initialString: string): string{
    let resultString = initialString.replace(/ [\w-]+=.*?(?=>)/gi, '');
    resultString = resultString
        .replace(/<meta>/ig, '')
        .replace(/<br>/ig, '')
        .replace(/<img>/ig, '')
        .replace(/<p>/ig, '')
        .replace(/ nowrap/ig, '')
        .replace(/&nbsp;/ig, ' ')
        .replace(/&/g, '&');

    return resultString + '</body></html>';
}
m
@Dmitry Masanov@michoel Thank you!
Now I'm getting a plain document without any of the styling. Any idea what I'm doing wrong? The HTMLDOC renders fine. I just want to be able to save it as a PDF