Morris S
Morris S

Reputation: 2594

netsuite Pdf url `&` throws an error

When trying to create a custom pdf that includes another pdf url it throws an error, it doesn't like the & in the url. I tried all kinds of stuff including changing the & to %26 or & nothing seems to work...

this is my code in netsuite debugger:

require(['N/render', 'N/search', 'N/file', 'N/record', 'N/xml', 'N/email'],
    function (render, search, file, record, mxml, email, R, dms) {
       var xml = "<?xml version=\"1.0\"?>\n<!DOCTYPE pdf PUBLIC \"-//big.faceless.org//report\" \"report-1.1.dtd\">\n"
            xml += "<pdfset>\n"
            xml += "<pdf>\n<body font-size='12'>\n"
            xml += "<p align='center'>Todays Date:</p>"
            xml += "</body>\n</pdf>"

           var res = 'https://debugger.sandbox.netsuite.com/core/media/media.nl?id=105000&c=566666&h=ddefrekl565jk65jgdgjre&whence=';
           xml += '<pdf src="'+ res+ '"></pdf>'
           xml += "</pdfset>"
           var renderer = render.create()
           renderer.templateContent = xml
           var pdfRend= renderer.renderAsPdf()
           pdfRend.name = 'Test pdf.pdf',
           pdfRend.folder = 1665666

        var fileid = pdfRend.save()
        return file.load({
            id: fileid
        }).url

    var x = 0;

})

Upvotes: 0

Views: 1543

Answers (2)

NetSuite Help
NetSuite Help

Reputation: 228

Try using escapeXML

Below is the sample code: var xmlEscapedDocument = xml.escape({ xmlText : xmlFileContent });

Upvotes: 0

bknights
bknights

Reputation: 15377

http://www.example.com/?candy_name=M%26M does not return a PDF.

The renderer is trying to download that and can't. The reported xml parser error is misleading.

Upvotes: 1

Related Questions