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 - File

Codeunit 5523672 bdev.Pdf - File reads a PDF file that is stored in the app. PDF Files is where a user uploads the documents a stationery or a concatenate configuration refers to - a letterhead, a terms and conditions page, a leaflet - and the same documents are available to your extension.

Code
pdfFile: Codeunit "bdev.Pdf - File";

How a PDF file is resolved

A PDF Files record holds one document and, optionally, one translation per language in PDF File Translations. Which document is returned for a language code follows three rules:

  1. the record is marked as All Languages, or no language code is asked for - the document of the record itself is returned;
  2. a translation exists for the language code - the document of the translation is returned;
  3. no translation exists for the language code - the document of the record itself is returned as the fallback.

A language that has no translation therefore never fails; it falls back to the default document. That is what makes it safe to pass the language of a sales document straight through.

GetPdfFile(Code, Code)

Returns the document of the PDF file with the given code, in the given language.

Code
procedure GetPdfFile(pdfFileCode: Code[20]; languageCode: Code[10]): Codeunit "Temp Blob"
ParameterTypeDescription
pdfFileCodeCode[20]Code of the PDF file, as set up in PDF Files.
languageCodeCode[10]The language of the PDF file. An empty code returns the document of the default language.

Returns the PDF file as a Temp Blob codeunit.

The method raises an error naming the code when no PDF file is set up for it. A language without a translation is not an error - it falls back to the default document, as described above.

Version

GetPdfFile(Code[20], Code[10]) has been introduced with 365 business PDF 20.6. The two overloads it replaces - GetPdfFile() and GetPdfFile(Code[10]) - never stated which PDF file to read and returned an empty document. They are obsolete as of 20.6; move calls over to the overload above.

Example

Code
procedure GetLetterhead(languageCode: Code[10]): Codeunit "Temp Blob" var pdfFile: Codeunit "bdev.Pdf - File"; begin exit(pdfFile.GetPdfFile(LetterheadCodeLbl, languageCode)); end; var LetterheadCodeLbl: Label 'LETTERHEAD', Locked = true;

The document the codeunit returns is the one a stationery configuration would use for the same language, so a letterhead you apply yourself through Pdf - Stationery matches the one the app applies during report processing.

PdfFileExists(Code)

States whether a PDF file is set up for the code.

Code
procedure PdfFileExists(pdfFileCode: Code[20]): Boolean
ParameterTypeDescription
pdfFileCodeCode[20]Code of the PDF file.

Returns true when the PDF file exists.

Use it where a missing PDF file is an expected state rather than an error - to hide an action, or to fall back to a document of your own - instead of catching the error of GetPdfFile.

See also

Last modified on