mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
[api-minor] Normalize the view
-getter on the worker-thread
*Please note:* I don't really expect that this is will be an observable change, since virtually all PDF documents already order e.g. /MediaBox and /CropBox entries correctly. By normalizing boundingBoxes already on the worker-thread, we can be sure that even a corrupt document won't cause issues. Note how we're passing the `view`-getter to the `PartialEvaluator.getTextContent` method, in order to detect textContent which is outside of the page, hence it makes sense to ensure that it's formatted as expected. Furthermore, by normalizing this once on the worker-tread we should no longer have to worry about a possibly negative width/height in the `PageViewport` constructor. Finally, the patch also simplifies the `view`-getter a little bit.
This commit is contained in:
parent
e3c2af14b3
commit
5f8598abb7
2 changed files with 14 additions and 17 deletions
|
@ -224,13 +224,13 @@ class PageViewport {
|
|||
if (rotateA === 0) {
|
||||
offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
|
||||
offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
|
||||
width = Math.abs(viewBox[3] - viewBox[1]) * scale;
|
||||
height = Math.abs(viewBox[2] - viewBox[0]) * scale;
|
||||
width = (viewBox[3] - viewBox[1]) * scale;
|
||||
height = (viewBox[2] - viewBox[0]) * scale;
|
||||
} else {
|
||||
offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
|
||||
offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
|
||||
width = Math.abs(viewBox[2] - viewBox[0]) * scale;
|
||||
height = Math.abs(viewBox[3] - viewBox[1]) * scale;
|
||||
width = (viewBox[2] - viewBox[0]) * scale;
|
||||
height = (viewBox[3] - viewBox[1]) * scale;
|
||||
}
|
||||
// creating transform for the following operations:
|
||||
// translate(-centerX, -centerY), rotate and flip vertically,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue