Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

M4: Organize extras: split by top-level bookmarks (named after them) and by file size; Extract options (separate files, delete after extracting); Rotate Pages dialog with range, even/odd and landscape/portrait filters; Organize ▸ Select odd/even/landscape/portrait; doc_split bookmarks/max_mb, page_extract separate/delete, page_rotate subset/orientation

Brandon Thomasdfc940b8f1ba
diff --git a/crates/automation/src/lib.rs b/crates/automation/src/lib.rs
index 889a35252..b697ba672 100644
--- a/crates/automation/src/lib.rs
+++ b/crates/automation/src/lib.rs
@@ -137,8 +137,31 @@ impl Automation {
if degrees % 90 != 0 {
return Err(ToolError::InvalidArgs("degrees must be a multiple of 90".into()));
}
- let pages = self.pages(&a, "pages")?;
- self.apply(&a, Edit::RotatePages { pages, degrees })?
+ let doc = self.doc(&a)?;
+ let base = match a.opt_ints("pages")? {
+ Some(_) => self.pages(&a, "pages")?,
+ None => (0..doc.info.pages.len()).collect(),
+ };
+ let parity = match a.opt_str("subset")?.unwrap_or("all") {
+ "all" => printcraft_engine::PageParity::Both,
+ "even" => printcraft_engine::PageParity::Even,
+ "odd" => printcraft_engine::PageParity::Odd,
+ s => return Err(ToolError::InvalidArgs(format!("unknown subset {s:?} (all, even, odd)"))),
+ };
+ let orientation = match a.opt_str("orientation")?.unwrap_or("all") {
+ "all" => printcraft_engine::PageOrientation::Both,
+ "landscape" => printcraft_engine::PageOrientation::Landscape,
+ "portrait" => printcraft_engine::PageOrientation::Portrait,
+ o => return Err(ToolError::InvalidArgs(format!("unknown orientation {o:?} (all, landscape, portrait)"))),
+ };
+ let pages = printcraft_engine::filter_pages(&self.doc(&a)?.info, &base, parity, orientation);
+ if pages.is_empty() {
+ return Err(failed("no pages match the filters"));
+ }
+ let n = pages.len();
+ let mut out = self.apply(&a, Edit::RotatePages { pages, degrees })?;
+ out["rotated"] = json!(n);
+ out
}
"page_delete" => {
let pages = self.pages(&a, "pages")?;
@@ -591,9 +614,29 @@ impl Automation {
fn page_extract(&mut self, a: &Args) -> Result<Value> {
let doc = self.doc(a)?;
let (id, name) = (doc.id, format!("{} (extract)", doc.name));
+ let stem = Path::new(&doc.name).file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or_else(|| "page".into());
let pages = self.pages(a, "pages")?;
- let bytes = self.session.extract(id, &pages).map_err(failed)?;
- self.deliver(a, &name, bytes)
+ let mut out = if a.opt_bool("separate")?.unwrap_or(false) {
+ // Each page as its own file.
+ let dir = self.resolve(a.str("out_dir").map_err(|_| ToolError::InvalidArgs("separate files need out_dir".into()))?, true)?;
+ std::fs::create_dir_all(&dir).map_err(|e| failed(format!("{}: {e}", dir.display())))?;
+ let mut files = Vec::new();
+ for &p in &pages {
+ let bytes = self.session.extract(id, &[p]).map_err(failed)?;
+ let path = dir.join(format!("{stem}-page{}.pdf", p + 1));
+ write_atomic(&path, &bytes)?;
+ files.push(path.to_string_lossy().into_owned());
+ }
+ json!({ "files": files })
+ } else {
+ let bytes = self.session.extract(id, &pages).map_err(failed)?;
+ self.deliver(a, &name, bytes)?
+ };
+ if a.opt_bool("delete")?.unwrap_or(false) {
+ let deleted = self.apply(a, Edit::DeletePages { pages })?;
+ out["original"] = deleted;
+ }
+ Ok(out)
}
fn doc_combine(&mut self, a: &Args) -> Result<Value> {
@@ -616,17 +659,45 @@ impl Automation {
let doc = self.doc(a)?;
let id = doc.id;
let stem = Path::new(&doc.name).file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or_else(|| "part".into());
- let by = match (a.opt_int("every")?, a.opt_ints("before")?) {
- (Some(n), None) if n > 0 => printcraft_organize::SplitBy::PageCount(n as usize),
- (None, Some(b)) => printcraft_organize::SplitBy::Before(one_based(&b)?),
- _ => return Err(ToolError::InvalidArgs("pass exactly one of every (a positive page count) or before (page numbers)".into())),
+ let bookmarks = a.opt_bool("bookmarks")?.unwrap_or(false);
+ let max_mb = a.opt_num("max_mb")?;
+ let chosen = [a.get("every").is_some(), a.get("before").is_some(), bookmarks, max_mb.is_some()].iter().filter(|x| **x).count();
+ if chosen != 1 {
+ return Err(ToolError::InvalidArgs(
+ "pass exactly one of every (pages per file), before (page numbers), bookmarks: true, or max_mb".into(),
+ ));
+ }
+ let mut titles: Vec<(usize, String)> = Vec::new();
+ let parts = if let Some(mb) = max_mb {
+ if !mb.is_finite() || mb <= 0.0 {
+ return Err(ToolError::InvalidArgs("max_mb must be positive".into()));
+ }
+ self.session.split_by_size(id, (mb * 1_048_576.0) as usize).map_err(failed)?
+ } else {
+ let by = match (a.opt_int("every")?, a.opt_ints("before")?) {
+ (Some(n), None) if n > 0 => printcraft_organize::SplitBy::PageCount(n as usize),
+ (None, Some(b)) => printcraft_organize::SplitBy::Before(one_based(&b)?),
+ _ if bookmarks => {
+ titles = self.session.bookmark_splits(id);
+ if titles.is_empty() {
+ return Err(failed("the document has no top-level bookmarks"));
+ }
+ printcraft_organize::SplitBy::Before(titles.iter().map(|t| t.0).collect())
+ }
+ _ => return Err(ToolError::InvalidArgs("every must be a positive page count".into())),
+ };
+ self.session.split(id, &by).map_err(failed)?
};
let dir = self.resolve(a.str("out_dir")?, true)?;
std::fs::create_dir_all(&dir).map_err(|e| failed(format!("{}: {e}", dir.display())))?;
- let parts = self.session.split(id, &by).map_err(failed)?;
let mut files = Vec::new();
for (i, (first, last, bytes)) in parts.iter().enumerate() {
- let path = dir.join(format!("{stem}-part{}.pdf", i + 1));
+ let safe = |t: &str| t.chars().map(|c| if c.is_alphanumeric() || " -_.,()".contains(c) { c } else { '_' }).collect::<String>();
+ let file = match titles.iter().find(|t| t.0 + 1 == *first) {
+ Some((_, t)) => format!("{stem}-{}.pdf", safe(t)),
+ None => format!("{stem}-part{}.pdf", i + 1),
+ };
+ let path = dir.join(file);
write_atomic(&path, bytes)?;
files.push(json!({ "path": path.to_string_lossy(), "first_page": first, "last_page": last }));
}
diff --git a/crates/automation/src/tools.rs b/crates/automation/src/tools.rs
index e49349329..9facd1e84 100644
--- a/crates/automation/src/tools.rs
+++ b/crates/automation/src/tools.rs
@@ -138,9 +138,16 @@ pub fn tools() -> Vec<ToolDef> {
.ro()
.cmd("edit.find")
.with(schema(json!({ "doc": doc(), "query": { "type": "string", "minLength": 1 }, "limit": { "type": "integer", "minimum": 1, "description": "Maximum matches (default 500)." } }), &["doc", "query"])),
- t("page_rotate", "Rotate pages", "Rotate pages by a multiple of 90 degrees (positive is clockwise). Undoable.")
+ t("page_rotate", "Rotate pages", "Rotate pages by a multiple of 90 degrees (positive is clockwise): the listed pages (default all), filtered like Acrobat's Rotate Pages by subset (all, even, odd page numbers) and orientation (all, landscape, portrait). Undoable.")
.cmd("page.rotate")
- .with(schema(json!({ "doc": doc(), "pages": pages("to rotate"), "degrees": { "type": "integer" } }), &["doc", "pages", "degrees"])),
+ .with(schema(
+ json!({
+ "doc": doc(), "pages": pages("to rotate (default: all)"), "degrees": { "type": "integer" },
+ "subset": { "type": "string", "enum": ["all", "even", "odd"] },
+ "orientation": { "type": "string", "enum": ["all", "landscape", "portrait"] },
+ }),
+ &["doc", "degrees"],
+ )),
t("page_delete", "Delete pages", "Delete pages. Undoable until saved.")
.destructive()
.cmd("page.delete")
@@ -158,16 +165,19 @@ pub fn tools() -> Vec<ToolDef> {
t("page_insert_file", "Insert pages from a file", "Insert pages of another PDF so the first becomes page `at`. Undoable.")
.cmd("page.insert")
.with(schema(json!({ "doc": doc(), "path": { "type": "string" }, "at": { "type": "integer", "minimum": 1 }, "pages": pages("of the source file (default: all)") }), &["doc", "path", "at"])),
- t("page_extract", "Extract pages", "Copy pages into a new PDF (links, bookmarks, fields and layers that belong to them come along).")
+ t("page_extract", "Extract pages", "Copy pages into a new PDF (links, bookmarks, fields and layers that belong to them come along). separate: true writes each page as its own file into out_dir; delete: true removes the pages from this document afterwards (undoable).")
.cmd("page.extract")
- .with(schema(json!({ "doc": doc(), "pages": pages("to extract"), "out": save_out.clone(), "open": open.clone() }), &["doc", "pages"])),
+ .with(schema(
+ json!({ "doc": doc(), "pages": pages("to extract"), "out": save_out.clone(), "open": open.clone(), "separate": { "type": "boolean" }, "out_dir": { "type": "string" }, "delete": { "type": "boolean" } }),
+ &["doc", "pages"],
+ )),
t("doc_combine", "Combine files", "Combine PDFs, in order, into one (bookmarks are kept under one entry per file).")
.cmd("page.combine")
.with(schema(json!({ "paths": { "type": "array", "items": { "type": "string" }, "minItems": 2 }, "out": save_out, "open": open }), &["paths"])),
- t("doc_split", "Split a document", "Split into several files, every N pages or before given pages, written to out_dir as <name>-partK.pdf.")
+ t("doc_split", "Split a document", "Split into several files written to out_dir: every N pages, before given pages, at top-level bookmarks (bookmarks: true; files named after them), or by file size (max_mb). Files are <name>-partK.pdf.")
.cmd("page.split")
.with(schema(
- json!({ "doc": doc(), "every": { "type": "integer", "minimum": 1 }, "before": pages("that start a new part"), "out_dir": { "type": "string" } }),
+ json!({ "doc": doc(), "every": { "type": "integer", "minimum": 1 }, "before": pages("that start a new part"), "bookmarks": { "type": "boolean" }, "max_mb": { "type": "number", "exclusiveMinimum": 0 }, "out_dir": { "type": "string" } }),
&["doc", "out_dir"],
)),
t("bookmark_list", "List bookmarks", "The bookmark tree with each bookmark's path, title, target page and open state.")
diff --git a/crates/automation/tests/automation.rs b/crates/automation/tests/automation.rs
index 7e8b7d90e..996d101fe 100644
--- a/crates/automation/tests/automation.rs
+++ b/crates/automation/tests/automation.rs
@@ -825,3 +825,30 @@ fn stamps_through_tools() {
Err(ToolError::InvalidArgs(_))
));
}
+
+#[test]
+fn organizing_with_filters_bookmark_splits_and_extract_options() {
+ let dir = workdir("organize2");
+ let mut a = auto(&dir);
+ let doc = ok(&mut a, "doc_open", json!({ "path": "a.pdf" }))["doc"].as_u64().unwrap();
+ // Rotate the even page numbers only (a.pdf has 3 pages: page 2 is the only even one).
+ let r = ok(&mut a, "page_rotate", json!({ "doc": doc, "degrees": 90, "subset": "even" }));
+ assert_eq!(r["rotated"], 1);
+ let info = ok(&mut a, "doc_info", json!({ "doc": doc }));
+ assert_eq!(info["pages"][1]["rotation"], 90);
+ assert_eq!(info["pages"][0]["rotation"], 0);
+ // Split at top-level bookmarks: parts named after them.
+ ok(&mut a, "bookmark_add", json!({ "doc": doc, "title": "Start", "page": 1 }));
+ ok(&mut a, "bookmark_add", json!({ "doc": doc, "title": "End/Part", "page": 3 }));
+ let s = ok(&mut a, "doc_split", json!({ "doc": doc, "bookmarks": true, "out_dir": "parts" }));
+ let files: Vec<String> =
+ s["files"].as_array().unwrap().iter().map(|f| f["path"].as_str().unwrap().rsplit('/').next().unwrap().to_string()).collect();
+ assert_eq!(files, ["a-Start.pdf", "a-End_Part.pdf"]);
+ let s = ok(&mut a, "doc_split", json!({ "doc": doc, "max_mb": 0.0001, "out_dir": "sized" }));
+ assert_eq!(s["files"].as_array().unwrap().len(), 3, "tiny limit: a page per file");
+ // Extract as separate files and delete them from the original.
+ let e = ok(&mut a, "page_extract", json!({ "doc": doc, "pages": [1, 2], "separate": true, "out_dir": "pages", "delete": true }));
+ assert_eq!(e["files"].as_array().unwrap().len(), 2);
+ assert_eq!(e["original"]["pages"], 1);
+ assert!(matches!(a.call("page_extract", &json!({ "doc": doc, "pages": [1], "separate": true })), Err(ToolError::InvalidArgs(_))));
+}
diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs
index ade571098..5477b42f7 100644
--- a/crates/engine/src/commands.rs
+++ b/crates/engine/src/commands.rs
@@ -236,6 +236,7 @@ pub const COMMANDS: &[CommandSpec] = &[
c("page.rotate_ccw", "Rotate pages counterclockwise", PAGES, None, Assembly, "rotate-ccw"),
c("page.delete", "Delete pages", PAGES, None, Assembly, "trash-2"),
c("page.insert_blank", "Insert blank page", PAGES, None, Assembly, "file-plus"),
+ c("page.rotate_dialog", "Rotate pages…", PAGES, None, Assembly, "rotate-cw"),
c("page.duplicate", "Duplicate pages", PAGES, None, Assembly, "copy-plus"),
c("page.crop", "Crop pages", PAGES, None, Assembly, "crop"),
c("page.boxes", "Set page boxes…", PAGES, None, Assembly, "square-dashed-mouse-pointer"),
diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs
index b524e0f21..a6438f320 100644
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@ -1543,6 +1543,37 @@ impl Session {
.collect()
}
+ /// Split into parts of at most `max_bytes` each (Acrobat's "File size"): pages are taken in
+ /// order while their size (as single-page files, an over-estimate because shared fonts and
+ /// images count once per part) fits; a page larger than the limit is a part of its own.
+ pub fn split_by_size(&self, id: DocId, max_bytes: usize) -> Result<Vec<SplitPart>, EditError> {
+ let src = self.cos(id)?;
+ if src.permissions().is_some_and(|p| !p.assemble()) {
+ return Err(EditError::NotPermitted("splitting the document"));
+ }
+ let n = printcraft_organize::page_count(src)?;
+ let mut cuts = Vec::new();
+ let mut used = 0usize;
+ for p in 0..n {
+ let size = self.write_new(&printcraft_organize::extract_pages(src, &[p])?)?.len();
+ if used > 0 && used + size > max_bytes {
+ cuts.push(p);
+ used = 0;
+ }
+ used += size;
+ }
+ self.split(id, &printcraft_organize::SplitBy::Before(cuts))
+ }
+
+ /// Top-level bookmarks as split points: (first page of each part, its bookmark's title).
+ pub fn bookmark_splits(&self, id: DocId) -> Vec<(usize, String)> {
+ let Some(doc) = self.get(id) else { return Vec::new() };
+ let mut out: Vec<(usize, String)> = doc.info.outline.iter().filter_map(|o| Some((o.page?, o.title.clone()))).collect();
+ out.sort_by_key(|x| x.0);
+ out.dedup_by_key(|x| x.0);
+ out
+ }
+
/// Open freshly created bytes (combine / extract) as a new, unsaved document.
pub fn open_new(&mut self, name: impl Into<String>, bytes: Arc<Vec<u8>>) -> Result<DocId, OpenError> {
let id = self.open(name, None, bytes, None)?;
@@ -1622,3 +1653,43 @@ impl Session {
#[cfg(test)]
mod tests;
+
+/// Page filters of Acrobat's Rotate Pages and page selection: even/odd page numbers and
+/// orientation (as displayed).
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
+pub enum PageParity {
+ #[default]
+ Both,
+ Even,
+ Odd,
+}
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
+pub enum PageOrientation {
+ #[default]
+ Both,
+ Landscape,
+ Portrait,
+}
+
+/// The pages of `pages` (0-based) that pass the filters.
+pub fn filter_pages(info: &printcraft_render::DocInfo, pages: &[usize], parity: PageParity, orientation: PageOrientation) -> Vec<usize> {
+ pages
+ .iter()
+ .copied()
+ .filter(|p| match parity {
+ PageParity::Both => true,
+ // Page numbers are 1-based: index 1 is page 2, an even page.
+ PageParity::Even => p % 2 == 1,
+ PageParity::Odd => p % 2 == 0,
+ })
+ .filter(|p| {
+ let Some(pg) = info.pages.get(*p) else { return false };
+ match orientation {
+ PageOrientation::Both => true,
+ PageOrientation::Landscape => pg.width > pg.height,
+ PageOrientation::Portrait => pg.width <= pg.height,
+ }
+ })
+ .collect()
+}
diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs
index 7ec18c19d..189080ccf 100644
--- a/crates/engine/src/tests.rs
+++ b/crates/engine/src/tests.rs
@@ -940,3 +940,24 @@ fn revert_goes_back_to_the_saved_version() {
assert_eq!(page_texts(&s, id), ["Page 2"], "the saved state, not the opened one");
assert_eq!(d.info.pages[0].rotation, 0);
}
+
+#[test]
+fn split_by_size_and_bookmarks_and_page_filters() {
+ let (mut s, id) = session_with(6);
+ // Every page alone is a few hundred bytes: a limit of about two pages gives three parts.
+ let one = s.split(id, &printcraft_organize::SplitBy::PageCount(1)).unwrap()[0].2.len();
+ let parts = s.split_by_size(id, one * 2 + one / 2).unwrap();
+ assert!(parts.len() >= 2 && parts.len() <= 6, "{}", parts.len());
+ assert_eq!(parts.last().unwrap().1, 6, "every page is in a part");
+ assert_eq!(s.split_by_size(id, 1).unwrap().len(), 6, "pages larger than the limit stand alone");
+ // Top-level bookmarks name the parts.
+ s.apply(id, Edit::AddBookmark { parent: vec![], index: 0, title: "Intro".into(), page: 0 }).unwrap();
+ s.apply(id, Edit::AddBookmark { parent: vec![], index: 1, title: "Results".into(), page: 3 }).unwrap();
+ assert_eq!(s.bookmark_splits(id), [(0, "Intro".to_string()), (3, "Results".to_string())]);
+ // Filters: page numbers 2, 4, 6 are even.
+ let info = &s.get(id).unwrap().info;
+ let all: Vec<usize> = (0..6).collect();
+ assert_eq!(filter_pages(info, &all, PageParity::Even, PageOrientation::Both), [1, 3, 5]);
+ assert_eq!(filter_pages(info, &all, PageParity::Odd, PageOrientation::Landscape), Vec::<usize>::new());
+ assert_eq!(filter_pages(info, &all, PageParity::Odd, PageOrientation::Portrait), [0, 2, 4]);
+}
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 4d09b5321..78c0fcf83 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -1725,6 +1725,29 @@ fn organize_toolbar(view: &mut DocView, info: &DocInfo, editable: bool, ui: &mut
if icons::button(ui, "scissors", 30.0, false, "Split into files…").clicked() {
view.pending_action = Some(ViewAction::Split);
}
+ // Select ▸ all, odd, even, landscape, portrait pages (Acrobat's page range
+ // selection in Organize Pages).
+ let sel = icons::button(ui, "list", 30.0, false, "Select pages");
+ egui::Popup::menu(&sel).show(|ui| {
+ use printcraft_engine::{PageOrientation as O, PageParity as P, filter_pages};
+ let all: Vec<usize> = (0..n).collect();
+ for (label, parity, orient) in [
+ ("All pages", P::Both, O::Both),
+ ("Odd pages", P::Odd, O::Both),
+ ("Even pages", P::Even, O::Both),
+ ("Landscape pages", P::Both, O::Landscape),
+ ("Portrait pages", P::Both, O::Portrait),
+ ] {
+ if ui.button(label).clicked() {
+ view.select_pages(&filter_pages(info, &all, parity, orient));
+ ui.close();
+ }
+ }
+ if ui.button("None").clicked() {
+ view.select_pages(&[]);
+ ui.close();
+ }
+ });
ui.add_space(8.0);
if ui.add_enabled_ui(first > 0, |ui| icons::button(ui, "chevron-left", 30.0, false, "Move earlier")).inner.clicked() {
view.pending_edit = Some(Edit::MovePages { pages: targets.clone(), to: first - 1 });
diff --git a/crates/ui-egui/src/commands.rs b/crates/ui-egui/src/commands.rs
index cf4b7e75d..21e9a21b3 100644
--- a/crates/ui-egui/src/commands.rs
+++ b/crates/ui-egui/src/commands.rs
@@ -327,7 +327,15 @@ impl PrintCraftApp {
self.boxes_draft.seeded = None;
self.dialog = Some(Dialog::PageBoxes);
}
- "page.extract" => self.extract_selection(),
+ "page.extract" => self.dialog = Some(Dialog::Extract),
+ "page.rotate_dialog" => {
+ if let Some(i) = active {
+ let n = self.session.get(self.views[i].id).map_or(1, |d| d.info.pages.len());
+ self.rotate_draft.to = n;
+ self.rotate_draft.which = if self.views[i].selected.is_empty() { 0 } else { 1 };
+ }
+ self.dialog = Some(Dialog::RotatePages);
+ }
"page.split" => self.dialog = Some(Dialog::Split),
"help.shortcuts" => self.dialog = Some(Dialog::Shortcuts),
"help.about" => self.dialog = Some(Dialog::About),
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index c4ca6a3d0..7ab84ad30 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -24,8 +24,10 @@ pub fn show(app: &mut PrintCraftApp, ctx: &egui::Context) {
app.props_draft = Some((id, INFO_KEYS.map(|k| doc.info_value(k).unwrap_or_default())));
}
let mut apply = false;
- let mut split_now: Option<printcraft_engine::SplitBy> = None;
- let mut split_ready: Option<printcraft_engine::SplitBy> = None;
+ let mut split_now: Option<crate::SplitPlan> = None;
+ let mut split_ready: Option<crate::SplitPlan> = None;
+ let mut extract_now = false;
+ let mut rotate_now = false;
let mut recover: Option<bool> = None;
let mut number_now: Option<Edit> = None;
let mut apply_number = false;
@@ -207,33 +209,55 @@ pub fn show(app: &mut PrintCraftApp, ctx: &egui::Context) {
let Some((vi, id)) = app.active_ids() else { return };
let n = app.session.get(id).map(|d| d.info.pages.len()).unwrap_or(0);
let selected: Vec<usize> = app.views[vi].selected.iter().copied().filter(|p| *p > 0).collect();
+ let marks = app.session.bookmark_splits(id);
let draft = &mut app.split_draft;
- if selected.is_empty() {
- draft.at_selection = false;
+ use crate::SplitMode as M;
+ if selected.is_empty() && draft.mode == M::Selection {
+ draft.mode = M::Pages;
}
- ui.radio_value(&mut draft.at_selection, false, "By number of pages");
- ui.add_enabled_ui(!draft.at_selection, |ui| {
+ ui.radio_value(&mut draft.mode, M::Pages, "Number of pages");
+ ui.add_enabled_ui(draft.mode == M::Pages, |ui| {
ui.horizontal(|ui| {
ui.add_space(24.0);
ui.label("Pages per file");
ui.add(egui::DragValue::new(&mut draft.every).range(1..=n.max(1)));
});
});
+ ui.radio_value(&mut draft.mode, M::Size, "File size");
+ ui.add_enabled_ui(draft.mode == M::Size, |ui| {
+ ui.horizontal(|ui| {
+ ui.add_space(24.0);
+ ui.label("At most");
+ ui.add(egui::DragValue::new(&mut draft.size_mb).range(0.05..=2000.0).speed(0.1).suffix(" MB"));
+ });
+ });
+ ui.add_enabled_ui(!marks.is_empty(), |ui| {
+ ui.radio_value(&mut draft.mode, M::Bookmarks, format!("Top-level bookmarks ({})", marks.len()))
+ });
ui.add_enabled_ui(!selected.is_empty(), |ui| {
- ui.radio_value(&mut draft.at_selection, true, "Before each selected page (select pages in Organize)")
+ ui.radio_value(&mut draft.mode, M::Selection, "Before each selected page (select pages in Organize)")
});
- let by = if draft.at_selection {
- printcraft_engine::SplitBy::Before(selected)
- } else {
- printcraft_engine::SplitBy::PageCount(draft.every)
+ let plan = match draft.mode {
+ M::Pages => crate::SplitPlan::By(printcraft_engine::SplitBy::PageCount(draft.every)),
+ M::Selection => crate::SplitPlan::By(printcraft_engine::SplitBy::Before(selected)),
+ M::Size => crate::SplitPlan::Size((draft.size_mb * 1_048_576.0) as usize),
+ M::Bookmarks => crate::SplitPlan::Bookmarks,
+ };
+ let files = match &plan {
+ crate::SplitPlan::By(by) => Some(printcraft_engine::split_ranges(n, by).len()),
+ crate::SplitPlan::Bookmarks => {
+ Some(printcraft_engine::split_ranges(n, &printcraft_engine::SplitBy::Before(marks.iter().map(|m| m.0).collect())).len())
+ }
+ crate::SplitPlan::Size(_) => None,
};
- let files = printcraft_engine::split_ranges(n, &by).len();
ui.add_space(8.0);
- ui.label(
- egui::RichText::new(format!("Creates {files} file{} from {n} pages.", if files == 1 { "" } else { "s" })).color(t.text_muted),
- );
- if files > 1 {
- split_ready = Some(by);
+ let text = match files {
+ Some(f) => format!("Creates {f} file{} from {n} pages.", if f == 1 { "" } else { "s" }),
+ None => format!("Each file holds as many of the {n} pages as fit."),
+ };
+ ui.label(egui::RichText::new(text).color(t.text_muted));
+ if files.is_none_or(|f| f > 1) {
+ split_ready = Some(plan);
}
}
Dialog::ReplacePages => {
@@ -318,6 +342,98 @@ pub fn show(app: &mut PrintCraftApp, ctx: &egui::Context) {
close = ok || cancel;
return;
}
+ Dialog::Extract => {
+ let count = app.active_ids().map_or(0, |(i, _)| app.views[i].target_pages().len());
+ ui.label(egui::RichText::new("Extract pages").font(theme::semibold(18.0)));
+ ui.add_space(8.0);
+ ui.label(format!("{count} page{} selected.", if count == 1 { "" } else { "s" }));
+ ui.checkbox(&mut app.extract_draft.delete, "Delete pages after extracting");
+ ui.checkbox(&mut app.extract_draft.separate, "Extract pages as separate files");
+ ui.add_space(12.0);
+ ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
+ if widgets::pill_button(ui, "Extract", true).clicked() {
+ extract_now = true;
+ close = true;
+ }
+ if widgets::pill_button(ui, "Cancel", false).clicked() {
+ close = true;
+ }
+ });
+ return;
+ }
+ Dialog::RotatePages => {
+ use printcraft_engine::{PageOrientation as O, PageParity as P};
+ let n = app.active_ids().and_then(|(_, id)| app.session.get(id)).map_or(1, |d| d.info.pages.len());
+ let d = &mut app.rotate_draft;
+ ui.label(egui::RichText::new("Rotate Pages").font(theme::semibold(18.0)));
+ ui.add_space(8.0);
+ egui::Grid::new("rotate-pages").num_columns(2).spacing([12.0, 8.0]).show(ui, |ui| {
+ ui.label("Direction:");
+ egui::ComboBox::from_id_salt("rotate-dir")
+ .selected_text(match d.degrees {
+ 270 => "Counterclockwise 90 degrees",
+ 180 => "180 degrees",
+ _ => "Clockwise 90 degrees",
+ })
+ .show_ui(ui, |ui| {
+ ui.selectable_value(&mut d.degrees, 90, "Clockwise 90 degrees");
+ ui.selectable_value(&mut d.degrees, 270, "Counterclockwise 90 degrees");
+ ui.selectable_value(&mut d.degrees, 180, "180 degrees");
+ });
+ ui.end_row();
+ ui.label("Pages:");
+ ui.vertical(|ui| {
+ ui.radio_value(&mut d.which, 0, "All");
+ ui.radio_value(&mut d.which, 1, "Selection");
+ ui.horizontal(|ui| {
+ ui.radio_value(&mut d.which, 2, "From");
+ ui.add_enabled(d.which == 2, egui::DragValue::new(&mut d.from).range(1..=n));
+ ui.label("to");
+ ui.add_enabled(d.which == 2, egui::DragValue::new(&mut d.to).range(1..=n));
+ ui.label(format!("of {n}"));
+ });
+ });
+ ui.end_row();
+ ui.label("Rotate:");
+ egui::ComboBox::from_id_salt("rotate-parity")
+ .selected_text(match d.parity {
+ P::Both => "Even and Odd Pages",
+ P::Even => "Even Pages Only",
+ P::Odd => "Odd Pages Only",
+ })
+ .show_ui(ui, |ui| {
+ ui.selectable_value(&mut d.parity, P::Both, "Even and Odd Pages");
+ ui.selectable_value(&mut d.parity, P::Even, "Even Pages Only");
+ ui.selectable_value(&mut d.parity, P::Odd, "Odd Pages Only");
+ });
+ ui.end_row();
+ ui.label("");
+ egui::ComboBox::from_id_salt("rotate-orient")
+ .selected_text(match d.orientation {
+ O::Both => "Landscape and Portrait Pages",
+ O::Landscape => "Landscape Pages",
+ O::Portrait => "Portrait Pages",
+ })
+ .show_ui(ui, |ui| {
+ ui.selectable_value(&mut d.orientation, O::Both, "Landscape and Portrait Pages");
+ ui.selectable_value(&mut d.orientation, O::Landscape, "Landscape Pages");
+ ui.selectable_value(&mut d.orientation, O::Portrait, "Portrait Pages");
+ });
+ ui.end_row();
+ });
+ d.to = d.to.max(d.from);
+ ui.add_space(12.0);
+ ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
+ if widgets::pill_button(ui, "OK", true).clicked() {
+ rotate_now = true;
+ close = true;
+ }
+ if widgets::pill_button(ui, "Cancel", false).clicked() {
+ close = true;
+ }
+ });
+ return;
+ }
Dialog::Revert => {
let name = app.active_ids().and_then(|(_, id)| app.session.get(id)).map(|d| d.name.clone()).unwrap_or_default();
ui.label(egui::RichText::new("Revert").font(theme::semibold(18.0)));
@@ -630,6 +746,12 @@ pub fn show(app: &mut PrintCraftApp, ctx: &egui::Context) {
if revert_now {
app.revert_active();
}
+ if extract_now {
+ app.extract_selection();
+ }
+ if rotate_now {
+ app.rotate_with_draft();
+ }
match redact_now {
Some(Dialog::RedactPages) => app.redact_pages(),
Some(Dialog::RedactSearch) => {
diff --git a/crates/ui-egui/src/editing.rs b/crates/ui-egui/src/editing.rs
index fa760de9f..6512ac7db 100644
--- a/crates/ui-egui/src/editing.rs
+++ b/crates/ui-egui/src/editing.rs
@@ -99,7 +99,7 @@ impl PrintCraftApp {
}
match self.views.get_mut(i).and_then(|v| v.pending_action.take()) {
Some(crate::canvas::ViewAction::InsertFromFile) => self.insert_from_file_dialog(),
- Some(crate::canvas::ViewAction::Extract) => self.extract_selection(),
+ Some(crate::canvas::ViewAction::Extract) => self.dialog = Some(crate::Dialog::Extract),
Some(crate::canvas::ViewAction::Split) => self.dialog = Some(crate::Dialog::Split),
None => {}
}
diff --git a/crates/ui-egui/src/files.rs b/crates/ui-egui/src/files.rs
index e3d7f54f2..d08649b11 100644
--- a/crates/ui-egui/src/files.rs
+++ b/crates/ui-egui/src/files.rs
@@ -36,8 +36,61 @@ pub type Requests = Arc<std::sync::Mutex<Vec<(FilePurpose, Vec<(String, Vec<u8>)
pub struct SplitDraft {
/// Pages per file.
pub every: usize,
- /// Split before each selected page instead of by count.
- pub at_selection: bool,
+ pub mode: SplitMode,
+ /// The largest part, in megabytes (File size mode).
+ pub size_mb: f64,
+}
+
+impl Default for SplitDraft {
+ fn default() -> Self {
+ SplitDraft { every: 1, mode: SplitMode::Pages, size_mb: 2.0 }
+ }
+}
+
+/// Acrobat's Split by: number of pages, file size, top-level bookmarks (and PrintCraft's
+/// before-selected-pages).
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum SplitMode {
+ Pages,
+ Selection,
+ Size,
+ Bookmarks,
+}
+
+/// What Split does once confirmed.
+#[derive(Clone, Debug, PartialEq)]
+pub enum SplitPlan {
+ By(SplitBy),
+ Size(usize),
+ Bookmarks,
+}
+
+/// Organize ▸ Extract options.
+#[derive(Clone, Debug, Default, PartialEq)]
+pub struct ExtractDraft {
+ /// Each page as its own file.
+ pub separate: bool,
+ /// Delete the pages after extracting them.
+ pub delete: bool,
+}
+
+/// Pages ▸ Rotate Pages.
+#[derive(Clone, Debug, PartialEq)]
+pub struct RotateDraft {
+ /// Degrees clockwise: 90, 180 or 270.
+ pub degrees: i64,
+ /// 0 all pages, 1 the selection, 2 the range below.
+ pub which: u8,
+ pub from: usize,
+ pub to: usize,
+ pub parity: printcraft_engine::PageParity,
+ pub orientation: printcraft_engine::PageOrientation,
+}
+
+impl Default for RotateDraft {
+ fn default() -> Self {
+ RotateDraft { degrees: 90, which: 0, from: 1, to: 1, parity: Default::default(), orientation: Default::default() }
+ }
}
impl PrintCraftApp {
@@ -169,53 +222,125 @@ impl PrintCraftApp {
let Some((i, id)) = self.active_ids() else { return };
let pages = self.views[i].target_pages();
let stem = self.session.get(id).map(|d| strip_pdf(&d.name).to_string()).unwrap_or_default();
- match self.session.extract(id, &pages) {
- Ok(bytes) => self.open_created(&format!("{stem} (extract).pdf"), bytes, &format!("Extracted {} page(s)", pages.len())),
- Err(e) => self.notify(format!("Couldn't extract pages: {e}")),
+ let opts = self.extract_draft.clone();
+ if opts.separate {
+ // Each page as its own file, in a chosen folder.
+ let mut named = Vec::new();
+ for &p in &pages {
+ match self.session.extract(id, &[p]) {
+ Ok(bytes) => named.push((format!("{stem} (page {}).pdf", p + 1), bytes)),
+ Err(e) => {
+ self.notify(format!("Couldn't extract pages: {e}"));
+ return;
+ }
+ }
+ }
+ if self.write_files(&named, "Choose a folder for the extracted pages") == 0 {
+ return;
+ }
+ } else {
+ match self.session.extract(id, &pages) {
+ Ok(bytes) => self.open_created(&format!("{stem} (extract).pdf"), bytes, &format!("Extracted {} page(s)", pages.len())),
+ Err(e) => {
+ self.notify(format!("Couldn't extract pages: {e}"));
+ return;
+ }
+ }
+ }
+ if opts.delete {
+ // Back on the original document.
+ self.active = Some(i);
+ self.apply_edit(printcraft_engine::Edit::DeletePages { pages });
}
}
- /// Split the active document and write the parts: into a chosen folder (desktop) or as
- /// downloads (web). Returns the number of files written.
- pub fn split_active(&mut self, by: &SplitBy) -> usize {
- let Some((_, id)) = self.active_ids() else { return 0 };
- let stem = self.session.get(id).map(|d| strip_pdf(&d.name).to_string()).unwrap_or_else(|| "document".into());
- let parts = match self.session.split(id, by) {
- Ok(p) => p,
- Err(e) => {
- self.notify(format!("Couldn't split: {e}"));
- return 0;
- }
- };
- let named: Vec<(String, Arc<Vec<u8>>)> = parts
- .into_iter()
- .map(|(a, b, bytes)| (if a == b { format!("{stem} (page {a}).pdf") } else { format!("{stem} (pages {a}-{b}).pdf") }, bytes))
- .collect();
+ /// Write named files into a chosen folder (desktop) or as downloads (web). Returns how many.
+ fn write_files(&mut self, named: &[(String, Arc<Vec<u8>>)], title: &str) -> usize {
#[cfg(not(target_arch = "wasm32"))]
{
let dir = match &self.export_dir_override {
Some(d) => Some(std::path::PathBuf::from(d)),
- None => rfd::FileDialog::new().set_title("Choose a folder for the split files").pick_folder(),
+ None => rfd::FileDialog::new().set_title(title).pick_folder(),
};
let Some(dir) = dir else { return 0 };
- for (name, bytes) in &named {
+ for (name, bytes) in named {
if let Err(e) = crate::editing::write_atomically(&dir.join(name).to_string_lossy(), bytes) {
self.notify(format!("Couldn't write {name}: {e}"));
return 0;
}
}
- self.notify(format!("Split into {} files in {}", named.len(), dir.display()));
+ self.notify(format!("Wrote {} file{} to {}", named.len(), if named.len() == 1 { "" } else { "s" }, dir.display()));
}
#[cfg(target_arch = "wasm32")]
- for (name, bytes) in &named {
- if let Err(e) = crate::editing::download(name, bytes) {
- self.notify(format!("Couldn't download {name}: {e}"));
- return 0;
+ {
+ let _ = title;
+ for (name, bytes) in named {
+ if let Err(e) = crate::editing::download(name, bytes) {
+ self.notify(format!("Couldn't download {name}: {e}"));
+ return 0;
+ }
}
}
named.len()
}
+ /// Pages ▸ Rotate Pages with the dialog's range and filters.
+ pub fn rotate_with_draft(&mut self) {
+ let Some((i, id)) = self.active_ids() else { return };
+ let Some(doc) = self.session.get(id) else { return };
+ let n = doc.info.pages.len();
+ let d = self.rotate_draft.clone();
+ let base: Vec<usize> = match d.which {
+ 1 => self.views[i].target_pages(),
+ 2 => (d.from.max(1) - 1..d.to.min(n)).collect(),
+ _ => (0..n).collect(),
+ };
+ let pages = printcraft_engine::filter_pages(&doc.info, &base, d.parity, d.orientation);
+ if pages.is_empty() {
+ self.notify("No pages match those choices");
+ return;
+ }
+ self.apply_edit(printcraft_engine::Edit::RotatePages { pages, degrees: d.degrees });
+ }
+
+ /// Split the active document and write the parts: into a chosen folder (desktop) or as
+ /// downloads (web). Returns the number of files written.
+ pub fn split_active(&mut self, plan: &SplitPlan) -> usize {
+ let Some((_, id)) = self.active_ids() else { return 0 };
+ let stem = self.session.get(id).map(|d| strip_pdf(&d.name).to_string()).unwrap_or_else(|| "document".into());
+ let (parts, titles) = match plan {
+ SplitPlan::By(by) => (self.session.split(id, by), Vec::new()),
+ SplitPlan::Size(max) => (self.session.split_by_size(id, *max), Vec::new()),
+ SplitPlan::Bookmarks => {
+ let marks = self.session.bookmark_splits(id);
+ let cuts: Vec<usize> = marks.iter().map(|m| m.0).collect();
+ (self.session.split(id, &SplitBy::Before(cuts)), marks)
+ }
+ };
+ let parts = match parts {
+ Ok(p) => p,
+ Err(e) => {
+ self.notify(format!("Couldn't split: {e}"));
+ return 0;
+ }
+ };
+ let safe = |t: &str| t.chars().map(|c| if c.is_alphanumeric() || " -_.,()".contains(c) { c } else { '_' }).collect::<String>();
+ let named: Vec<(String, Arc<Vec<u8>>)> = parts
+ .into_iter()
+ .map(|(a, b, bytes)| {
+ // Bookmark splits are named after the bookmark that starts the part.
+ let title = titles.iter().find(|(p, _)| *p + 1 == a).map(|(_, t)| safe(t));
+ let name = match title {
+ Some(t) => format!("{stem} - {t}.pdf"),
+ None if a == b => format!("{stem} (page {a}).pdf"),
+ None => format!("{stem} (pages {a}-{b}).pdf"),
+ };
+ (name, bytes)
+ })
+ .collect();
+ self.write_files(&named, "Choose a folder for the split files")
+ }
+
fn open_created(&mut self, name: &str, bytes: Arc<Vec<u8>>, message: &str) {
match self.session.open_new(name, bytes) {
Ok(id) => {
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index b2d1b7a95..e8974cd56 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -46,7 +46,7 @@ use printcraft_engine::{DocId, Session};
pub use canvas::DocView;
pub use editing::{CloseRequest, SaveTarget};
-pub use files::{FilePurpose, SplitDraft};
+pub use files::{ExtractDraft, FilePurpose, RotateDraft, SplitDraft, SplitMode, SplitPlan};
pub use recovery::{AUTOSAVE_SECS, RecoveryMeta, RecoveryStore};
use theme::ThemeKind;
@@ -132,6 +132,9 @@ pub enum Dialog {
Print,
/// File ▸ Revert confirmation.
Revert,
+ /// Organize ▸ Extract (options), Rotate Pages.
+ Extract,
+ RotatePages,
/// Remove Hidden Information and Sanitize Document.
RemoveHidden,
Sanitize,
@@ -205,6 +208,8 @@ pub struct PrintCraftApp {
pub export_dir_override: Option<String>,
/// Split dialog settings.
pub split_draft: SplitDraft,
+ pub extract_draft: ExtractDraft,
+ pub rotate_draft: RotateDraft,
/// Where autosaves go (`None`: autosave off, e.g. on the web and in tests).
pub recovery: Option<RecoveryStore>,
/// Entries left by a previous session, offered in the Recovery dialog.
@@ -299,7 +304,9 @@ impl PrintCraftApp {
props_draft: None,
requests: Default::default(),
export_dir_override: None,
- split_draft: SplitDraft { every: 1, at_selection: false },
+ split_draft: SplitDraft::default(),
+ extract_draft: ExtractDraft::default(),
+ rotate_draft: RotateDraft::default(),
recovery: None,
recoverable: Vec::new(),
recovery_keys: Default::default(),
diff --git a/crates/ui-egui/tests/editing.rs b/crates/ui-egui/tests/editing.rs
index e1e5625b6..416a70d08 100644
--- a/crates/ui-egui/tests/editing.rs
+++ b/crates/ui-egui/tests/editing.rs
@@ -341,6 +341,9 @@ fn extract_button_copies_selected_pages_to_a_new_tab() {
h.run_steps(2);
h.get_by_label("Extract pages to a new document").click();
h.run_steps(3);
+ h.get_by_label("2 pages selected.");
+ h.get_all_by_label("Extract").last().unwrap().click();
+ h.run_steps(3);
let app = h.state();
assert_eq!(app.views.len(), 2);
assert_eq!(texts_of(app, 1), ["Page 2", "Page 3"]);
@@ -392,7 +395,7 @@ fn split_before_selected_pages() {
let mut h = organize(4);
h.state_mut().export_dir_override = Some(dir.to_string_lossy().into_owned());
h.state_mut().views[0].select_pages(&[2]);
- h.state_mut().split_draft.at_selection = true;
+ h.state_mut().split_draft.mode = printcraft_ui_egui::SplitMode::Selection;
h.state_mut().run_command("page.split");
h.run_steps(3);
h.get_by_label_contains("Creates 2 files from 4 pages");
@@ -484,3 +487,33 @@ fn replace_pages_dialog_swaps_page_content() {
assert_eq!(doc.info.pages.len(), 3);
assert_eq!(doc.can_undo(), Some("Replace page"));
}
+
+#[test]
+fn extract_options_and_rotate_pages_dialog() {
+ let dir = temp_path("extract-sep");
+ let _ = std::fs::remove_dir_all(&dir);
+ std::fs::create_dir_all(&dir).unwrap();
+ let mut h = organize(4);
+ h.state_mut().export_dir_override = Some(dir.to_string_lossy().into_owned());
+ h.state_mut().views[0].select_pages(&[1, 2]);
+ h.state_mut().run_command("page.extract");
+ h.run_steps(2);
+ h.state_mut().extract_draft = printcraft_ui_egui::ExtractDraft { separate: true, delete: true };
+ h.get_all_by_label("Extract").last().unwrap().click();
+ h.run_steps(3);
+ let mut names: Vec<String> = std::fs::read_dir(&dir).unwrap().map(|e| e.unwrap().file_name().to_string_lossy().into_owned()).collect();
+ names.sort();
+ assert_eq!(names, ["doc (page 2).pdf", "doc (page 3).pdf"]);
+ assert_eq!(texts_of(h.state(), 0), ["Page 1", "Page 4"], "deleted after extracting");
+ let _ = std::fs::remove_dir_all(dir);
+ // Rotate Pages: odd page numbers only.
+ h.state_mut().run_command("page.rotate_dialog");
+ h.run_steps(2);
+ h.state_mut().rotate_draft.which = 0;
+ h.state_mut().rotate_draft.parity = printcraft_engine::PageParity::Odd;
+ h.get_by_label("OK").click();
+ h.run_steps(3);
+ let s = h.state();
+ let d = s.session.get(s.views[0].id).unwrap();
+ assert_eq!(d.info.pages.iter().map(|p| p.rotation).collect::<Vec<_>>(), [90, 0]);
+}
diff --git a/parity/acrobat-features.toml b/parity/acrobat-features.toml
index 900e66515..dc057fa6a 100644
--- a/parity/acrobat-features.toml
+++ b/parity/acrobat-features.toml
@@ -2551,11 +2551,11 @@ title = "Rotate by range with even/odd and orientation filters"
area = "D"
tier = "P1"
milestone = "M4"
-status = "planned"
-commands = []
-tools = []
-evidence = []
-notes = ""
+status = "shipped"
+commands = ["page.rotate_dialog"]
+tools = ["page_rotate"]
+evidence = ["crates/ui-egui/tests/editing.rs::extract_options_and_rotate_pages_dialog", "crates/automation/tests/automation.rs::organizing_with_filters_bookmark_splits_and_extract_options", "crates/engine/src/tests.rs::split_by_size_and_bookmarks_and_page_filters"]
+notes = "Rotate Pages: all/selection/range; even/odd; landscape/portrait"
[[feature]]
id = "organize.delete-pages"
@@ -2683,10 +2683,10 @@ title = "Extract pages as separate files"
area = "D"
tier = "P1"
milestone = "M4"
-status = "planned"
-commands = []
-tools = []
-evidence = []
+status = "shipped"
+commands = ["page.extract"]
+tools = ["page_extract"]
+evidence = ["crates/ui-egui/tests/editing.rs::extract_options_and_rotate_pages_dialog", "crates/automation/tests/automation.rs::organizing_with_filters_bookmark_splits_and_extract_options"]
notes = ""
[[feature]]
@@ -2695,11 +2695,11 @@ title = "Delete pages after extracting"
area = "D"
tier = "P1"
milestone = "M4"
-status = "planned"
-commands = []
-tools = []
-evidence = []
-notes = ""
+status = "shipped"
+commands = ["page.extract"]
+tools = ["page_extract"]
+evidence = ["crates/ui-egui/tests/editing.rs::extract_options_and_rotate_pages_dialog", "crates/automation/tests/automation.rs::organizing_with_filters_bookmark_splits_and_extract_options"]
+notes = "undoable"
[[feature]]
id = "organize.replace-pages"
@@ -2767,11 +2767,11 @@ title = "Select by range, odd/even, landscape/portrait"
area = "D"
tier = "P1"
milestone = "M4"
-status = "planned"
-commands = []
-tools = []
-evidence = []
-notes = ""
+status = "partial"
+commands = ["page.organize"]
+tools = ["page_rotate"]
+evidence = ["crates/engine/src/tests.rs::split_by_size_and_bookmarks_and_page_filters"]
+notes = "Organize ▸ Select: all, odd, even, landscape, portrait; ranges via the page tools"
[[feature]]
id = "organize.thumbnail-size"
@@ -2815,11 +2815,11 @@ title = "Split by file size"
area = "D"
tier = "P1"
milestone = "M4"
-status = "planned"
-commands = []
-tools = []
-evidence = []
-notes = ""
+status = "shipped"
+commands = ["page.split"]
+tools = ["doc_split"]
+evidence = ["crates/automation/tests/automation.rs::organizing_with_filters_bookmark_splits_and_extract_options", "crates/engine/src/tests.rs::split_by_size_and_bookmarks_and_page_filters"]
+notes = "greedy by single-page size (an over-estimate: parts stay under the limit)"
[[feature]]
id = "organize.split-by-bookmarks"
@@ -2827,11 +2827,11 @@ title = "Split by top-level bookmarks"
area = "D"
tier = "P1"
milestone = "M4"
-status = "planned"
-commands = []
-tools = []
-evidence = []
-notes = ""
+status = "shipped"
+commands = ["page.split"]
+tools = ["doc_split"]
+evidence = ["crates/automation/tests/automation.rs::organizing_with_filters_bookmark_splits_and_extract_options", "crates/engine/src/tests.rs::split_by_size_and_bookmarks_and_page_filters"]
+notes = "files named after the bookmarks"
[[feature]]
id = "organize.split-naming"