Some test text!
Web / Guides / Create a thumbnail
Page thumbnails are rendered image representations of the page they are generated from.
The SDK API has the flexibility to alter the resolution or size of the thumbnail output and whether to include annotations or not.
To create a basic PDF page thumbnail where the result is a HTMLCanvasElement or HTMLImageElement.
loadThumbnailAsync
is deprecated since version 8.3 and removed since version 10.0. Please use loadThumbnail
instead.
WebViewer(...)
.then(instance => {
const { documentViewer } = instance.Core;
documentViewer.addEventListener('documentLoaded', () => {
const doc = documentViewer.getDocument();
const pageNum = 1;
doc.loadThumbnail(pageNum, (thumbnail) => {
// thumbnail is a HTMLCanvasElement or HTMLImageElement
console.log(thumbnail);
});
});
});
To create a high resolution page thumnbails and optionally with annotations where the result is a HTMLCanvasElement or HTMLImageElement.
loadCanvasAsync
is deprecated since version 8.3 and removed since version 10.0. Please use loadCanvas
instead.
WebViewer(...)
.then(instance => {
const { documentViewer } = instance.Core;
documentViewer.addEventListener('annotationsLoaded', () => {
const doc = documentViewer.getDocument();
const pageNumber = 1;
const zoom = 2; // render at twice the resolution
doc.loadCanvas({
pageNumber,
zoom,
drawComplete: async (thumbnail) => {
const corePageRotation = (doc.getPageRotation(pageNumber) / 90) % 4;
annotationManager.setAnnotationCanvasTransform(thumbnail.getContext('2d'), zoom, corePageRotation);
// optionally comment out "drawAnnotations" below to exclude annotations
await instance.Core.documentViewer.getAnnotationManager().drawAnnotations(pageNumber, thumbnail);
// thumbnail is a HTMLCanvasElement or HTMLImageElement
console.log(thumbnail);
}
});
});
});
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales