leptos-pdf-0.1.0 has been yanked.
leptos-pdf
leptos-pdf is a lightweight Leptos component library for rendering and viewing PDF files directly in your browser using PDF.js.
It provides an idiomatic Leptos interface for embedding PDFs in your Rust + WebAssembly applications - complete with canvas-based renderings, text selection, and reactive props for paging and scaling.
Installation
Add leptos-pdf to your Leptos project:
cargo add leptos-pdf
Example
use *;
use PdfRenderer;
Will render the /public/sample.pdf PDF file in your browser.
PdfRenderer
The main component, PdfRenderer, handles fetching, rendering, and optionally displaying a selectable text layer on top of the PDF page.
Props
| Prop | Type | Description |
|---|---|---|
url |
String |
The source URL or path of the PDF to render. |
page |
MaybeSignal<usize> |
(optional) The current page number to display. |
scale |
MaybeSignal<f32> |
(optional) Scale factor for zooming in/out of the page. |
text |
MaybeSignal<bool> |
(optional) Enables a selectable text layer overlay using PDF.js's text extraction. |