On this page
@addTagHelper *, Webority.Ui.RazorFiles in the page
Show a PDF, image, video or audio file in the page, with paging, zoom, search and print where the file allows.
Sample PDF
An image
No file yet
Audio
Jump to a point
Open a long video or recording at a point a reader names, such as a chapter or a timestamp.
Video from a point
Actions and download
Add a download and your own buttons to the toolbar when a reader needs the file, not only to view it.
Download with a Details action
Every option
Every value of every prop, one cell each.
src
src="/samples/file-viewer-sample.pdf"src="/samples/file-viewer-sample.png"src="/samples/file-viewer-sample.mp4"src="/samples/file-viewer-sample.mp3"src="/samples/notes.docx"no src: draws the frame with No file to showname
name="Quarterly report.pdf"type
type="application/pdf"viewKey
view-key="invoice": keeps the zoom and thumbnails in this browserdownload
download="false" (default)download="true"print="true" (default)print="false"workerSrc
worker-src: a hosted pdf.js worker, for a strict content security policyassetBase
asset-base: the folder of pdf.js cmaps, fonts and wasm, for unusual PDFscaptions
captions="/samples/file-viewer-sample.vtt"actions
no actions (default)one button in an <app-file-viewer-actions> childtwo buttons in an <app-file-viewer-actions> child: Reject and ApproveonLoad
onLoad: the wui-file-viewer:load event, once the file shows, with its kind and page countonError
onError: the wui-file-viewer:error event when the file cannot be openedprefs
no prefs (default): the browser keeps the viewprefs (React form), on Razor use view-keyonPrefsChange
onPrefsChange: the wui-file-viewer:prefs-change event, with all the view settingsclassName
class="file-viewer-tall"ref
ref (React): the element, seekTo(seconds) on an open video or audio file; Razor calls it by idGuidance
What to do, and what to avoid.
Use it when
- Someone needs to read a document without leaving the page: an invoice, a contract, a report.
- A review or approval step, where the decision buttons belong next to the file.
Reach for something else when
- Someone is choosing a file to upload. → AppFilePicker or AppFileAttachment
- The file only needs to be downloaded. → AppButton with an href
Reference
Try every prop, read the full list, and check keyboard and screen reader behaviour.
11 props. The 5 most used come first.
Used on most screens 5 props
| Prop | Type | Default | Description |
|---|---|---|---|
| srcdefault - | string | - | The file's URL. Changing it opens the new file. Without one the viewer draws its frame with a "No file to show." message. |
| namedefault - | string | - | The name shown in the toolbar and used for printing and download. Defaults to the last part of src. |
| typedefault - | string | - | The file's MIME type. Defaults to a guess from the extension of name or src. |
| downloaddefault false | bool | false | Shows a download button in the toolbar. |
| printdefault true | bool | true | Shows the print button for a PDF or an image. Pass false to hide it. |
Less common 6 props
| Prop | Type | Default | Description |
|---|---|---|---|
| view-keydefault - | string | - | Remembers the view settings (zoom, two-page view, thumbnails) in this browser under this key. Without it they last for the viewer's life. |
| worker-srcdefault - | string | - | URL of a hosted pdf.js worker, for a site whose content security policy refuses blob: workers. Defaults to the bundled copy. |
| asset-basedefault beside the viewer script | string | beside the viewer script | Folder holding pdf.js's cmaps/, standard_fonts/ and wasm/, which unusual PDFs need (Asian text, fonts a file does not embed, some scanned images). |
| captionsdefault - | string | - | A WebVTT captions file for a video; adds a captions button to the player. |
| classdefault - | string | - | Extra classes on the element; passes through as a plain HTML attribute. |
| styledefault - | string | - | Inline style on the element. Set a height here to size the viewer. |
Screen reader
3 notes- The toolbar buttons carry accessible names.
- The settings menus use the menu role with menuitemradio rows and respond to the keyboard.
- The React wrapper adds no roles of its own; the element draws the toolbar and the file.