Mark canvasContext as optional

In #20016, the `canvasContext` property of `RenderParameters` was deprecated in favor of the new `canvas` property.

The JSDoc was updated to include the new parameter along with the old one.

I think the old one should be enclosed in `[]` to mark it as optional (and to allow usage from TypeScript with just the `canvas` parameter provided).

I also reordered the properties so that all required properties come first, follow by optional ones.
This commit is contained in:
Knut Hühne 2025-08-06 12:38:30 +02:00 committed by GitHub
parent fcf69d8536
commit 760c8d632c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1182,16 +1182,16 @@ class PDFDocumentProxy {
* Page render parameters. * Page render parameters.
* *
* @typedef {Object} RenderParameters * @typedef {Object} RenderParameters
* @property {CanvasRenderingContext2D} canvasContext - 2D context of a DOM
* Canvas object for backwards compatibility; it is recommended to use the
* `canvas` parameter instead.
* If the context must absolutely be used to render the page, the canvas must
* be null.
* @property {HTMLCanvasElement|null} canvas - A DOM Canvas object. The default * @property {HTMLCanvasElement|null} canvas - A DOM Canvas object. The default
* value is the canvas associated with the `canvasContext` parameter if no * value is the canvas associated with the `canvasContext` parameter if no
* value is provided explicitly. * value is provided explicitly.
* @property {PageViewport} viewport - Rendering viewport obtained by calling * @property {PageViewport} viewport - Rendering viewport obtained by calling
* the `PDFPageProxy.getViewport` method. * the `PDFPageProxy.getViewport` method.
* @property {CanvasRenderingContext2D} [canvasContext] - 2D context of a DOM
* Canvas object for backwards compatibility; it is recommended to use the
* `canvas` parameter instead.
* If the context must absolutely be used to render the page, the canvas must
* be null.
* @property {string} [intent] - Rendering intent, can be 'display', 'print', * @property {string} [intent] - Rendering intent, can be 'display', 'print',
* or 'any'. The default value is 'display'. * or 'any'. The default value is 'display'.
* @property {number} [annotationMode] Controls which annotations are rendered * @property {number} [annotationMode] Controls which annotations are rendered