Skip to main content

max / balanced_breakfast

1.4 KB · 34 lines History Blame Raw
1 //! Render a representative article to a PDF for visual inspection.
2 //! Usage: cargo run -p bb-pdf --example sample -- /path/to/out.pdf
3
4 fn main() {
5 let out = std::env::args()
6 .nth(1)
7 .unwrap_or_else(|| "bb-pdf-sample.pdf".to_string());
8
9 let html = r#"
10 <h1>The Morning Read</h1>
11 <p>This is a <strong>bold</strong> lead paragraph with an <em>italic</em>
12 aside, long enough to force line wrapping across the A5 column so we can
13 see how the body text flows on the Supernote page.</p>
14 <h2>A second-level heading</h2>
15 <p>Ordinary body copy follows, then a list:</p>
16 <ul><li>first bullet item</li><li>second bullet item that runs long enough to wrap onto a second line for good measure</li></ul>
17 <ol><li>numbered one</li><li>numbered two</li></ol>
18 <blockquote>A quoted passage, rendered in italic with a left indent.</blockquote>
19 <h3>Code</h3>
20 <pre><code>fn main() { println!("monospace"); }</code></pre>
21 <p>And a closing paragraph to round things out. Lorem ipsum dolor sit amet,
22 consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.</p>
23 "#;
24
25 let bytes = bb_pdf::render_article(
26 html,
27 "Sample Article",
28 Some("https://example.com/morning-read"),
29 )
30 .expect("render");
31 std::fs::write(&out, &bytes).expect("write");
32 println!("wrote {} ({} bytes)", out, bytes.len());
33 }
34