<@UALJZANH0> <https://medium.com/@morrisdev/append...
# suitescript
m
Hi Morris, thanks for sharing this with me. I followed this guide, but I’m getting a lot of parsing errors when I’m trying to load a pdf file from the file cabinet. I’m not sure if you have a lot of experience with XML, but the xml string i’m sending is the following <?xml version=“1.0” encoding=“UTF-8"?> <!DOCTYPE pdf PUBLIC “-//big.faceless.org//report” “report-1.1.dtd”> <pdfset> <pdf> <body> <h3>Generated PDF</h3> <p> </p> Document body here </body> </pdf> <pdf src=“https://core/media/media.nl?id=16977&amp;amp;c=4495526_SB1&amp;amp;h=ee648509acf5071e3627&amp;amp;_xt=.pdf“/&gt; <pdf src=“https://core/media/media.nl?id=16673&amp;amp;c=4495526_SB1&amp;amp;h=a5db5aa990ae877c3413&amp;amp;_xt=.pdf”/&gt; <pdf src=“https://core/media/media.nl?id=16674&amp;amp;c=4495526_SB1&amp;amp;h=3c47bb652ce4edbda179&amp;amp;_xt=.pdf”/&gt; </pdfset>
m
@Michael Luu xml can be a big pain! 1. use this header
<?xml version=\"1.0\"?>\n<!DOCTYPE pdf PUBLIC \"-//big.faceless.org//report\" \"report-1.1.dtd\">
2. make sure to only use this type of quotes
"
not the ones you are using around the pdf urls
Im not an xml pro but I did spend a lot of time on it, let me know if you need more help.
m
Thanks @Morris I think I got the header working correctly. My issue specifically is around specifying the pdf src. If I remove the 3 <pdf src=" https..." lines, then the Netsuite function xmlToPdf seems to work. but as soon as I put even one of those statements in, i get the following error message: "Error Parsing XML: //system.netsuite.com/core/media/media.nl?id=16977&c=4495526_SB1&h=ee648509acf5071e3627&_xt=.pdf"
m
&
has to be parsed to
&amp;
if you want you can parse it using the
'N/xml'
module and use this function
Copy code
var cleanPdfURL = xml.escape({
xmlText: x
});
xml += '<pdf src="' + cleanPdfURL + '"></pdf>';
m
yep, i did exactly that. this is the xml string that I am sending to netsuite to try to parse/interpret <?xml version="1.0"?> <!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd"> <pdfset> <pdf> <body> <h3>Generated PDF</h3> <p>Invoice Form</p> </body> </pdf> <pdf src="/core/media/media.nl?id=16977&amp;c=4495526_SB1&amp;h=ee648509acf5071e3627&amp;_xt=.pdf"/> <pdf src="/core/media/media.nl?id=16673&amp;c=4495526_SB1&amp;h=a5db5aa990ae877c3413&amp;_xt=.pdf"/> <pdf src="/core/media/media.nl?id=16674&amp;c=4495526_SB1&amp;h=3c47bb652ce4edbda179&amp;_xt=.pdf"/> </pdfset>
m
make sure the pdf is "available without login"
and insert the full pdf path not the relative path
m
So after my trial, I don’t think this method actually works (at least in SuiteScript 2.0). I emailed support and they replied saying that merging PDFs with the <pdf src> tags aren’t currently supported and that an enhancement request has already been submitted. 😞