Configuration object
Name of the component
Source of the PDF file. Can be a base64 string, blob URL, data URL, or a function that returns any of these
Optional unique identifier for the component
Optional debounce time in milliseconds for state updates
- The component supports multiple source formats:
- Base64 encoded PDF strings
- Blob URLs (starting with 'blob:')
- Data URLs (starting with 'data:application/pdf;base64,')
- To obtain base64 from various sources, use mwFile helpers such as:
- mwFileFromDrive: For files from drive
- mwFileFromUrl: For files from URLs
- The component is commonly used within a splitView layout
Usage with data URL
pdf({
name: 'pdf-viewer',
src: 'data:application/pdf;base64,base64-encoded-pdf-string'
});
Usage with mwFile helper and splitView
const mwFile = await mwFileFromUrl(
ctx,
'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
);
const splitData = await showUI(
ctx,
splitView(
{title: 'Document Viewer'},
[
pdf({
name: 'pdf',
src: mwFile.base64()
})
],
[
// Other UI components
]
)
);
PDF viewer component for displaying PDF files.