mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Re-factor the CSS_PIXELS_PER_INCH
/PDF_PIXELS_PER_INCH
exports (PR 13991 follow-up)
For improved maintainability, since these constants are being exposed in the official API, this patch moves them into an Object instead.
This commit is contained in:
parent
bd51bbfd16
commit
0e54f568fb
7 changed files with 18 additions and 20 deletions
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { CSS_PIXELS_PER_INCH, PDF_PIXELS_PER_INCH } from "./display_utils.js";
|
||||
|
||||
import {
|
||||
FONT_IDENTITY_MATRIX,
|
||||
IDENTITY_MATRIX,
|
||||
|
@ -28,6 +28,7 @@ import {
|
|||
warn,
|
||||
} from "../shared/util.js";
|
||||
import { getShadingPattern, TilingPattern } from "./pattern_helper.js";
|
||||
import { PixelsPerInch } from "./display_utils.js";
|
||||
|
||||
// <canvas> contexts store most of the state we need natively.
|
||||
// However, PDF needs a bit more state, which we store here.
|
||||
|
@ -878,8 +879,7 @@ function getImageSmoothingEnabled(transform, interpolate) {
|
|||
scale[0] = Math.fround(scale[0]);
|
||||
scale[1] = Math.fround(scale[1]);
|
||||
const actualScale = Math.fround(
|
||||
((globalThis.devicePixelRatio || 1) * CSS_PIXELS_PER_INCH) /
|
||||
PDF_PIXELS_PER_INCH
|
||||
((globalThis.devicePixelRatio || 1) * PixelsPerInch.CSS) / PixelsPerInch.PDF
|
||||
);
|
||||
if (interpolate !== undefined) {
|
||||
// If the value is explicitly set use it.
|
||||
|
|
|
@ -32,8 +32,10 @@ import {
|
|||
const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
|
||||
const SVG_NS = "http://www.w3.org/2000/svg";
|
||||
|
||||
const CSS_PIXELS_PER_INCH = 96.0;
|
||||
const PDF_PIXELS_PER_INCH = 72.0;
|
||||
const PixelsPerInch = {
|
||||
CSS: 96.0,
|
||||
PDF: 72.0,
|
||||
};
|
||||
|
||||
class DOMCanvasFactory extends BaseCanvasFactory {
|
||||
constructor({ ownerDocument = globalThis.document } = {}) {
|
||||
|
@ -625,7 +627,6 @@ function getXfaPageViewport(xfaPage, { scale = 1, rotation = 0 }) {
|
|||
|
||||
export {
|
||||
addLinkAttributes,
|
||||
CSS_PIXELS_PER_INCH,
|
||||
DEFAULT_LINK_REL,
|
||||
deprecated,
|
||||
DOMCanvasFactory,
|
||||
|
@ -641,8 +642,8 @@ export {
|
|||
LinkTarget,
|
||||
loadScript,
|
||||
PageViewport,
|
||||
PDF_PIXELS_PER_INCH,
|
||||
PDFDateString,
|
||||
PixelsPerInch,
|
||||
RenderingCancelledException,
|
||||
StatTimer,
|
||||
};
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
import {
|
||||
addLinkAttributes,
|
||||
CSS_PIXELS_PER_INCH,
|
||||
getFilenameFromUrl,
|
||||
getPdfFilenameFromUrl,
|
||||
getXfaPageViewport,
|
||||
|
@ -24,8 +23,8 @@ import {
|
|||
isValidFetchUrl,
|
||||
LinkTarget,
|
||||
loadScript,
|
||||
PDF_PIXELS_PER_INCH,
|
||||
PDFDateString,
|
||||
PixelsPerInch,
|
||||
RenderingCancelledException,
|
||||
} from "./display/display_utils.js";
|
||||
import {
|
||||
|
@ -105,14 +104,13 @@ if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
|||
export {
|
||||
// From "./display/display_utils.js":
|
||||
addLinkAttributes,
|
||||
CSS_PIXELS_PER_INCH,
|
||||
getFilenameFromUrl,
|
||||
getPdfFilenameFromUrl,
|
||||
isPdfFile,
|
||||
LinkTarget,
|
||||
loadScript,
|
||||
PDF_PIXELS_PER_INCH,
|
||||
PDFDateString,
|
||||
PixelsPerInch,
|
||||
RenderingCancelledException,
|
||||
getXfaPageViewport,
|
||||
// From "./shared/util.js":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue