Skip to content

[api-minor] Fix the annotationStorage parameter in PDFPageProxy.render #12173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,8 @@ class PDFPageProxy {
pageIndex: this._pageIndex,
intent: renderingIntent,
renderInteractiveForms: renderInteractiveForms === true,
annotationStorage,
annotationStorage:
(annotationStorage && annotationStorage.getAll()) || null,
});
}

Expand Down
6 changes: 5 additions & 1 deletion web/base_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ class BaseViewer {
const pagesCount = pdfDocument.numPages;
const firstPagePromise = pdfDocument.getPage(1);

const annotationStorage = pdfDocument.annotationStorage;

this._pagesCapability.promise.then(() => {
this.eventBus.dispatch("pagesloaded", {
source: this,
Expand Down Expand Up @@ -481,6 +483,7 @@ class BaseViewer {
eventBus: this.eventBus,
id: pageNum,
scale,
annotationStorage,
defaultViewport: viewport.clone(),
renderingQueue: this.renderingQueue,
textLayerFactory,
Expand Down Expand Up @@ -1153,18 +1156,19 @@ class BaseViewer {
createAnnotationLayerBuilder(
pageDiv,
pdfPage,
annotationStorage = null,
imageResourcesPath = "",
renderInteractiveForms = false,
l10n = NullL10n
) {
return new AnnotationLayerBuilder({
pageDiv,
pdfPage,
annotationStorage,
imageResourcesPath,
renderInteractiveForms,
linkService: this.linkService,
downloadManager: this.downloadManager,
annotationStorage: this.pdfDocument.annotationStorage,
l10n,
});
}
Expand Down
2 changes: 1 addition & 1 deletion web/firefox_print_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function composePage(
transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
viewport: pdfPage.getViewport({ scale: 1, rotation: size.rotation }),
intent: "print",
annotationStorage: pdfDocument.annotationStorage.getAll(),
annotationStorage: pdfDocument.annotationStorage,
};
return pdfPage.render(renderContext).promise;
})
Expand Down
3 changes: 2 additions & 1 deletion web/interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ class IPDFAnnotationLayerFactory {
/**
* @param {HTMLDivElement} pageDiv
* @param {PDFPage} pdfPage
* @param {AnnotationStorage} [annotationStorage]
* @param {AnnotationStorage} [annotationStorage] - Storage for annotation
* data in forms.
* @param {string} [imageResourcesPath] - Path for image resources, mainly
* for annotation icons. Include trailing slash.
* @param {boolean} renderInteractiveForms
Expand Down
4 changes: 4 additions & 0 deletions web/pdf_page_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import { viewerCompatibilityParams } from "./viewer_compatibility.js";
* @property {number} id - The page unique ID (normally its number).
* @property {number} scale - The page scale display.
* @property {PageViewport} defaultViewport - The page viewport.
* @property {AnnotationStorage} [annotationStorage] - Storage for annotation
* data in forms. The default value is `null`.
* @property {PDFRenderingQueue} renderingQueue - The rendering queue object.
* @property {IPDFTextLayerFactory} textLayerFactory
* @property {number} [textLayerMode] - Controls if the text layer used for
Expand Down Expand Up @@ -81,6 +83,7 @@ class PDFPageView {
this.rotation = 0;
this.scale = options.scale || DEFAULT_SCALE;
this.viewport = defaultViewport;
this._annotationStorage = options.annotationStorage || null;
this.pdfPageRotate = defaultViewport.rotation;
this.hasRestrictedScaling = false;
this.textLayerMode = Number.isInteger(options.textLayerMode)
Expand Down Expand Up @@ -533,6 +536,7 @@ class PDFPageView {
this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(
div,
pdfPage,
this._annotationStorage,
this.imageResourcesPath,
this.renderInteractiveForms,
this.l10n
Expand Down
2 changes: 1 addition & 1 deletion web/pdf_print_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function renderPage(
transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
viewport: pdfPage.getViewport({ scale: 1, rotation: size.rotation }),
intent: "print",
annotationStorage: pdfDocument.annotationStorage.getAll(),
annotationStorage: pdfDocument.annotationStorage,
};
return pdfPage.render(renderContext).promise;
})
Expand Down