-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[api-minor] Add support for PageLabels in the API #6803
Conversation
I definitely think that this would be a nice feature to include in PDF.js, especially since it is used in practice and test cases are available. I usually see this kind of page numbering in e-books. With regards to hooking this into the viewer, we must look into how other readers handle this in their page number box, i.e., if a user enters page 1, will he arrive at the page with page label 1 or at the first page of the document? I have added some comments to improve the code, but overall it's already looking good. I really like the minimal changes required to re-use the |
|
||
switch (style) { | ||
case 'D': | ||
currentLabel = '' + currentIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we reset the label at the end of the loop, we might be able to simplify this to currentLabel += currentIndex
, according to a quick fiddle I made at https://jsfiddle.net/evyujauw/1/.
There has been some discussion about this on IRC, starting here: http://logs.glob.uno/?c=mozilla%23pdfjs#c43831 The API for this appears fine, but we need to carefully determine how to hook this into the viewer. Adobe's behavior can be confusing, so we need to implement this in a way that makes more sense. Let's think about ideas to realize this. |
I'm thinking there is mistake at "Uppercase letters (A to Z for the first 26 pages, AA to ZZ for the next 26, and so on) " at http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=383&zoom=100,-178,800 I'm thinking they meant "... AA to ZZ for the next 26*26 (676)... " -- it goes as AA, AB, ... AZ, BA, ... ZZ |
You might think so, but that's not how it's implemented in Adobe Reader, which seems to follow the specification to the letter (sorry, couldn't resist the pun :-). |
Oh, wow! That's so .... unorthodox. |
Given that the API/core parts of this are pretty self-contained, and have unit-tests, could we consider landing this as-is and then figure out how/if we should wire this into the default viewer in a follow-up? In my opinion, having the ability to at least fetch pageLabels in the API seems like a good thing regardless of what we decide to do for the default viewer. |
The test commit was removed, the following code can be used in the console to fetch the pageLabels:
|
|
||
var romanStr = romanBuf.join(''); | ||
return (lowerCase ? romanStr.toLowerCase() : romanStr); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line does not appear to be indented correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, fixed now. Thanks for spotting this.
Could you rebase this patch and fix the comment above? We can land the API first and file a follow-up issue for hooking it into the viewer: see http://logs.glob.uno/?c=mozilla%23pdfjs&s=28+Dec+2015&e=28+Dec+2015&h=api#c43853. |
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/de07095a1154df9/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/de07095a1154df9/output.txt Total script time: 0.85 mins Published |
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/ec6c40bf43540bd/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/868e91673424a49/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/ec6c40bf43540bd/output.txt Total script time: 21.37 mins
|
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/868e91673424a49/output.txt Total script time: 21.49 mins
|
[api-minor] Add support for PageLabels in the API
This API looks really good! I'll file a follow-up issue for deciding if/how we want to hook this into the viewer. |
This PR adds support for PageLabels in the API.
TODO:
Hook this functionality into the viewer.Re: #3165 and https://bugzilla.mozilla.org/show_bug.cgi?id=793632.