From 58fb4200c92da5f09ea993429b256bb426517b3c Mon Sep 17 00:00:00 2001 From: SF4524LogeshKumar Date: Wed, 6 May 2026 12:04:31 +0530 Subject: [PATCH 1/6] 1024133: Document Handling in Blazor PDF Viewer --- Document-Processing-toc.html | 8 + .../document-handling/load-large-pdf.md | 105 +++++++++ .../document-handling/load-password-pdf.md | 95 +++++++++ .../document-handling/preprocess-pdf.md | 199 ++++++++++++++++++ .../document-handling/retrieve-loadedDoc.md | 172 +++++++++++++++ 5 files changed, 579 insertions(+) create mode 100644 Document-Processing/PDF/PDF-Viewer/blazor/document-handling/load-large-pdf.md create mode 100644 Document-Processing/PDF/PDF-Viewer/blazor/document-handling/load-password-pdf.md create mode 100644 Document-Processing/PDF/PDF-Viewer/blazor/document-handling/preprocess-pdf.md create mode 100644 Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loadedDoc.md diff --git a/Document-Processing-toc.html b/Document-Processing-toc.html index ac7f5252c..4cffb2bde 100644 --- a/Document-Processing-toc.html +++ b/Document-Processing-toc.html @@ -1134,6 +1134,14 @@
  • To Box cloud file storage
  • +
  • Document Handling + +
  • Toolbar Customization
  • Toolbar Customization diff --git a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loadedDoc.md b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md similarity index 100% rename from Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loadedDoc.md rename to Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md From 54b2ca3951cced8de14c43a2502fade535a7c72f Mon Sep 17 00:00:00 2001 From: SF4524LogeshKumar Date: Tue, 12 May 2026 17:31:50 +0530 Subject: [PATCH 4/6] 1024133: Updated review changes. --- .../blazor/document-handling/load-large-pdf.md | 2 -- .../blazor/document-handling/preprocess-pdf.md | 8 -------- .../document-handling/retrieve-loaded-document.md | 10 +++++----- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/load-large-pdf.md b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/load-large-pdf.md index 8b1df083f..b50747a86 100644 --- a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/load-large-pdf.md +++ b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/load-large-pdf.md @@ -12,8 +12,6 @@ domainurl: ##DomainURL## This section explains how to load and render **large PDF files (up to approximately 1 GB)** efficiently using the Syncfusion Blazor PDF Viewer. It also covers the recommended configurations required to achieve stable and responsive performance while working with large documents. -Large PDF rendering in the Blazor PDF Viewer is supported through **chunk-based processing**, which allows the document to be processed incrementally instead of downloading and rendering the entire file in a single request. - ## Why Large PDFs Require Special Handling Large PDF files may contain: diff --git a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/preprocess-pdf.md b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/preprocess-pdf.md index bdf5f7778..3f6a2106e 100644 --- a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/preprocess-pdf.md +++ b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/preprocess-pdf.md @@ -67,17 +67,11 @@ Use the following code-snippet when you want uploaded PDFs to be flattened befor @using Syncfusion.Pdf @using Syncfusion.Pdf.Parsing - - @code{ - private SfPdfViewer2? Viewer; - async Task OnCreated() - { - if (Viewer is null) return; PdfLoadedDocument loadedDocument = new PdfLoadedDocument("wwwroot/Annotations.pdf"); @@ -103,9 +97,7 @@ Use the following code-snippet when you want uploaded PDFs to be flattened befor loadedDocument.Close(true); // Reload flattened document into viewer await Viewer.LoadAsync(flattenedBytes); - } - } ``` diff --git a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md index b2db990b9..5bd276b85 100644 --- a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md +++ b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md @@ -7,14 +7,14 @@ documentation: ug domainurl: ##DomainURL## --- -# Retrieve the Loaded Document Instance in Blazor PDF Viewer +# Retrieve the Blazor PDF Viewer Instance -This page explains how to access the Blazor PDF Viewer instance using Blazor component references, listen for the `OnCreated` event, and retrieve document information, page details, and metadata—so you can safely invoke viewer APIs after the PDF is loaded. +This page explains how to access the Blazor PDF Viewer instance using Blazor component references, listen for the `Created` event, and retrieve document information, page details, and metadata—so you can safely invoke viewer APIs after the PDF is loaded. ## Explanation: Why access the loaded document instance? - The viewer instance (via **Blazor component reference**) gives you a stable handle to call APIs such as [`Zoom`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/magnification), [`Print`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/print), [`Download`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/saving-pdf-file#download), and [`Navigation`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/navigation). -- The **OnCreated event** (fires after the PDF is parsed and pages are ready) is the correct moment to read **document information** (title, author, page count, etc.) and **page metrics**, and to trigger post‑load UI logic. +- The **Created event** (fires after the PDF is parsed and pages are ready) is the correct moment to read **document information** (title, author, page count, etc.) and **page metrics**, and to trigger post‑load UI logic. - Accessing the instance too early (before load completes) may cause null/undefined errors or incomplete information. ## Reference: What you can access/call after load @@ -29,13 +29,13 @@ After the PDF is loaded you can: - **Interactions**: enable/disable features - **Export**: `Download()`, `Print()` -> Always invoke these after the `OnCreated` event fires, or from user actions that occur after load. Guard calls with null checks or readiness flags. +> Always invoke these after the `Created` event fires, or from user actions that occur after load. Guard calls with null checks or readiness flags. ## How‑to: Get the instance with a ref and read details on load Below is a focused snippet showing: 1) Creating a **component reference** for the viewer, -2) Wiring the **`OnCreated`** event, and +2) Wiring the **`Created`** event, and 3) Reading basic **document info** and **page count**, then calling **viewer APIs** safely. ```cs From f35f34cb09d3fca133d6c5838e45de85585fec92 Mon Sep 17 00:00:00 2001 From: SF4524LogeshKumar Date: Tue, 12 May 2026 20:00:41 +0530 Subject: [PATCH 5/6] 1024133: Updated the Requested review changes --- .../document-handling/load-large-pdf.md | 2 +- .../retrieve-loaded-document.md | 55 ++++++++++++------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/load-large-pdf.md b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/load-large-pdf.md index b50747a86..aaa24a3bf 100644 --- a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/load-large-pdf.md +++ b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/load-large-pdf.md @@ -33,7 +33,7 @@ With proper configuration, the Blazor PDF Viewer can: - Improve page navigation and scrolling responsiveness - Reduce memory pressure on the browser -N> Large PDF support depends on enabling chunk-based processing and proper server configuration. The actual supported size may vary based on browser memory limits, server settings, and system resources. +N> Large PDF support depends on enabling chunk-based processing (refer [EnableChunkMessages](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnableChunkMessages)) and proper server configuration. The actual supported size may vary based on browser memory limits, server settings, and system resources. --- diff --git a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md index 5bd276b85..8cf34ee39 100644 --- a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md +++ b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md @@ -1,20 +1,21 @@ --- layout: post -title: Retrieve the Loaded Document in Blazor PDF Viewer | syncfusion +title: Retrieve Loaded Document Instance Blazor PDF Viewer | syncfusion description: Learn how to access the loaded PDF document instance in the Blazor PDF Viewer using component references and the DocumentLoad event. platform: document-processing documentation: ug domainurl: ##DomainURL## --- -# Retrieve the Blazor PDF Viewer Instance +# Retrieve the Loaded Document Instance -This page explains how to access the Blazor PDF Viewer instance using Blazor component references, listen for the `Created` event, and retrieve document information, page details, and metadata—so you can safely invoke viewer APIs after the PDF is loaded. +This page explains how to access the loaded document instance in the Blazor PDF Viewer using Blazor component references, listen for the [DocumentLoaded](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_DocumentLoaded) event, and retrieve document information, page details, and metadata—so you can safely invoke viewer APIs after the PDF document is loaded. ## Explanation: Why access the loaded document instance? - The viewer instance (via **Blazor component reference**) gives you a stable handle to call APIs such as [`Zoom`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/magnification), [`Print`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/print), [`Download`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/saving-pdf-file#download), and [`Navigation`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/navigation). -- The **Created event** (fires after the PDF is parsed and pages are ready) is the correct moment to read **document information** (title, author, page count, etc.) and **page metrics**, and to trigger post‑load UI logic. +- The **Created event** fires when the PDF Viewer component is rendered and initialized in the DOM. +- The **DocumentLoaded event** (fires after the PDF document is fully loaded and parsed) is the correct moment to read **document information** (Document Name, page count) and **page metrics**, and to trigger post‑load UI logic. Use [DocumentLoaded](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_DocumentLoaded) event to access document details after successful load, and [DocumentLoadFailed](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_DocumentLoadFailed) to handle load failures. - Accessing the instance too early (before load completes) may cause null/undefined errors or incomplete information. ## Reference: What you can access/call after load @@ -29,14 +30,14 @@ After the PDF is loaded you can: - **Interactions**: enable/disable features - **Export**: `Download()`, `Print()` -> Always invoke these after the `Created` event fires, or from user actions that occur after load. Guard calls with null checks or readiness flags. +N> The **Created event** triggers when the PDF Viewer component is rendered in the DOM. The **DocumentLoaded event** triggers when the document is successfully loaded and parsed. Always invoke viewer APIs after the `DocumentLoaded` event fires to ensure document information is available, or from user actions that occur after load. Guard calls with null checks or readiness flags. ## How‑to: Get the instance with a ref and read details on load Below is a focused snippet showing: 1) Creating a **component reference** for the viewer, -2) Wiring the **`Created`** event, and -3) Reading basic **document info** and **page count**, then calling **viewer APIs** safely. +2) Wiring the **`Created`** event for viewer initialization and the **`DocumentLoaded`** event for document details, and +3) Reading basic **document info** (name and page count) from the **DocumentLoaded** event, then calling **viewer APIs** safely. ```cs @page "/" @@ -48,15 +49,15 @@ Below is a focused snippet showing:
    Document Info
    - Name: @Info.Name
    - Pages: @Info.PageCount
    - Title: @Info.Title
    - Author: @Info.Author + Name: @Info2.Name
    + Pages: @Info2.PageCount
    + Title: @Info1.Title
    + Author: @Info1.Author
    - +
    @@ -64,20 +65,20 @@ Below is a focused snippet showing: private SfPdfViewer2? Viewer; - private DocumentInfo Info = new(); + private DocumentInfo1 Info1 = new(); + private DocumentInfo2 Info2 = new(); private async Task OnCreated() { + // Created event: Fires when the PDF Viewer component is rendered string filePath = "wwwroot/pdf-succinctly.pdf"; //Load using Syncfusion.Pdf PdfLoadedDocument doc = new PdfLoadedDocument(filePath); //Read document info - Info = new DocumentInfo + Info1 = new DocumentInfo1 { - Name = Path.GetFileName(filePath), - PageCount = doc.Pages.Count, Title = doc.DocumentInformation.Title, Author = doc.DocumentInformation.Author }; @@ -92,18 +93,34 @@ Below is a focused snippet showing: await Viewer!.LoadAsync(bytes); } - class DocumentInfo + private async Task OnDocumentLoaded(LoadEventArgs args) + { + // DocumentLoaded event: Fires when the document is successfully loaded + Info2 = new DocumentInfo2 + { + Name = args.DocumentName, + PageCount = args.PageData.PageCount, + }; + } + + class DocumentInfo1 { - public string Name { get; set; } = ""; - public int PageCount { get; set; } public string Title { get; set; } = ""; public string Author { get; set; } = ""; } + + class DocumentInfo2 + { + public string Name { get; set; } = ""; + public int PageCount { get; set; } + } } ``` **Notes** - Use `SfPdfViewer2` component with `@ref` to get direct access to the viewer instance. +- **Created event** triggers when the PDF Viewer component is rendered. +- **DocumentLoaded event** triggers when the document is successfully loaded. Use this event to access document name, page count, and other document-specific details. - Call methods directly on the viewer reference like `Viewer.ZoomAsync()`, `Viewer.GoToPageAsync()`, etc. ## Tutorial: End‑to‑End — Call Viewer APIs with TextBox Input From 70095c3221281c3b7fe65f83e784d27fd48ee889 Mon Sep 17 00:00:00 2001 From: SF4524LogeshKumar Date: Wed, 13 May 2026 12:22:44 +0530 Subject: [PATCH 6/6] 1024133: Updated requested review changes --- Document-Processing-toc.html | 2 +- ...ocument.md => retrieve-viewer-instance.md} | 64 ++++++------------- 2 files changed, 19 insertions(+), 47 deletions(-) rename Document-Processing/PDF/PDF-Viewer/blazor/document-handling/{retrieve-loaded-document.md => retrieve-viewer-instance.md} (67%) diff --git a/Document-Processing-toc.html b/Document-Processing-toc.html index 37f6d0fe4..9ebc968d0 100644 --- a/Document-Processing-toc.html +++ b/Document-Processing-toc.html @@ -1139,7 +1139,7 @@
  • Load Large PDF Files
  • Load Password Protected PDFs
  • Preprocess PDF Document Before Displaying
  • -
  • Retrieve the Loaded Document Instance
  • +
  • Retrieve the Viewer Instance
  • Toolbar Customization diff --git a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-viewer-instance.md similarity index 67% rename from Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md rename to Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-viewer-instance.md index 8cf34ee39..454bc29fd 100644 --- a/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-loaded-document.md +++ b/Document-Processing/PDF/PDF-Viewer/blazor/document-handling/retrieve-viewer-instance.md @@ -1,17 +1,17 @@ --- layout: post -title: Retrieve Loaded Document Instance Blazor PDF Viewer | syncfusion -description: Learn how to access the loaded PDF document instance in the Blazor PDF Viewer using component references and the DocumentLoad event. +title: Retrieve PDF Viewer Instance Blazor PDF Viewer | syncfusion +description: Learn how to access the PDF Viewer instance in the Blazor PDF Viewer using component references and the DocumentLoad event. platform: document-processing documentation: ug domainurl: ##DomainURL## --- -# Retrieve the Loaded Document Instance +# Retrieve the Blazor PDF Viewer Instance -This page explains how to access the loaded document instance in the Blazor PDF Viewer using Blazor component references, listen for the [DocumentLoaded](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_DocumentLoaded) event, and retrieve document information, page details, and metadata—so you can safely invoke viewer APIs after the PDF document is loaded. +This page explains how to access the PDF Viewer instance in the Blazor PDF Viewer using Blazor component references, listen for the [DocumentLoaded](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_DocumentLoaded) event, and retrieve document information, page details, and metadata—so you can safely invoke viewer APIs after the PDF document is loaded. -## Explanation: Why access the loaded document instance? +## Explanation: Why access the PDF Viewer instance? - The viewer instance (via **Blazor component reference**) gives you a stable handle to call APIs such as [`Zoom`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/magnification), [`Print`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/print), [`Download`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/saving-pdf-file#download), and [`Navigation`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/navigation). - The **Created event** fires when the PDF Viewer component is rendered and initialized in the DOM. @@ -25,19 +25,19 @@ After the PDF is loaded you can: - **Read document information**: title, author, subject, keywords (metadata), page count. - **Read page details**: total pages, current page, page size(s). - **Call Viewer APIs** (typical examples): - - **Zoom / Fit**: `ZoomTo(125)`; fit to page/width - - **Navigation**: go to a specific page - - **Interactions**: enable/disable features - - **Export**: `Download()`, `Print()` + - **[Zoom](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/magnification) / Fit**: `ZoomTo(125)`; fit to page/width + - **[Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/navigation)**: go to a specific page + - **[Interactions](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/interaction)**: Enable selection mode and panning + - **Export**: [Download()](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/saving-pdf-file#download), [Print()](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/print). -N> The **Created event** triggers when the PDF Viewer component is rendered in the DOM. The **DocumentLoaded event** triggers when the document is successfully loaded and parsed. Always invoke viewer APIs after the `DocumentLoaded` event fires to ensure document information is available, or from user actions that occur after load. Guard calls with null checks or readiness flags. +N> The **[Created event](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_Created)** triggers when the PDF Viewer component is rendered in the DOM. The **[DocumentLoaded event](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_DocumentLoaded)** triggers when the document is successfully loaded and parsed. Always invoke viewer APIs after the `DocumentLoaded` event fires to ensure document information is available, or from user actions that occur after load. Guard calls with null checks or readiness flags. ## How‑to: Get the instance with a ref and read details on load Below is a focused snippet showing: 1) Creating a **component reference** for the viewer, -2) Wiring the **`Created`** event for viewer initialization and the **`DocumentLoaded`** event for document details, and -3) Reading basic **document info** (name and page count) from the **DocumentLoaded** event, then calling **viewer APIs** safely. +2) Wiring the **[Created](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_Created)** event for viewer initialization and the **[DocumentLoaded](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_DocumentLoaded)** event for document details, and +3) Reading basic **document info** (name and page count) from the **DocumentLoaded** event, then calling viewer APIs safely. ```cs @page "/" @@ -49,10 +49,8 @@ Below is a focused snippet showing:
    Document Info
    - Name: @Info2.Name
    - Pages: @Info2.PageCount
    - Title: @Info1.Title
    - Author: @Info1.Author + Name: @Info.Name
    + Pages: @Info.PageCount
    @@ -65,51 +63,25 @@ Below is a focused snippet showing: private SfPdfViewer2? Viewer; - private DocumentInfo1 Info1 = new(); - private DocumentInfo2 Info2 = new(); + private DocumentInfo Info = new(); private async Task OnCreated() { // Created event: Fires when the PDF Viewer component is rendered - string filePath = "wwwroot/pdf-succinctly.pdf"; - - //Load using Syncfusion.Pdf - PdfLoadedDocument doc = new PdfLoadedDocument(filePath); - - //Read document info - Info1 = new DocumentInfo1 - { - Title = doc.DocumentInformation.Title, - Author = doc.DocumentInformation.Author - }; - - //Load into the viewer - using MemoryStream ms = new(); - doc.Save(ms); - byte[] bytes = ms.ToArray(); - - doc.Close(true); - - await Viewer!.LoadAsync(bytes); + await Viewer!.LoadAsync("wwwroot/pdf-succinctly.pdf"); } private async Task OnDocumentLoaded(LoadEventArgs args) { // DocumentLoaded event: Fires when the document is successfully loaded - Info2 = new DocumentInfo2 + Info = new DocumentInfo { Name = args.DocumentName, PageCount = args.PageData.PageCount, }; } - class DocumentInfo1 - { - public string Title { get; set; } = ""; - public string Author { get; set; } = ""; - } - - class DocumentInfo2 + class DocumentInfo { public string Name { get; set; } = ""; public int PageCount { get; set; }