---
id: post/yzhums-com/68624
type: post
title: "Dynamics 365 Business Central: How to get the page number of a PDF or Word file in AL (Display the page count on Attached Documents and Doc. Attachment List Factbox)"
summary: This post explains how to retrieve and display page counts for PDF and Word documents in Business Central using AL code. It covers using the PDF Document codeunit to get page counts directly for PDFs and converting Word files to PDF first, with examples for extending document attachment pages.
tier: community
language: en
tags:
  - pdf processing
  - word documents
  - attachments
  - al code
  - document management
system: development
review:
  state: reviewed
  by: opus
  at: "2026-10-26T06:41:46.651Z"
  flags: []
generated:
  at: "2026-10-26T08:08:59.782Z"
  pipeline: 0.2.0
  prompts:
    extract-post: 1
  input_hash: c91e02c40a4acb466f788619b2b801597a98f4b79d4d8503ad3f659d9cb7c42c
evidence:
  - kind: blog
    url: https://yzhums.com/68624/
    title: "Dynamics 365 Business Central: How to get the page number of a PDF or Word file in AL (Display the page count on Attached Documents and Doc. Attachment List Factbox)"
    date: "2025-10-24"
    commit: null
    t: null
    quote: null
  - kind: blog
    url: https://yzhums.com/68624/
    title: "Dynamics 365 Business Central: How to get the page number of a PDF or Word file in AL (Display the page count on Attached Documents and Doc. Attachment List Factbox)"
    date: "2025-10-24"
    commit: null
    t: null
    quote: By default, Business Central does not display the page count of these files, but if we want to display it, is there any way?
  - kind: blog
    url: https://yzhums.com/68624/
    title: "Dynamics 365 Business Central: How to get the page number of a PDF or Word file in AL (Display the page count on Attached Documents and Doc. Attachment List Factbox)"
    date: "2025-10-24"
    commit: null
    t: null
    quote: For Word files, we need to convert them to PDF first.
links:
  learn: []
  objects:
    - object/codeunit/3110
    - object/codeunit/419
    - object/codeunit/9651
    - object/codeunit/4100
    - object/table/1173
    - object/page/1173
    - object/page/1178
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  related:
    - to: https://learn.microsoft.com/dynamics365/business-central/dev-itpro/ai/ai-development-toolkit-attachments
      title: Attachment capabilities and limitations (preview)
      label: possibly related
      why: names Codeunit 4100 "Temp Blob"
      by: code
    - to: post/yzhums-com/68077
      title: "Business Central 2025 wave 2 (BC27): Support for new ExtendedDataType value: Document (display/preview a PDF as a portrait image in FactBox)"
      label: possibly related
      why: both name Codeunit 3110 "PDF Document"
      by: code
    - to: post/yzhums-com/64042
      title: "Dynamics 365 Business Central: Convert Word (.docx) To HTML (.html) within BC (No control add-in and APIs)"
      label: possibly related
      why: both name Table 1173 "Document Attachment"
      by: code
    - to: post/yzhums-com/63595
      title: "Dynamics 365 Business Central: Convert Word (.docx) To PDF (.pdf) within BC (No control add-in and APIs)"
      label: possibly related
      why: both name Page 1173 "Document Attachment Details"
      by: code
    - to: post/yzhums-com/65522
      title: "Dynamics 365 Business Central: Generate Swiss QR Code without external services/APIs"
      label: possibly related
      why: both name Codeunit 4100 "Temp Blob"
      by: code
    - to: post/yzhums-com/66463
      title: "Dynamics 365 Business Central: How to prevent users from uploading duplicate files as attachments (Duplicate file names)"
      label: possibly related
      why: both name Table 1173 "Document Attachment"
      by: code
    - to: post/yzhums-com/63942
      title: "Dynamics 365 Business Central: How to preview Word (.docx) in web client without downloading (No control add-in and APIs)"
      label: possibly related
      why: both name Codeunit 9651 "Document Report Mgt."
      by: code
    - to: post/yzhums-com/66461
      title: "Dynamics 365 Business Central: How to quickly strip not supported chars in File Name via AL"
      label: possibly related
      why: both name Codeunit 419 "File Management"
      by: code
    - to: post/demiliani-com/12623
      title: "Dynamics 365 Business Central: previewing PDF files in web client using the new ExtendedDataType = Document."
      label: possibly related
      why: both name Codeunit 419 "File Management"
      by: code
    - to: post/gerardorenteria-blog/11203
      title: New Application Ideas of Dynamics 365 Business Central (2025 MAY)
      label: possibly related
      why: both name Table 1173 "Document Attachment"
      by: code
post_id: "68624"
source_id: yzhums-com
source_name: Dynamics 365 Lab - Yun Zhu
url: https://yzhums.com/68624/
published_at: "2025-10-24T01:02:53.000Z"
author: Yun Zhu
full_text: false
words: 679
quotes:
  - text: By default, Business Central does not display the page count of these files, but if we want to display it, is there any way?
    why_it_matters: Identifies the problem that motivates the solution of displaying page counts in document attachments
  - text: For Word files, we need to convert them to PDF first.
    why_it_matters: Explains the key limitation that Word files require conversion before page counting is possible
