Write native PDF catalogs and open actions

This commit is contained in:
gloamxun committed 2026-11-19 08:54:04 +08:00
1 parent a53d9c9bf9
commit f4b003bd27
20 files changed
+811 -40

No files matched your search

@@ -0,0 +1,29 @@
//! Job-global additions to the PDF catalog and its initial action.
use super::links::DestinationId;
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct PdfCatalog {
pub(crate) entries: Vec<u8>,
pub(crate) open_action: Option<CatalogAction>,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub(crate) enum CatalogAction {
User(Vec<u8>),
GoTo {
target: CatalogTarget,
file: Option<Vec<u8>>,
window: Option<bool>,
structure: Option<Vec<u8>>,
},
Thread {
destination: DestinationId<String>,
file: Option<Vec<u8>>,
},
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub(crate) enum CatalogTarget {
Destination(DestinationId<String>),
Page { number: i32, view: Vec<u8> },
}
+10 -2
View File
@@ -27,12 +27,20 @@ pub enum DestinationView {
FitBV,
}
#[derive(
Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize,
)]
pub enum DestinationId<T> {
Name(T),
Number(i32),
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub enum LinkNode {
Start(LinkStart),
End,
Destination {
name: Vec<Token>,
destination: DestinationId<Vec<Token>>,
view: DestinationView,
},
}
@@ -53,7 +61,7 @@ pub struct LinkAnnotation {
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct PageDestination {
pub name: String,
pub destination: DestinationId<String>,
pub point: [i64; 2],
pub view: DestinationView,
}