mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 01:35:43 +02:00
[api-minor] Make isOffscreenCanvasSupported
configurable via the API (issue 14952)
This patch first of all makes `isOffscreenCanvasSupported` configurable, defaulting to `true` in browsers and `false` in Node.js environments, with a new `getDocument` parameter. While you normally want to use this, in order to improve performance, it should still be possible for users to control it (similar to e.g. `isEvalSupported`). The specific problem, as reported in issue 14952, is that the SVG back-end doesn't support the new ImageMask data-format that's introduced in PR 14754. In particular: - When the SVG back-end is used in Node.js environments, this patch will "just work" without the user needing to make any code changes. - If the SVG back-end is used in browsers, this patch will require that `isOffscreenCanvasSupported: false` is added to the `getDocument`-call.
This commit is contained in:
parent
7d5f7a517c
commit
1ea4c4b519
6 changed files with 37 additions and 5 deletions
|
@ -189,6 +189,10 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
|
|||
* @property {boolean} [isEvalSupported] - Determines if we can evaluate strings
|
||||
* as JavaScript. Primarily used to improve performance of font rendering, and
|
||||
* when parsing PDF functions. The default value is `true`.
|
||||
* @property {boolean} [isOffscreenCanvasSupported] - Determines if we can use
|
||||
* `OffscreenCanvas` in the worker. Primarily used to improve performance of
|
||||
* image conversion/rendering.
|
||||
* The default value is `true` in web environments and `false` in Node.js.
|
||||
* @property {boolean} [disableFontFace] - By default fonts are converted to
|
||||
* OpenType fonts and loaded via the Font Loading API or `@font-face` rules.
|
||||
* If disabled, fonts will be rendered using a built-in font renderer that
|
||||
|
@ -365,6 +369,9 @@ function getDocument(src) {
|
|||
if (typeof params.isEvalSupported !== "boolean") {
|
||||
params.isEvalSupported = true;
|
||||
}
|
||||
if (typeof params.isOffscreenCanvasSupported !== "boolean") {
|
||||
params.isOffscreenCanvasSupported = !isNodeJS;
|
||||
}
|
||||
if (typeof params.disableFontFace !== "boolean") {
|
||||
params.disableFontFace = isNodeJS;
|
||||
}
|
||||
|
@ -516,6 +523,7 @@ async function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||
docBaseUrl: source.docBaseUrl,
|
||||
ignoreErrors: source.ignoreErrors,
|
||||
isEvalSupported: source.isEvalSupported,
|
||||
isOffscreenCanvasSupported: source.isOffscreenCanvasSupported,
|
||||
fontExtraProperties: source.fontExtraProperties,
|
||||
enableXfa: source.enableXfa,
|
||||
useSystemFonts: source.useSystemFonts,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue