Hi all I'm working on a user event script where I ...
# suitescript
a
Hi all I'm working on a user event script where I create a PDF, and then attempt to send it via an API. The issue arises when I retrieve the file contents using getContents(); it seems to return binary encoded base64 data. The PDF is successfully sent by the API, but I'm unable to load its content outside netsuite.
var myFile = render.create();
myFile.templateContent = invoicePdf;
myFile.addRecord('record', record.load({
type: record.Type.INVOICE,
id: invId
}));
var InvoicePDF = myFile.renderAsPdf();
InvoicePDF.name = "INV" + invId + ".pdf";
InvoicePDF.folder = 7448;
var fileId = InvoicePDF.save();
var savedPdf = file.load({
id: fileId
})
var invicePdfContent = savedPdf.getContents()
I've tried encoding it to UTF-8 using the encode.convert function, but it results in a blank page.  code: var decodedString = encode.convert({
string: base64String,
inputEncoding: encode.Encoding.BASE_64,
outputEncoding: encode.Encoding.UTF_8
});
b
pdfs are binary content
netsuite represents binary content using base64
your attempt to convert it to text is doomed, it isnt text
f
Hi @battk , is the usual workaround for this is to do the upload of files via a 3rd party integration tool (ex. Dell Boomi, Mulesoft, Celigo)?