mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Add PDF_TO_CSS_UNITS
to the PixelsPerInch
-structure
Rather than re-computing this value in a number of different places throughout the code-base[1], we can expose this in the API via the existing `PixelsPerInch`-structure instead. There's also been feature requests asking for the old `CSS_UNITS` viewer constant to be made accessible, such that it could be used in third-party implementations. I suppose that it could be argued that it's somewhat confusing to place a unitless property in `PixelsPerInch`, however given that the `PDF_TO_CSS_UNITS`-property is defined strictly in terms of the existing properties this is hopefully deemed reasonable. --- [1] These include: - The viewer, with the `CSS_UNITS` name. - The reference-tests. - The display-layer, when rendering images; see PR 13991.
This commit is contained in:
parent
580bfad628
commit
3e550f392a
7 changed files with 38 additions and 22 deletions
|
@ -29,7 +29,6 @@ const {
|
|||
const { SimpleLinkService } = pdfjsViewer;
|
||||
|
||||
const WAITING_TIME = 100; // ms
|
||||
const PDF_TO_CSS_UNITS = PixelsPerInch.CSS / PixelsPerInch.PDF;
|
||||
const CMAP_URL = "/build/generic/web/cmaps/";
|
||||
const CMAP_PACKED = true;
|
||||
const STANDARD_FONT_DATA_URL = "/build/generic/web/standard_fonts/";
|
||||
|
@ -656,7 +655,9 @@ var Driver = (function DriverClosure() {
|
|||
ctx = this.canvas.getContext("2d", { alpha: false });
|
||||
task.pdfDoc.getPage(task.pageNum).then(
|
||||
function (page) {
|
||||
var viewport = page.getViewport({ scale: PDF_TO_CSS_UNITS });
|
||||
var viewport = page.getViewport({
|
||||
scale: PixelsPerInch.PDF_TO_CSS_UNITS,
|
||||
});
|
||||
self.canvas.width = viewport.width;
|
||||
self.canvas.height = viewport.height;
|
||||
self._clearCanvas();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue