Password encryption

If needed, encrypt a rendered report with a password.

Either toggle ON the option Set password in the Ninox UI, or alternatively use a custom script and the functions printRecord or printAndSaveRecord.

Option A: without a custom script (Ninox UI)

Option B: with a custom script

printRecord(this, "templateLayoutName", data)
printAndSaveRecord(this, "templateLayoutName", data)

The data object can include the property _options with pdfPassword which overrides the default settings set by the print engine in the Ninox UI, if you previously toggled OFF Set password.

An empty password like"" will not encrypt your report.

Example

  1. Add a new layout element, here: a button.

  2. Paste the script below in the formula editor.

  3. Save changes.

  4. Click or tap the button to run the script.

printRecord(this, "en_invoice_template", {
	date: "02.09.2022",
	notes: "Net 30",
	invoiceNumber: "RE-00001",
	totalNet: "1,342.30 €",
	totalGross: "€1,597.34",
	paymentTerm: "30.09.2022",
	vat: [{
			rate: "19%",
			amount: "€255.04"
		}],
	customer: {
		companyName: "Happy GmbH & Co. KG",
		salutation: "Mrs.",
		lastName: "Sorglos",
		department: "Purchasing",
		address: "Willy-Brandt-Weg 2",
		postalCode: "10178",
		city: "Berlin"
	},
	contact: {
		name: "Elsa Excel",
		phone: "(030) 234 567 89",
		email: "elsa.excel@ninox.com"
	},
	items: [{
			pos: 1,
			article: "Ninox Cloud",
			number: 10,
			price: "€120.00",
			sum: "€1,200.00"
		}, {
			pos: 3,
			article: "Ninox coffee cup (porcelain)",
			number: 5,
			price: "€7.50",
			sum: "€37.50"
		}, {
			pos: 4,
			article: "Ninox coffee cup (recycled)",
			number: 10,
			price: "€0.49",
			sum: "€4.90"
		}, {
			pos: 5,
			article: "Ninox basecap",
			number: 10,
			price: "€9.99",
			sum: "€99.90"
		}],
	_options: {
		pdfPassword: "lite-wake-grill"
	}
})

Result

A report (PDF file) is created and downloaded to your local files. When you open the PDF from your browser, you are prompted to enter a password to open the document.

Last updated