Security change on December 1, 2026: TLS 1.2 will become the minimum standard for 365 business Print Agent. Details and system requirements
365 business development
365 business PDF

Pdf - Stationery

Codeunit 5523673 bdev.Pdf - Stationery applies a stationery - a PDF document that is laid under the pages of another PDF - to a document of your own. It is what the app itself uses when a report selection carries a stationery configuration, so a document you process this way looks exactly like one the app processed.

There are two ways to state which stationery to apply:

  • a stationery document, passed as a Temp Blob. It is laid under every page.
  • a stationery configuration, a bdev.Pdf Stationery Config. record. The configuration states a PDF file per page position - first page, following pages, second last page, last page, or all pages - and whether it applies to the print intent at hand.
Code
pdfStationery: Codeunit "bdev.Pdf - Stationery";

ApplyStationeryToDocument(Codeunit, Codeunit)

Applies a stationery document to every page of a PDF document.

Code
procedure ApplyStationeryToDocument(var document: Codeunit "Temp Blob"; stationery: Codeunit "Temp Blob")
ParameterTypeDescription
documentCodeunit "Temp Blob"The PDF document. It is replaced by the result.
stationeryCodeunit "Temp Blob"The stationery document.

Example

Code
procedure ApplyStationery(var document: Codeunit "Temp Blob") var mySetup: Record "My Setup"; pdfStationery: Codeunit "bdev.Pdf - Stationery"; stationery: Codeunit "Temp Blob"; begin mySetup.Get(); stationery.FromRecord(mySetup, mySetup.FieldNo("Stationery Document")); pdfStationery.ApplyStationeryToDocument(document, stationery); end;

ApplyStationeryToDocument(Codeunit, Record)

Applies the page settings of a stationery configuration to a PDF document, with the print intent Print.

Code
procedure ApplyStationeryToDocument(var document: Codeunit "Temp Blob"; pdfStationeryConfig: Record "bdev.Pdf Stationery Config.")
ParameterTypeDescription
documentCodeunit "Temp Blob"The PDF document. It is replaced by the result.
pdfStationeryConfigRecord "bdev.Pdf Stationery Config."The stationery configuration to apply.

Example

Code
procedure ApplyStationery(var document: Codeunit "Temp Blob"; stationeryConfigCode: Code[20]) var pdfStationeryConfig: Record "bdev.Pdf Stationery Config."; pdfStationery: Codeunit "bdev.Pdf - Stationery"; begin if (not pdfStationeryConfig.Get(stationeryConfigCode)) then exit; pdfStationery.ApplyStationeryToDocument(document, pdfStationeryConfig); end;

Letting the user pick the configuration works the same way as anywhere else:

Code
procedure SelectAndApplyStationery(var document: Codeunit "Temp Blob") var pdfStationeryConfig: Record "bdev.Pdf Stationery Config."; pdfStationery: Codeunit "bdev.Pdf - Stationery"; pdfStationeryConfigList: Page "bdev.Pdf Stat. Config. List"; begin pdfStationeryConfigList.LookupMode(true); if (pdfStationeryConfigList.RunModal() <> Action::LookupOK) then exit; pdfStationeryConfigList.GetRecord(pdfStationeryConfig); pdfStationery.ApplyStationeryToDocument(document, pdfStationeryConfig); end;

ApplyStationeryToDocument(Codeunit, Record, Code)

Applies the page settings of a stationery configuration in a given language, with the print intent Print.

Code
procedure ApplyStationeryToDocument(var document: Codeunit "Temp Blob"; pdfStationeryConfig: Record "bdev.Pdf Stationery Config."; languageCode: Code[10])
ParameterTypeDescription
documentCodeunit "Temp Blob"The PDF document. It is replaced by the result.
pdfStationeryConfigRecord "bdev.Pdf Stationery Config."The stationery configuration to apply.
languageCodeCode[10]The language of the stationery.

The language decides which PDF file the configuration resolves to. A PDF file marked as All Languages is used regardless of the language code, and so is the default file when no translation exists for the language - see Pdf - File.

ApplyStationeryToDocument(Codeunit, Record, Enum)

Applies the page settings of a stationery configuration for a given print intent.

Code
procedure ApplyStationeryToDocument(var document: Codeunit "Temp Blob"; pdfStationeryConfig: Record "bdev.Pdf Stationery Config."; documentPrintIntent: Enum "bdev.Pdf Document Print Intent")
ParameterTypeDescription
documentCodeunit "Temp Blob"The PDF document. It is replaced by the result.
pdfStationeryConfigRecord "bdev.Pdf Stationery Config."The stationery configuration to apply.
documentPrintIntentEnum "bdev.Pdf Document Print Intent"Print, Preview, Download or Save.

ApplyStationeryToDocument(Codeunit, Record, Enum, Code)

The full overload: a stationery configuration, a print intent and a language.

Code
procedure ApplyStationeryToDocument(var document: Codeunit "Temp Blob"; pdfStationeryConfig: Record "bdev.Pdf Stationery Config."; documentPrintIntent: Enum "bdev.Pdf Document Print Intent"; languageCode: Code[10])
ParameterTypeDescription
documentCodeunit "Temp Blob"The PDF document. It is replaced by the result.
pdfStationeryConfigRecord "bdev.Pdf Stationery Config."The stationery configuration to apply.
documentPrintIntentEnum "bdev.Pdf Document Print Intent"Print, Preview, Download or Save.
languageCodeCode[10]The language of the stationery.

The print intent decides whether anything happens

A stationery configuration carries a Perform on ... switch per print intent. When the switch of the intent you pass is off, the method returns without applying anything and without an error - the same behavior the app shows when a user previews a document whose stationery is configured for printing only.

A silent return is not a failure

The overloads that take a configuration return nothing, and a disabled configuration is indistinguishable from an applied one at the call site. If your process depends on the stationery having been applied, read the Perform on ... field of the configuration before you call, or compare the document size afterwards.

The overload that takes a stationery document rather than a configuration has no such switch and always applies the stationery.

See also

Last modified on