Merge pull request #15981 from Snuffleupagus/cMapPacked-true
[api-minor] Let the `cMapPacked` parameter, in `getDocument`, default to `true`
This commit is contained in:
commit
e848a0e61c
@ -166,7 +166,7 @@ if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
|||||||
* @property {string} [cMapUrl] - The URL where the predefined Adobe CMaps are
|
* @property {string} [cMapUrl] - The URL where the predefined Adobe CMaps are
|
||||||
* located. Include the trailing slash.
|
* located. Include the trailing slash.
|
||||||
* @property {boolean} [cMapPacked] - Specifies if the Adobe CMaps are binary
|
* @property {boolean} [cMapPacked] - Specifies if the Adobe CMaps are binary
|
||||||
* packed or not.
|
* packed or not. The default value is `true`.
|
||||||
* @property {Object} [CMapReaderFactory] - The factory that will be used when
|
* @property {Object} [CMapReaderFactory] - The factory that will be used when
|
||||||
* reading built-in CMap files. Providing a custom factory is useful for
|
* reading built-in CMap files. Providing a custom factory is useful for
|
||||||
* environments without Fetch API or `XMLHttpRequest` support, such as
|
* environments without Fetch API or `XMLHttpRequest` support, such as
|
||||||
@ -347,6 +347,7 @@ function getDocument(src) {
|
|||||||
params[key] = val;
|
params[key] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params.cMapPacked = params.cMapPacked !== false;
|
||||||
params.CMapReaderFactory =
|
params.CMapReaderFactory =
|
||||||
params.CMapReaderFactory || DefaultCMapReaderFactory;
|
params.CMapReaderFactory || DefaultCMapReaderFactory;
|
||||||
params.StandardFontDataFactory =
|
params.StandardFontDataFactory =
|
||||||
|
@ -65,7 +65,7 @@ class BaseCanvasFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BaseCMapReaderFactory {
|
class BaseCMapReaderFactory {
|
||||||
constructor({ baseUrl = null, isCompressed = false }) {
|
constructor({ baseUrl = null, isCompressed = true }) {
|
||||||
if (this.constructor === BaseCMapReaderFactory) {
|
if (this.constructor === BaseCMapReaderFactory) {
|
||||||
unreachable("Cannot initialize BaseCMapReaderFactory.");
|
unreachable("Cannot initialize BaseCMapReaderFactory.");
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ const { GenericL10n, NullL10n, parseQueryString, SimpleLinkService } =
|
|||||||
|
|
||||||
const WAITING_TIME = 100; // ms
|
const WAITING_TIME = 100; // ms
|
||||||
const CMAP_URL = "/build/generic/web/cmaps/";
|
const CMAP_URL = "/build/generic/web/cmaps/";
|
||||||
const CMAP_PACKED = true;
|
|
||||||
const STANDARD_FONT_DATA_URL = "/build/generic/web/standard_fonts/";
|
const STANDARD_FONT_DATA_URL = "/build/generic/web/standard_fonts/";
|
||||||
const IMAGE_RESOURCES_PATH = "/web/images/";
|
const IMAGE_RESOURCES_PATH = "/web/images/";
|
||||||
const VIEWER_CSS = "../build/components/pdf_viewer.css";
|
const VIEWER_CSS = "../build/components/pdf_viewer.css";
|
||||||
@ -475,7 +474,6 @@ class Driver {
|
|||||||
url: absoluteUrl,
|
url: absoluteUrl,
|
||||||
password: task.password,
|
password: task.password,
|
||||||
cMapUrl: CMAP_URL,
|
cMapUrl: CMAP_URL,
|
||||||
cMapPacked: CMAP_PACKED,
|
|
||||||
standardFontDataUrl: STANDARD_FONT_DATA_URL,
|
standardFontDataUrl: STANDARD_FONT_DATA_URL,
|
||||||
disableRange: task.disableRange,
|
disableRange: task.disableRange,
|
||||||
disableAutoFetch: !task.enableAutoFetch,
|
disableAutoFetch: !task.enableAutoFetch,
|
||||||
|
@ -32,7 +32,7 @@ import {
|
|||||||
stringToUTF8String,
|
stringToUTF8String,
|
||||||
} from "../../src/shared/util.js";
|
} from "../../src/shared/util.js";
|
||||||
import {
|
import {
|
||||||
CMAP_PARAMS,
|
CMAP_URL,
|
||||||
createIdFactory,
|
createIdFactory,
|
||||||
STANDARD_FONT_DATA_URL,
|
STANDARD_FONT_DATA_URL,
|
||||||
XRefMock,
|
XRefMock,
|
||||||
@ -108,8 +108,7 @@ describe("annotation", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const CMapReaderFactory = new DefaultCMapReaderFactory({
|
const CMapReaderFactory = new DefaultCMapReaderFactory({
|
||||||
baseUrl: CMAP_PARAMS.cMapUrl,
|
baseUrl: CMAP_URL,
|
||||||
isCompressed: CMAP_PARAMS.cMapPacked,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const builtInCMapCache = new Map();
|
const builtInCMapCache = new Map();
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { CMap, CMapFactory, IdentityCMap } from "../../src/core/cmap.js";
|
import { CMap, CMapFactory, IdentityCMap } from "../../src/core/cmap.js";
|
||||||
import { CMAP_PARAMS } from "./test_utils.js";
|
import { CMAP_URL } from "./test_utils.js";
|
||||||
import { DefaultCMapReaderFactory } from "../../src/display/api.js";
|
import { DefaultCMapReaderFactory } from "../../src/display/api.js";
|
||||||
import { Name } from "../../src/core/primitives.js";
|
import { Name } from "../../src/core/primitives.js";
|
||||||
import { StringStream } from "../../src/core/stream.js";
|
import { StringStream } from "../../src/core/stream.js";
|
||||||
@ -25,8 +25,7 @@ describe("cmap", function () {
|
|||||||
beforeAll(function () {
|
beforeAll(function () {
|
||||||
// Allow CMap testing in Node.js, e.g. for Travis.
|
// Allow CMap testing in Node.js, e.g. for Travis.
|
||||||
const CMapReaderFactory = new DefaultCMapReaderFactory({
|
const CMapReaderFactory = new DefaultCMapReaderFactory({
|
||||||
baseUrl: CMAP_PARAMS.cMapUrl,
|
baseUrl: CMAP_URL,
|
||||||
isCompressed: CMAP_PARAMS.cMapPacked,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
fetchBuiltInCMap = function (name) {
|
fetchBuiltInCMap = function (name) {
|
||||||
@ -232,7 +231,7 @@ describe("cmap", function () {
|
|||||||
it("attempts to load a built-in CMap with inconsistent API parameters", async function () {
|
it("attempts to load a built-in CMap with inconsistent API parameters", async function () {
|
||||||
function tmpFetchBuiltInCMap(name) {
|
function tmpFetchBuiltInCMap(name) {
|
||||||
const CMapReaderFactory = new DefaultCMapReaderFactory({
|
const CMapReaderFactory = new DefaultCMapReaderFactory({
|
||||||
baseUrl: CMAP_PARAMS.cMapUrl,
|
baseUrl: CMAP_URL,
|
||||||
isCompressed: false,
|
isCompressed: false,
|
||||||
});
|
});
|
||||||
return CMapReaderFactory.fetch({ name });
|
return CMapReaderFactory.fetch({ name });
|
||||||
|
@ -21,10 +21,8 @@ import { isNodeJS } from "../../src/shared/is_node.js";
|
|||||||
import { SimpleLinkService } from "../../web/pdf_link_service.js";
|
import { SimpleLinkService } from "../../web/pdf_link_service.js";
|
||||||
|
|
||||||
const tracemonkeyFileName = "tracemonkey.pdf";
|
const tracemonkeyFileName = "tracemonkey.pdf";
|
||||||
const CMAP_PARAMS = {
|
|
||||||
cMapUrl: isNodeJS ? "./external/bcmaps/" : "../../../external/bcmaps/",
|
const CMAP_URL = isNodeJS ? "./external/bcmaps/" : "../../../external/bcmaps/";
|
||||||
cMapPacked: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockLinkService extends SimpleLinkService {
|
class MockLinkService extends SimpleLinkService {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -57,7 +55,7 @@ async function initPdfFindController(
|
|||||||
) {
|
) {
|
||||||
const loadingTask = getDocument(
|
const loadingTask = getDocument(
|
||||||
buildGetDocumentParams(filename || tracemonkeyFileName, {
|
buildGetDocumentParams(filename || tracemonkeyFileName, {
|
||||||
...CMAP_PARAMS,
|
cMapUrl: CMAP_URL,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
const pdfDocument = await loadingTask.promise;
|
const pdfDocument = await loadingTask.promise;
|
||||||
|
@ -20,10 +20,7 @@ import { Ref } from "../../src/core/primitives.js";
|
|||||||
|
|
||||||
const TEST_PDFS_PATH = isNodeJS ? "./test/pdfs/" : "../pdfs/";
|
const TEST_PDFS_PATH = isNodeJS ? "./test/pdfs/" : "../pdfs/";
|
||||||
|
|
||||||
const CMAP_PARAMS = {
|
const CMAP_URL = isNodeJS ? "./external/bcmaps/" : "../../external/bcmaps/";
|
||||||
cMapUrl: isNodeJS ? "./external/bcmaps/" : "../../external/bcmaps/",
|
|
||||||
cMapPacked: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
const STANDARD_FONT_DATA_URL = isNodeJS
|
const STANDARD_FONT_DATA_URL = isNodeJS
|
||||||
? "./external/standard_fonts/"
|
? "./external/standard_fonts/"
|
||||||
@ -145,7 +142,7 @@ function createIdFactory(pageIndex) {
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
buildGetDocumentParams,
|
buildGetDocumentParams,
|
||||||
CMAP_PARAMS,
|
CMAP_URL,
|
||||||
createIdFactory,
|
createIdFactory,
|
||||||
DefaultFileReaderFactory,
|
DefaultFileReaderFactory,
|
||||||
STANDARD_FONT_DATA_URL,
|
STANDARD_FONT_DATA_URL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user