65 lines
1.7 KiB
Rust
Executable File
65 lines
1.7 KiB
Rust
Executable File
//! 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, FontFace, 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: 100 * 65_536,
|
|
y: 140 * 65_536,
|
|
size: 12 * 65_536,
|
|
text: "bold face".to_owned(),
|
|
font: FontFace::Bold,
|
|
});
|
|
list.push(DisplayItem::Text {
|
|
x: 220 * 65_536,
|
|
y: 140 * 65_536,
|
|
size: 12 * 65_536,
|
|
text: "italic face".to_owned(),
|
|
font: FontFace::Italic,
|
|
});
|
|
list.push(DisplayItem::Text {
|
|
x: 72 * 65_536,
|
|
y: 100 * 65_536,
|
|
size: 12 * 65_536,
|
|
text: "route-D XObject".to_string(),
|
|
font: texrra_tex_core::render::FontFace::Roman,
|
|
});
|
|
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");
|
|
}
|