Appearance
Function: pdf()
ts
function pdf(props: PDFBlockProps): Element;Defined in: src/UI/blocks/pdf.tsx:91
PDF viewer component for displaying PDF files.
Parameters
| Parameter | Type | Description |
|---|---|---|
props | PDFBlockProps | Configuration object |
Returns
Element
Examples
ts
- 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 layoutBasic usage with base64 string
pdf({
name: 'pdf-viewer',
src: 'base64-encoded-pdf-string'
});Usage with blob URL
pdf({
name: 'pdf-viewer',
src: 'blob:http://example.com/123-456-789'
});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
]
)
);