mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 23:58:07 +02:00
Move the imageResourcesPath
option to a BaseViewer
/PDFPageView
/AnnotationLayerBuilder
option
This removes the `PDFJS.imageResourcesPath` dependency from the viewer components and the test-suite, but please note that as a *temporary* solution the default viewer still uses it.
This commit is contained in:
parent
fdf99c6af5
commit
c45c394364
9 changed files with 42 additions and 24 deletions
|
@ -21,6 +21,8 @@ import { SimpleLinkService } from './pdf_link_service';
|
|||
* @typedef {Object} AnnotationLayerBuilderOptions
|
||||
* @property {HTMLDivElement} pageDiv
|
||||
* @property {PDFPage} pdfPage
|
||||
* @property {string} imageResourcesPath - (optional) Path for image resources,
|
||||
* mainly for annotation icons. Include trailing slash.
|
||||
* @property {boolean} renderInteractiveForms
|
||||
* @property {IPDFLinkService} linkService
|
||||
* @property {DownloadManager} downloadManager
|
||||
|
@ -32,11 +34,13 @@ class AnnotationLayerBuilder {
|
|||
* @param {AnnotationLayerBuilderOptions} options
|
||||
*/
|
||||
constructor({ pageDiv, pdfPage, linkService, downloadManager,
|
||||
renderInteractiveForms = false, l10n = NullL10n, }) {
|
||||
imageResourcesPath = '', renderInteractiveForms = false,
|
||||
l10n = NullL10n, }) {
|
||||
this.pageDiv = pageDiv;
|
||||
this.pdfPage = pdfPage;
|
||||
this.linkService = linkService;
|
||||
this.downloadManager = downloadManager;
|
||||
this.imageResourcesPath = imageResourcesPath;
|
||||
this.renderInteractiveForms = renderInteractiveForms;
|
||||
this.l10n = l10n;
|
||||
|
||||
|
@ -59,6 +63,7 @@ class AnnotationLayerBuilder {
|
|||
div: this.div,
|
||||
annotations,
|
||||
page: this.pdfPage,
|
||||
imageResourcesPath: this.imageResourcesPath,
|
||||
renderInteractiveForms: this.renderInteractiveForms,
|
||||
linkService: this.linkService,
|
||||
downloadManager: this.downloadManager,
|
||||
|
@ -104,15 +109,19 @@ class DefaultAnnotationLayerFactory {
|
|||
/**
|
||||
* @param {HTMLDivElement} pageDiv
|
||||
* @param {PDFPage} pdfPage
|
||||
* @param {string} imageResourcesPath - (optional) Path for image resources,
|
||||
* mainly for annotation icons. Include trailing slash.
|
||||
* @param {boolean} renderInteractiveForms
|
||||
* @param {IL10n} l10n
|
||||
* @returns {AnnotationLayerBuilder}
|
||||
*/
|
||||
createAnnotationLayerBuilder(pageDiv, pdfPage, renderInteractiveForms = false,
|
||||
createAnnotationLayerBuilder(pageDiv, pdfPage, imageResourcesPath = '',
|
||||
renderInteractiveForms = false,
|
||||
l10n = NullL10n) {
|
||||
return new AnnotationLayerBuilder({
|
||||
pageDiv,
|
||||
pdfPage,
|
||||
imageResourcesPath,
|
||||
renderInteractiveForms,
|
||||
linkService: new SimpleLinkService(),
|
||||
l10n,
|
||||
|
|
|
@ -396,6 +396,7 @@ let PDFViewerApplication = {
|
|||
renderer: viewerPrefs['renderer'],
|
||||
l10n: this.l10n,
|
||||
enhanceTextSelection: viewerPrefs['enhanceTextSelection'],
|
||||
imageResourcesPath: PDFJS.imageResourcesPath,
|
||||
renderInteractiveForms: viewerPrefs['renderInteractiveForms'],
|
||||
enablePrintAutoRotate: viewerPrefs['enablePrintAutoRotate'],
|
||||
useOnlyCssZoom: PDFJS.useOnlyCssZoom,
|
||||
|
|
|
@ -42,6 +42,8 @@ const DEFAULT_CACHE_SIZE = 10;
|
|||
* around the pages. The default is false.
|
||||
* @property {boolean} enhanceTextSelection - (optional) Enables the improved
|
||||
* text selection behaviour. The default is `false`.
|
||||
* @property {string} imageResourcesPath - (optional) Path for image resources,
|
||||
* mainly for annotation icons. Include trailing slash.
|
||||
* @property {boolean} renderInteractiveForms - (optional) Enables rendering of
|
||||
* interactive form elements. The default is `false`.
|
||||
* @property {boolean} enablePrintAutoRotate - (optional) Enables automatic
|
||||
|
@ -113,6 +115,7 @@ class BaseViewer {
|
|||
this.downloadManager = options.downloadManager || null;
|
||||
this.removePageBorders = options.removePageBorders || false;
|
||||
this.enhanceTextSelection = options.enhanceTextSelection || false;
|
||||
this.imageResourcesPath = options.imageResourcesPath || '';
|
||||
this.renderInteractiveForms = options.renderInteractiveForms || false;
|
||||
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
|
||||
this.renderer = options.renderer || RendererType.CANVAS;
|
||||
|
@ -382,6 +385,7 @@ class BaseViewer {
|
|||
textLayerFactory,
|
||||
annotationLayerFactory: this,
|
||||
enhanceTextSelection: this.enhanceTextSelection,
|
||||
imageResourcesPath: this.imageResourcesPath,
|
||||
renderInteractiveForms: this.renderInteractiveForms,
|
||||
renderer: this.renderer,
|
||||
useOnlyCssZoom: this.useOnlyCssZoom,
|
||||
|
@ -881,15 +885,19 @@ class BaseViewer {
|
|||
/**
|
||||
* @param {HTMLDivElement} pageDiv
|
||||
* @param {PDFPage} pdfPage
|
||||
* @param {string} imageResourcesPath - (optional) Path for image resources,
|
||||
* mainly for annotation icons. Include trailing slash.
|
||||
* @param {boolean} renderInteractiveForms
|
||||
* @param {IL10n} l10n
|
||||
* @returns {AnnotationLayerBuilder}
|
||||
*/
|
||||
createAnnotationLayerBuilder(pageDiv, pdfPage, renderInteractiveForms = false,
|
||||
createAnnotationLayerBuilder(pageDiv, pdfPage, imageResourcesPath = '',
|
||||
renderInteractiveForms = false,
|
||||
l10n = NullL10n) {
|
||||
return new AnnotationLayerBuilder({
|
||||
pageDiv,
|
||||
pdfPage,
|
||||
imageResourcesPath,
|
||||
renderInteractiveForms,
|
||||
linkService: this.linkService,
|
||||
downloadManager: this.downloadManager,
|
||||
|
|
|
@ -145,11 +145,13 @@ class IPDFAnnotationLayerFactory {
|
|||
/**
|
||||
* @param {HTMLDivElement} pageDiv
|
||||
* @param {PDFPage} pdfPage
|
||||
* @param {IL10n} l10n
|
||||
* @param {string} imageResourcesPath - (optional) Path for image resources,
|
||||
* mainly for annotation icons. Include trailing slash.
|
||||
* @param {boolean} renderInteractiveForms
|
||||
* @param {IL10n} l10n
|
||||
* @returns {AnnotationLayerBuilder}
|
||||
*/
|
||||
createAnnotationLayerBuilder(pageDiv, pdfPage,
|
||||
createAnnotationLayerBuilder(pageDiv, pdfPage, imageResourcesPath = '',
|
||||
renderInteractiveForms = false,
|
||||
l10n = undefined) {}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ import { viewerCompatibilityParams } from './viewer_compatibility';
|
|||
* @property {IPDFAnnotationLayerFactory} annotationLayerFactory
|
||||
* @property {boolean} enhanceTextSelection - Turns on the text selection
|
||||
* enhancement. The default is `false`.
|
||||
* @property {string} imageResourcesPath - (optional) Path for image resources,
|
||||
* mainly for annotation icons. Include trailing slash.
|
||||
* @property {boolean} renderInteractiveForms - Turns on rendering of
|
||||
* interactive form elements. The default is `false`.
|
||||
* @property {string} renderer - 'canvas' or 'svg'. The default is 'canvas'.
|
||||
|
@ -71,6 +73,7 @@ class PDFPageView {
|
|||
this.pdfPageRotate = defaultViewport.rotation;
|
||||
this.hasRestrictedScaling = false;
|
||||
this.enhanceTextSelection = options.enhanceTextSelection || false;
|
||||
this.imageResourcesPath = options.imageResourcesPath || '';
|
||||
this.renderInteractiveForms = options.renderInteractiveForms || false;
|
||||
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
|
||||
this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
|
||||
|
@ -475,7 +478,7 @@ class PDFPageView {
|
|||
if (this.annotationLayerFactory) {
|
||||
if (!this.annotationLayer) {
|
||||
this.annotationLayer = this.annotationLayerFactory.
|
||||
createAnnotationLayerBuilder(div, pdfPage,
|
||||
createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath,
|
||||
this.renderInteractiveForms, this.l10n);
|
||||
}
|
||||
this.annotationLayer.render(this.viewport, 'display');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue