mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 01:35:43 +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
|
@ -18,6 +18,7 @@ import {
|
|||
BaseException,
|
||||
isString,
|
||||
removeNullCharacters,
|
||||
shadow,
|
||||
stringToBytes,
|
||||
Util,
|
||||
warn,
|
||||
|
@ -35,6 +36,11 @@ const SVG_NS = "http://www.w3.org/2000/svg";
|
|||
const PixelsPerInch = {
|
||||
CSS: 96.0,
|
||||
PDF: 72.0,
|
||||
|
||||
/** @type {number} */
|
||||
get PDF_TO_CSS_UNITS() {
|
||||
return shadow(this, "PDF_TO_CSS_UNITS", this.CSS / this.PDF);
|
||||
},
|
||||
};
|
||||
|
||||
class DOMCanvasFactory extends BaseCanvasFactory {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue