To generate a PDF from a record or Carbone template, save it in Ninox's internal file system, and return a download link
This function creates a PDF from a specified record in either a Ninox layout or Carbone template, stores it in Ninox's internal file system, and returns a download link to the file.
You can use this link for internal access or save it as a record attachment using the importFile
function.
Caution: This function can only be executed on the client side. For more information, see execution context documentation.
The printAndSaveRecord
function supports Carbone templates, allowing you to optionally add a JSON input to overwrite record fields in the template. You can also apply advanced configuration through the _options
parameter for features including test print, password protection, and PDF versioning.
printAndSaveRecord(nid, string)
printAndSaveRecord(nid, string, JSON)
record: The record to be saved as a PDF.
myLayout: The layout or Carbone template used to format the PDF.
data (optional): A JSON object that overwrites the record data in the Carbone template.
_options (optional): Additional configuration options for Carbone templates.
_options
configuration:
testPrint: boolean
, default is false
. If true
, prints a test PDF with a Carbone watermark; this action doesn’t consume Carbone tokens.
pdfPassword: string
. Protects the PDF with a password.
pdfVersion: number
. Specifies the PDF version:
0
: Default
15
: PDF 1.5
16
: PDF 1.6
1
: PDF/A-1
2
: PDF/A-2
3
: PDF/A-3
Note: _options
configurations are stackable, allowing you to apply multiple settings in one function call. For example, you can enable both pdfPassword
and pdfVersion
for added customization.
link: A URL to the saved PDF file in Ninox's internal file system.
printAndSaveRecord(record, myLayout)
This version of the function works for both Ninox layouts and Carbone templates. It generates and saves a PDF for the specified record and returns a link to the file.
Example:
Result:
A link to the generated PDF that follows the Invoices layout: https://dbde0000.ninox.com/AbCD1234/12345xYZzyX/loadfile/Invoices.pdf?
printAndSaveRecord(record, myLayout, data)
To save a record in a Carbone template as a PDF in the internal file system, returning a link to the file. Record data can be overwritten with a JSON object.
Example:
Result:
A link to the generated PDF that includes an entry in the Date field: https://dbde0000.ninox.com/AbCD1234/12345xYZzyX/loadfile/Invoices.pdf?
If no entry is provided, today's date will be added. For example, 08/28/2024
for August 28, 2024.
_options
)Example:
Result:
A link to the generated PDF where the Name and Age placeholders are replaced by provided values: https://dbde0000.ninox.com/AbCD1234/12345xYZzyX/loadfile/Invoices.pdf?
Note: Test printing doesn't use Carbone tokens.
Example:
Result:
A link to the generated test PDF, which includes a Carbone watermark: https://dbde0000.ninox.com/AbCD1234/12345xYZzyX/loadfile/Invoices.pdf?
Example:
Result:
A link to the generated PDF, which is password-protected with password 1234
:
https://dbde0000.ninox.com/AbCD1234/12345xYZzyX/loadfile/Invoices.pdf?
Example:
Result:
A link to the generated PDF, which is formatted to PDF/A-1 standards: https://dbde0000.ninox.com/AbCD1234/12345xYZzyX/loadfile/Invoices.pdf?
importFile
, which imports a file from a URL and saves it as an attachment of a record.
printRecord
, which prints a record to a PDF in a specified layout and opens it in the default program.
Want to learn more about this topic? Check out the corresponding part of our video tutorial.