Merge pull request #10508 from Snuffleupagus/issue-8276
Do the final text scaling correctly in `flushTextContentItem` (issue 8276)
This commit is contained in:
commit
291e62b41e
@ -1332,7 +1332,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
fontFamily: font.fallbackName,
|
fontFamily: font.fallbackName,
|
||||||
ascent: font.ascent,
|
ascent: font.ascent,
|
||||||
descent: font.descent,
|
descent: font.descent,
|
||||||
vertical: font.vertical,
|
vertical: !!font.vertical,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
textContentItem.fontName = font.loadedName;
|
textContentItem.fontName = font.loadedName;
|
||||||
@ -1508,9 +1508,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do final text scaling
|
// Do final text scaling.
|
||||||
textContentItem.width *= textContentItem.textAdvanceScale;
|
if (!textContentItem.vertical) {
|
||||||
textContentItem.height *= textContentItem.textAdvanceScale;
|
textContentItem.width *= textContentItem.textAdvanceScale;
|
||||||
|
} else {
|
||||||
|
textContentItem.height *= textContentItem.textAdvanceScale;
|
||||||
|
}
|
||||||
textContent.items.push(runBidiTransform(textContentItem));
|
textContent.items.push(runBidiTransform(textContentItem));
|
||||||
|
|
||||||
textContentItem.initialized = false;
|
textContentItem.initialized = false;
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -54,6 +54,7 @@
|
|||||||
!issue8088.pdf
|
!issue8088.pdf
|
||||||
!issue8125.pdf
|
!issue8125.pdf
|
||||||
!issue8229.pdf
|
!issue8229.pdf
|
||||||
|
!issue8276_reduced.pdf
|
||||||
!issue8372.pdf
|
!issue8372.pdf
|
||||||
!issue8424.pdf
|
!issue8424.pdf
|
||||||
!issue8480.pdf
|
!issue8480.pdf
|
||||||
|
70
test/pdfs/issue8276_reduced.pdf
Normal file
70
test/pdfs/issue8276_reduced.pdf
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%âãÏÓ
|
||||||
|
1 0 obj
|
||||||
|
<<
|
||||||
|
/Pages 2 0 R
|
||||||
|
/Type /Catalog
|
||||||
|
>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<<
|
||||||
|
/Kids [3 0 R]
|
||||||
|
/Count 1
|
||||||
|
/Type /Pages
|
||||||
|
>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<<
|
||||||
|
/Parent 2 0 R
|
||||||
|
/MediaBox [0 0 594.000000 840.239990]
|
||||||
|
/Resources
|
||||||
|
<<
|
||||||
|
/Font
|
||||||
|
<<
|
||||||
|
/F1 4 0 R
|
||||||
|
>>
|
||||||
|
>>
|
||||||
|
/Contents 5 0 R
|
||||||
|
/Type /Page
|
||||||
|
>>
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<<
|
||||||
|
/BaseFont /Times-Roman
|
||||||
|
/Subtype /Type1
|
||||||
|
/Encoding /WinAnsiEncoding
|
||||||
|
/Type /Font
|
||||||
|
>>
|
||||||
|
endobj
|
||||||
|
5 0 obj
|
||||||
|
<<
|
||||||
|
/Length 76
|
||||||
|
>>
|
||||||
|
stream
|
||||||
|
q
|
||||||
|
0.03 0 0 0.03 0 0 cm
|
||||||
|
BT
|
||||||
|
/F1 600.00 Tf
|
||||||
|
14727 23615 TD
|
||||||
|
(Issue 8276) Tj
|
||||||
|
ET
|
||||||
|
Q
|
||||||
|
|
||||||
|
endstream
|
||||||
|
endobj xref
|
||||||
|
0 6
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000066 00000 n
|
||||||
|
0000000125 00000 n
|
||||||
|
0000000269 00000 n
|
||||||
|
0000000370 00000 n
|
||||||
|
trailer
|
||||||
|
|
||||||
|
<<
|
||||||
|
/Root 1 0 R
|
||||||
|
/Size 6
|
||||||
|
>>
|
||||||
|
startxref
|
||||||
|
498
|
||||||
|
%%EOF
|
@ -1174,6 +1174,39 @@ describe('api', function() {
|
|||||||
done();
|
done();
|
||||||
}).catch(done.fail);
|
}).catch(done.fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('gets text content, with correct properties (issue 8276)',
|
||||||
|
function(done) {
|
||||||
|
const loadingTask = getDocument(
|
||||||
|
buildGetDocumentParams('issue8276_reduced.pdf'));
|
||||||
|
|
||||||
|
loadingTask.promise.then((pdfDoc) => {
|
||||||
|
pdfDoc.getPage(1).then((pdfPage) => {
|
||||||
|
pdfPage.getTextContent().then(({ items, styles, }) => {
|
||||||
|
expect(items.length).toEqual(1);
|
||||||
|
expect(Object.keys(styles)).toEqual(['Times']);
|
||||||
|
|
||||||
|
expect(items[0]).toEqual({
|
||||||
|
dir: 'ltr',
|
||||||
|
fontName: 'Times',
|
||||||
|
height: 18,
|
||||||
|
str: 'Issue 8276',
|
||||||
|
transform: [18, 0, 0, 18, 441.81, 708.4499999999999],
|
||||||
|
width: 77.49,
|
||||||
|
});
|
||||||
|
expect(styles.Times).toEqual({
|
||||||
|
fontFamily: 'serif',
|
||||||
|
ascent: NaN,
|
||||||
|
descent: NaN,
|
||||||
|
vertical: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
loadingTask.destroy().then(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}).catch(done.fail);
|
||||||
|
});
|
||||||
|
|
||||||
it('gets operator list', function(done) {
|
it('gets operator list', function(done) {
|
||||||
var promise = page.getOperatorList();
|
var promise = page.getOperatorList();
|
||||||
promise.then(function (oplist) {
|
promise.then(function (oplist) {
|
||||||
@ -1191,11 +1224,12 @@ describe('api', function() {
|
|||||||
pdfPage.getOperatorList().then((opList) => {
|
pdfPage.getOperatorList().then((opList) => {
|
||||||
let imgIndex = opList.fnArray.indexOf(OPS.paintImageXObject);
|
let imgIndex = opList.fnArray.indexOf(OPS.paintImageXObject);
|
||||||
let imgArgs = opList.argsArray[imgIndex];
|
let imgArgs = opList.argsArray[imgIndex];
|
||||||
let { data: imgData, } = pdfPage.objs.get(imgArgs[0]);
|
let { data, } = pdfPage.objs.get(imgArgs[0]);
|
||||||
|
|
||||||
expect(imgData instanceof Uint8ClampedArray).toEqual(true);
|
expect(data instanceof Uint8ClampedArray).toEqual(true);
|
||||||
expect(imgData.length).toEqual(90000);
|
expect(data.length).toEqual(90000);
|
||||||
done();
|
|
||||||
|
loadingTask.destroy().then(done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch(done.fail);
|
}).catch(done.fail);
|
||||||
|
Loading…
Reference in New Issue
Block a user