Fix PDF zoom: preserve buffer with slice(0), cap base width to 900px
- Use arrayBuffer.slice(0) before passing to pdfjsLib.getDocument so PDF.js doesn't transfer/detach currentPdfBuffer, enabling re-renders on zoom change - Cap containerWidth to min(viewport-32, 900px) so PDF doesn't stretch across the full viewport on wide screens Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
04818c939e
commit
1cba67b3ed
1 changed files with 2 additions and 2 deletions
|
|
@ -2836,7 +2836,7 @@ async function _parsePdfOutline(pdf, items, depth) {
|
|||
}
|
||||
|
||||
async function renderPdf(arrayBuffer, contentEl, scaleOverride) {
|
||||
const pdf = currentPdfDoc || await pdfjsLib.getDocument({data: new Uint8Array(arrayBuffer)}).promise;
|
||||
const pdf = currentPdfDoc || await pdfjsLib.getDocument({data: new Uint8Array(arrayBuffer.slice(0))}).promise;
|
||||
currentPdfDoc = pdf;
|
||||
|
||||
let pdfTitle = '', pdfAuthor = '';
|
||||
|
|
@ -2854,7 +2854,7 @@ async function renderPdf(arrayBuffer, contentEl, scaleOverride) {
|
|||
|
||||
contentEl.innerHTML = '';
|
||||
|
||||
const containerWidth = contentEl.clientWidth - 32;
|
||||
const containerWidth = Math.min(contentEl.clientWidth - 32, 900);
|
||||
|
||||
for (let pageNum = 1; pageNum <= pdf.numPages; pageNum++) {
|
||||
const page = await pdf.getPage(pageNum);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue