---
id: object/codeunit/3110
type: object
title: Codeunit 3110 "PDF Document"
summary: Codeunit 3110 "PDF Document" in System Application (System.IO). 18 public procedures. Introduced in BC26, still in BC30, changed in BC27.
tier: official
language: en
tags:
  - codeunit
  - system application
versions:
  introduced: "26"
  last_changed: "27"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 315a837df788b05f744b001fdd06a591ea5924dd7a4e3afa6136d3875c6cedbd
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/Pdf/src/PDFDocument.Codeunit.al
    title: src/System Application/App/Pdf/src/PDFDocument.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
object_type: codeunit
object_id: 3110
name: PDF Document
namespace: System.IO
app: System Application
extends: null
first_version: "26"
last_version: "30"
present_in:
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "27"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 18
  events: 0
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 1
  called_by: 4
  implements: 0
---

# Codeunit 3110 "PDF Document"

> Codeunit 3110 "PDF Document" in System Application (System.IO). 18 public procedures. Introduced in BC26, still in BC30, changed in BC27.

System Application · System.IO · BC26-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/Pdf/src/PDFDocument.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| Access | Public |

## Procedures

- `Initialize()`: This procedure initializes the internal state of the object by resetting attachment lists and clearing user and admin codes, as well as any additional document names.
- `Load(DocumentStream: InStream): Boolean`: This procedure is used to load a PDF document from a stream.
- `ConvertPdfToImage(var ImageStream: InStream; ImageFormat: Enum "Image Format"; PageNumber: Integer): Boolean`: This procedure is used to convert a PDF file to an image.
- `ConvertToImage(var ImageStream: InStream; ImageFormat: Enum "Image Format"; PageNumber: Integer)` (obsolete 27.2: Use the ConvertPdfToImage procedure instead.): This procedure is used to convert a PDF file to an image.
- `GetDocumentAttachmentStream(PdfStream: InStream; var TempBlob: Codeunit "Temp Blob"): Boolean`: This procedure is used to get the invoice attachment stream from a PDF file.
- `GetPdfProperties(DocumentInStream: InStream): JsonObject`: Retrieves metadata properties from a PDF file, such as page size, author, title, and creation date.
- `GetPdfPageCount(DocumentInStream: InStream): Integer`: Returns the number of pages in the provided PDF stream.
- `GetZipArchive(PdfStream: InStream)`: Initiates a download of a ZIP archive containing all embedded attachments from the provided PDF stream.
- `GetAttachmentNames(PdfStream: InStream): List of [Text]`: Retrieves the names of embedded file attachments from a PDF document.
- `AddAttachment(AttachmentName: Text; PDFAttachmentDataType: Enum "PDF Attach. Data Relationship"; MimeType: Text; FileName: Text; Description: Text; PrimaryDocument: Boolean)`: Configure the attachment lists. An empty name will reset the list. This procedure adds a new attachment to the PDF document with the specified metadata and relationship type.
- `AddAttachment(AttachmentName: Text; PDFAttachmentDataType: Enum "PDF Attach. Data Relationship"; MimeType: Text; FileInStream: InStream; Description: Text; PrimaryDocument: Boolean)`: Configure the attachment lists. An empty name will reset the list. This procedure adds a new attachment to the PDF document with the specified metadata and relationship type.
- `AddFileToAppend(FileName: Text)`: Add a file to the list of files to append to the rendered document. Empty name will reset the list.
- `AddStreamToAppend(FileInStream: InStream)`: Add a stream to the list of files to append to the rendered document using a temporary file name.
- `ProtectDocument(User: Text; Admin: Text)`: Protect the document with a user and admin code using text data type.
- `ProtectDocument(User: SecretText; Admin: SecretText)`: Protect the document with a user and admin code using secrettext data type.
- `AttachmentCount(): Integer`: Returns the number of configured attachments. Validates that all attachment-related lists (names, MIME types, data types, filenames, and descriptions) are synchronized in length. Throws an error if any of the lists are out of sync.
- `AppendedDocumentCount(): Integer`: Returns the number of additional document names that have been appended. This count reflects how many supplementary documents are currently tracked.
- `ToJson(RenderingPayload: JsonObject): JsonObject`: Converts the internal state of the PDF document configuration into a structured JSON payload. This includes metadata such as version, primary document, attachments, additional documents, and protection settings.

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 3109 "PDF Document Impl."](../codeunit/3109.md) (15 calls: `AddAttachment → AddAttachment`, `AddFileToAppend → AddFileToAppend`, `AddStreamToAppend → AddStreamToAppend`, …)

## Called by

- [Report 25 "Account Schedule"](../report/25.md) (6 calls: `AppendDimPerspectiveReports → AddStreamToAppend`, `AppendDimPerspectiveReports → Initialize`, `AppendDimPerspectiveReports → ToJson`, …)
- [Page 6956 "Expense Picture"](../page/6956.md) (2 calls: `LoadPdfImage → ConvertPdfToImage`, `LoadPdfImage → Load`)
- [Codeunit 4400 "SOA Setup"](../codeunit/4400.md) (1 call: `DocumentExceedsPageCountThreshold → GetPdfPageCount`)
- [Codeunit 5579 "Digital Voucher Impl."](../codeunit/5579.md) (1 call: `ExtractXMLFromPDF → GetDocumentAttachmentStream`)

## Across versions

- Present in: BC26-30
- Changed (declaration) in: BC27

## Deprecations

- procedure ConvertToImage: Pending 27.2 (#if not CLEAN27), "Use the ConvertPdfToImage procedure instead."

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "PDF Document")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
