Inject raw PDF specials from display lists

This commit is contained in:
gloamxun committed 2026-10-20 18:15:42 +08:00
1 parent da7f580bf0
commit eac5bd649a
4 files changed
+32

No files matched your search

+13
View File
@@ -38,6 +38,7 @@ pub enum DisplayItem {
height: i64,
url: String,
},
Special(String),
}
/// A raw RGB image that can be painted as a PDF XObject.
@@ -62,6 +63,10 @@ impl DisplayList {
self.items.push(item);
}
pub fn special(&mut self, content: &str) {
self.items.push(DisplayItem::Special(content.to_string()));
}
pub fn link(&mut self, x: i64, y: i64, width: i64, height: i64, url: &str) {
self.items.push(DisplayItem::Link {
x,
@@ -93,6 +98,7 @@ impl DisplayList {
*x += dx;
*y += dy;
}
DisplayItem::Special(_) => {}
}
}
}
@@ -145,6 +151,13 @@ impl DisplayList {
"
));
}
DisplayItem::Special(content) => {
out.push_str(&format!(
"<!-- special: {} -->
",
escape(content)
));
}
DisplayItem::Image {
x,
y,