printRecord
To print to a PDF from a given record in a given layout and open the file with a program set as default
This function prints a record in a PDF and automatically downloads the PDF to your computer on which you execute the function.
The PDF name refers to the table and the record ID.
The function can be executed only on the client. Learn more about execution context.
Carbone templates
This function also works for Carbone templates and allows you to add optionally a JSON to overwrite the record data for the template.
Syntax
printRecord(nid, string)
printRecord(nid, string, JSON)
Return
void
Examples
printRecord(record, myLayout)
To print to a PDF from a given record in a given layout or Carbone template and open the file with a program set as default.
printRecord(this, "Invoices")
Result: The current record will be printed as a PDF in the Invoices layout. You'll find the PDF in your downloads.
printRecord(record, myLayout, data)
To print to a PDF from a given record in a given Carbone template and open the file with a program set as default. Record data can be overwritten with a JSON object.
printRecord(this, "Invoices", {
Date: format(if Date = null then Date else today(), "MM/DD/YYYY")
})
Result: The current record will be printed as a PDF in the Invoices layout. You'll find the PDF in your downloads. If there is no entry in the Date field, Today's date, for example, 08/28/2022 on August 28, 2022.
See also
printAndSaveRecord
which saves a given record in a given layout as a PDF in the internal file system and returns a link to the file.