Skip to content

Commit 3c4233c

Browse files
1010724: Updated Proper UG after Review for Load.
1 parent 2013c7b commit 3c4233c

2 files changed

Lines changed: 251 additions & 88 deletions

File tree

Document-Processing/PDF/PDF-Viewer/react/document-handling/load-large-pdf.md

Lines changed: 144 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,176 @@ domainurl: ##DomainURL##
1010

1111
# Handling Large PDF Files in React PDF Viewer
1212

13-
This article explains why large PDF files require special handling in web applications and provides best practices for loading and displaying them efficiently in the Syncfusion React PDF Viewer.
13+
This article explains how to efficiently load and view large PDF files using the Syncfusion React PDF Viewer. It includes recommended best practices and performance tips for documents ranging from **50 MB to 2 GB**.
1414

1515
---
1616

17-
## Explanation: Why Large PDFs Need Special Handling
17+
## Why Large PDFs Need Special Handling
1818

19-
Large PDF files (typically 50MB–100MB or more) can cause high memory usage and performance issues in browsers. Browsers may become unresponsive or crash when attempting to load or render very large documents, especially if inefficient loading methods are used.
19+
Large PDF files often contain thousands of embedded objects such as images, compressed streams, digital signatures, form fields, annotations, vector graphics, and complex page structures. Rendering such heavy documents requires more processing time and memory.
20+
21+
The **Syncfusion PDF Viewer is fully optimized for these heavy workloads**, and it delivers excellent performance even when working with very large files.
22+
23+
### Viewer Capability Highlights
24+
- **Smooth performance for PDFs up to 1 GB**
25+
- **Supports viewing files up to ~2 GB** depending on system capacity
26+
- **1 GB PDFs typically load within 5–6 seconds**
27+
- **Optimized incremental page loading** for faster interaction
28+
29+
Performance may vary if the user’s system is heavily loaded or low on available RAM. In such cases, enabling the recommended optimizations below ensures maximum performance.
2030

2131
---
2232

23-
## How-to Guide: Best Ways to Load Large PDFs
33+
# Best Practices for Loading Large PDFs
34+
35+
## 1. Load PDFs Using Blob (Recommended)
36+
37+
Blob loading provides the fastest and most efficient performance for large PDFs.
38+
39+
### Why Blob Loading Is Better
40+
41+
When a large PDF (for example, 1 GB) is loaded directly via `documentPath` (URL):
2442

25-
Follow these recommendations to optimize the loading and viewing experience for large PDF files:
43+
- The browser must **download the full document first**
44+
- Only after the full download completes, the viewer starts parsing and rendering
45+
- This causes delay for large files
2646

27-
### 1. Load from Blob (Recommended)
47+
But when the PDF is fetched as a **Blob**:
2848

29-
If you fetch the PDF from a custom API or server, use the Blob approach. This avoids base64 encoding overhead and is more memory-efficient.
49+
- The file is downloaded first in an optimized stream
50+
- A Blob URL is created and passed to the viewer
51+
- The viewer can begin rendering faster
52+
- Improves load time, memory usage, and overall responsiveness
3053

54+
### Example: Load a PDF as Blob
3155
```js
3256
fetch('https://your-api/large-file.pdf')
33-
.then((response) => response.blob())
34-
.then((blob) => {
35-
const blobUrl = URL.createObjectURL(blob);
36-
viewer.load(blobUrl, null); // Load using blob URL
37-
})
38-
.catch((error) => {
39-
console.error('Error loading PDF:', error);
40-
});
57+
.then(response => response.blob())
58+
.then(blob => {
59+
const blobUrl = URL.createObjectURL(blob);
60+
viewer.load(blobUrl, null);
61+
})
62+
.catch(error => console.error('Error loading PDF:', error));
4163
```
4264

43-
### 2. Avoid Base64 for Large Files
65+
Blob loading is highly recommended for all PDFs above **200 MB**, especially when working with 500 MB – 1 GB files.
66+
67+
---
68+
69+
## 2. Viewer Performance Range
70+
71+
The Syncfusion PDF Viewer is optimized to handle:
72+
73+
- **Up to 1 GB** → very smooth
74+
- **Up to ~2 GB** → supported based on system capability
75+
76+
This suits enterprise workflows involving large engineering drawings, client records, scanned books, and multi‑page financial reports.
77+
78+
---
79+
80+
## 3. Minimize Injected Modules
81+
82+
The PDF Viewer internally uses background workers for text processing, thumbnail generation, image rendering, and metadata extraction. Disabling modules that are not needed helps reduce background activity and improves performance.
83+
84+
### 3.1 Text Search & Text Selection
85+
86+
Modules:
87+
- [`Text Search`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/react/text-search)
88+
- [`Text Selection`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/react/text-selection)
89+
90+
These features require **continuous background text extraction and indexing**.
91+
92+
For large PDFs:
4493

45-
Base64 encoding increases file size by ~33% and consumes more memory. For large PDFs, always prefer Blob or direct URL loading over base64.
94+
- Text extraction runs longer
95+
- Consumes additional CPU and memory
96+
- Increases initial load time
4697

