mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 23:28:06 +02:00
Merge pull request #6803 from Snuffleupagus/page-labels
[api-minor] Add support for PageLabels in the API
This commit is contained in:
commit
58329f7f92
7 changed files with 238 additions and 39 deletions
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -24,6 +24,7 @@
|
|||
!arial_unicode_ab_cidfont.pdf
|
||||
!arial_unicode_en_cidfont.pdf
|
||||
!asciihexdecode.pdf
|
||||
!bug793632.pdf
|
||||
!bug1020858.pdf
|
||||
!bug1050040.pdf
|
||||
!bug1200096.pdf
|
||||
|
|
BIN
test/pdfs/bug793632.pdf
Normal file
BIN
test/pdfs/bug793632.pdf
Normal file
Binary file not shown.
|
@ -329,6 +329,36 @@ describe('api', function() {
|
|||
expect(data).toEqual(null);
|
||||
});
|
||||
});
|
||||
it('gets non-existent page labels', function () {
|
||||
var promise = doc.getPageLabels();
|
||||
waitsForPromiseResolved(promise, function (data) {
|
||||
expect(data).toEqual(null);
|
||||
});
|
||||
});
|
||||
it('gets page labels', function () {
|
||||
// PageLabels with Roman/Arabic numerals.
|
||||
var url0 = combineUrl(window.location.href, '../pdfs/bug793632.pdf');
|
||||
var promise0 = PDFJS.getDocument(url0).promise.then(function (pdfDoc) {
|
||||
return pdfDoc.getPageLabels();
|
||||
});
|
||||
// PageLabels with only a label prefix.
|
||||
var url1 = combineUrl(window.location.href, '../pdfs/issue1453.pdf');
|
||||
var promise1 = PDFJS.getDocument(url1).promise.then(function (pdfDoc) {
|
||||
return pdfDoc.getPageLabels();
|
||||
});
|
||||
// PageLabels identical to standard page numbering.
|
||||
var url2 = combineUrl(window.location.href, '../pdfs/rotation.pdf');
|
||||
var promise2 = PDFJS.getDocument(url2).promise.then(function (pdfDoc) {
|
||||
return pdfDoc.getPageLabels();
|
||||
});
|
||||
|
||||
waitsForPromiseResolved(Promise.all([promise0, promise1, promise2]),
|
||||
function (pageLabels) {
|
||||
expect(pageLabels[0]).toEqual(['i', 'ii', 'iii', '1']);
|
||||
expect(pageLabels[1]).toEqual(['Front Page1']);
|
||||
expect(pageLabels[2]).toEqual([]);
|
||||
});
|
||||
});
|
||||
it('gets attachments', function() {
|
||||
var promise = doc.getAttachments();
|
||||
waitsForPromiseResolved(promise, function (data) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue