<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>pdfrs WASM Demo</title>
<style>
body { font-family: sans-serif; max-width: 800px; margin: 2rem auto; padding: 0 1rem; }
textarea { width: 100%; height: 200px; font-family: monospace; }
button { padding: 0.5rem 1rem; font-size: 1rem; margin-top: 0.5rem; }
</style>
</head>
<body>
<h1>pdfrs WASM Demo</h1>
<p>Enter Markdown below and click <strong>Generate PDF</strong>:</p>
<textarea id="input"># Hello from WASM
This PDF was generated entirely in your browser using **pdfrs**.
## Features
- No server required
- Pure Rust compiled to WebAssembly
- *Italic* and **bold** text
- Unicode: α β γ δ ε 中文
```rust
fn main() {
println!("Hello, WebAssembly!");
}
```
</textarea>
<br>
<button id="generate">Generate PDF</button>
<script type="module">
import init, { render_markdown_to_pdf } from './pkg/pdfrs.js';
await init();
document.getElementById('generate').addEventListener('click', () => {
const md = document.getElementById('input').value;
const pdfBytes = render_markdown_to_pdf(md);
const blob = new Blob([pdfBytes], { type: 'application/pdf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'output.pdf';
a.click();
URL.revokeObjectURL(url);
});
</script>
</body>
</html>