47-
### 3. Minimize Injected Modules
98+
If these features are not required in your application:
4899

49-
Reduce the number of injected modules in the PDF Viewer to lower background processing and memory usage. For large files, avoid modules like:
50-
- [Text Search](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/react/text-search)
51-
- [Text Selection](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/react/text-selection)
52-
- [Organize Pages](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/react/organize-pages/overview)
53-
- [Thumbnail View](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/react/interactive-pdf-navigation/page-thumbnail)
100+
- Disable them to reduce background tasks
101+
- Improve page rendering speed
102+
- Provide a smoother experience for large documents
54103

55-
**Example:**
104+
### Example (remove text search & selection)
56105
```tsx
57-
<PdfViewerComponent
58-
id="container"
59-
documentPath={...}
60-
serviceUrl={...}
61-
style={{ height: '640px' }}
62-
>
63-
<Inject services={[Toolbar, Magnification, Navigation, Print]} />
64-
</PdfViewerComponent>
106+
<Inject services={[Toolbar, Magnification, Navigation, Print]} />
65107
```
66108

67-
### 4. Enable Local Storage for Performance
109+
---
110+
111+
### 3.2 Thumbnail View & Organize Pages
112+
113+
Modules:
114+
- [`Organize Pages`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/react/organize-pages/overview)
115+
- [`Thumbnail View`](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/react/interactive-pdf-navigation/page-thumbnail)
116+
117+
These rely on **background thumbnail rendering**, where the viewer renders small preview images of every page.
118+
For PDFs with hundreds or thousands of pages, this becomes heavy.
119+
120+
If thumbnails or page reordering are not essential:
121+
122+
- Disable these modules
123+
- Prevent background thumbnail rendering
124+
- Reduce memory usage
125+
- Improve navigation responsiveness
126+
127+
---
128+
129+
## 4. Enable Local Storage for Large PDFs With Many Form Fields or Annotations
130+
131+
PDFs with a high number of:
132+
133+
- Form fields (textbox, dropdown, signatures, etc.)
134+
- Annotations (highlight, shapes, comments)
135+
136+
require more storage for:
137+
138+
- Field values
139+
- Annotation metadata
140+
- Interaction states
141+
- Undo/redo data
68142

69143
Enabling local storage in the PDF Viewer can improve performance and smoothness when working with large files. This allows the viewer to cache document data locally, reducing repeated network requests and memory spikes.
70144

71145
Use the [`enableLocalStorage`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#enablelocalstorage) property to control this behavior. When set to `true`, session data is stored in memory for the current session; when `false` (default), browser session storage is used.
72146

73-
**Example:**
147+
**How the viewer stores this data by default**
148+
149+
By default, the viewer uses **sessionStorage** to store interactive session data. For heavy PDFs with many form fields/annotations, sessionStorage can get filled more quickly and may cause slower interactions or instability when navigating across many pages.
150+
151+
**Why enabling localStorage helps**
152+
153+
- Provides more storage capacity than session storage
154+
- Avoids storage overflow for annotation‑heavy PDFs
155+
- Improves saving/loading of form values
156+
- Enhances stability when navigating large documents
157+
- Reduces repeated processing for form/annotation‑heavy pages
158+
159+
### Enable Local Storage
160+
```tsx
161+
enableLocalStorage={true}
162+
```
163+
164+
This is highly recommended when working with legal documents, tax forms, interactive applications, or PDFs containing thousands of annotations.
165+
166+
---
167+
168+
## 5. Reduce Unnecessary Background System Processes
169+
170+
For the best large‑PDF experience:
171+
172+
- Close unused applications
173+
- Avoid multiple heavy tasks running in parallel
174+
- Minimize other browser tabs
175+
- Avoid opening multiple large PDFs simultaneously
176+
177+
This ensures the viewer receives enough system resources.
178+
179+
---
180+
181+
# Minimal Recommended Configuration Example
182+
74183
```tsx
75184
import * as ReactDOM from 'react-dom';
76185
import * as React from 'react';
@@ -95,21 +204,8 @@ const root = ReactDOM.createRoot(document.getElementById('sample'));
95204
root.render(<App />);
96205
```
97206

98-
**Considerations:**
99-
- Enabling in-memory storage can increase memory usage, especially for large documents or many interactive elements.
100-
- Dispose the PDF Viewer instance when not needed to avoid memory leaks.
101-
- The default value is `false` (browser session storage).
102-
103-
---
104-
105-
## Reference
106-
107-
- [React PDF Viewer API Reference](https://ej2.syncfusion.com/react/documentation/api/pdfviewer)
108-
- [FAQ in Syncfusion React PDF Viewer](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/react/how-to-overview)
109-
110207
---
111208

112209
## See Also
113210

114-
- [Load PDF (GitHub Sample)](https://github.com/SyncfusionExamples/react-pdf-viewer-examples/tree/master/Save%20and%20Load)
115-
- [General PDF Viewer Documentation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/react/getting-started)
211+
- [Load PDF (GitHub Sample)](https://github.com/SyncfusionExamples/react-pdf-viewer-examples/tree/master/Save%20and%20Load)

0 commit comments

Comments
 (0)