code_objects_mentioned:
  - codeunit PDF Document
  - codeunit File Management
  - codeunit Document Report Mgt.
  - codeunit Temp Blob
  - table Document Attachment
  - page Document Attachment Details
  - page Doc. Attachment List Factbox
systems:
  - development
versions_mentioned: []
preview:
  embeddable: true
  frame_url: null
  image: https://yzhums.com/wp-content/uploads/2025/10/Snipaste_2025-10-23_14-01-58.png
  image_alt: null
  image_w: null
  image_h: null
  site_name: Dynamics 365 Lab
  favicon: https://yzhums.com/wp-content/uploads/2020/08/cropped-logo-3-32x32.png
  probed_at: "2026-10-26T06:12:53.431Z"
---

# Dynamics 365 Business Central: How to get the page number of a PDF or Word file in AL (Display the page count on Attached Documents and Doc. Attachment List Factbox)

[Read the post](https://yzhums.com/68624/) · Dynamics 365 Lab - Yun Zhu (Yun Zhu, MVP) · 2025-10-24 · 679 words · tier community · reviewed (checked by Opus)

> This post explains how to retrieve and display page counts for PDF and Word documents in Business Central using AL code. It covers using the PDF Document codeunit to get page counts directly for PDFs and converting Word files to PDF first, with examples for extending document attachment pages.

## Key points

- Codeunit 3110 'PDF Document' has a GetPdfPageCount method that returns the page count of a PDF stream
- Word files must first be converted to PDF with Document Report Mgt. ConvertWordToPdf
- A PageCount field is added to the Document Attachment table and shown on the Document Attachment Details page and the Doc. Attachment List Factbox
- A subscriber to OnBeforeSaveAttachment fills in the page count when a file is uploaded; for Word files it first copies the data into a second Temp Blob

## Quotes

- "By default, Business Central does not display the page count of these files, but if we want to display it, is there any way?" (Identifies the problem that motivates the solution of displaying page counts in document attachments)
- "For Word files, we need to convert them to PDF first." (Explains the key limitation that Word files require conversion before page counting is possible)

## AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

- [codeunit 3110 "PDF Document"](../../objects/codeunit/3110.md)
- [codeunit 419 "File Management"](../../objects/codeunit/419.md)
- [codeunit 9651 "Document Report Mgt."](../../objects/codeunit/9651.md)
- [codeunit 4100 "Temp Blob"](../../objects/codeunit/4100.md)
- [table 1173 "Document Attachment"](../../objects/table/1173.md)
- [page 1173 "Document Attachment Details"](../../objects/page/1173.md)
- [page 1178 "Doc. Attachment List Factbox"](../../objects/page/1178.md)

## Possibly related

No source states these links: they share an object, a model read them, or a person found the same subject.

- [Attachment capabilities and limitations (preview)](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/ai/ai-development-toolkit-attachments) — possibly related: names Codeunit 4100 "Temp Blob"
- [Business Central 2025 wave 2 (BC27): Support for new ExtendedDataType value: Document (display/preview a PDF as a portrait image in FactBox)](../../posts/yzhums-com/68077.md) — possibly related: both name Codeunit 3110 "PDF Document"
- [Dynamics 365 Business Central: Convert Word (.docx) To HTML (.html) within BC (No control add-in and APIs)](../../posts/yzhums-com/64042.md) — possibly related: both name Table 1173 "Document Attachment"
- [Dynamics 365 Business Central: Convert Word (.docx) To PDF (.pdf) within BC (No control add-in and APIs)](../../posts/yzhums-com/63595.md) — possibly related: both name Page 1173 "Document Attachment Details"
- [Dynamics 365 Business Central: Generate Swiss QR Code without external services/APIs](../../posts/yzhums-com/65522.md) — possibly related: both name Codeunit 4100 "Temp Blob"
- [Dynamics 365 Business Central: How to prevent users from uploading duplicate files as attachments (Duplicate file names)](../../posts/yzhums-com/66463.md) — possibly related: both name Table 1173 "Document Attachment"
- [Dynamics 365 Business Central: How to preview Word (.docx) in web client without downloading (No control add-in and APIs)](../../posts/yzhums-com/63942.md) — possibly related: both name Codeunit 9651 "Document Report Mgt."
- [Dynamics 365 Business Central: How to quickly strip not supported chars in File Name via AL](../../posts/yzhums-com/66461.md) — possibly related: both name Codeunit 419 "File Management"
- [Dynamics 365 Business Central: previewing PDF files in web client using the new ExtendedDataType = Document.](../../posts/demiliani-com/12623.md) — possibly related: both name Codeunit 419 "File Management"
- [New Application Ideas of Dynamics 365 Business Central (2025 MAY)](../../posts/gerardorenteria-blog/11203.md) — possibly related: both name Table 1173 "Document Attachment"

## Context

- Features: PDF page count retrieval, Word to PDF conversion, document attachment extensions, attachment metadata display, event subscriber implementation

Source: Dynamics 365 Lab - Yun Zhu, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.
