2014-01-22 08:07:07 +09:00
|
|
|
/* Copyright 2012 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2021-03-16 19:56:31 +09:00
|
|
|
import { getPageSizeInches, isPortraitOrientation } from "./ui_utils.js";
|
2022-03-08 01:41:41 +09:00
|
|
|
import { PDFDateString, PromiseCapability } from "pdfjs-lib";
|
2016-04-09 02:34:27 +09:00
|
|
|
|
2017-05-05 21:04:08 +09:00
|
|
|
const DEFAULT_FIELD_CONTENT = "-";
|
|
|
|
|
2018-03-20 21:51:56 +09:00
|
|
|
// See https://en.wikibooks.org/wiki/Lentis/Conversion_to_the_Metric_Standard_in_the_United_States
|
2023-11-13 21:55:01 +09:00
|
|
|
const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
|
2018-03-20 21:51:56 +09:00
|
|
|
|
2023-10-21 17:27:47 +09:00
|
|
|
// Should use the format: `width x height`, in portrait orientation. The names,
|
|
|
|
// which are l10n-ids, should be lowercase.
|
2018-03-20 22:26:49 +09:00
|
|
|
// See https://en.wikipedia.org/wiki/Paper_size
|
|
|
|
const US_PAGE_NAMES = {
|
2023-10-21 17:27:47 +09:00
|
|
|
"8.5x11": "letter",
|
|
|
|
"8.5x14": "legal",
|
2018-03-20 22:26:49 +09:00
|
|
|
};
|
|
|
|
const METRIC_PAGE_NAMES = {
|
2023-10-13 23:23:17 +09:00
|
|
|
"297x420": "a-three",
|
|
|
|
"210x297": "a-four",
|
2018-03-20 22:26:49 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
function getPageName(size, isPortrait, pageNames) {
|
|
|
|
const width = isPortrait ? size.width : size.height;
|
|
|
|
const height = isPortrait ? size.height : size.width;
|
|
|
|
|
|
|
|
return pageNames[`${width}x${height}`];
|
|
|
|
}
|
|
|
|
|
2015-04-25 04:01:03 +09:00
|
|
|
/**
|
|
|
|
* @typedef {Object} PDFDocumentPropertiesOptions
|
2022-03-25 22:10:13 +09:00
|
|
|
* @property {HTMLDialogElement} dialog - The overlay's DOM element.
|
2015-04-25 04:19:58 +09:00
|
|
|
* @property {Object} fields - Names and elements of the overlay's fields.
|
|
|
|
* @property {HTMLButtonElement} closeButton - Button for closing the overlay.
|
2015-04-25 04:01:03 +09:00
|
|
|
*/
|
|
|
|
|
2017-04-16 23:42:57 +09:00
|
|
|
class PDFDocumentProperties {
|
2022-03-14 01:06:27 +09:00
|
|
|
#fieldData = null;
|
|
|
|
|
2015-04-25 03:47:38 +09:00
|
|
|
/**
|
|
|
|
* @param {PDFDocumentPropertiesOptions} options
|
2017-05-26 21:52:23 +09:00
|
|
|
* @param {OverlayManager} overlayManager - Manager for the viewer overlays.
|
2018-03-18 02:50:34 +09:00
|
|
|
* @param {EventBus} eventBus - The application event bus.
|
2017-05-04 10:05:53 +09:00
|
|
|
* @param {IL10n} l10n - Localization service.
|
2022-05-28 18:05:40 +09:00
|
|
|
* @param {function} fileNameLookup - The function that is used to lookup
|
|
|
|
* the document fileName.
|
2015-04-25 03:47:38 +09:00
|
|
|
*/
|
2022-05-28 18:05:40 +09:00
|
|
|
constructor(
|
|
|
|
{ dialog, fields, closeButton },
|
|
|
|
overlayManager,
|
|
|
|
eventBus,
|
|
|
|
l10n,
|
|
|
|
fileNameLookup
|
|
|
|
) {
|
2022-03-25 22:10:13 +09:00
|
|
|
this.dialog = dialog;
|
2017-05-05 21:04:08 +09:00
|
|
|
this.fields = fields;
|
2017-05-26 21:52:23 +09:00
|
|
|
this.overlayManager = overlayManager;
|
2017-05-04 10:05:53 +09:00
|
|
|
this.l10n = l10n;
|
2022-05-28 18:05:40 +09:00
|
|
|
this._fileNameLookup = fileNameLookup;
|
2015-04-25 04:19:58 +09:00
|
|
|
|
2022-03-14 01:06:27 +09:00
|
|
|
this.#reset();
|
2020-03-22 23:46:50 +09:00
|
|
|
// Bind the event listener for the Close button.
|
|
|
|
closeButton.addEventListener("click", this.close.bind(this));
|
2014-01-22 08:07:07 +09:00
|
|
|
|
2022-03-25 22:10:22 +09:00
|
|
|
this.overlayManager.register(this.dialog);
|
2018-03-18 02:50:34 +09:00
|
|
|
|
2020-03-22 23:46:50 +09:00
|
|
|
eventBus._on("pagechanging", evt => {
|
|
|
|
this._currentPageNumber = evt.pageNumber;
|
|
|
|
});
|
|
|
|
eventBus._on("rotationchanging", evt => {
|
|
|
|
this._pagesRotation = evt.pagesRotation;
|
|
|
|
});
|
2018-03-20 21:51:56 +09:00
|
|
|
|
2023-10-13 23:23:17 +09:00
|
|
|
this._isNonMetricLocale = NON_METRIC_LOCALES.includes(l10n.getLanguage());
|
2015-04-25 03:47:38 +09:00
|
|
|
}
|
2014-01-22 08:07:07 +09:00
|
|
|
|
2017-04-16 23:42:57 +09:00
|
|
|
/**
|
|
|
|
* Open the document properties overlay.
|
|
|
|
*/
|
2020-11-21 21:42:02 +09:00
|
|
|
async open() {
|
|
|
|
await Promise.all([
|
2022-03-25 22:10:22 +09:00
|
|
|
this.overlayManager.open(this.dialog),
|
2017-04-16 23:42:57 +09:00
|
|
|
this._dataAvailableCapability.promise,
|
2020-11-21 21:42:02 +09:00
|
|
|
]);
|
|
|
|
const currentPageNumber = this._currentPageNumber;
|
|
|
|
const pagesRotation = this._pagesRotation;
|
|
|
|
|
|
|
|
// If the document properties were previously fetched (for this PDF file),
|
|
|
|
// just update the dialog immediately to avoid redundant lookups.
|
|
|
|
if (
|
2022-03-14 01:06:27 +09:00
|
|
|
this.#fieldData &&
|
|
|
|
currentPageNumber === this.#fieldData._currentPageNumber &&
|
|
|
|
pagesRotation === this.#fieldData._pagesRotation
|
2020-11-21 21:42:02 +09:00
|
|
|
) {
|
2022-03-14 01:06:27 +09:00
|
|
|
this.#updateUI();
|
2020-11-21 21:42:02 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the document properties.
|
|
|
|
const {
|
|
|
|
info,
|
|
|
|
/* metadata, */
|
2022-05-28 18:05:40 +09:00
|
|
|
/* contentDispositionFilename, */
|
2020-11-21 21:42:02 +09:00
|
|
|
contentLength,
|
|
|
|
} = await this.pdfDocument.getMetadata();
|
|
|
|
|
|
|
|
const [
|
|
|
|
fileName,
|
|
|
|
fileSize,
|
|
|
|
creationDate,
|
|
|
|
modificationDate,
|
|
|
|
pageSize,
|
|
|
|
isLinearized,
|
|
|
|
] = await Promise.all([
|
2022-05-28 18:05:40 +09:00
|
|
|
this._fileNameLookup(),
|
2022-03-14 01:06:27 +09:00
|
|
|
this.#parseFileSize(contentLength),
|
|
|
|
this.#parseDate(info.CreationDate),
|
|
|
|
this.#parseDate(info.ModDate),
|
2024-01-21 23:47:39 +09:00
|
|
|
// eslint-disable-next-line arrow-body-style
|
2020-11-21 21:42:02 +09:00
|
|
|
this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
|
2022-03-14 01:06:27 +09:00
|
|
|
return this.#parsePageSize(getPageSizeInches(pdfPage), pagesRotation);
|
2020-11-21 21:42:02 +09:00
|
|
|
}),
|
2022-03-14 01:06:27 +09:00
|
|
|
this.#parseLinearization(info.IsLinearized),
|
2020-11-21 21:42:02 +09:00
|
|
|
]);
|
|
|
|
|
2022-03-14 01:06:27 +09:00
|
|
|
this.#fieldData = Object.freeze({
|
2020-11-21 21:42:02 +09:00
|
|
|
fileName,
|
|
|
|
fileSize,
|
|
|
|
title: info.Title,
|
|
|
|
author: info.Author,
|
|
|
|
subject: info.Subject,
|
|
|
|
keywords: info.Keywords,
|
|
|
|
creationDate,
|
|
|
|
modificationDate,
|
|
|
|
creator: info.Creator,
|
|
|
|
producer: info.Producer,
|
|
|
|
version: info.PDFFormatVersion,
|
|
|
|
pageCount: this.pdfDocument.numPages,
|
|
|
|
pageSize,
|
|
|
|
linearized: isLinearized,
|
|
|
|
_currentPageNumber: currentPageNumber,
|
|
|
|
_pagesRotation: pagesRotation,
|
2017-04-16 23:42:57 +09:00
|
|
|
});
|
2022-03-14 01:06:27 +09:00
|
|
|
this.#updateUI();
|
2020-11-21 21:42:02 +09:00
|
|
|
|
|
|
|
// Get the correct fileSize, since it may not have been available
|
|
|
|
// or could potentially be wrong.
|
|
|
|
const { length } = await this.pdfDocument.getDownloadInfo();
|
|
|
|
if (contentLength === length) {
|
|
|
|
return; // The fileSize has already been correctly set.
|
|
|
|
}
|
2022-03-14 01:06:27 +09:00
|
|
|
const data = Object.assign(Object.create(null), this.#fieldData);
|
|
|
|
data.fileSize = await this.#parseFileSize(length);
|
2020-11-21 21:42:02 +09:00
|
|
|
|
2022-03-14 01:06:27 +09:00
|
|
|
this.#fieldData = Object.freeze(data);
|
|
|
|
this.#updateUI();
|
2017-04-16 23:42:57 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Close the document properties overlay.
|
|
|
|
*/
|
2022-03-25 22:10:13 +09:00
|
|
|
async close() {
|
2022-03-25 22:10:22 +09:00
|
|
|
this.overlayManager.close(this.dialog);
|
2017-04-16 23:42:57 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-05-28 18:05:40 +09:00
|
|
|
* Set a reference to the PDF document in order to populate the dialog fields
|
|
|
|
* with the document properties. Note that the dialog will contain no
|
|
|
|
* information if this method is not called.
|
2017-04-16 23:42:57 +09:00
|
|
|
*
|
2018-09-22 00:19:33 +09:00
|
|
|
* @param {PDFDocumentProxy} pdfDocument - A reference to the PDF document.
|
2017-04-16 23:42:57 +09:00
|
|
|
*/
|
2022-05-28 18:05:40 +09:00
|
|
|
setDocument(pdfDocument) {
|
2017-05-05 21:04:08 +09:00
|
|
|
if (this.pdfDocument) {
|
2022-03-14 01:06:27 +09:00
|
|
|
this.#reset();
|
|
|
|
this.#updateUI(true);
|
2017-05-05 21:04:08 +09:00
|
|
|
}
|
|
|
|
if (!pdfDocument) {
|
|
|
|
return;
|
|
|
|
}
|
2017-04-16 23:42:57 +09:00
|
|
|
this.pdfDocument = pdfDocument;
|
2017-05-05 21:04:08 +09:00
|
|
|
|
2017-04-16 23:42:57 +09:00
|
|
|
this._dataAvailableCapability.resolve();
|
|
|
|
}
|
|
|
|
|
2022-03-14 01:06:27 +09:00
|
|
|
#reset() {
|
2017-05-05 21:04:08 +09:00
|
|
|
this.pdfDocument = null;
|
|
|
|
|
2022-03-14 01:06:27 +09:00
|
|
|
this.#fieldData = null;
|
2022-03-08 01:41:41 +09:00
|
|
|
this._dataAvailableCapability = new PromiseCapability();
|
2018-03-18 02:50:34 +09:00
|
|
|
this._currentPageNumber = 1;
|
2018-03-20 21:37:19 +09:00
|
|
|
this._pagesRotation = 0;
|
2017-04-16 23:42:57 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-05 21:04:08 +09:00
|
|
|
* Always updates all of the dialog fields, to prevent inconsistent UI state.
|
|
|
|
* NOTE: If the contents of a particular field is neither a non-empty string,
|
|
|
|
* nor a number, it will fall back to `DEFAULT_FIELD_CONTENT`.
|
2017-04-16 23:42:57 +09:00
|
|
|
*/
|
2022-03-14 01:06:27 +09:00
|
|
|
#updateUI(reset = false) {
|
|
|
|
if (reset || !this.#fieldData) {
|
2019-12-27 08:22:32 +09:00
|
|
|
for (const id in this.fields) {
|
2017-05-05 21:04:08 +09:00
|
|
|
this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2022-03-25 22:10:22 +09:00
|
|
|
if (this.overlayManager.active !== this.dialog) {
|
2017-05-05 21:04:08 +09:00
|
|
|
// Don't bother updating the dialog if has already been closed,
|
|
|
|
// since it will be updated the next time `this.open` is called.
|
|
|
|
return;
|
|
|
|
}
|
2019-12-27 08:22:32 +09:00
|
|
|
for (const id in this.fields) {
|
2022-03-14 01:06:27 +09:00
|
|
|
const content = this.#fieldData[id];
|
2017-05-05 21:04:08 +09:00
|
|
|
this.fields[id].textContent =
|
|
|
|
content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
|
2017-04-16 23:42:57 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-14 01:06:27 +09:00
|
|
|
async #parseFileSize(fileSize = 0) {
|
2021-02-22 20:43:16 +09:00
|
|
|
const kb = fileSize / 1024,
|
|
|
|
mb = kb / 1024;
|
2017-04-16 23:42:57 +09:00
|
|
|
if (!kb) {
|
2019-05-10 19:54:06 +09:00
|
|
|
return undefined;
|
2017-04-16 23:42:57 +09:00
|
|
|
}
|
2023-10-13 23:23:17 +09:00
|
|
|
return this.l10n.get(`pdfjs-document-properties-${mb >= 1 ? "mb" : "kb"}`, {
|
2021-02-22 20:43:16 +09:00
|
|
|
size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
|
2021-03-06 00:45:13 +09:00
|
|
|
size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
|
2021-02-22 20:43:16 +09:00
|
|
|
size_b: fileSize.toLocaleString(),
|
|
|
|
});
|
2017-04-16 23:42:57 +09:00
|
|
|
}
|
2014-01-22 08:07:07 +09:00
|
|
|
|
2022-03-14 01:06:27 +09:00
|
|
|
async #parsePageSize(pageSizeInches, pagesRotation) {
|
2018-03-09 02:23:47 +09:00
|
|
|
if (!pageSizeInches) {
|
2019-05-10 19:54:06 +09:00
|
|
|
return undefined;
|
2018-03-09 02:23:47 +09:00
|
|
|
}
|
2018-03-20 21:37:19 +09:00
|
|
|
// Take the viewer rotation into account as well; compare with Adobe Reader.
|
|
|
|
if (pagesRotation % 180 !== 0) {
|
|
|
|
pageSizeInches = {
|
|
|
|
width: pageSizeInches.height,
|
|
|
|
height: pageSizeInches.width,
|
|
|
|
};
|
|
|
|
}
|
2018-03-20 21:58:55 +09:00
|
|
|
const isPortrait = isPortraitOrientation(pageSizeInches);
|
2018-03-20 21:51:56 +09:00
|
|
|
|
2018-03-21 21:39:07 +09:00
|
|
|
let sizeInches = {
|
2018-03-20 21:51:56 +09:00
|
|
|
width: Math.round(pageSizeInches.width * 100) / 100,
|
|
|
|
height: Math.round(pageSizeInches.height * 100) / 100,
|
|
|
|
};
|
|
|
|
// 1in == 25.4mm; no need to round to 2 decimals for millimeters.
|
2018-03-21 21:39:07 +09:00
|
|
|
let sizeMillimeters = {
|
2018-03-20 21:51:56 +09:00
|
|
|
width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
|
|
|
|
height: Math.round(pageSizeInches.height * 25.4 * 10) / 10,
|
|
|
|
};
|
2018-03-18 01:10:37 +09:00
|
|
|
|
2020-03-13 20:55:00 +09:00
|
|
|
let rawName =
|
2018-03-21 21:39:07 +09:00
|
|
|
getPageName(sizeInches, isPortrait, US_PAGE_NAMES) ||
|
|
|
|
getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
2018-03-21 21:39:07 +09:00
|
|
|
if (
|
2020-03-13 20:55:00 +09:00
|
|
|
!rawName &&
|
2018-03-21 21:39:07 +09:00
|
|
|
!(
|
|
|
|
Number.isInteger(sizeMillimeters.width) &&
|
|
|
|
Number.isInteger(sizeMillimeters.height)
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
)
|
2018-03-21 21:39:07 +09:00
|
|
|
) {
|
|
|
|
// Attempt to improve the page name detection by falling back to fuzzy
|
|
|
|
// matching of the metric dimensions, to account for e.g. rounding errors
|
|
|
|
// and/or PDF files that define the page sizes in an imprecise manner.
|
|
|
|
const exactMillimeters = {
|
|
|
|
width: pageSizeInches.width * 25.4,
|
|
|
|
height: pageSizeInches.height * 25.4,
|
|
|
|
};
|
|
|
|
const intMillimeters = {
|
|
|
|
width: Math.round(sizeMillimeters.width),
|
|
|
|
height: Math.round(sizeMillimeters.height),
|
|
|
|
};
|
|
|
|
|
|
|
|
// Try to avoid false positives, by only considering "small" differences.
|
|
|
|
if (
|
|
|
|
Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 &&
|
|
|
|
Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1
|
|
|
|
) {
|
2020-03-13 20:55:00 +09:00
|
|
|
rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
|
|
|
|
if (rawName) {
|
2018-03-21 21:39:07 +09:00
|
|
|
// Update *both* sizes, computed above, to ensure that the displayed
|
|
|
|
// dimensions always correspond to the detected page name.
|
|
|
|
sizeInches = {
|
|
|
|
width: Math.round((intMillimeters.width / 25.4) * 100) / 100,
|
|
|
|
height: Math.round((intMillimeters.height / 25.4) * 100) / 100,
|
|
|
|
};
|
|
|
|
sizeMillimeters = intMillimeters;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-20 22:26:49 +09:00
|
|
|
|
2021-02-22 20:43:16 +09:00
|
|
|
const [{ width, height }, unit, name, orientation] = await Promise.all([
|
2018-03-20 21:51:56 +09:00
|
|
|
this._isNonMetricLocale ? sizeInches : sizeMillimeters,
|
|
|
|
this.l10n.get(
|
2023-10-13 23:23:17 +09:00
|
|
|
`pdfjs-document-properties-page-size-unit-${
|
2021-02-22 20:43:16 +09:00
|
|
|
this._isNonMetricLocale ? "inches" : "millimeters"
|
|
|
|
}`
|
2018-03-20 21:51:56 +09:00
|
|
|
),
|
2021-02-22 20:43:16 +09:00
|
|
|
rawName &&
|
2023-10-21 17:27:47 +09:00
|
|
|
this.l10n.get(`pdfjs-document-properties-page-size-name-${rawName}`),
|
2018-03-20 21:58:55 +09:00
|
|
|
this.l10n.get(
|
2023-10-13 23:23:17 +09:00
|
|
|
`pdfjs-document-properties-page-size-orientation-${
|
2021-02-22 20:43:16 +09:00
|
|
|
isPortrait ? "portrait" : "landscape"
|
|
|
|
}`
|
2018-03-20 21:58:55 +09:00
|
|
|
),
|
2021-02-22 20:43:16 +09:00
|
|
|
]);
|
|
|
|
|
|
|
|
return this.l10n.get(
|
2023-10-13 23:23:17 +09:00
|
|
|
`pdfjs-document-properties-page-size-dimension-${
|
|
|
|
name ? "name-" : ""
|
|
|
|
}string`,
|
2021-02-22 20:43:16 +09:00
|
|
|
{
|
|
|
|
width: width.toLocaleString(),
|
|
|
|
height: height.toLocaleString(),
|
|
|
|
unit,
|
|
|
|
name,
|
|
|
|
orientation,
|
|
|
|
}
|
|
|
|
);
|
2018-03-09 02:23:47 +09:00
|
|
|
}
|
|
|
|
|
2022-03-14 01:06:27 +09:00
|
|
|
async #parseDate(inputDate) {
|
2019-04-22 04:21:01 +09:00
|
|
|
const dateObject = PDFDateString.toDateObject(inputDate);
|
2019-05-10 19:54:06 +09:00
|
|
|
if (!dateObject) {
|
|
|
|
return undefined;
|
2017-04-16 23:42:57 +09:00
|
|
|
}
|
2023-10-13 23:23:17 +09:00
|
|
|
return this.l10n.get("pdfjs-document-properties-date-string", {
|
2021-02-22 20:43:16 +09:00
|
|
|
date: dateObject.toLocaleDateString(),
|
|
|
|
time: dateObject.toLocaleTimeString(),
|
|
|
|
});
|
2017-04-16 23:42:57 +09:00
|
|
|
}
|
2018-07-24 23:24:30 +09:00
|
|
|
|
2022-03-14 01:06:27 +09:00
|
|
|
#parseLinearization(isLinearized) {
|
2018-07-24 23:24:30 +09:00
|
|
|
return this.l10n.get(
|
2023-10-13 23:23:17 +09:00
|
|
|
`pdfjs-document-properties-linearized-${isLinearized ? "yes" : "no"}`
|
2018-07-24 23:24:30 +09:00
|
|
|
);
|
|
|
|
}
|
2017-04-16 23:42:57 +09:00
|
|
|
}
|
2016-04-09 02:34:27 +09:00
|
|
|
|
2017-03-28 08:07:27 +09:00
|
|
|
export { PDFDocumentProperties };
|