Any way to mimic the print packing slip functional...
# suitescript
e
Any way to mimic the print packing slip functionality via suitescript? The goal is to generate 1 PDF with numerous packing slips. But I'm trying not to save all the individual packing slips to the file cabinet, then use <pdfset> to generate a single one referencing all the other
Copy code
arrFulfillmentIds.forEach(( fulfillmentId ) => {
                const objPackingSlipFile = render.packingSlip({
                    entityId: fulfillmentId,
                    printMode: render.PrintMode.PDF,
                });
                objPackingSlipFile.folder = -15;
                objPackingSlipFile.name = `PackingSlip-${fulfillmentId}.pdf`;
                objPackingSlipFile.isOnline = true;
                const stPackingSlipId = objPackingSlipFile.save();
                arrFileIds.push( stPackingSlipId );
            });
Copy code
SL.renderSinglePDF = ( fileIds ) => {
            const xmlLines = [ "<?xml version=\"1.0\"?>", "<pdfset>" ];

            fileIds.forEach(( fileId ) => {
                const singlePDF = file.load({ id: fileId });
                const stPDFURL = xml.escape({ xmlText: singlePDF.url });
                xmlLines.push( `<pdf src='<https://XXXXXX-sb1.app.netsuite.com>${stPDFURL}'/>` );
            });

            xmlLines.push( "</pdfset>" );

            return render.xmlToPdf({
                xmlString: xmlLines.join( "\n" ),
            });
        };
This works, but forces me to use a ton of governance for file.save / file.load Wondering if there is a way around that?
b
you can be more efficient and do 1 search for all your urls, instead of loading them one at a time
but otherwise there isnt any quick fix
if you were dedicated, you can print it as html which is a string you can actually manipulate and parse through in code to make your own combined pdf
e
Search is a good idea to save some governance. I appreciate that. I was using file.getContents and was able to get back a “pdf string”, but couldnt figure out how to concatenate them together to create a new file. Felt like I was very close but couldnt get it to work
b
a pdf is binary content, netsuite represents it as a base 64 string which is not a form that is easily manipulated
which is why you change the print mode to html, which is plain text and can be manipulated, though not easily
e
all super helpful information- thanks @battk