Add PDF thumbnail sidebar to EnvelopeViewer

Introduced a PDF thumbnail sidebar in `EnvelopeViewer.razor` to enhance navigation between pages. Added a toggle button to show/hide the sidebar and implemented dynamic thumbnail rendering for all pages.

Updated `envelope-viewer.css` with styles for the sidebar, including hover/active states, transitions, and mobile responsiveness.

Enhanced `pdf-viewer.js` with a `renderThumbnail` method to render page previews on canvas elements. Added error handling for non-critical thumbnail rendering issues.

Improved user experience by providing an intuitive way to preview and navigate PDF pages.
This commit is contained in:
2026-06-05 21:16:15 +02:00
parent d9ab6b3eff
commit 6024f5c040
3 changed files with 250 additions and 0 deletions

View File

@@ -233,6 +233,31 @@ window.pdfViewer = {
}
},
async renderThumbnail(pageNum, canvasId) {
if (!this.pdfDoc) return;
try {
const canvas = document.getElementById(canvasId);
if (!canvas) return;
const page = await this.pdfDoc.getPage(pageNum);
const viewport = page.getViewport({ scale: 0.2 });
canvas.height = viewport.height;
canvas.width = viewport.width;
const ctx = canvas.getContext('2d');
const renderContext = {
canvasContext: ctx,
viewport: viewport
};
await page.render(renderContext).promise;
} catch (error) {
// Thumbnail rendering errors are non-critical
}
},
getCurrentPage() {
return this.pageNum;
},