how do i create a pdf which pdf template and save ...
# suitescript
r
how do i create a pdf which pdf template and save it into the file cabinet? How do i create a file with this? it is erroring out at contents: renderer.templateContent,
Copy code
var renderer = render.create();
    renderer.setTemplateByScriptId("CUSTTMPL_GBS_CONSOLIDATED_BOL");
    renderer.addCustomDataSource({
      format: render.DataSource.OBJECT,
      alias: "JSON",
      data: pdf
    });
    var bol = renderer.renderAsPdf();

 var filex = file.create({
      name: "samplepdf" + num,
      fileType: file.Type.PDF,
      contents: renderer.templateContent,
      folder: 2244
    });

    let fileid = filex.save();
n
What record are you trying to render?
r
custom JSON object i am sending
n
Ah sorry I was thinking you were adding in a custom data source as part of rendering another record.
r
do I just create a render inside the for loop and add those objects inside a <pdfset>
created pdf objects
that might work?
n
If you are creating more than one pdf within a pdf then yes you use <pdfset>
c
Is it a JSON object or a JSON string you are passing in? They require different options
r
json obj
b
Copy code
renderer.templateContent
is used for the same purpose as
Copy code
renderer.setTemplateByScriptId
both are used to set the template
r
oh
b
bol
should already be a file object, you dont need to create another