## class: `WyPdfViewer`, `wy-pdf-viewer`

PDF Viewer component based on pdf.js examples.

### Fields

| Name                  | Type                                | Default                                     | Description                                          | Inherited From |
| --------------------- | ----------------------------------- | ------------------------------------------- | ---------------------------------------------------- | -------------- |
| `MAX_CANVAS_PIXELS`   | `number`                            | `0`                                         |                                                      |                |
| `TEXT_LAYER_MODE`     | `number`                            | `0`                                         |                                                      |                |
| `MAX_IMAGE_SIZE`      | `number`                            | `-1`                                        |                                                      |                |
| `CMAP_URL`            | `URL \| undefined`                  |                                             |                                                      |                |
| `CMAP_PACKED`         | `boolean`                           | `true`                                      |                                                      |                |
| `DEFAULT_SCALE_DELTA` | `number`                            | `1.1`                                       |                                                      |                |
| `MIN_SCALE`           | `number`                            | `0.25`                                      |                                                      |                |
| `MAX_SCALE`           | `number`                            | `10.0`                                      |                                                      |                |
| `DEFAULT_SCALE_VALUE` | `string`                            | `"auto"`                                    |                                                      |                |
| `ENABLE_XFA`          | `boolean`                           | `true`                                      |                                                      |                |
| `DEFAULT_WORKER_URL`  | `string`                            | `"/pdfjs/pdf.worker.min.mjs"`               |                                                      |                |
| `DEFAULT_CMAPS_URL`   | `string`                            | `"/pdfjs/cmaps/"`                           |                                                      |                |
| `DEFAULT_WASM_URL`    | `string`                            | `"/pdfjs/wasm/"`                            |                                                      |                |
| `DEFAULT_ICC_URL`     | `string`                            | `"/pdfjs/iccs/"`                            |                                                      |                |
| `DEFAULT_FONTS_URL`   | `string`                            | `"/pdfjs/fonts/"`                           |                                                      |                |
| `WORKER_URL`          | `URL \| undefined`                  |                                             |                                                      |                |
| `WASM_URL`            | `URL \| undefined`                  |                                             |                                                      |                |
| `ICC_URL`             | `URL \| undefined`                  |                                             |                                                      |                |
| `FONTS_URL`           | `URL \| undefined`                  |                                             |                                                      |                |
| `src`                 | `string \| undefined`               |                                             | Source URL for the PDF to display.                   |                |
| `size`                | `number \| undefined`               |                                             | The length of the pdf file, used to enhance loading. |                |
| `pdfDocument`         | `PDFDocumentProxy \| undefined`     |                                             |                                                      |                |
| `progress`            | `OnProgressParameters \| undefined` | `{ loaded: NaN, total: NaN, percent: NaN }` |                                                      |                |

### Methods

| Name         | Description                                                    | Parameters                | Return | Inherited From |
| ------------ | -------------------------------------------------------------- | ------------------------- | ------ | -------------- |
| `setPage`    | Navigate to the provided page number.                          | `pageNumber: number`      |        |                |
| `zoomIn`     | Increase zoom level by the configured delta.                   | `ticks: number`           |        |                |
| `zoomOut`    | Decrease zoom level by the configured delta.                   | `ticks: number`           |        |                |
| `setScale`   | Apply an absolute zoom level or named scale preset.            | `scale: number \| string` |        |                |
| `updatePage` | Validate and update the current page based on the input value. |                           |        |                |
| `select`     | Select all text inside an input, aiding quick replacement.     | `e: Event`                |        |                |
| `fitToPage`  | Fit the PDF to the current viewport height.                    |                           |        |                |
| `fitToWidth` | Fit the PDF to the current viewport width.                     |                           |        |                |
| `updateZoom` | Validate and persist zoom level from the input field.          |                           |        |                |

### Events

| Name                  | Type                         | Description                            | Inherited From |
| --------------------- | ---------------------------- | -------------------------------------- | -------------- |
| `file-preview-loaded` | `FilePreviewLoadedEventType` | The file preview is considered loaded. |                |

### Attributes

| Name   | Field | Inherited From |
| ------ | ----- | -------------- |
| `src`  | src   |                |
| `size` | size  |                |

### CSS Parts

| Name                     | Description                              |
| ------------------------ | ---------------------------------------- |
| `wy-toolbars-bottom`     | Bottom toolbar wrapper.                  |
| `wy-toolbar`             | Toolbar container.                       |
| `wy-toolbar-center`      | Centered toolbar area.                   |
| `wy-toolbar-buttons`     | Button group inside toolbar.             |
| `wy-input`               | Inputs in toolbars (page number / zoom). |
| `wy-toolbar-center-text` | Centered text in toolbar.                |
| `wy-toolbar-text`        | Text elements in the toolbar.            |
| `wy-pdf-container`       | Viewer container for PDF pages.          |

<details><summary>Private API</summary>

### Fields

| Name             | Privacy   | Type                                  | Default                                                                                                                                                                                                                                                                                                                                   | Description | Inherited From |
| ---------------- | --------- | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------------- |
| `pdfLoadingTask` | protected | `PDFDocumentLoadingTask \| undefined` |                                                                                                                                                                                                                                                                                                                                           |             |                |
| `delayedResize`  | protected | `number \| undefined`                 |                                                                                                                                                                                                                                                                                                                                           |             |                |
| `resizer`        | protected | `ResizeObserver`                      | `new ResizeObserver(() => { if (this.pdfViewer) { if (this.delayedResize) { clearTimeout(this.delayedResize); this.delayedResize = undefined; } this.delayedResize = window.setTimeout(() => { if (this.pdfViewer) { // Update/Set scale this.pdfViewer.currentScaleValue = this.pdfViewer._currentScaleValue as string; } }, 100); } })` |             |                |

### Methods

| Name             | Privacy   | Description                                                   | Parameters | Return    | Inherited From |
| ---------------- | --------- | ------------------------------------------------------------- | ---------- | --------- | -------------- |
| `dispatchLoaded` | protected | Emit \`file-preview-loaded\` once the viewer has initialized. |            | `boolean` |                |

</details>

<hr/>

## Exports

| Kind                        | Name            | Declaration | Module                          | Package |
| --------------------------- | --------------- | ----------- | ------------------------------- | ------- |
| `js`                        | `WyPdfViewer`   | WyPdfViewer | lib/components/wy-pdf-viewer.ts |         |
| `custom-element-definition` | `wy-pdf-viewer` | WyPdfViewer | lib/components/wy-pdf-viewer.ts |         |
