Loading and rendering documents without using WebViewer UI
It's common to use the built in WebViewer UI to view and interact with documents, however it's also possible to load documents and render pages without using the UI. By using the lower level Document class, you can load documents in memory and have full control over how the pages are laid out, or use non-viewing APIs like extracting text.
Create documents
You can use the Core.createDocument API to instantiate documents from different sources, for example URLs or blobs.
Below are some examples of creating commonly used documents:
After the document has been created, use the loadCanvas API to render a page on a canvas. You have full control of how the pages are rendered by passing different values to this API.
loadCanvasAsync is deprecated since version 8.3 and removed since version 10.0. Please use loadCanvas instead.
If you want to render just part of a page, you can define the area you want to render as explained in the API docs and pass it to the renderRect option:
1doc.loadCanvas({
2 pageNumber: 1 // Render the first page
3 renderRect: {x1:0, y1:0, x2:200, y2:200}, // The area to render
4 drawComplete: canvas => {
5 // The canvas of the cropped first page
6 console.log(canvas);
7 }
8})
1doc.loadCanvasAsync({
2 pageNumber: 1 // Render the first page
3 renderRect: {x1:0, y1:0, x2:200, y2:200}, // The area to render
4 drawComplete: canvas => {
5 // The canvas of the cropped first page
6 console.log(canvas);
7 }
8})
1doc.loadCanvasAsync({
2 pageIndex: 0, // Render the first page
3 renderRect: {x1:0, y1:0, x2:200, y2:200}, // The area to render
4 drawComplete: canvas => {
5 // The canvas of the cropped first page
6 console.log(canvas);
7 }
8})
Load page text
Text extraction To extract text in the document without rendering it using loadPageText API.