Skip to content

Commit 931e8ac

Browse files
committed
iframetitle added
1 parent 0892a5b commit 931e8ac

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

docs-website/docs/api/component-inputs.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,20 @@ cspNonce = 'random-nonce-value';
427427
The viewer is CSP-compliant by default. The `cspNonce` input is only needed when using `customCSS` with strict Content Security Policy that requires nonces for inline styles.
428428
:::
429429

430+
#### `iframeTitle`
431+
432+
- **Type**: `string`
433+
- **Default**: `'PDF document viewer'`
434+
- **Description**: Accessible title for the iframe element. Improves accessibility for screen readers.
435+
436+
```typescript
437+
// Default accessible title
438+
iframeTitle = undefined; // Uses 'PDF document viewer'
439+
440+
// Custom accessible title
441+
iframeTitle = 'User Manual - Chapter 3';
442+
```
443+
430444
### Advanced Theming
431445

432446
#### `themeConfig`
@@ -443,6 +457,7 @@ interface ThemeConfig {
443457
borderRadius?: string;
444458
customCSS?: string;
445459
cspNonce?: string; // Optional CSP nonce
460+
iframeTitle?: string; // Optional iframe title for accessibility
446461
}
447462

448463
themeConfig: ThemeConfig = {

lib/src/interfaces/ViewerTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export interface ThemeConfig {
120120
borderRadius?: string;
121121
customCSS?: string;
122122
cspNonce?: string; // CSP nonce for customCSS (optional)
123+
iframeTitle?: string; // Accessible title for the iframe (optional)
123124
}
124125

125126
// New event data interfaces for enhanced PDF viewer functionality

lib/src/ng2-pdfjs-viewer.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ import { ChangeOriginTracker } from "./utils/ChangeOriginTracker";
9494
style="position:relative;width:100%;height:100%;"
9595
>
9696
<iframe
97-
title="ng2-pdfjs-viewer"
97+
[title]="iframeTitle || 'PDF document viewer'"
9898
[hidden]="externalWindow || (!externalWindow && !pdfSrc)"
9999
sandbox="allow-forms allow-scripts allow-same-origin allow-modals"
100100
[style.border]="iframeBorder"
@@ -267,7 +267,8 @@ export class PdfJsViewerComponent
267267
@Input() public textColor?: string;
268268
@Input() public borderRadius?: string;
269269
@Input() public customCSS?: string;
270-
@Input() public cspNonce?: string; // CSP nonce for customCSS (optional)
270+
@Input() public cspNonce?: string;
271+
@Input() public iframeTitle?: string; // CSP nonce for customCSS (optional)
271272
// #endregion
272273

273274
// #region Loading & Spinner Customization

0 commit comments

Comments
 (0)