Add a route-D PDF backend smoke example

This commit is contained in:
gloamxun committed 2026-10-20 18:16:55 +08:00
1 parent eac5bd649a
commit 8b33051355
1 file changed
+49
+49
View File
@@ -0,0 +1,49 @@
//! Emit a small route-D PDF with text, a rule, an image XObject, and a link.
//!
//! Run with `cargo run -p texrra-tex-core --example pdf_display > /tmp/route-d.pdf`.
use texrra_tex_core::render::{DisplayItem, DisplayList, PdfImage};
fn main() {
let mut list = DisplayList {
width: 612 * 65_536,
height: 792 * 65_536,
items: Vec::new(),
images: Vec::new(),
};
list.push(DisplayItem::Text {
x: 72 * 65_536,
y: 100 * 65_536,
size: 12 * 65_536,
text: "route-D XObject".to_string(),
});
list.push(DisplayItem::Rule {
x: 72 * 65_536,
y: 120 * 65_536,
width: 200 * 65_536,
height: 2 * 65_536,
});
let index = list.add_image(PdfImage {
width: 2,
height: 2,
rgb: vec![255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 0],
});
list.push(DisplayItem::Image {
x: 72 * 65_536,
y: 150 * 65_536,
width: 40 * 65_536,
height: 40 * 65_536,
index,
});
list.link(
72 * 65_536,
220 * 65_536,
120 * 65_536,
12 * 65_536,
"https://example.com/route-d",
);
let pdf = texrra_tex_core::pdf::display_list_to_pdf(&list, 792 * 65_536);
use std::io::Write;
std::io::stdout().write_all(&pdf).expect("write pdf");
}