Skip to content

ViewPdf

The ViewPdf component displays PDF documents using an iframe. It supports PDF files from URLs, base64 encoded strings, or data URIs.

The component automatically detects the format of the input and handles it appropriately.

import { ViewPdf } from '@fintech-sandpit/ui/react';
// With URL
const pdfUrl = 'https://example.com/document.pdf';
return (
<ViewPdf src={pdfUrl} />
);

You can also use base64 encoded PDF strings:

import { ViewPdf } from '@fintech-sandpit/ui/react';
// With base64 (without data URI prefix)
const pdfBase64 = 'JVBERi0xLjQKJeLjz9MK...';
return (
<ViewPdf src={pdfBase64} />
);
// With data URI
const pdfDataUri = 'data:application/pdf;base64,JVBERi0xLjQKJeLjz9MK...';
return (
<ViewPdf src={pdfDataUri} />
);
NameTypeRequiredDefaultDescription
srcstringYesThe PDF source. Can be a URL, base64 string, or data URI. The component automatically detects the format.
titlestringNoPDF documentThe title of the PDF document.