mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Take the userUnit
into account in the PageViewport
class (issue 19176)
This commit is contained in:
parent
3f1d07a35e
commit
c6e3fc4fe6
6 changed files with 84 additions and 6 deletions
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -553,6 +553,7 @@
|
|||
!poppler-67295-0.pdf
|
||||
!poppler-85140-0.pdf
|
||||
!issue15012.pdf
|
||||
!issue19176.pdf
|
||||
!issue15150.pdf
|
||||
!poppler-395-0-fuzzed.pdf
|
||||
!issue14165.pdf
|
||||
|
|
28
test/pdfs/issue19176.pdf
Normal file
28
test/pdfs/issue19176.pdf
Normal file
|
@ -0,0 +1,28 @@
|
|||
%PDF-2.0
|
||||
%¿÷¢þ
|
||||
1 0 obj
|
||||
<< /Pages 2 0 R /Type /Catalog >>
|
||||
endobj
|
||||
2 0 obj
|
||||
<< /Count 1 /Kids [ 3 0 R ] /Type /Pages >>
|
||||
endobj
|
||||
3 0 obj
|
||||
<< /Type /Page /Parent 2 0 R /Resources << >> /MediaBox [0 0 8.5 11] /UserUnit 72 /Contents 4 0 R >>
|
||||
endobj
|
||||
4 0 obj
|
||||
<< /Length 15 >>
|
||||
stream
|
||||
1 1 6.5 9 re f
|
||||
endstream
|
||||
endobj
|
||||
xref
|
||||
0 5
|
||||
0000000000 65535 f
|
||||
0000000015 00000 n
|
||||
0000000064 00000 n
|
||||
0000000123 00000 n
|
||||
0000000239 00000 n
|
||||
trailer << /Root 1 0 R /Size 5 >>
|
||||
startxref
|
||||
303
|
||||
%%EOF
|
|
@ -2734,6 +2734,13 @@
|
|||
"type": "eq",
|
||||
"about": "TrueType font with (0, 1) cmap."
|
||||
},
|
||||
{
|
||||
"id": "issue19176",
|
||||
"file": "pdfs/issue19176.pdf",
|
||||
"md5": "c307418412a72997671518fa978439e0",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{
|
||||
"id": "issue4801",
|
||||
"file": "pdfs/issue4801.pdf",
|
||||
|
|
|
@ -3081,10 +3081,21 @@ describe("api", function () {
|
|||
expect(page.ref).toEqual({ num: 15, gen: 0 });
|
||||
});
|
||||
|
||||
it("gets userUnit", function () {
|
||||
it("gets default userUnit", function () {
|
||||
expect(page.userUnit).toEqual(1.0);
|
||||
});
|
||||
|
||||
it("gets non-default userUnit", async function () {
|
||||
const loadingTask = getDocument(buildGetDocumentParams("issue19176.pdf"));
|
||||
|
||||
const pdfDoc = await loadingTask.promise;
|
||||
const pdfPage = await pdfDoc.getPage(1);
|
||||
|
||||
expect(pdfPage.userUnit).toEqual(72);
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("gets view", function () {
|
||||
expect(page.view).toEqual([0, 0, 595.28, 841.89]);
|
||||
});
|
||||
|
@ -3116,6 +3127,7 @@ describe("api", function () {
|
|||
expect(viewport instanceof PageViewport).toEqual(true);
|
||||
|
||||
expect(viewport.viewBox).toEqual(page.view);
|
||||
expect(viewport.userUnit).toEqual(page.userUnit);
|
||||
expect(viewport.scale).toEqual(1.5);
|
||||
expect(viewport.rotation).toEqual(90);
|
||||
expect(viewport.transform).toEqual([0, 1.5, 1.5, 0, 0, 0]);
|
||||
|
@ -3123,6 +3135,26 @@ describe("api", function () {
|
|||
expect(viewport.height).toEqual(892.92);
|
||||
});
|
||||
|
||||
it("gets viewport with non-default userUnit", async function () {
|
||||
const loadingTask = getDocument(buildGetDocumentParams("issue19176.pdf"));
|
||||
|
||||
const pdfDoc = await loadingTask.promise;
|
||||
const pdfPage = await pdfDoc.getPage(1);
|
||||
|
||||
const viewport = pdfPage.getViewport({ scale: 1 });
|
||||
expect(viewport instanceof PageViewport).toEqual(true);
|
||||
|
||||
expect(viewport.viewBox).toEqual(pdfPage.view);
|
||||
expect(viewport.userUnit).toEqual(pdfPage.userUnit);
|
||||
expect(viewport.scale).toEqual(1);
|
||||
expect(viewport.rotation).toEqual(0);
|
||||
expect(viewport.transform).toEqual([72, 0, 0, -72, 0, 792]);
|
||||
expect(viewport.width).toEqual(612);
|
||||
expect(viewport.height).toEqual(792);
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it('gets viewport with "offsetX/offsetY" arguments', function () {
|
||||
const viewport = page.getViewport({
|
||||
scale: 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue