mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Ignore pageLabels, in the viewer, when they're all empty
Unfortunately there exist PDF documents where all pageLabels are empty strings, see e.g. http://www.cs.cornell.edu/~ragarwal/pubs/blk-switch.pdf (taken from an old issue), which result in the pageNumber-input being completely blank. That doesn't seem very helpful, and this patch simply extends the approach used to ignore pageLabels that are identical to standard page numbering.
This commit is contained in:
parent
c85cd80b1b
commit
66c26d70d4
1 changed files with 14 additions and 5 deletions
19
web/app.js
19
web/app.js
|
@ -1632,12 +1632,21 @@ const PDFViewerApplication = {
|
|||
return;
|
||||
}
|
||||
const numLabels = labels.length;
|
||||
let i = 0;
|
||||
// Ignore page labels that correspond to standard page numbering.
|
||||
while (i < numLabels && labels[i] === (i + 1).toString()) {
|
||||
i++;
|
||||
// Ignore page labels that correspond to standard page numbering,
|
||||
// or page labels that are all empty.
|
||||
let standardLabels = 0,
|
||||
emptyLabels = 0;
|
||||
for (let i = 0; i < numLabels; i++) {
|
||||
const label = labels[i];
|
||||
if (label === (i + 1).toString()) {
|
||||
standardLabels++;
|
||||
} else if (label === "") {
|
||||
emptyLabels++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i === numLabels) {
|
||||
if (standardLabels >= numLabels || emptyLabels >= numLabels) {
|
||||
return;
|
||||
}
|
||||
const { pdfViewer, pdfThumbnailViewer, toolbar } = this;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue