Is there a way to render a PDF with SS2.0 and then...
# suitescript
k
Is there a way to render a PDF with SS2.0 and then get the base64 encoding for it? I want the binary of the file to upload into a FTP
m
Cant you get the contents of the pdf once you create it?
j
renderAsPDF returns a file object and I think if you do a getContents on the file object that just might be base64
k
@JohnnyC - i can't find a renderAsPDF function? Is that a 1.0 function? @mayerlench - How do I do that within 2.0?
j
Nope 2.0 on the TemplateRenderer
in the N/render module.
k
oh I see it. so should I call render.create() first?
j
Yeap that gives you the TemplateRenderer then you'll need to specify your template string, attach any records, search results custom data etc and call renderAsPDF
Then getContents on the N/file object returned from renderAsPDF which should be base64
k
@JohnnyC - I think I am following what you are saying. Will this method work for generating the PDF invoice from an invoice record?
j
Assuming Advanced PDF is turned on the invoice form you could use render.transaction instead of render.create. The render.create can still work but you would have to first load and set the template string for the invoice which with render.transaction you wouldn't have to.