Skip to content

Commit 7417661

Browse files
1010807: UG review corrections
1 parent 543bfcf commit 7417661

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Document-Processing/PDF/PDF-Viewer/react/open-pdf-files.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ Below are concise instructions and short snippets for loading PDFs from several
5959
6060
```js
6161
// Using load API
62-
const viewer = document.getElementById('container').ej2_instances[0];
63-
viewer.load('data:application/pdf;base64,' + base64String, null);
62+
const viewerRef = useRef(null);
63+
const loadBase64 = (base64String: string) => {
64+
viewerRef.current?.load('data:application/pdf;base64,' + base64String, null);
65+
};
6466
```
6567
6668
- Recommendation: avoid Base64 for very large files (memory and payload size concerns).
@@ -70,12 +72,12 @@ viewer.load('data:application/pdf;base64,' + base64String, null);
7072
- Fetch a Blob and create an object URL, then load it into the viewer:
7173
7274
```js
75+
const viewerRef = useRef(null);
7376
fetch(url)
7477
.then(r => r.blob())
7578
.then(blob => {
7679
const objectUrl = URL.createObjectURL(blob);
77-
const viewer = document.getElementById('container').ej2_instances[0];
78-
viewer.load(objectUrl, null);
80+
viewerRef.current?.load(objectUrl, null);
7981
});
8082
```
8183

0 commit comments

Comments
 (0)