Skip to content

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

Merge remote-tracking branch 'upstream/main' into main

Combiler018e95a63e9820
diff --cc crates/automation/src/lib.rs
index 28a194c3e,e94354021..1affe04d3
--- a/crates/automation/src/lib.rs
+++ b/crates/automation/src/lib.rs
@@@ -571,14 -572,9 +572,14 @@@ impl Automation
"flip_horizontal" => ImageEdit::Flip { horizontal: true },
"flip_vertical" => ImageEdit::Flip { horizontal: false },
"delete" => ImageEdit::Delete,
+ "bring_to_front" => ImageEdit::Arrange(pdfcraft_engine::ArrangeOrder::BringToFront),
+ "send_to_back" => ImageEdit::Arrange(pdfcraft_engine::ArrangeOrder::SendToBack),
+ "bring_forward" => ImageEdit::Arrange(pdfcraft_engine::ArrangeOrder::BringForward),
+ "send_backward" => ImageEdit::Arrange(pdfcraft_engine::ArrangeOrder::SendBackward),
+ "remove_crop" => ImageEdit::RemoveCrop,
"replace" => {
let path = self.resolve(a.str("path")?, false)?;
- let bytes = std::fs::read(&path).map_err(|e| failed(format!("{}: {e}", path.display())))?;
+ let bytes = read_input(&path)?;
ImageEdit::Replace {
name: path.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(),
bytes: Arc::new(bytes),
diff --cc crates/edit/src/tests.rs
index 7d4c1e235,3ad46e864..fe2367f4e
--- a/crates/edit/src/tests.rs
+++ b/crates/edit/src/tests.rs
@@@ -7609,47 -6960,418 +7930,463 @@@ fn a_flatten_refused_on_a_later_page_ch
assert_eq!((*doc.get(first)).clone(), before, "the first page keeps its comment and content");
}
+#[test]
+fn arrange_preserves_clip_leaked_out_of_marked_unit() {
+ let content = "/Figure <</MCID 0>> BDC 0 0 300 300 re W n q 10 0 0 10 50 50 cm /Im0 Do Q EMC q 10 0 0 10 400 400 cm /Im0 Do Q";
+ let mut doc = image_page_with(content);
+ let initial = images::page_images(&doc, 0).unwrap();
+ assert_eq!(initial.len(), 2);
+ assert!(initial[0].visible_rect.is_some());
+ assert!(initial[1].visible_rect.is_none(), "second image is fully clipped initially");
+
+ images::arrange_image(&mut doc, 0, 0, images::ArrangeOrder::BringToFront).unwrap();
+ let doc = reopen(&doc);
+ let after = images::page_images(&doc, 0).unwrap();
+ assert_eq!(after.len(), 2);
+ let img1 = after.iter().find(|img| (img.rect[0] - 400.0).abs() < 1e-3).expect("second image exists");
+ assert!(img1.visible_rect.is_none(), "second image must stay clipped after BringToFront");
+
+ // Conflicting leaking transform with leaking clip must be refused
+ let content_cm_clip =
+ "/Figure <</MCID 0>> BDC 2 0 0 2 0 0 cm 0 0 300 300 re W n q 10 0 0 10 50 50 cm /Im0 Do Q EMC q 10 0 0 10 400 400 cm /Im0 Do Q";
+ let mut doc3 = image_page_with(content_cm_clip);
+ let res3 = images::arrange_image(&mut doc3, 0, 0, images::ArrangeOrder::BringToFront);
+ assert!(res3.is_err(), "moving marked unit with both leaking cm and leaking clip must be refused");
+}
+
+#[test]
+fn arrange_preserves_leaked_color_and_text_state() {
+ let content = "/Figure <</MCID 0>> BDC /DeviceRGB cs 1 0 0 sc /F1 14 Tf 2 Tc q 10 0 0 10 50 50 cm /Im0 Do Q EMC 0 0 10 10 re f q 10 0 0 10 200 200 cm /Im0 Do Q";
+ let mut doc = image_page_with(content);
+ images::arrange_image(&mut doc, 0, 0, images::ArrangeOrder::BringToFront).unwrap();
+ let doc = reopen(&doc);
+ let bytes = page_content_bytes(&doc, 0);
+ let s = String::from_utf8_lossy(&bytes);
+ assert!(s.contains("1 0 0 sc"), "sc must be preserved in content stream: {s}");
+ assert!(s.contains("/F1 14 Tf"), "Tf must be preserved in content stream: {s}");
+ assert!(s.contains("2 Tc"), "Tc must be preserved in content stream: {s}");
+
+ // Pixel test: 0 0 10 10 re f still fills red [255, 0, 0] after arrange
+ let pdf_bytes = write_incremental(&doc, &SaveOptions::default()).unwrap();
+ let mut renderer = pdfcraft_render::PageRenderer::new(Arc::new(pdf_bytes), pdfcraft_render::RenderConfig::default());
+ let page =
+ renderer.render(pdfcraft_render::RenderRequest { page: 0, kind: pdfcraft_render::RequestKind::Pixels, scale: 1.0, ..Default::default() });
+ let idx = (((page.height - 5) * page.width + 5) * 4) as usize;
+ assert_eq!(page.rgba[idx..idx + 3], [255, 0, 0], "point (5, 5 from bottom) inside 10x10 rect fills red");
+}
++
+ /// How each glyph-showing operator on page 0 is painted, read the way a renderer reads the page:
+ /// its text, `Tr`, stroke colour operators, line width (from `w` or an ExtGState's `/LW`) and
+ /// the ExtGStates selected before it, following `q`/`Q`.
+ #[derive(Clone, Debug, PartialEq)]
+ struct Painted {
+ text: String,
+ render_mode: i64,
+ stroke: Vec<String>,
+ line_width: f64,
+ gs: Vec<String>,
+ }
+
+ fn painted_shows(doc: &Document) -> Vec<Painted> {
+ let (_, ops) = joined_ops(doc);
+ let p = &pdfcraft_model::pages(doc)[0];
+ let res = doc.resolve(p.dict.get(b"Resources").unwrap());
+ let ext = res.as_dict().unwrap().get(b"ExtGState").map(|g| doc.resolve(g).as_dict().cloned().unwrap()).unwrap_or_default();
+ let mut state = Painted { text: String::new(), render_mode: 0, stroke: Vec::new(), line_width: 1.0, gs: Vec::new() };
+ let mut stack = Vec::new();
+ let mut out = Vec::new();
+ let show = |op: &pdfcraft_content::Op| String::from_utf8_lossy(&pdfcraft_content::serialize_ops(std::slice::from_ref(op))).trim().to_string();
+ for op in ops {
+ match op.op.as_slice() {
+ b"q" => stack.push(state.clone()),
+ b"Q" => state = stack.pop().unwrap(),
+ b"Tr" => state.render_mode = op.operands[0].as_int().unwrap(),
+ b"G" | b"RG" | b"K" | b"CS" => state.stroke = vec![show(&op)],
+ b"SC" | b"SCN" => state.stroke.push(show(&op)),
+ b"w" => state.line_width = op.num(0).unwrap(),
+ b"gs" => {
+ let name = op.name(0).unwrap();
+ state.gs.push(String::from_utf8_lossy(name).into_owned());
+ let lw = ext.get(name).and_then(|g| doc.resolve(g).as_dict().and_then(|g| g.get(b"LW")).and_then(|w| w.as_f64()));
+ state.line_width = lw.unwrap_or(state.line_width);
+ }
+ b"Tj" => {
+ let Some(Object::String(s)) = op.operands.last() else { continue };
+ if !s.bytes.is_empty() {
+ out.push(Painted { text: String::from_utf8_lossy(&s.bytes).into_owned(), ..state.clone() });
+ }
+ }
+ _ => {}
+ }
+ }
+ out
+ }
+
+ /// A page with Helvetica as /F1, /GS1, an ExtGState that paints at 20 % opacity, /GS2, one that
+ /// sets the line width to 4, /GS3, another at 20 % opacity, and /GS4, at 20 % opacity and dashed.
+ fn faint_page(content: &str) -> Document {
+ build(&[
+ "<< /Type /Catalog /Pages 2 0 R >>",
+ "<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
+ "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 600 800] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> /ExtGState << /GS1 6 0 R /GS2 7 0 R /GS3 8 0 R /GS4 9 0 R >> >> >>",
+ &format!("<< /Length {} >>\nstream\n{content}\nendstream", content.len()),
+ "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>",
+ "<< /Type /ExtGState /ca 0.2 >>",
+ "<< /Type /ExtGState /LW 4 >>",
+ "<< /Type /ExtGState /ca 0.2 >>",
+ "<< /Type /ExtGState /ca 0.2 /D [[6 3] 0] >>",
+ ])
+ }
+
+ /// Rewriting a paragraph drew it before its text object, restating only the font, spacing and
+ /// fill: a `1 Tr 1 0 0 RG 2 w` set inside `BT` was lost, and red outline text came back filled
+ /// black, even with the text unchanged (#3508). Set before `BT` (the control), it already worked.
+ #[test]
+ fn a_rewritten_paragraph_keeps_the_rendering_mode_stroke_and_width_set_inside_its_text_object() {
+ let outline = |text: &str| Painted { text: text.into(), render_mode: 1, stroke: vec!["1 0 0 RG".into()], line_width: 2.0, gs: Vec::new() };
+ for content in ["BT /F1 72 Tf 1 Tr 1 0 0 RG 2 w 40 400 Td (OUTLINE) Tj ET\n", "1 Tr 1 0 0 RG 2 w BT /F1 72 Tf 40 400 Td (OUTLINE) Tj ET\n"] {
+ assert_eq!(painted_shows(&text_page(content)), [outline("OUTLINE")], "the fixture: {content}");
+ for new in ["OUTLINE", "OUTLINED"] {
+ let mut doc = text_page(content);
+ text::rewrite_block(&mut doc, 0, 0, Some(new), &BlockStyle::default()).unwrap();
+ let doc = reopen(&doc);
+ assert_eq!(painted_shows(&doc), [outline(new)], "{content} -> {new}: {}", streams(&doc, 0).join("\n"));
+ }
+ }
+ }
+
+ /// The same for transparency: `/GS1 gs` (`/ca 0.2`) inside `BT` was not in force for the
+ /// rewritten paragraph, so 20 % blue text came back opaque (#3509).
+ #[test]
+ fn a_rewritten_paragraph_keeps_the_extgstate_selected_inside_its_text_object() {
+ for content in ["BT /GS1 gs /F1 72 Tf 0 0 1 rg 40 400 Td (FAINT) Tj ET\n", "/GS1 gs BT /F1 72 Tf 0 0 1 rg 40 400 Td (FAINT) Tj ET\n"] {
+ for new in ["FAINT", "FAINTER"] {
+ let mut doc = faint_page(content);
+ text::rewrite_block(&mut doc, 0, 0, Some(new), &BlockStyle::default()).unwrap();
+ let doc = reopen(&doc);
+ let shows = painted_shows(&doc);
+ assert_eq!(shows.len(), 1, "{content} -> {new}: {shows:?}");
+ assert_eq!(
+ (shows[0].text.as_str(), shows[0].gs.as_slice()),
+ (new, ["GS1".to_string()].as_slice()),
+ "{content} -> {new}: {}",
+ streams(&doc, 0).join("\n")
+ );
+ }
+ }
+ }
+
+ /// A paragraph of differently coloured runs goes through the styled rewrite, which draws each
+ /// run in its own text object: each keeps the state its source set inside `BT`.
+ #[test]
+ fn a_styled_rewrite_keeps_the_paint_state_set_inside_the_text_object() {
+ let content = "BT /GS1 gs 1 Tr 1 0 0 RG 2 w /F1 72 Tf 40 400 Td (FAI) Tj 0 0 1 rg (NT) Tj ET\n";
+ let mut doc = faint_page(content);
+ assert_eq!(text::text_blocks(&doc, 0).unwrap()[0].rows[0].len(), 2, "two runs on one row");
+ text::rewrite_block(&mut doc, 0, 0, Some("FAINTS"), &BlockStyle::default()).unwrap();
+ let doc = reopen(&doc);
+ let shows = painted_shows(&doc);
+ let joined = streams(&doc, 0).join("\n");
+ assert_eq!(shows.iter().map(|s| s.text.as_str()).collect::<String>(), "FAINTS", "{joined}");
+ for s in &shows {
+ assert_eq!((s.render_mode, s.stroke.as_slice(), s.line_width), (1, ["1 0 0 RG".to_string()].as_slice(), 2.0), "{s:?}: {joined}");
+ assert_eq!(s.gs, ["GS1"], "{s:?}: {joined}");
+ }
+ }
+
+ /// A `gs` has no inverse, so one run's ExtGState stayed in force for the runs the styled rewrite
+ /// drew after it. Two ExtGStates at the same opacity paint the same (see `Paint`), so their runs
+ /// share a paragraph, but either may set what that doesn't compare (a dash, a line cap): each run
+ /// is drawn with only the ones its source selected.
+ #[test]
+ fn a_styled_rewrite_does_not_carry_one_runs_extgstate_into_the_next() {
+ // "FAI" ends at 40 + 72 * (0.611 + 0.667 + 0.278) = 152.032; "NT" is blue, so another run.
+ let content = "q BT /GS3 gs /F1 72 Tf 40 400 Td (FAI) Tj ET Q BT /GS1 gs /F1 72 Tf 0 0 1 rg 152.032 400 Td (NT) Tj ET
+ ";
+ for new in ["FAINT", "FAINTS"] {
+ let mut doc = faint_page(content);
+ assert_eq!(text::text_blocks(&doc, 0).unwrap()[0].rows[0].len(), 2, "two runs on one row");
+ text::rewrite_block(&mut doc, 0, 0, Some(new), &BlockStyle::default()).unwrap();
+ let doc = reopen(&doc);
+ let shows = painted_shows(&doc);
+ let joined = streams(&doc, 0).join(
+ "
+ ",
+ );
+ assert_eq!(shows.iter().map(|s| s.text.as_str()).collect::<String>(), new, "{joined}");
+ let gs: Vec<_> = shows.iter().map(|s| (s.text.as_str(), s.gs.as_slice())).collect();
+ assert_eq!(gs.first(), Some(&("FAI", ["GS3".to_string()].as_slice())), "{gs:?}: {joined}");
+ assert!(gs.iter().skip(1).all(|(_, gs)| *gs == ["GS1"]), "{gs:?}: {joined}");
+ }
+ }
+
+ /// An ExtGState's `/LW` sets the line width as `w` does: `2 w /GS2 gs` (`/LW 4`) outlines at 4,
+ /// and the rewrite replayed `/GS2 gs` and then `2 w`. `/GS2 gs 1 w` outlines at 1, and the
+ /// rewrite replayed only `/GS2 gs`, since 1 is the initial width.
+ #[test]
+ fn a_rewritten_paragraph_keeps_the_line_width_an_extgstate_set() {
+ for (content, width) in [
+ ("BT /F1 72 Tf 1 Tr 2 w /GS2 gs 40 400 Td (OUTLINE) Tj ET\n", 4.0),
+ ("BT /F1 72 Tf 1 Tr /GS2 gs 2 w 40 400 Td (OUTLINE) Tj ET\n", 2.0),
+ ("BT /F1 72 Tf 1 Tr /GS2 gs 1 w 40 400 Td (OUTLINE) Tj ET\n", 1.0),
+ ] {
+ assert_eq!(painted_shows(&faint_page(content))[0].line_width, width, "the fixture: {content}");
+ for new in ["OUTLINE", "OUTLINED"] {
+ let mut doc = faint_page(content);
+ text::rewrite_block(&mut doc, 0, 0, Some(new), &BlockStyle::default()).unwrap();
+ let doc = reopen(&doc);
+ let shows = painted_shows(&doc);
+ assert_eq!(
+ shows.iter().map(|s| (s.text.as_str(), s.render_mode, s.line_width)).collect::<Vec<_>>(),
+ [(new, 1, width)],
+ "{content} -> {new}: {}",
+ streams(&doc, 0).join("\n")
+ );
+ }
+ }
+ }
+
+ /// A line is rewritten in the state of its first run, so outline text partway through a text
+ /// object came back filled: "FAI" filled and "NT" a red outline came back all filled. The change
+ /// of `Tr` now starts a run. (A `gs` partway already starts a paragraph; see `Paint`.)
+ #[test]
+ fn a_rendering_mode_partway_through_a_line_starts_a_run_of_its_own() {
+ let content = "BT /F1 72 Tf 40 400 Td (FAI) Tj 1 Tr 1 0 0 RG 2 w (NT) Tj ET
+ ";
+ for new in ["FAINT", "FAINTS"] {
+ let mut doc = faint_page(content);
+ assert_eq!(text::text_blocks(&doc, 0).unwrap()[0].rows[0].len(), 2, "two runs on one row");
+ text::rewrite_block(&mut doc, 0, 0, Some(new), &BlockStyle::default()).unwrap();
+ let doc = reopen(&doc);
+ let shows = painted_shows(&doc);
+ let joined = streams(&doc, 0).join(
+ "
+ ",
+ );
+ assert_eq!(shows.iter().map(|s| s.text.as_str()).collect::<String>(), new, "{joined}");
+ let modes: Vec<_> = shows.iter().map(|s| (s.text.as_str(), s.render_mode, s.stroke.as_slice(), s.line_width)).collect();
+ assert_eq!(modes.first().map(|m| (m.0, m.1)), Some(("FAI", 0)), "{modes:?}: {joined}");
+ let outline = ["1 0 0 RG".to_string()];
+ assert!(modes.iter().skip(1).all(|m| (m.1, m.2, m.3) == (1, outline.as_slice(), 2.0)), "{modes:?}: {joined}");
+ }
+ }
+
+ /// Two ExtGStates at the same opacity paint text the same (see `Paint`), but one of them dashes
+ /// its outline: a dashed outline after a solid one in the same text object joined its line and
+ /// came back solid, drawn with the first run's selections. A different dash now starts a run.
+ #[test]
+ fn a_dash_partway_through_an_outlined_line_starts_a_run_of_its_own() {
+ let content = "BT /GS3 gs /F1 72 Tf 1 Tr 1 0 0 RG 2 w 40 400 Td (FAI) Tj /GS4 gs (NT) Tj ET
+ ";
+ for new in ["FAINT", "FAINTS"] {
+ let mut doc = faint_page(content);
+ assert_eq!(text::text_blocks(&doc, 0).unwrap()[0].rows[0].len(), 2, "two runs on one row");
+ text::rewrite_block(&mut doc, 0, 0, Some(new), &BlockStyle::default()).unwrap();
+ let doc = reopen(&doc);
+ let shows = painted_shows(&doc);
+ let joined = streams(&doc, 0).join(
+ "
+ ",
+ );
+ assert_eq!(shows.iter().map(|s| s.text.as_str()).collect::<String>(), new, "{joined}");
+ let gs: Vec<_> = shows.iter().map(|s| (s.text.as_str(), s.gs.as_slice())).collect();
+ assert_eq!(gs.first(), Some(&("FAI", ["GS3".to_string()].as_slice())), "{gs:?}: {joined}");
+ assert!(gs.iter().skip(1).all(|(_, gs)| gs.last().is_some_and(|g| g == "GS4")), "{gs:?}: {joined}");
+ }
+ }
+
+ /// The dash and cap are compared as the operators set them too: `d` or `J` partway through an
+ /// outlined line starts a run, and a malformed one (too long, not numbers, out of range) is ignored.
+ #[test]
+ fn a_dash_or_cap_operator_partway_through_an_outlined_line_starts_a_run() {
+ let long = format!("[{}] 0 d", "1 ".repeat(40));
+ for (change, runs) in [("[6 3] 0 d", 2), ("1 J", 2), (long.as_str(), 1), ("[(a) 3] 0 d", 1), ("[6 3] /x d", 1), ("7 J", 1), ("J", 1)] {
+ let content = format!("BT /F1 72 Tf 1 Tr 1 0 0 RG 2 w 40 400 Td (FAI) Tj {change} (NT) Tj ET\n");
+ let mut doc = faint_page(&content);
+ assert_eq!(text::text_blocks(&doc, 0).unwrap()[0].rows[0].len(), runs, "{change}");
+ text::rewrite_block(&mut doc, 0, 0, Some("FAINTS"), &BlockStyle::default()).unwrap();
+ let shows = painted_shows(&reopen(&doc));
+ assert_eq!(shows.iter().map(|s| s.text.as_str()).collect::<String>(), "FAINTS", "{change}");
+ }
+ }
+
+ /// #4199, #3797: every space typed into a paragraph is saved, not folded into one.
+ #[test]
+ fn an_edited_paragraph_keeps_every_space_typed() {
+ for typed in ["Hello world", "Hello world end", " indented and trailing "] {
+ let mut doc = text_page("BT /F1 12 Tf 72 700 Td (Hello world) Tj ET");
+ assert_eq!(text::replace_block(&mut doc, 0, 0, typed).unwrap().substituted, None);
+ let doc = reopen(&doc);
+ let content = String::from_utf8_lossy(&page_content_bytes(&doc, 0)).into_owned();
+ assert!(content.contains(&format!("({typed}) Tj")), "{typed:?}: {content}");
+ assert_eq!(text::text_lines(&doc, 0).unwrap()[0].text, typed);
+ }
+ }
+
+ /// Spaces after a row's last word are kept but take no part in its alignment: a justified row
+ /// still reaches the margin, and a centred or right-aligned one sits where it would without them.
+ #[test]
+ fn spaces_after_a_rows_last_word_do_not_move_its_alignment() {
+ let shown = |text: &str, align: added::Align| {
+ let mut doc = text_page("BT /F1 12 Tf 72 700 Td (Hello world) Tj ET");
+ let style =
+ text::BlockStyle { family: Some((added::Family::Helvetica, false, false)), align: Some(align), width: Some(300.0), ..Default::default() };
+ text::rewrite_block(&mut doc, 0, 0, Some(text), &style).unwrap();
+ String::from_utf8_lossy(&page_content_bytes(&doc, 0)).into_owned()
+ };
+ for (plain, trailing, align) in [
+ ("aaa bbb ccc\nddd eee", "aaa bbb ccc \nddd eee", added::Align::Justify),
+ ("Title", "Title ", added::Align::Center),
+ ("Title", "Title ", added::Align::Right),
+ ] {
+ let first = trailing.split('\n').next().unwrap();
+ let expected = shown(plain, align);
+ let actual = shown(trailing, align).replace(&format!("({first})"), &format!("({})", first.trim_end()));
+ assert_eq!(actual, expected, "{trailing:?} {align:?}");
+ }
+ }
+
+ /// A justified row runs from the paragraph's left edge to the margin. Word spacing reaches only
+ /// the spaces between its words: the spaces before its first word and after its last are left
+ /// out of a stretched row (as before #4199), so the reopened rows stay inside the paragraph and
+ /// can be edited again in place.
+ #[test]
+ fn a_justified_row_keeps_its_indent_and_ends_at_the_margin() {
+ let style = text::BlockStyle {
+ family: Some((added::Family::Helvetica, false, false)),
+ align: Some(added::Align::Justify),
+ width: Some(300.0),
+ ..Default::default()
+ };
+ for typed in [" Pack my box with five dozen jugs\nof liquor", " Pack my box with five dozen jugs \nof liquor"] {
+ let mut doc = text_page("BT /F1 12 Tf 72 700 Td (Hello world) Tj ET");
+ text::rewrite_block(&mut doc, 0, 0, Some(typed), &style).unwrap();
+ let mut doc = reopen(&doc);
+ let lines = text::text_lines(&doc, 0).unwrap();
+ let first = lines.iter().find(|l| l.text.contains("Pack")).unwrap();
+ assert_eq!(first.text, "Pack my box with five dozen jugs", "{typed:?}");
+ assert!((first.rect[0] - 72.0).abs() < 0.5, "{typed:?}: {:?}", first.rect);
+ assert!(lines.iter().all(|l| l.rect[0] >= 72.0 - 0.5 && l.rect[2] <= 372.5), "{typed:?}: {lines:?}");
+ let blocks = text::text_blocks(&doc, 0).unwrap();
+ assert_eq!(blocks.len(), 1, "{typed:?}: {blocks:?}");
+ text::replace_block(&mut doc, 0, 0, "Edited again").unwrap();
+ let again = text::text_lines(&reopen(&doc), 0).unwrap();
+ assert!(again.iter().all(|l| l.rect[0] >= 0.0 && l.rect[2] <= 600.0), "{typed:?}: {again:?}");
+ }
+ }
+
+ /// A justified paragraph whose first row was typed with an indent is edited again through the
+ /// styled path (a draft with a line break): its rows keep their scaling and stay one paragraph
+ /// inside its width.
+ #[test]
+ fn a_justified_paragraph_with_an_indent_edits_again_at_its_own_scale() {
+ let style = text::BlockStyle {
+ family: Some((added::Family::Helvetica, false, false)),
+ align: Some(added::Align::Justify),
+ width: Some(300.0),
+ ..Default::default()
+ };
+ let mut doc = text_page("BT /F1 12 Tf 72 700 Td (Hello world) Tj ET");
+ text::rewrite_block(&mut doc, 0, 0, Some(" aaa bbb ccc \nddd"), &style).unwrap();
+ let mut doc = reopen(&doc);
+ let draft = text::text_blocks(&doc, 0).unwrap()[0].editor_text.replacen("ccc", "cc", 1);
+ assert!(draft.contains('\n'), "{draft:?}");
+ text::replace_block(&mut doc, 0, 0, &draft).unwrap();
+ let content = String::from_utf8_lossy(&page_content_bytes(&doc, 0)).into_owned();
+ let scales: Vec<&str> = content.lines().filter(|l| l.ends_with(" Tz")).collect();
+ assert!(scales.iter().all(|l| *l == "100 Tz"), "{scales:?}: {content}");
+ let doc = reopen(&doc);
+ let blocks = text::text_blocks(&doc, 0).unwrap();
+ assert_eq!(blocks.len(), 1, "{blocks:?}");
+ let lines = text::text_lines(&doc, 0).unwrap();
+ assert!(lines.iter().all(|l| l.rect[0] >= 72.0 - 0.5 && l.rect[2] <= 372.5), "{lines:?}");
+ }
+
+ /// A paragraph drawn at `0 Tz` has no width to justify into: nothing is divided by it. The
+ /// writer writes a number that isn't finite as 0, so the test looks for the word spacing and
+ /// the move a division by zero would add, rather than for `NaN`.
+ #[test]
+ fn justifying_text_at_zero_horizontal_scaling_divides_by_nothing() {
+ let mut doc = text_page("BT /F1 12 Tf 0 Tz 72 700 Td (Hello world) Tj ET");
+ let style = text::BlockStyle { family: Some((added::Family::Helvetica, false, false)), align: Some(added::Align::Justify), ..Default::default() };
+ text::rewrite_block(&mut doc, 0, 0, Some(" aaa bbb\nccc"), &style).unwrap();
+ let content = String::from_utf8_lossy(&page_content_bytes(&doc, 0)).into_owned();
+ let block = content.split("ET").next().unwrap();
+ assert_eq!(block.matches(" Tw").count(), 1, "only the paragraph's own 0 Tw: {content}");
+ let first_row = block.split(" Tm").nth(1).and_then(|rest| rest.split(" Tj").next()).unwrap();
+ assert!(!first_row.contains(" Td"), "no move before the first row: {content}");
+ }
+
+ /// The preview's box is the box of the rows Apply writes, measured to their last glyphs.
+ #[test]
+ fn a_drafts_box_is_the_box_apply_draws() {
+ let doc = text_page("BT /F1 12 Tf 14 TL 72 700 Td [(First) -2000 (row here )] TJ T* (Second row ) Tj ET");
+ let source = text::text_blocks(&doc, 0).unwrap().swap_remove(0);
+ let draft = source.editor_text.replacen("Second", "Third", 1);
+ let layout = text::text_edit_layout(&doc, 0, 0, &draft, &text::BlockStyle::default()).unwrap();
+ let mut applied = doc.clone();
+ text::replace_block(&mut applied, 0, 0, &draft).unwrap();
+ let boxed = text::text_lines(&applied, 0)
+ .unwrap()
+ .into_iter()
+ .map(|l| {
+ let end = l.ink.iter().map(|r| r[2]).fold(f64::NEG_INFINITY, f64::max);
+ [l.rect[0], l.rect[1], if end.is_finite() { end.min(l.rect[2]) } else { l.rect[2] }, l.rect[3]]
+ })
+ .reduce(|a, r| [a[0].min(r[0]), a[1].min(r[1]), a[2].max(r[2]), a[3].max(r[3])]);
+ let (d, b) = (layout.draft_rect.unwrap(), boxed.unwrap());
+ assert!(d.iter().zip(b).all(|(x, y)| (x - y).abs() < 0.01), "{draft:?}: preview {d:?}, applied {b:?}");
+ }
+
+ /// The draft's box is measured to its last glyph, not over the spaces typed after it.
+ #[test]
+ fn a_drafts_box_leaves_out_spaces_after_the_last_word() {
+ let doc = text_page("BT /F1 12 Tf 72 700 Td (Hello world) Tj ET");
+ let layout = |text: &str| text::text_edit_layout(&doc, 0, 0, text, &text::BlockStyle::default()).unwrap().draft_rect;
+ assert_eq!(layout("Hello there "), layout("Hello there"));
+ }
+
+ /// A lone carriage return (an old Mac line ending) breaks the row, as `\n` and `\r\n` do.
+ #[test]
+ fn a_lone_carriage_return_breaks_an_edited_paragraph() {
+ let mut doc = text_page("BT /F1 12 Tf 72 700 Td (Hello world) Tj ET");
+ text::replace_block(&mut doc, 0, 0, "one\rtwo").unwrap();
+ let lines: Vec<String> = text::text_lines(&reopen(&doc), 0).unwrap().into_iter().map(|l| l.text).collect();
+ assert_eq!(lines, ["one", "two"]);
+ }
+
+ /// On the styled rewrite path too, `\r\n` is one row break and a lone `\r` another, and no
+ /// carriage return reaches the page: with no other formatting, and with a part set in red.
+ #[test]
+ fn carriage_returns_break_rows_on_the_styled_path() {
+ let draft = "one\r\ntwo\rthree";
+ let red = text::RangeStyle {
+ range: 0..3,
+ family: None,
+ resource: None,
+ size: None,
+ color: Some([1.0, 0.0, 0.0]),
+ underline: None,
+ char_spacing: None,
+ scale: None,
+ };
+ for style in [text::BlockStyle::default(), text::BlockStyle { ranges: vec![red], ..Default::default() }] {
+ let mut doc = text_page("BT /F1 12 Tf 72 700 Td (Hello world) Tj ET");
+ text::rewrite_block(&mut doc, 0, 0, Some(draft), &style).unwrap();
+ let doc = reopen(&doc);
+ let content = page_content_bytes(&doc, 0);
+ assert!(!content.contains(&b'\r') && !content.windows(2).any(|w| w == b"\\r"), "{}", String::from_utf8_lossy(&content));
+ let lines: Vec<String> = text::text_lines(&doc, 0).unwrap().into_iter().map(|l| l.text).collect();
+ assert_eq!(lines, ["one", "two", "three"], "{style:?}");
+ }
+ }
+
+ /// A subset with no space glyph shows each space as a positioning gap one space wide, so a run
+ /// of spaces still takes a run's width (#4199).
+ #[test]
+ fn a_run_of_spaces_in_a_subset_without_a_space_glyph_keeps_its_width() {
+ let mut doc = text_page("BT /F2 12 Tf 72 700 Td (ab) Tj /F1 12 Tf ( ) Tj /F2 12 Tf (ba) Tj ET");
+ assert_eq!(text::replace_block(&mut doc, 0, 0, "ab ba ab").unwrap().substituted, None);
+ let content = String::from_utf8_lossy(&page_content_bytes(&reopen(&doc), 0)).into_owned();
+ assert_eq!(content.matches("[-330] TJ").count(), 5, "{content}");
+ }
diff --cc crates/engine/src/lib.rs
index 21175bdb4,f11671bf8..9654558b5
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@@ -4349,7 -4336,7 +4500,8 @@@ impl Session
| Edit::UpdateContent { .. }
| Edit::DeleteContent { .. }
| Edit::ReplaceImage { .. }
+ | Edit::EditPageImage { .. }
+ | Edit::PasteContent { .. }
) || matches!(e, Edit::MoveObjects { objects, .. } if objects.iter().any(|o| o.kind == ObjectKind::Added))
});
let touches_marks = edit.is_none_or(|e| {
@@@ -4484,8 -4479,7 +4644,8 @@@
// file so that revision stays in the chain. A full rewrite (redaction, new encryption,
// a reconstructed file) still writes the current graph on its own.
let rewrite = editor.cos.full_save_required() || editor.cos.encryption_changed() || editor.cos.revisions().is_empty();
- let mut cos = editor.cos.clone();
- pdfcraft_edit::text::subset_document_fonts(&mut cos)?;
- let cos = writable(&editor.cos)?;
++ let mut cos = writable(&editor.cos)?;
++ pdfcraft_edit::text::subset_document_fonts(cos.to_mut())?;
guard(|| {
if on_saved || rewrite {
write_incremental(&cos, &opts)
@@@ -4508,8 -4502,7 +4668,8 @@@
}
let editor = doc.editor.as_ref().ok_or_else(|| EditError::ReadOnly(doc.read_only_reason.clone().unwrap_or_default()))?;
let opts = SaveOptions { mod_date: self.now().map(pdfcraft_cos::pdf_date), ..SaveOptions::default() };
- let mut cos = editor.cos.clone();
- pdfcraft_edit::text::subset_document_fonts(&mut cos)?;
- let cos = writable(&editor.cos)?;
++ let mut cos = writable(&editor.cos)?;
++ pdfcraft_edit::text::subset_document_fonts(cos.to_mut())?;
guard(|| write_full(&cos, &opts)).map_err(EditError::Write)?.map(Arc::new).map_err(|e| EditError::Write(e.to_string()))
}
diff --cc crates/engine/src/tests.rs
index 7f5a10108,ba6f2c1c7..3f2c93c8b
--- a/crates/engine/src/tests.rs
+++ b/crates/engine/src/tests.rs
@@@ -7479,281 -8445,108 +8485,387 @@@ fn a_page_truncated_for_forms_and_pictu
assert_eq!(truncated, [0]);
}
+/// Moving an added image, then rotating it, must keep the moved position.
+#[test]
+fn added_image_move_then_rotate_keeps_position() {
+ let mut png = Vec::new();
+ {
+ let mut enc = png::Encoder::new(&mut png, 2, 2);
+ enc.set_color(png::ColorType::Rgb);
+ enc.write_header().unwrap().write_image_data(&[255u8; 12]).unwrap();
+ }
+ let (mut s, id) = session_with(1);
+ s.apply(id, Edit::AddImage { page: 0, rect: Some([20.0, 20.0, 60.0, 60.0]), name: "p.png".into(), bytes: Arc::new(png) }).unwrap();
+ let rect = |s: &Session| s.get(id).unwrap().page_images(0)[0].rect;
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Move([120.0, 120.0, 160.0, 160.0]) }).unwrap();
+ let moved = rect(&s);
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Rotate(1) }).unwrap();
+ let rotated = rect(&s);
+ let c = |r: [f64; 4]| ((r[0] + r[2]) / 2.0, (r[1] + r[3]) / 2.0);
+ let (a, b) = (c(moved), c(rotated));
+ assert!((a.0 - b.0).abs() < 1.0 && (a.1 - b.1).abs() < 1.0, "rotate moved the centre from {a:?} to {b:?}");
+}
+
+/// Transforming an added image, then rotating it, must keep the moved position.
+#[test]
+fn added_image_transform_then_rotate_keeps_position() {
+ let mut png = Vec::new();
+ {
+ let mut enc = png::Encoder::new(&mut png, 2, 2);
+ enc.set_color(png::ColorType::Rgb);
+ enc.write_header().unwrap().write_image_data(&[255u8; 12]).unwrap();
+ }
+ let (mut s, id) = session_with(1);
+ s.apply(id, Edit::AddImage { page: 0, rect: Some([20.0, 20.0, 60.0, 60.0]), name: "p.png".into(), bytes: Arc::new(png) }).unwrap();
+ let rect = |s: &Session| s.get(id).unwrap().page_images(0)[0].rect;
+ // Translate by (100, 100): matrix [1, 0, 0, 1, 100, 100]
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Transform([1.0, 0.0, 0.0, 1.0, 100.0, 100.0]) }).unwrap();
+ let transformed = rect(&s);
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Rotate(1) }).unwrap();
+ let rotated = rect(&s);
+ let c = |r: [f64; 4]| ((r[0] + r[2]) / 2.0, (r[1] + r[3]) / 2.0);
+ let (a, b) = (c(transformed), c(rotated));
+ assert!((a.0 - b.0).abs() < 1.0 && (a.1 - b.1).abs() < 1.0, "rotate moved the centre from {a:?} to {b:?}");
+}
+
+/// Moving an added image, then rotating by degrees, must keep the moved position.
+#[test]
+fn added_image_move_then_rotate_by_keeps_position() {
+ let mut png = Vec::new();
+ {
+ let mut enc = png::Encoder::new(&mut png, 2, 2);
+ enc.set_color(png::ColorType::Rgb);
+ enc.write_header().unwrap().write_image_data(&[255u8; 12]).unwrap();
+ }
+ let (mut s, id) = session_with(1);
+ s.apply(id, Edit::AddImage { page: 0, rect: Some([20.0, 20.0, 60.0, 60.0]), name: "p.png".into(), bytes: Arc::new(png) }).unwrap();
+ let rect = |s: &Session| s.get(id).unwrap().page_images(0)[0].rect;
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Move([120.0, 120.0, 160.0, 160.0]) }).unwrap();
+ let moved = rect(&s);
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::RotateBy(90.0) }).unwrap();
+ let rotated = rect(&s);
+ let c = |r: [f64; 4]| ((r[0] + r[2]) / 2.0, (r[1] + r[3]) / 2.0);
+ let (a, b) = (c(moved), c(rotated));
+ assert!((a.0 - b.0).abs() < 1.0 && (a.1 - b.1).abs() < 1.0, "rotate_by moved the centre from {a:?} to {b:?}");
+}
+
+/// Arranging an added image moves it into the document stream and converts it to an ordinary
+/// page image (dropping the PCAdded marker), so no empty shell remains in list_added.
+#[test]
+fn added_image_arrange_converts_to_ordinary_image() {
+ let mut png = Vec::new();
+ {
+ let mut enc = png::Encoder::new(&mut png, 2, 2);
+ enc.set_color(png::ColorType::Rgb);
+ enc.write_header().unwrap().write_image_data(&[255u8; 12]).unwrap();
+ }
+ let (mut s, id) = session_with(1);
+ s.apply(id, Edit::AddImage { page: 0, rect: Some([20.0, 20.0, 60.0, 60.0]), name: "p1.png".into(), bytes: Arc::new(png.clone()) }).unwrap();
+ s.apply(id, Edit::AddImage { page: 0, rect: Some([100.0, 100.0, 200.0, 200.0]), name: "p2.png".into(), bytes: Arc::new(png) }).unwrap();
+ assert_eq!(s.get(id).unwrap().page_images(0).len(), 2);
+ assert_eq!(s.get(id).unwrap().added().len(), 2);
+ s.apply(id, Edit::EditPageImage { page: 0, index: 1, change: ImageEdit::Arrange(ArrangeOrder::SendToBack) }).unwrap();
+ assert_eq!(s.get(id).unwrap().page_images(0).len(), 2);
+ assert_eq!(s.get(id).unwrap().added().len(), 1, "arranged image is converted and no longer an added-item shell");
+}
+
+#[test]
+fn added_image_crop_then_move_keeps_crop() {
+ let mut png = Vec::new();
+ {
+ let mut enc = png::Encoder::new(&mut png, 2, 2);
+ enc.set_color(png::ColorType::Rgb);
+ enc.write_header().unwrap().write_image_data(&[255u8; 12]).unwrap();
+ }
+ let (mut s, id) = session_with(1);
+ s.apply(id, Edit::AddImage { page: 0, rect: Some([20.0, 20.0, 100.0, 100.0]), name: "p.png".into(), bytes: Arc::new(png) }).unwrap();
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Crop([30.0, 30.0, 70.0, 70.0]) }).unwrap();
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Move([50.0, 50.0, 130.0, 130.0]) }).unwrap();
+ let img = s.get(id).unwrap().page_images(0)[0].clone();
+ assert_eq!(img.visible_rect, Some([60.0, 60.0, 100.0, 100.0]));
+}
+
+#[test]
+fn added_image_move_and_transform_on_rotated_and_user_unit_pages() {
+ let mut png = Vec::new();
+ {
+ let mut enc = png::Encoder::new(&mut png, 2, 2);
+ enc.set_color(png::ColorType::Rgb);
+ enc.write_header().unwrap().write_image_data(&[255u8; 12]).unwrap();
+ }
+ let png_bytes = Arc::new(png);
+
+ let cases = [(90, 1.0), (180, 1.0), (270, 1.0), (0, 2.0), (90, 2.0)];
+
+ for (rotate, user_unit) in cases {
+ let pdf = fixture_with_rotation_and_user_unit(rotate, user_unit);
+ let mut s = Session::new().with_clock(|| 1_700_000_000);
+ let id = s.open("test.pdf", None, Arc::new(pdf), None).expect("opens");
+
+ s.apply(id, Edit::AddImage { page: 0, rect: Some([10.0, 10.0, 50.0, 50.0]), name: "img.png".into(), bytes: png_bytes.clone() }).unwrap();
+
+ // Target user-space rectangle R
+ let r = [30.0, 40.0, 80.0, 90.0];
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Move(r) }).unwrap();
+
+ let painted = s.get(id).unwrap().page_images(0)[0].rect;
+ for i in 0..4 {
+ assert!(
+ (painted[i] - r[i]).abs() < 1e-3,
+ "Move: rotate={rotate}, user_unit={user_unit}: painted[{i}] = {}, expected {}",
+ painted[i],
+ r[i]
+ );
+ }
+
+ let cos = pdfcraft_cos::Document::open(s.get(id).unwrap().bytes.clone()).unwrap();
+ let added = pdfcraft_edit::list_added(&cos);
+ assert_eq!(added.len(), 1);
+ let stream_obj = match &*cos.get(added[0].obj) {
+ pdfcraft_cos::Object::Stream(s) => s.clone(),
+ other => panic!("expected stream, got {other:?}"),
+ };
+ let pc_rect = stream_obj
+ .dict
+ .get(b"PCAdded")
+ .and_then(|o| cos.resolve(o).as_dict().cloned())
+ .and_then(|d| d.get(b"Rect").cloned())
+ .and_then(|o| cos.resolve(&o).as_array().cloned())
+ .unwrap();
+ let pc_box: [f64; 4] =
+ [pc_rect[0].as_f64().unwrap(), pc_rect[1].as_f64().unwrap(), pc_rect[2].as_f64().unwrap(), pc_rect[3].as_f64().unwrap()];
+ let content = String::from_utf8(stream_obj.decoded().unwrap()).unwrap();
+ let re_idx = content.find(" re W n").expect("re W n in content stream");
+ let prefix = &content[..re_idx];
+ let nums: Vec<f64> =
+ prefix.split_whitespace().rev().take(4).collect::<Vec<_>>().into_iter().rev().map(|val| val.parse::<f64>().unwrap()).collect();
+ assert_eq!(nums.len(), 4);
+ let (rx, ry, rw, rh) = (nums[0], nums[1], nums[2], nums[3]);
+ assert!((rx - pc_box[0]).abs() < 1e-3, "re x {rx} != pc_box[0] {}", pc_box[0]);
+ assert!((ry - pc_box[1]).abs() < 1e-3, "re y {ry} != pc_box[1] {}", pc_box[1]);
+ assert!((rw - (pc_box[2] - pc_box[0])).abs() < 1e-3, "re w {rw} != {}", pc_box[2] - pc_box[0]);
+ assert!((rh - (pc_box[3] - pc_box[1])).abs() < 1e-3, "re h {rh} != {}", pc_box[3] - pc_box[1]);
+
+ // Transform test: user-space translation by (10, 10)
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Transform([1.0, 0.0, 0.0, 1.0, 10.0, 10.0]) }).unwrap();
+
+ let expected_transformed = [r[0] + 10.0, r[1] + 10.0, r[2] + 10.0, r[3] + 10.0];
+ let painted_transformed = s.get(id).unwrap().page_images(0)[0].rect;
+ for i in 0..4 {
+ assert!(
+ (painted_transformed[i] - expected_transformed[i]).abs() < 1e-3,
+ "Transform: rotate={rotate}, user_unit={user_unit}: painted[{i}] = {}, expected {}",
+ painted_transformed[i],
+ expected_transformed[i]
+ );
+ }
+ }
+}
+
+#[test]
+fn replace_on_added_image_replaces_xobject_and_undo_restores() {
+ let make_png = |rgb: [u8; 3]| {
+ let mut png = Vec::new();
+ {
+ let mut enc = png::Encoder::new(&mut png, 2, 2);
+ enc.set_color(png::ColorType::Rgb);
+ let data = [rgb[0], rgb[1], rgb[2], rgb[0], rgb[1], rgb[2], rgb[0], rgb[1], rgb[2], rgb[0], rgb[1], rgb[2]];
+ enc.write_header().unwrap().write_image_data(&data).unwrap();
+ }
+ Arc::new(png)
+ };
+ let png1 = make_png([255, 0, 0]);
+ let png2 = make_png([0, 0, 255]);
+
+ let (mut s, id) = session_with(1);
+ s.apply(id, Edit::AddImage { page: 0, rect: Some([20.0, 20.0, 60.0, 60.0]), name: "img1.png".into(), bytes: png1 }).unwrap();
+
+ let old_obj = s.get(id).unwrap().page_images(0)[0].object.expect("initial image object ref");
+
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Replace { name: "img2.png".into(), bytes: png2 } }).unwrap();
+
+ let new_obj = s.get(id).unwrap().page_images(0)[0].object.expect("new image object ref");
+ assert_ne!(new_obj, old_obj, "after Replace the page references the new XObject");
+
+ s.undo(id).unwrap();
+
+ let restored_obj = s.get(id).unwrap().page_images(0)[0].object.expect("restored image object ref");
+ assert_eq!(restored_obj, old_obj, "undo restores the old XObject");
+
+ // Also test replacement on an image with active crop (promoted path)
+ let png3 = make_png([0, 255, 0]);
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Crop([25.0, 25.0, 55.0, 55.0]) }).unwrap();
+ let crop_obj = s.get(id).unwrap().page_images(0)[0].object.expect("crop image object ref");
+ assert_eq!(crop_obj, old_obj);
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Replace { name: "img3.png".into(), bytes: png3 } }).unwrap();
+ let promoted_new_obj = s.get(id).unwrap().page_images(0)[0].object.expect("promoted replace object ref");
+ assert_ne!(promoted_new_obj, crop_obj);
+ s.undo(id).unwrap();
+ assert_eq!(s.get(id).unwrap().page_images(0)[0].object.expect("undo promoted replace"), crop_obj);
+}
+
+#[test]
+fn mirroring_transform_on_added_image_flips_and_non_finite_is_refused() {
+ let make_png = |rgb: [u8; 3]| {
+ let mut png = Vec::new();
+ {
+ let mut enc = png::Encoder::new(&mut png, 2, 2);
+ enc.set_color(png::ColorType::Rgb);
+ let data = [rgb[0], rgb[1], rgb[2], rgb[0], rgb[1], rgb[2], rgb[0], rgb[1], rgb[2], rgb[0], rgb[1], rgb[2]];
+ enc.write_header().unwrap().write_image_data(&data).unwrap();
+ }
+ Arc::new(png)
+ };
+ let png1 = make_png([255, 0, 0]);
+
+ let (mut s, id) = session_with(1);
+ s.apply(id, Edit::AddImage { page: 0, rect: Some([0.0, 0.0, 80.0, 40.0]), name: "img1.png".into(), bytes: png1 }).unwrap();
+
+ let initial_img = s.get(id).unwrap().page_images(0)[0].clone();
+ assert_eq!(initial_img.rect, [0.0, 0.0, 80.0, 40.0]);
+ assert!(initial_img.matrix[0] > 0.0, "initially unflipped");
+
+ // Mirroring transform: [-1.0, 0.0, 0.0, 1.0, 80.0, 0.0]
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Transform([-1.0, 0.0, 0.0, 1.0, 80.0, 0.0]) }).unwrap();
+
+ let flipped_img = s.get(id).unwrap().page_images(0)[0].clone();
+ assert!(flipped_img.matrix[0] < 0.0, "horizontal mirror flips matrix x-axis, got matrix: {:?}", flipped_img.matrix);
+
+ let cos = pdfcraft_cos::Document::open(s.get(id).unwrap().bytes.clone()).unwrap();
+ let added = pdfcraft_edit::list_added(&cos);
+ assert_eq!(added.len(), 1);
+ let AddedContent::Image(ai) = &added[0].content else { panic!("expected added image") };
+ assert!(ai.flip_h, "PCAdded record must have flip_h = true");
+
+ // Mirroring horizontally again flips it back
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Transform([-1.0, 0.0, 0.0, 1.0, 80.0, 0.0]) }).unwrap();
+ let unflipped_img = s.get(id).unwrap().page_images(0)[0].clone();
+ assert!(unflipped_img.matrix[0] > 0.0, "double horizontal mirror restores positive x-axis");
+ let cos2 = pdfcraft_cos::Document::open(s.get(id).unwrap().bytes.clone()).unwrap();
+ let AddedContent::Image(ai2) = &pdfcraft_edit::list_added(&cos2)[0].content else { panic!("expected added image") };
+ assert!(!ai2.flip_h, "PCAdded record must have flip_h = false");
+
+ // Mirroring vertically: [1.0, 0.0, 0.0, -1.0, 0.0, 40.0]
+ s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Transform([1.0, 0.0, 0.0, -1.0, 0.0, 40.0]) }).unwrap();
+ let v_flipped_img = s.get(id).unwrap().page_images(0)[0].clone();
+ assert!(v_flipped_img.matrix[3] < 0.0, "vertical mirror flips matrix y-axis, got matrix: {:?}", v_flipped_img.matrix);
+ let cos3 = pdfcraft_cos::Document::open(s.get(id).unwrap().bytes.clone()).unwrap();
+ let AddedContent::Image(ai3) = &pdfcraft_edit::list_added(&cos3)[0].content else { panic!("expected added image") };
+ assert!(ai3.flip_v, "PCAdded record must have flip_v = true");
+
+ // Non-finite transform must be refused with error
+ let res = s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Transform([f64::NAN, 0.0, 0.0, 1.0, 0.0, 0.0]) });
+ assert!(res.is_err(), "NaN transform must be refused");
+
+ let res_inf = s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Transform([1.0, 0.0, 0.0, f64::INFINITY, 0.0, 0.0]) });
+ assert!(res_inf.is_err(), "infinite transform must be refused");
+
+ let res_move = s.apply(id, Edit::EditPageImage { page: 0, index: 0, change: ImageEdit::Move([f64::NAN, 20.0, 100.0, 60.0]) });
+ assert!(res_move.is_err(), "NaN position must be refused");
+}
++
+ /// ISO 32000-2 Table 192, 12.7.5.2.3 and Table 228 (Comb): a check box, a push button, a comb
+ /// field the file leaves to the viewer. The page as displayed and printed as an image shows the
+ /// check box's caption symbol in its text colour, the button's grey face and the comb's cells in
+ /// the border colour, and saving writes the file as it was.
+ #[test]
+ fn buttons_and_combs_left_to_the_viewer_are_displayed() {
+ let pdf = b"%PDF-1.7\n\
+ 1 0 obj << /Type /Catalog /Pages 2 0 R /AcroForm 4 0 R >> endobj\n\
+ 2 0 obj << /Type /Pages /Kids [3 0 R] /Count 1 >> endobj\n\
+ 3 0 obj << /Type /Page /Parent 2 0 R /MediaBox [0 0 400 200] /Annots [6 0 R 7 0 R 8 0 R] >> endobj\n\
+ 4 0 obj << /Fields [6 0 R 7 0 R 8 0 R] /DA (/Helv 0 Tf 0 g) /DR << /Font << /Helv 5 0 R >> >> >> endobj\n\
+ 5 0 obj << /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >> endobj\n\
+ 6 0 obj << /Type /Annot /Subtype /Widget /FT /Btn /T (k) /V /Yes /AS /Yes /DA (/ZaDb 0 Tf 1 0 0 rg) /MK << /CA (8) /BC [0 0 0] >> /Rect [20 150 60 190] /F 4 /P 3 0 R >> endobj\n\
+ 7 0 obj << /Type /Annot /Subtype /Widget /FT /Btn /Ff 65536 /T (o) /DA (/Helv 12 Tf 0 g) /MK << /CA (Press) /BG [0.8 0.8 0.8] /BC [0 0 0] >> /BS << /W 2 /S /B >> /Rect [100 150 220 190] /F 4 /P 3 0 R >> endobj\n\
+ 8 0 obj << /Type /Annot /Subtype /Widget /FT /Tx /Ff 16777216 /MaxLen 4 /T (d) /V (AB) /DA (/Helv 12 Tf 0 g) /MK << /BC [0 0 1] >> /Rect [20 80 220 110] /F 4 /P 3 0 R >> endobj\n\
+ trailer << /Root 1 0 R >>\n%%EOF"
+ .to_vec();
+ let render = |bytes: Arc<Vec<u8>>| {
+ let mut r = pdfcraft_render::PageRenderer::new(bytes, pdfcraft_render::RenderConfig::default());
+ r.render(pdfcraft_render::RenderRequest { page: 0, scale: 1.0, ..Default::default() })
+ };
+ // Pixels of the page (drawn at scale 1, 400 x 200) in user-space box x0..x1, y0..y1 that `keep`.
+ let count = |page: &pdfcraft_render::RenderedPage, (x0, y0, x1, y1): (u32, u32, u32, u32), keep: &dyn Fn(&[u8; 4]) -> bool| {
+ let (px, _) = page.rgba.as_chunks::<4>();
+ (200 - y1..200 - y0)
+ .flat_map(|y| (x0..x1).map(move |x| (x, y)))
+ .filter(|&(x, y)| px.get((y * page.width + x) as usize).is_some_and(keep))
+ .count()
+ };
+ let red = |p: &[u8; 4]| p[0] > 200 && p[1] < 80 && p[2] < 80;
+ let grey = |p: &[u8; 4]| (180..=230).contains(&p[0]) && p[0] == p[1] && p[1] == p[2];
+ // Bluish: a 1 pt line on a pixel edge is half blue on each side.
+ let blue = |p: &[u8; 4]| p[2] > 200 && p[0] < 180 && p[1] < 180 && p[0] + 40 < p[2];
+ let mut s = Session::new();
+ let id = s.open("form.pdf", None, Arc::new(pdf), None).unwrap();
+ let shown = render(s.get(id).unwrap().display.clone());
+ assert!(count(&shown, (24, 154, 56, 186), &red) > 60, "the check box's red cross");
+ assert!(count(&shown, (104, 154, 216, 186), &grey) > 1000, "the push button's grey face");
+ // The comb's three inner lines at x = 70, 120 and 170, between its cells.
+ for x in [70, 120, 170] {
+ assert!(count(&shown, (x - 1, 84, x + 1, 106), &blue) >= 20, "a cell line at {x}");
+ }
+ assert_eq!(count(&shown, (95, 84, 97, 106), &blue), 0, "no line inside a cell");
+ // Print as Image: the page as a picture, at 72 dpi so it is the size of the page here.
+ let raster = pdfcraft_print::Raster { dpi: 72.0, grayscale: false };
+ let pictures = crate::print_raster::rasterize(s.get(id).unwrap(), &[0], &raster, pdfcraft_print::Content::Document).unwrap();
+ let printed = render(Arc::new(pictures));
+ assert!(count(&printed, (24, 154, 56, 186), &red) > 60, "the check box prints");
+ assert!(count(&printed, (104, 154, 216, 186), &grey) > 1000, "and the push button");
+ // The file is saved as it was: no widget has an appearance.
+ let saved = pdfcraft_cos::Document::open(s.save_bytes(id).unwrap()).unwrap();
+ for f in pdfcraft_forms::fields(&saved) {
+ assert!(saved.get(f.widgets[0].obj).as_dict().is_some_and(|d| !d.contains(b"AP")), "{} has no appearance", f.name);
+ }
+ }
+
+ /// ISO 32000-2 Tables 166 and 183, drawn on the page: a square without an appearance whose
+ /// `/Border [0 0 3 [6 3]]` names its width before a dash array is stroked 3 pt wide and dashed
+ /// (it was 1 pt and solid), and a caret with `/Sy /P` shows a ¶ to its right.
+ #[test]
+ fn legacy_border_dashes_and_the_caret_paragraph_symbol_are_drawn() {
+ let original = Arc::new(pdf_with_annots(&[
+ b"<< /Type /Annot /Subtype /Square /Rect [20 180 120 280] /Border [0 0 3 [6 3]] /C [1 0 0] >>",
+ b"<< /Type /Annot /Subtype /Caret /Rect [20 20 80 80] /Sy /P /C [0 0 1] >>",
+ ]));
+ let mut s = Session::new().with_clock(|| 1_700_000_000);
+ let id = s.open("noap.pdf", None, original, None).expect("opens");
+ let p = shown(&s, id, 0);
+ let px = |x: u32, y: u32| p.rgba[((y * p.width + x) * 4) as usize..][..4].to_vec();
+ // y down: the bottom edge's stroke is centred 1.5 pt inside /Rect, on row 118.
+ let row: Vec<Vec<u8>> = (24..116).map(|x| px(x, 118)).collect();
+ let red = row.iter().filter(|c| c[0] > 200 && c[1] < 80).count();
+ let white = row.iter().filter(|c| c[1] > 200).count();
+ assert!(red > 40 && white > 15, "3 pt and dashed: {red} red, {white} white");
+ // The ¶ sits in the right part of the caret's /Rect, where the caret no longer reaches.
+ let blue = (250..270).flat_map(|y| (68..80).map(move |x| (x, y))).filter(|&(x, y)| {
+ let c = px(x, y);
+ c[2] > 150 && c[0] < 100
+ });
+ assert!(blue.count() > 20, "the pilcrow is drawn beside the caret");
+ }
+
+ /// A one-page 200 × 300 document whose page lists `annots` (objects 4, 5, …).
+ fn pdf_with_annots(annots: &[&[u8]]) -> Vec<u8> {
+ let list: String = (0..annots.len()).map(|i| format!("{} 0 R ", i + 4)).collect();
+ let page = format!("<< /Type /Page /Parent 2 0 R /Annots [{list}] >>");
+ let mut objs: Vec<&[u8]> =
+ vec![b"<< /Type /Catalog /Pages 2 0 R >>", b"<< /Type /Pages /Kids [3 0 R] /Count 1 /MediaBox [0 0 200 300] >>", page.as_bytes()];
+ objs.extend_from_slice(annots);
+ let mut bytes = b"%PDF-1.7\n".to_vec();
+ let mut offsets = Vec::new();
+ for (i, o) in objs.iter().enumerate() {
+ offsets.push(bytes.len());
+ bytes.extend_from_slice(format!("{} 0 obj\n", i + 1).as_bytes());
+ bytes.extend_from_slice(o);
+ bytes.extend_from_slice(b"\nendobj\n");
+ }
+ let xref = bytes.len();
+ bytes.extend_from_slice(format!("xref\n0 {}\n0000000000 65535 f \n", objs.len() + 1).as_bytes());
+ for o in offsets {
+ bytes.extend_from_slice(format!("{o:010} 00000 n \n").as_bytes());
+ }
+ bytes.extend_from_slice(format!("trailer\n<< /Size {} /Root 1 0 R >>\nstartxref\n{xref}\n%%EOF\n", objs.len() + 1).as_bytes());
+ bytes
+ }
diff --cc crates/ui-egui/src/canvas.rs
index 42eea3b64,c7015c465..86c3202be
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@@ -2715,9 -2373,8 +2818,9 @@@ impl DocView
/// The hover popup for an annotation. Replies and Fill & Sign marks (typed text, checks, signatures)
/// show none: they are page content being edited, not comments.
+/// If `display_author_no_comment` is false, highlighted text markup with no comment body shows no popup.
fn annotation_hover_text(a: &pdfcraft_render::Annotation) -> Option<String> {
- if a.in_reply_to.is_some() || a.fill_sign {
+ if a.is_reply() || a.fill_sign {
return None;
}
let who = a.author.clone().unwrap_or_else(|| a.subtype.clone());
@@@ -3198,19 -2762,12 +3302,22 @@@ pub fn document_area(app: &mut PdfCraft
let editing_content =
(app.left_open && app.left == crate::LeftPanel::Tool("edit")) || matches!(app.quick_tool, QuickTool::AddText | QuickTool::EditText);
let text_style = app.text_style.clone();
+ let show_secured_notice = app.show_secured_notice;
+ // Asking means opening the system clipboard (and decoding any image on it), so it's asked
+ // once when a right-click opens a menu, not on every frame.
+ let can_paste_key = egui::Id::new("can-paste-image");
+ let can_paste_image = if ui.input(|i| i.pointer.secondary_pressed()) {
+ let can = app.can_paste_image();
+ ui.data_mut(|d| d.insert_temp(can_paste_key, can));
+ can
+ } else {
+ ui.data(|d| d.get_temp(can_paste_key)).unwrap_or(false)
+ };
let view = &mut app.views[index];
- // Opened without the owner password and something is restricted.
- let secured = doc.security_summary().is_some_and(|s| !(s.owner || (s.permissions.modify() && s.permissions.assemble())));
+ // Opened without the owner password and something is restricted. The notice says so unless
+ // the user turned it off (#4035): the restrictions themselves, and Document Properties ▸
+ // Security, stay as they are.
+ let secured = show_secured_notice && doc.security_summary().is_some_and(|s| !(s.owner || (s.permissions.modify() && s.permissions.assemble())));
let repaired = !doc.repair_log().is_empty();
match notices(view, doc, secured, repaired, crate::sign_ui::banner(&doc.signatures), ui, &t) {
#[cfg(not(target_arch = "wasm32"))]
@@@ -4634,27 -4101,14 +4740,27 @@@
}
return;
}
- if view.comments.selected.is_none() {
- let selected = view.selected_text().is_some_and(|t| !t.is_empty());
- let key = crate::commands::shortcut_label(ui.ctx(), crate::commands::COPY);
- if ui.add_enabled(can_copy && selected, egui::Button::new(tl!("Copy")).shortcut_text(key)).clicked() {
- copy_selected = true;
- ui.close();
- }
- ui.separator();
+ let is_image_menu = tool == QuickTool::EditText
+ && (ui.ctx().data_mut(|d| d.get_persisted::<bool>(crate::edit_text_ui::image_menu_id())).unwrap_or(false)
+ || view.image_selection.as_ref().is_some_and(|sel| {
+ let pointer_pos = ui.input(|inp| inp.pointer.hover_pos().or(inp.pointer.interact_pos()));
+ let Some(p) = pointer_pos else { return false };
+ let Some((_, xf)) = view.screen_xforms.iter().find(|(page_idx, _)| *page_idx == sel.page) else { return false };
+ let images = doc.page_images(sel.page);
+ let Some(img) = images.get(sel.index) else { return false };
+ let obb = ImageObb::from_image(img, xf, info, sel.page);
+ let b = image_screen_rect(img, xf, info, sel.page);
+ (b.is_positive() && b.contains(p)) || crate::edit_text_ui::quad_contains(obb.corners(), p)
+ }));
+ if is_image_menu && let Some(sel) = view.image_selection.clone() {
+ let images = doc.page_images(sel.page);
+ let at = view.comments.context_at.map(|(_, at)| at);
+ crate::edit_text_ui::image_context_menu(ui, view, &images, sel.page, sel.index, can_paste_image, &mut image_action, at);
+ return;
+ }
+ if view.comments.selected.is_some() {
- canvas_action = comments::context_menu(ui, view, info, prefs, allowed);
++ canvas_action = comments::context_menu(ui, view, info, prefs, allowed, can_modify);
+ return;
}
// Over a picture (and no comment): Copy Image, as in Acrobat's page menu.
let mut copy_image = None;
diff --cc crates/ui-egui/src/content_ui.rs
index 46f1c5c2b,ed4d0622f..70cbb49ba
--- a/crates/ui-egui/src/content_ui.rs
+++ b/crates/ui-egui/src/content_ui.rs
@@@ -310,10 -309,8 +312,8 @@@ pub(crate) fn select_grabs(xf: &PageXfo
if cv.grab.is_some_and(|(grab_page, _, _)| grab_page == page) {
return true;
}
- let Some(p) = ui.input(|i| i.pointer.hover_pos().or(i.pointer.interact_pos())).filter(|p| xf.rect.contains(*p)) else {
- return false;
- };
+ let Some(p) = ptr.within(xf.rect) else { return false };
- on_page(added, page).into_iter().any(|(index, item)| {
+ on_page(added, page).into_iter().filter(|(_, item)| matches!(item.content, AddedContent::Text(_))).any(|(index, item)| {
let rect = screen_rect(xf, info, page, item.content.rect());
rect.expand(2.0).contains(p)
|| cv.selected == Some((page, index)) && handles(rect).into_iter().any(|(corner, _, _)| corner.distance(p) <= 6.0)
@@@ -452,14 -451,19 +453,22 @@@ pub(crate) fn page_input
consumed || hit.is_some() && resp.is_pointer_button_down_on()
}
- /// Outlines of added items (hover and selection with handles) and the box being dragged.
- pub(crate) fn paint_page(ui: &egui::Ui, painter: &egui::Painter, xf: &PageXform, page: usize, info: &DocInfo, added: &[Added], view: &DocView) {
+ /// Outlines of added items (hover and selection with handles) and the box being dragged, the
+ /// pages' `pointer` over them.
+ pub(crate) fn paint_page(
+ painter: &egui::Painter,
+ xf: &PageXform,
+ page: usize,
+ info: &DocInfo,
+ added: &[Added],
+ view: &DocView,
+ pointer: Option<Pos2>,
+ ) {
let cv = &view.content;
- let pointer = ui.input(|i| i.pointer.hover_pos());
for (i, a) in on_page(added, page) {
+ if matches!(a.content, AddedContent::Image(_)) {
+ continue;
+ }
if cv.draft.as_ref().is_some_and(|d| d.page == page && d.index == Some(i)) {
continue;
}
@@@ -718,7 -748,9 +753,9 @@@ impl crate::PdfCraftApp
}
/// Copy Image: image `index` on `page`, at its own resolution, to the clipboard.
- pub(crate) fn copy_page_image(&mut self, page: usize, index: usize) -> bool {
+ pub fn copy_page_image(&mut self, page: usize, index: usize) -> bool {
+ // A newer copy wins over a whole-document copy still reading its pages.
+ self.document_copy = None;
let Some((_, id)) = self.active_ids() else { return false };
if !self.may_copy(id) {
return false;
@@@ -1083,64 -964,16 +1120,74 @@@ pub(crate) fn image_panel(ui: &mut egui
out
}
+/// Update an added image's crop box and adjust its rect dimensions immediately.
+pub fn update_image_crop(img: &mut pdfcraft_engine::AddedImage, new_crop: [f64; 4]) {
+ let new_crop = [new_crop[0].clamp(0.0, 0.95), new_crop[1].clamp(0.0, 0.95), new_crop[2].clamp(0.0, 0.95), new_crop[3].clamp(0.0, 0.95)];
+ if new_crop != img.crop {
+ let [old_l, old_b, old_r, old_t] = img.crop.map(|v| v.clamp(0.0, 0.95));
+ let old_cw = (1.0 - old_l - old_r).max(0.05);
+ let old_ch = (1.0 - old_b - old_t).max(0.05);
+
+ let [new_l, new_b, new_r, new_t] = new_crop;
+ let new_cw = (1.0 - new_l - new_r).max(0.05);
+ let new_ch = (1.0 - new_b - new_t).max(0.05);
+
+ let [x0, y0, x1, y1] =
+ [img.rect[0].min(img.rect[2]), img.rect[1].min(img.rect[3]), img.rect[0].max(img.rect[2]), img.rect[1].max(img.rect[3])];
+ let current_w = x1 - x0;
+ let current_h = y1 - y0;
+
+ let base_w = current_w / old_cw;
+ let base_h = current_h / old_ch;
+
+ let new_w = base_w * new_cw;
+ let new_h = base_h * new_ch;
+
+ let (ux, uy, vx, vy): (f64, f64, f64, f64) = match img.rotation % 4 {
+ 1 => (0.0, 1.0, -1.0, 0.0),
+ 2 => (-1.0, 0.0, 0.0, -1.0),
+ 3 => (0.0, -1.0, 1.0, 0.0),
+ _ => (1.0, 0.0, 0.0, 1.0),
+ };
+ let (ux, uy) = if img.flip_h { (-ux, -uy) } else { (ux, uy) };
+ let (vx, vy) = if img.flip_v { (-vx, -vy) } else { (vx, vy) };
+
+ let base_ox = x0
+ - (base_w * old_l) * ux.max(0.0)
+ - (base_w * old_r) * (-ux).max(0.0)
+ - (base_h * old_b) * vx.max(0.0)
+ - (base_h * old_t) * (-vx).max(0.0);
+ let base_oy = y0
+ - (base_w * old_l) * uy.max(0.0)
+ - (base_w * old_r) * (-uy).max(0.0)
+ - (base_h * old_b) * vy.max(0.0)
+ - (base_h * old_t) * (-vy).max(0.0);
+
+ let new_ox = base_ox
+ + (base_w * new_l) * ux.max(0.0)
+ + (base_w * new_r) * (-ux).max(0.0)
+ + (base_h * new_b) * vx.max(0.0)
+ + (base_h * new_t) * (-vx).max(0.0);
+ let new_oy = base_oy
+ + (base_w * new_l) * uy.max(0.0)
+ + (base_w * new_r) * (-uy).max(0.0)
+ + (base_h * new_b) * vy.max(0.0)
+ + (base_h * new_t) * (-vy).max(0.0);
+
+ img.crop = new_crop;
+ img.rect = [new_ox, new_oy, new_ox + new_w, new_oy + new_h];
+ }
+}
+ /// The editor's layout of added text with character spacing. The page puts the spacing after every
+ /// character, the last of a line included (`latin_width`), while epaint puts it only between
+ /// characters: the wrap width gives up one spacing so both break lines at the same place.
+ fn spaced_job(text: &str, font: &egui::FontId, color: Color32, letter_spacing: f32, wrap_width: f32, halign: egui::Align) -> egui::text::LayoutJob {
+ let format = egui::TextFormat { font_id: font.clone(), color, extra_letter_spacing: letter_spacing, ..Default::default() };
+ let mut job = egui::text::LayoutJob::single_section(text.to_owned(), format);
+ job.wrap.max_width = (wrap_width - letter_spacing).max(0.0);
+ job.halign = halign;
+ job
+ }
#[cfg(test)]
mod tests {
diff --cc crates/ui-egui/src/dialogs.rs
index cd980cc4c,a6f247757..7fd8998ad
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@@ -1304,47 -1333,47 +1430,51 @@@ fn dialogs(app: &mut PdfCraftApp, ctx:
}
ui.add_space(16.0);
let changed = draft_changes(app).is_some_and(|c| !c.is_empty());
- ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
- if dialog == Dialog::Recovery {
- if widgets::pill_button(ui, tl!("Recover"), true).clicked() {
- recover = Some(true);
- close = true;
- }
- if widgets::pill_button(ui, tl!("Discard"), false).clicked() {
- recover = Some(false);
- close = true;
- }
- } else if dialog == Dialog::PinTool {
- if widgets::pill_button(ui, tl!("Done"), true).clicked() {
- close = true;
- }
- } else if dialog == Dialog::NumberPages {
- if widgets::pill_button(ui, tl!("OK"), true).clicked() {
- apply_number = true;
- close = true;
- }
- if widgets::pill_button(ui, tl!("Cancel"), false).clicked() {
- close = true;
- }
- } else if dialog == Dialog::Split {
- if ui.add_enabled_ui(split_ready.is_some(), |ui| widgets::pill_button(ui, tl!("Split"), true)).inner.clicked() {
- split_now = split_ready.clone();
- close = true;
- }
- if widgets::pill_button(ui, tl!("Cancel"), false).clicked() {
- close = true;
- }
- } else if changed {
- if widgets::pill_button(ui, tl!("OK"), true).clicked() {
- apply = true;
- close = true;
- }
- if widgets::pill_button(ui, tl!("Cancel"), false).clicked() {
+ // One row high: on its own, a right-to-left layout centres the buttons in all the height
+ // left, which after a taller Properties tab is the room that tab left behind.
+ ui.horizontal(|ui| {
+ ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
+ if dialog == Dialog::Recovery {
+ if widgets::pill_button(ui, tl!("Recover"), true).clicked() {
+ recover = Some(true);
+ close = true;
+ }
+ if widgets::pill_button(ui, tl!("Discard"), false).clicked() {
+ recover = Some(false);
+ close = true;
+ }
++ } else if dialog == Dialog::PinTool {
++ if widgets::pill_button(ui, tl!("Done"), true).clicked() {
++ close = true;
++ }
+ } else if dialog == Dialog::NumberPages {
+ if widgets::pill_button(ui, tl!("OK"), true).clicked() {
+ apply_number = true;
+ close = true;
+ }
+ if widgets::pill_button(ui, tl!("Cancel"), false).clicked() {
+ close = true;
+ }
+ } else if dialog == Dialog::Split {
+ if ui.add_enabled_ui(split_ready.is_some(), |ui| widgets::pill_button(ui, tl!("Split"), true)).inner.clicked() {
+ split_now = split_ready.clone();
+ close = true;
+ }
+ if widgets::pill_button(ui, tl!("Cancel"), false).clicked() {
+ close = true;
+ }
+ } else if changed {
+ if widgets::pill_button(ui, tl!("OK"), true).clicked() {
+ apply = true;
+ close = true;
+ }
+ if widgets::pill_button(ui, tl!("Cancel"), false).clicked() {
+ close = true;
+ }
+ } else if widgets::pill_button(ui, tl!("Close"), true).clicked() {
close = true;
}
- } else if widgets::pill_button(ui, tl!("Close"), true).clicked() {
- close = true;
- }
- })
++ });
});
});
if let Some(yes) = recover {
diff --cc crates/ui-egui/src/edit_text_ui.rs
index 2502c2927,f67398d84..c2db801c5
--- a/crates/ui-egui/src/edit_text_ui.rs
+++ b/crates/ui-egui/src/edit_text_ui.rs
@@@ -12,7 -12,7 +12,8 @@@ use pdfcraft_engine::{Edit, ObjectKind
use pdfcraft_render::DocInfo;
use crate::canvas::{DocView, PageXform};
+use crate::image_engine::{CROP_ACCENT, HandleId, apply_crop, apply_resize, apply_resize_proportional, draw_handle, draw_rule_of_thirds};
+ use crate::page_pointer::PagePointer;
const ACCENT: Color32 = Color32::from_rgb(0x14, 0x73, 0xE6);
@@@ -1080,25 -510,16 +1085,25 @@@ fn crop_input
allow_interaction: bool,
) -> bool {
let painter = ui.painter();
- let Some(mode) = view.image_selection.as_mut().and_then(|s| s.crop.as_mut()) else { return false };
+ let Some(sel) = view.image_selection.as_mut() else { return false };
+ if let Some(rect) = sel.crop_rect
+ && let Some(mode) = sel.crop.as_mut()
+ {
+ mode.keep = user_box(xf, info, page, rect);
+ sel.crop_rect = None;
+ }
+ let Some(mode) = sel.crop.as_mut() else { return false };
- let hover_pos = ui.input(|inp| inp.pointer.hover_pos());
+ let hover_pos = ptr.pos;
+ let full_b = xf.user_rect(info, page, image.rect.map(|v| v as f32));
+ let b = if full_b.is_positive() { full_b } else { xf.user_rect(info, page, image.visible_rect.unwrap_or(image.rect).map(|v| v as f32)) };
let keep_screen = |keep: [f64; 4]| xf.user_rect(info, page, keep.map(|v| v as f32)).intersect(b);
- // A drag in progress moves a grip; the box stays inside the picture and at least 6 px.
+ let k = keep_screen(mode.keep);
+
if allow_interaction
&& resp.drag_started()
- && let Some(o) = ui.input(|inp| inp.pointer.press_origin())
+ && let Some(o) = ptr.origin
{
- let k = keep_screen(mode.keep);
- let grip = crop_handles(k).iter().position(|h| h.distance(o) < 8.0).or_else(|| k.contains(o).then_some(8));
+ let grip = crop_handles(k).iter().position(|h| h.distance(o) < 10.0).or_else(|| k.contains(o).then_some(8));
if let Some(g) = grip {
mode.drag = Some((g, o, mode.keep));
}
@@@ -1109,38 -529,41 +1114,37 @@@
{
let d = p - start;
let k0 = keep_screen(at_start);
- let (mut min, mut max) = (k0.min, k0.max);
- match grip {
- 0 => {
- min.x += d.x;
- min.y += d.y;
- }
- 1 => {
- max.x += d.x;
- min.y += d.y;
- }
- 2 => {
- min.x += d.x;
- max.y += d.y;
- }
- 3 => {
- max.x += d.x;
- max.y += d.y;
- }
- 4 => min.y += d.y,
- 5 => max.x += d.x,
- 6 => max.y += d.y,
- 7 => min.x += d.x,
- _ => {
- let shift = egui::vec2(d.x.clamp(b.min.x - k0.min.x, b.max.x - k0.max.x), d.y.clamp(b.min.y - k0.min.y, b.max.y - k0.max.y));
- min += shift;
- max += shift;
- }
+ if grip < 8 {
+ let handle_id = match grip {
+ 0 => HandleId::TopLeft,
+ 1 => HandleId::TopRight,
+ 2 => HandleId::BottomLeft,
+ 3 => HandleId::BottomRight,
+ 4 => HandleId::TopMid,
+ 5 => HandleId::RightMid,
+ 6 => HandleId::BottomMid,
+ _ => HandleId::LeftMid,
+ };
+ let uv0 = if b.width() > 0.0 && b.height() > 0.0 {
+ Rect::from_min_max(
+ pos2(((k0.min.x - b.min.x) / b.width()).clamp(0.0, 1.0), ((k0.min.y - b.min.y) / b.height()).clamp(0.0, 1.0)),
+ pos2(((k0.max.x - b.min.x) / b.width()).clamp(0.0, 1.0), ((k0.max.y - b.min.y) / b.height()).clamp(0.0, 1.0)),
+ )
+ } else {
+ Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0))
+ };
+ let (new_screen, _) = apply_crop(k0, uv0, handle_id, d);
+ let (min_w, min_h) = (6.0_f32.min(b.width()), 6.0_f32.min(b.height()));
+ let clamped = Rect::from_min_max(
+ pos2(new_screen.min.x.clamp(b.min.x, b.max.x - min_w), new_screen.min.y.clamp(b.min.y, b.max.y - min_h)),
+ pos2(new_screen.max.x.clamp(b.min.x + min_w, b.max.x), new_screen.max.y.clamp(b.min.y + min_h, b.max.y)),
+ );
+ mode.keep = user_box(xf, info, page, clamped);
+ } else {
+ let shift = egui::vec2(d.x.clamp(b.min.x - k0.min.x, b.max.x - k0.max.x), d.y.clamp(b.min.y - k0.min.y, b.max.y - k0.max.y));
+ mode.keep = user_box(xf, info, page, Rect::from_min_max(k0.min + shift, k0.max + shift));
}
-
- if resp.drag_stopped() || !ui.input(|inp| inp.pointer.primary_down()) {
- let (min_w, min_h) = (6.0_f32.min(b.width()), 6.0_f32.min(b.height()));
- min.x = min.x.clamp(b.min.x, b.max.x - min_w);
- min.y = min.y.clamp(b.min.y, b.max.y - min_h);
- max.x = max.x.clamp(min.x + min_w, b.max.x);
- max.y = max.y.clamp(min.y + min_h, b.max.y);
- mode.keep = user_box(xf, info, page, Rect::from_min_max(min, max));
+ if resp.drag_stopped() || !ptr.primary_down {
mode.drag = None;
}
}
@@@ -1357,17 -669,17 +1361,17 @@@ fn stretched_picture(painter: &egui::Pa
/// Once a selected corner or the rotate knob is grabbed, text under it cannot take over the gesture. The same
/// applies after the pointer leaves the image/page while dragging.
- pub(crate) fn image_owns_pointer(ui: &egui::Ui, xf: &PageXform, page: usize, info: &DocInfo, view: &DocView) -> bool {
-pub(crate) fn image_owns_pointer(ui: &egui::Ui, xf: &PageXform, ptr: &PagePointer, page: usize, info: &DocInfo, view: &DocView) -> bool {
++pub(crate) fn image_owns_pointer(_ui: &egui::Ui, xf: &PageXform, ptr: &PagePointer, page: usize, info: &DocInfo, view: &DocView) -> bool {
let Some(selection) = view.image_selection.as_ref().filter(|s| s.page == page) else { return false };
- if selection.drag.is_some() {
+ if selection.drag.is_some() || selection.crop.is_some() || selection.crop_mode {
return true;
}
let Some(image) = view.edit_images.get(&page).and_then(|(_, images)| images.get(selection.index)) else { return false };
- let Some(rect) = image.visible_rect else { return false };
- let b = xf.user_rect(info, page, rect.map(|v| v as f32));
+ let obb = ImageObb::from_image(image, xf, info, page);
- let p = ui.input(|i| if i.pointer.primary_down() { i.pointer.press_origin() } else { i.pointer.hover_pos() });
+ let p = if ptr.primary_down { ptr.origin } else { ptr.pos };
- let knob = rotate_knob(b, ui.clip_rect()).0;
- p.is_some_and(|p| [b.left_top(), b.right_top(), b.left_bottom(), b.right_bottom(), knob].iter().any(|c| c.distance(p) < 8.0))
+ let Some(p) = p else { return false };
+
+ obb.handles().iter().any(|(_, h)| h.distance(p) < 8.0) || obb.s_rot.distance(p) < 8.0
}
/// What a drag on a paragraph box takes hold of.
@@@ -1505,12 -810,12 +1510,12 @@@ pub(crate) fn image_input
info: &DocInfo,
images: &[pdfcraft_engine::PageImage],
view: &mut DocView,
- action: &mut Option<ImageAction>,
+ _action: &mut Option<ImageAction>,
allow_interaction: bool,
) -> bool {
- let boxes: Vec<Rect> = images.iter().map(|im| im.visible_rect.map_or(Rect::NOTHING, |r| xf.user_rect(info, page, r.map(|v| v as f32)))).collect();
+ let boxes: Vec<Rect> = images.iter().map(|im| crate::canvas::image_screen_rect(im, xf, info, page)).collect();
let painter = ui.painter();
- let hover_pos = ui.input(|i| i.pointer.hover_pos());
+ let hover_pos = ptr.pos;
let image_contains = |index: usize, point: Pos2| {
let (x, y) = xf.screen_to_view(point);
let Some(p) = info.pages.get(page) else { return false };
@@@ -1584,10 -858,31 +1589,16 @@@
// The selected image: frame, corner handles, dragging.
if let Some(i) = selected.filter(|i| boxes.get(*i).is_some_and(|b| b.is_positive())) {
let b = boxes[i];
- if view.image_selection.as_ref().is_some_and(|s| s.crop.is_some()) {
- return crop_input(ui, resp, xf, ptr, page, info, view, i, b, allow_interaction);
- }
- let corners = [b.left_top(), b.right_top(), b.left_bottom(), b.right_bottom()];
- let handles = |rect: Rect| {
- for c in [rect.left_top(), rect.right_top(), rect.left_bottom(), rect.right_bottom()] {
- painter.rect(
- Rect::from_center_size(c, egui::vec2(8.0, 8.0)),
- CornerRadius::ZERO,
- Color32::WHITE,
- Stroke::new(1.0, ACCENT),
- egui::StrokeKind::Middle,
- );
- }
- };
+ let image = &images[i];
+ let obb = ImageObb::from_image(image, xf, info, page);
+ // Until the page is rendered again its raster has an applied move or resize's picture
+ // where it was: it stays blanked there and drawn where it went.
+ // The whole-page raster and its tiles are replaced separately: the old frame stays blanked
+ // while anything still shows the picture there, but its pixels come from the old frame
+ // only while the whole-page raster itself is the old one. Once that is fresh it has the
+ // picture where it went, and that is where they come from.
let (out_of_date, raster_old, raster) = (view.page_out_of_date(page), view.page_raster_out_of_date(page), view.page_raster(page));
let screen = |r: Rect| Rect::from_two_pos(xf.norm_to_screen(r.min.x, r.min.y), xf.norm_to_screen(r.max.x, r.max.y));
- // Where the screen may still show the picture from before an applied move, while the page
- // isn't drawn again yet. Another drag keeps it blanked too.
let left_at = view.image_selection.as_ref().and_then(|s| s.settled).filter(|_| out_of_date).map(|(from, _)| from);
if let Some(s) = view.image_selection.as_mut().filter(|s| s.drag.is_none()) {
match (s.settled, raster) {
@@@ -1595,119 -890,43 +1606,119 @@@
let source = if raster_old { from } else { to };
stretched_picture(painter, xf, tex, &[screen(from)], screen(source), screen(to));
}
- _ => s.settled = None,
+ _ if !out_of_date => s.settled = None,
+ _ => {}
}
}
- if view.image_selection.as_ref().is_some_and(|s| s.drag.is_none()) {
- painter.rect_stroke(b, CornerRadius::ZERO, Stroke::new(1.5, ACCENT), egui::StrokeKind::Outside);
- handles(b);
- }
- if allow_interaction && let Some(corner) = hover_pos.and_then(|p| corners.iter().position(|c| c.distance(p) < 8.0)) {
- ui.ctx().set_cursor_icon(if matches!(corner, 0 | 3) { egui::CursorIcon::ResizeNwSe } else { egui::CursorIcon::ResizeNeSw });
+
+ if view.image_selection.as_ref().is_some_and(|s| s.crop.is_some() || s.crop_mode) {
+ if let Some(s) = view.image_selection.as_mut()
+ && s.crop.is_none()
+ {
+ let rect = images.get(i).and_then(|im| im.visible_rect).unwrap_or(images.get(i).map_or([0.0; 4], |im| im.rect));
+ s.crop = Some(CropMode::new(rect));
+ }
- return crop_input(ui, resp, xf, page, info, view, i, image, allow_interaction);
++ return crop_input(ui, resp, xf, ptr, page, info, view, i, image, allow_interaction);
}
- // The rotate handle: a knob above the top edge, joined to it by a short stem.
let (knob, stem) = rotate_knob(b, ui.clip_rect());
if view.image_selection.as_ref().is_some_and(|s| s.drag.is_none()) {
- painter.line_segment([stem, knob], Stroke::new(1.0, ACCENT));
- painter.circle(knob, 5.0, Color32::WHITE, Stroke::new(1.0, ACCENT));
- if allow_interaction && hover_pos.is_some_and(|p| p.distance(knob) < 8.0) {
- ui.ctx().set_cursor_icon(egui::CursorIcon::Grab);
+ if obb.is_rotated {
+ painter.polygon(obb.corners().to_vec(), Color32::TRANSPARENT, Stroke::new(1.5, ACCENT));
+ painter.line_segment([obb.s_tc, obb.s_rot], Stroke::new(1.2, ACCENT));
+ painter.circle(obb.s_rot, 4.5, Color32::WHITE, Stroke::new(1.0, ACCENT));
+ } else {
+ painter.rect_stroke(b, CornerRadius::ZERO, Stroke::new(1.5, ACCENT), egui::StrokeKind::Outside);
+ painter.line_segment([stem, knob], Stroke::new(1.0, ACCENT));
+ painter.circle(knob, 5.0, Color32::WHITE, Stroke::new(1.0, ACCENT));
+ }
+ for (_, h) in obb.handles() {
+ let is_hovered = hover_pos.is_some_and(|p| p.distance(h) < 10.0);
+ draw_handle(painter, h, false, is_hovered, false, ACCENT);
}
}
- if allow_interaction
- && resp.drag_started()
- && let Some(o) = ptr.origin
- && o.distance(knob) < 8.0
- {
- if let Some(s) = view.image_selection.as_mut() {
- s.drag = Some((o, None));
- s.turning = true;
+
+ let mut handle_drag = None;
+ for (h, h_pos, handle_id) in obb.handles_with_ids(ui.id().with("img_handle")) {
+ let handle_rect = Rect::from_center_size(h_pos, egui::vec2(18.0, 18.0));
+ let handle_resp = ui.interact(handle_rect, handle_id, egui::Sense::drag());
+ if allow_interaction && handle_resp.drag_started() {
+ handle_drag = Some(h);
}
- } else if allow_interaction
- && resp.drag_started()
- && let Some(o) = ptr.origin
- {
- let corner = corners.iter().position(|c| c.distance(o) < 8.0);
- if corner.is_some() || image_contains(i, o) {
- let opposite = corner.map(|k| corners[3 - k]);
+ }
+ let rot_id = ui.id().with("img_handle").with(8);
+ let rot_rect = Rect::from_center_size(if obb.is_rotated { obb.s_rot } else { knob }, egui::vec2(12.0, 12.0));
+ let rot_resp = ui.interact(rot_rect, rot_id, egui::Sense::drag());
+ let rot_drag = allow_interaction && rot_resp.drag_started();
+
+ if allow_interaction && let Some(p) = hover_pos {
+ if obb.s_rot.distance(p) < 8.0 || knob.distance(p) < 8.0 {
+ ui.ctx().set_cursor_icon(egui::CursorIcon::Grab);
+ } else if let Some((h, _)) = obb.handles().iter().find(|(_, pos)| pos.distance(p) < 8.0) {
+ let icon = match h {
+ ImageHandle::TopLeft | ImageHandle::BottomRight => {
+ if obb.is_rotated {
+ let v = obb.handle_pos(*h) - obb.screen_center;
+ if v.x * v.y > 0.0 { egui::CursorIcon::ResizeNwSe } else { egui::CursorIcon::ResizeNeSw }
+ } else {
+ egui::CursorIcon::ResizeNwSe
+ }
+ }
+ ImageHandle::TopRight | ImageHandle::BottomLeft => {
+ if obb.is_rotated {
+ let v = obb.handle_pos(*h) - obb.screen_center;
+ if v.x * v.y > 0.0 { egui::CursorIcon::ResizeNwSe } else { egui::CursorIcon::ResizeNeSw }
+ } else {
+ egui::CursorIcon::ResizeNeSw
+ }
+ }
+ ImageHandle::TopCenter | ImageHandle::BottomCenter => {
+ if obb.is_rotated && (obb.v_axis.0.abs() > obb.v_axis.1.abs()) {
+ egui::CursorIcon::ResizeHorizontal
+ } else {
+ egui::CursorIcon::ResizeVertical
+ }
+ }
+ ImageHandle::RightCenter | ImageHandle::LeftCenter => {
+ if obb.is_rotated && (obb.u_axis.1.abs() > obb.u_axis.0.abs()) {
+ egui::CursorIcon::ResizeVertical
+ } else {
+ egui::CursorIcon::ResizeHorizontal
+ }
+ }
+ };
+ ui.ctx().set_cursor_icon(icon);
+ }
+ }
+
- let origin = ui.input(|i| i.pointer.press_origin());
++ let origin = ptr.origin;
+ if allow_interaction {
+ if let Some(h) = handle_drag {
+ if let Some(s) = view.image_selection.as_mut() {
+ let o = origin.unwrap_or_else(|| obb.handle_pos(h));
+ s.drag = Some(ImageDrag { start: o, target: DragTarget::Handle(h), initial_rect: b, initial_matrix: image.matrix });
+ }
+ } else if rot_drag {
if let Some(s) = view.image_selection.as_mut() {
- s.drag = Some((o, opposite));
+ let o = origin.unwrap_or(if obb.is_rotated { obb.s_rot } else { knob });
+ s.drag = Some(ImageDrag { start: o, target: DragTarget::Rotate, initial_rect: b, initial_matrix: image.matrix });
+ s.turning = true;
+ }
+ } else if resp.drag_started()
+ && let Some(o) = origin
+ {
+ if obb.s_rot.distance(o) < 8.0 || knob.distance(o) < 8.0 {
+ if let Some(s) = view.image_selection.as_mut() {
+ s.drag = Some(ImageDrag { start: o, target: DragTarget::Rotate, initial_rect: b, initial_matrix: image.matrix });
+ s.turning = true;
+ }
+ } else if let Some((h, _)) = obb.handles().iter().find(|(_, pos)| pos.distance(o) < 8.0) {
+ if let Some(s) = view.image_selection.as_mut() {
+ s.drag = Some(ImageDrag { start: o, target: DragTarget::Handle(*h), initial_rect: b, initial_matrix: image.matrix });
+ }
+ } else if (image_contains(i, o) || quad_contains(obb.corners(), o))
+ && let Some(s) = view.image_selection.as_mut()
+ {
+ s.drag = Some(ImageDrag { start: o, target: DragTarget::Move, initial_rect: b, initial_matrix: image.matrix });
}
}
}
@@@ -1741,265 -959,71 +1752,264 @@@
}
return true;
}
- if let Some((start, opposite)) = view.image_selection.as_ref().and_then(|s| s.drag)
+
+ if let Some(drag) = view.image_selection.as_ref().and_then(|s| s.drag)
&& let Some(p) = hover_pos
{
- let preview = match opposite {
- // Resize from the opposite corner, keeping the aspect ratio.
- Some(fixed) => {
- let (w0, h0) = (b.width().max(1.0), b.height().max(1.0));
- // Use the axis with the larger relative pointer change. Taking the maximum
- // absolute size freezes shrinking when the other axis hasn't moved. Measure
- // from the press point so grabbing a handle off-centre cannot cause a jump.
- let horizontal = (p.x - start.x) * (start.x - fixed.x).signum() / w0;
- let vertical = (p.y - start.y) * (start.y - fixed.y).signum() / h0;
- let delta = if horizontal.abs() > vertical.abs() { horizontal } else { vertical };
- let k = (1.0 + delta).max(0.05);
- let (w, h) = (w0 * k, h0 * k);
- let x = if start.x < fixed.x { fixed.x - w } else { fixed.x };
- let y = if start.y < fixed.y { fixed.y - h } else { fixed.y };
- Rect::from_min_size(Pos2::new(x, y), egui::vec2(w, h))
+ if !obb.is_rotated && !matches!(drag.target, DragTarget::Rotate) {
+ let preview = match drag.target {
+ DragTarget::Handle(handle) => {
+ let handle_id = HandleId::from(handle);
+ let delta = p - drag.start;
+ let is_corner = matches!(handle_id, HandleId::TopLeft | HandleId::TopRight | HandleId::BottomLeft | HandleId::BottomRight);
+ let shift = ui.input(|inp| inp.modifiers.shift);
+ if is_corner && !shift {
+ apply_resize_proportional(drag.initial_rect, handle_id, delta)
+ } else {
+ apply_resize(drag.initial_rect, handle_id, delta)
+ }
+ }
+ DragTarget::Move => drag.initial_rect.translate(p - drag.start),
+ _ => drag.initial_rect,
+ };
+
+ let raw = images.get(i).map_or(b, |im| xf.user_rect(info, page, im.rect.map(|v| v as f32)));
+ let ratio = |new: f32, old: f32| if old.abs() > 1e-3 && (new / old).is_finite() { new / old } else { 1.0 };
+ let factor = egui::vec2(ratio(preview.width(), b.width()), ratio(preview.height(), b.height()));
+ let f_min = egui::vec2((raw.min.x - b.min.x) * factor.x, (raw.min.y - b.min.y) * factor.y);
+ let f_max = egui::vec2((raw.max.x - b.min.x) * factor.x, (raw.max.y - b.min.y) * factor.y);
+ let target = Rect::from_min_max(preview.min + f_min, preview.min + f_max);
+ let visible = preview.intersect(xf.rect);
+
+ if visible.is_positive() {
+ if preview != b
+ && let Some(tex) = raster
+ {
+ let source = left_at.filter(|_| raster_old).map_or(b, screen);
+ let blank: Vec<Rect> = left_at.map(screen).into_iter().chain(std::iter::once(b)).collect();
+ stretched_picture(painter, xf, tex, &blank, source, preview);
+ }
+ painter.rect_filled(visible, CornerRadius::ZERO, ACCENT.gamma_multiply(0.04));
+ painter.rect_stroke(visible, CornerRadius::ZERO, Stroke::new(1.5, ACCENT), egui::StrokeKind::Outside);
+ for h in [
+ preview.left_top(),
+ preview.right_top(),
+ preview.left_bottom(),
+ preview.right_bottom(),
+ preview.center_top(),
+ preview.right_center(),
+ preview.center_bottom(),
+ preview.left_center(),
+ ] {
+ draw_handle(painter, h, false, false, false, ACCENT);
+ }
+ }
+
+ if resp.drag_stopped() || !ui.input(|inp| inp.pointer.primary_down()) {
+ if let Some(s) = view.image_selection.as_mut() {
+ s.drag = None;
+ let norm = |r: Rect| {
+ let ((u0, v0), (u1, v1)) = (xf.screen_to_norm(r.min), xf.screen_to_norm(r.max));
+ Rect::from_two_pos(Pos2::new(u0, v0), Pos2::new(u1, v1))
+ };
+ s.settled = (preview != b).then(|| (left_at.unwrap_or_else(|| norm(b)), norm(preview)));
+ }
+ if preview != b {
+ view.pending_edit =
+ Some(Edit::EditPageImage { page, index: i, change: pdfcraft_engine::ImageEdit::Move(user_box(xf, info, page, target)) });
+ }
+ }
+
+ let icon = match drag.target {
+ DragTarget::Handle(handle) => HandleId::from(handle).cursor_icon(),
+ DragTarget::Move => egui::CursorIcon::Grabbing,
+ _ => egui::CursorIcon::Move,
+ };
+ ui.ctx().set_cursor_icon(icon);
+ return true;
+ }
-
+ let m_init = Matrix(drag.initial_matrix);
+ let [a0, b0, c0, d0, e0, f0] = drag.initial_matrix;
+ let w0 = (a0 * a0 + b0 * b0).sqrt().max(1e-6);
+ let h0 = (c0 * c0 + d0 * d0).sqrt().max(1e-6);
+ let u_axis = (a0 / w0, b0 / w0);
+ let v_axis = (c0 / h0, d0 / h0);
+ let center_user = (e0 + 0.5 * (a0 + c0), f0 + 0.5 * (b0 + d0));
+
+ let (sx, sy) = screen_to_user(xf, info, page, drag.start);
+ let (px, py) = screen_to_user(xf, info, page, p);
+
+ let (m_new, cursor_icon) = match drag.target {
+ DragTarget::Rotate => {
+ let v0 = (sx - center_user.0, sy - center_user.1);
+ let v1 = (px - center_user.0, py - center_user.1);
+ let theta0 = v0.1.atan2(v0.0);
+ let theta1 = v1.1.atan2(v1.0);
+ let mut delta = theta1 - theta0;
+ if ui.input(|i| i.modifiers.shift) {
+ let step = std::f64::consts::PI / 12.0;
+ delta = (delta / step).round() * step;
+ }
+ let (cos_d, sin_d) = (delta.cos(), delta.sin());
+ let t_rot = [
+ cos_d,
+ sin_d,
+ -sin_d,
+ cos_d,
+ center_user.0 * (1.0 - cos_d) + center_user.1 * sin_d,
+ center_user.1 * (1.0 - cos_d) - center_user.0 * sin_d,
+ ];
+ (m_init.then(&Matrix(t_rot)), egui::CursorIcon::Grab)
+ }
+ DragTarget::Move => {
+ let (dx, dy) = (px - sx, py - sy);
+ (Matrix([a0, b0, c0, d0, e0 + dx, f0 + dy]), egui::CursorIcon::Move)
}
- None => b.translate(p - start),
+ DragTarget::Handle(handle) => {
+ let p00 = (e0, f0);
+ let p10 = (e0 + a0, f0 + b0);
+ let p11 = (e0 + a0 + c0, f0 + b0 + d0);
+ let p01 = (e0 + c0, f0 + d0);
+ let p_curr = (px, py);
+
+ let (new_w, new_h, p00_new, icon) = match handle {
+ ImageHandle::TopRight => {
+ let anchor = p00;
+ let d = (p_curr.0 - anchor.0, p_curr.1 - anchor.1);
+ let du = d.0 * u_axis.0 + d.1 * u_axis.1;
+ let dv = d.0 * v_axis.0 + d.1 * v_axis.1;
+ let su = du / w0;
+ let sv = dv / h0;
+ let s = if (su - 1.0).abs() >= (sv - 1.0).abs() { su } else { sv };
+ let s = s.max(5.0 / w0).max(5.0 / h0);
+ (w0 * s, h0 * s, anchor, egui::CursorIcon::ResizeNeSw)
+ }
+ ImageHandle::TopLeft => {
+ let anchor = p10;
+ let d = (p_curr.0 - anchor.0, p_curr.1 - anchor.1);
+ let du = d.0 * (-u_axis.0) + d.1 * (-u_axis.1);
+ let dv = d.0 * v_axis.0 + d.1 * v_axis.1;
+ let su = du / w0;
+ let sv = dv / h0;
+ let s = if (su - 1.0).abs() >= (sv - 1.0).abs() { su } else { sv };
+ let s = s.max(5.0 / w0).max(5.0 / h0);
+ let nw = w0 * s;
+ let nh = h0 * s;
+ (nw, nh, (anchor.0 - nw * u_axis.0, anchor.1 - nw * u_axis.1), egui::CursorIcon::ResizeNwSe)
+ }
+ ImageHandle::BottomLeft => {
+ let anchor = p11;
+ let d = (p_curr.0 - anchor.0, p_curr.1 - anchor.1);
+ let du = d.0 * (-u_axis.0) + d.1 * (-u_axis.1);
+ let dv = d.0 * (-v_axis.0) + d.1 * (-v_axis.1);
+ let su = du / w0;
+ let sv = dv / h0;
+ let s = if (su - 1.0).abs() >= (sv - 1.0).abs() { su } else { sv };
+ let s = s.max(5.0 / w0).max(5.0 / h0);
+ let nw = w0 * s;
+ let nh = h0 * s;
+ (
+ nw,
+ nh,
+ (anchor.0 - nw * u_axis.0 - nh * v_axis.0, anchor.1 - nw * u_axis.1 - nh * v_axis.1),
+ egui::CursorIcon::ResizeNeSw,
+ )
+ }
+ ImageHandle::BottomRight => {
+ let anchor = p01;
+ let d = (p_curr.0 - anchor.0, p_curr.1 - anchor.1);
+ let du = d.0 * u_axis.0 + d.1 * u_axis.1;
+ let dv = d.0 * (-v_axis.0) + d.1 * (-v_axis.1);
+ let su = du / w0;
+ let sv = dv / h0;
+ let s = if (su - 1.0).abs() >= (sv - 1.0).abs() { su } else { sv };
+ let s = s.max(5.0 / w0).max(5.0 / h0);
+ let nw = w0 * s;
+ let nh = h0 * s;
+ (nw, nh, (anchor.0 - nh * v_axis.0, anchor.1 - nh * v_axis.1), egui::CursorIcon::ResizeNwSe)
+ }
+ ImageHandle::RightCenter => {
+ let anchor = p00;
+ let d = (p_curr.0 - anchor.0, p_curr.1 - anchor.1);
+ let du = (d.0 * u_axis.0 + d.1 * u_axis.1).max(5.0);
+ (du, h0, anchor, egui::CursorIcon::ResizeHorizontal)
+ }
+ ImageHandle::LeftCenter => {
+ let anchor = p10;
+ let d = (p_curr.0 - anchor.0, p_curr.1 - anchor.1);
+ let du = (d.0 * (-u_axis.0) + d.1 * (-u_axis.1)).max(5.0);
+ (du, h0, (anchor.0 - du * u_axis.0, anchor.1 - du * u_axis.1), egui::CursorIcon::ResizeHorizontal)
+ }
+ ImageHandle::TopCenter => {
+ let anchor = p00;
+ let d = (p_curr.0 - anchor.0, p_curr.1 - anchor.1);
+ let dv = (d.0 * v_axis.0 + d.1 * v_axis.1).max(5.0);
+ (w0, dv, anchor, egui::CursorIcon::ResizeVertical)
+ }
+ ImageHandle::BottomCenter => {
+ let anchor = p01;
+ let d = (p_curr.0 - anchor.0, p_curr.1 - anchor.1);
+ let dv = (d.0 * (-v_axis.0) + d.1 * (-v_axis.1)).max(5.0);
+ (w0, dv, (anchor.0 - dv * v_axis.0, anchor.1 - dv * v_axis.1), egui::CursorIcon::ResizeVertical)
+ }
+ };
+ let mat = Matrix([new_w * u_axis.0, new_w * u_axis.1, new_h * v_axis.0, new_h * v_axis.1, p00_new.0, p00_new.1]);
+ (mat, icon)
+ }
+ _ => (m_init, egui::CursorIcon::Default),
};
- // Move/resize the full placement by the visible frame's change. The engine
- // transforms an isolated crop together with its image, preserving its contents.
- let raw = images.get(i).map_or(b, |im| xf.user_rect(info, page, im.rect.map(|v| v as f32)));
- // A zero-width or zero-height visible frame (or a degenerate ratio) keeps the
- // placement's scale instead of producing inf/NaN.
- let ratio = |new: f32, old: f32| if old.abs() > 1e-3 && (new / old).is_finite() { new / old } else { 1.0 };
- let factor = egui::vec2(ratio(preview.width(), b.width()), ratio(preview.height(), b.height()));
- let target = Rect::from_min_max(preview.min + (raw.min - b.min) * factor, preview.min + (raw.max - b.min) * factor);
- let visible = preview.intersect(xf.rect);
- if visible.is_positive() {
- // The pixels follow the frame: the page raster's picture of the image, stretched
- // into the preview over a blank where it was. Re-rendering every frame of a drag
- // would lag; the edit renders it properly on release.
- if preview != b
- && let Some(tex) = view.page_raster(page)
- {
- // Its pixels: where the whole-page raster has it.
- let source = left_at.filter(|_| raster_old).map_or(b, screen);
- let blank: Vec<Rect> = left_at.map(screen).into_iter().chain(std::iter::once(b)).collect();
- stretched_picture(painter, xf, tex, &blank, source, preview);
+
+ let preview_obb = ImageObb::new(m_new.0, xf, info, page);
+ if let Some(tex) = view.page_raster(page) {
+ let clipped = painter.with_clip_rect(painter.clip_rect().intersect(xf.rect));
+ let mut mesh = egui::Mesh::with_texture(tex);
+ let orig_corners = obb.corners();
+ let new_corners = preview_obb.corners();
+ for (from, to) in [
+ (orig_corners[3], new_corners[3]),
+ (orig_corners[2], new_corners[2]),
+ (orig_corners[1], new_corners[1]),
+ (orig_corners[0], new_corners[0]),
+ ] {
+ let (u, v) = xf.screen_to_norm(from);
+ mesh.vertices.push(egui::epaint::Vertex { pos: to, uv: Pos2::new(u, v), color: Color32::WHITE });
+ }
+ mesh.add_triangle(0, 1, 2);
+ mesh.add_triangle(0, 2, 3);
+ clipped.add(egui::Shape::mesh(mesh));
+ }
+
+ if preview_obb.is_rotated {
+ let pts = preview_obb.corners();
+ painter.polygon(pts.to_vec(), ACCENT.gamma_multiply(0.04), Stroke::new(1.5, ACCENT));
+ } else {
+ let p_rect = Rect::from_two_pos(preview_obb.s01, preview_obb.s10);
+ let visible = p_rect.intersect(xf.rect);
+ if visible.is_positive() {
+ painter.rect_filled(visible, CornerRadius::ZERO, ACCENT.gamma_multiply(0.04));
+ painter.rect_stroke(visible, CornerRadius::ZERO, Stroke::new(1.5, ACCENT), egui::StrokeKind::Outside);
}
- painter.rect_filled(visible, CornerRadius::ZERO, ACCENT.gamma_multiply(0.04));
- painter.rect_stroke(visible, CornerRadius::ZERO, Stroke::new(1.5, ACCENT), egui::StrokeKind::Outside);
- handles(preview);
}
+ for (_, h) in preview_obb.handles() {
+ draw_handle(painter, h, false, false, false, ACCENT);
+ }
+
- if resp.drag_stopped() || !ui.input(|inp| inp.pointer.primary_down()) {
+ if resp.drag_stopped() || !ptr.primary_down {
if let Some(s) = view.image_selection.as_mut() {
s.drag = None;
- let norm = |r: Rect| {
- let ((u0, v0), (u1, v1)) = (xf.screen_to_norm(r.min), xf.screen_to_norm(r.max));
- Rect::from_two_pos(Pos2::new(u0, v0), Pos2::new(u1, v1))
- };
- s.settled = (preview != b).then(|| (left_at.unwrap_or_else(|| norm(b)), norm(preview)));
}
- if preview != b {
- view.pending_edit =
- Some(Edit::EditPageImage { page, index: i, change: pdfcraft_engine::ImageEdit::Move(user_box(xf, info, page, target)) });
+ if m_new.0 != drag.initial_matrix {
+ if matches!(drag.target, DragTarget::Move) {
+ let (dx, dy) = (px - sx, py - sy);
+ let new_rect = [image.rect[0] + dx, image.rect[1] + dy, image.rect[2] + dx, image.rect[3] + dy];
+ view.pending_edit = Some(Edit::EditPageImage { page, index: i, change: pdfcraft_engine::ImageEdit::Move(new_rect) });
+ } else if let Some(inv) = Matrix(drag.initial_matrix).invert() {
+ let t = inv.then(&m_new);
+ view.pending_edit = Some(Edit::EditPageImage { page, index: i, change: pdfcraft_engine::ImageEdit::Transform(t.0) });
+ }
}
}
- ui.ctx().set_cursor_icon(match opposite {
- Some(fixed) if (start.x - fixed.x) * (start.y - fixed.y) < 0.0 => egui::CursorIcon::ResizeNeSw,
- Some(_) => egui::CursorIcon::ResizeNwSe,
- None => egui::CursorIcon::Move,
- });
+ ui.ctx().set_cursor_icon(cursor_icon);
return true;
}
if allow_interaction
@@@ -2963,101 -1980,4 +3039,103 @@@ mod tests
assert_eq!(caret_color_on(Color32::BLACK), Color32::WHITE);
assert_eq!(caret_color_on(DARK_EDITOR_FILL), Color32::WHITE);
}
+
+ #[test]
+ fn bullet_list_toggles_and_preserves_content() {
+ let mut text = "First line\nSecond line\n\nThird line".to_string();
+ assert!(!is_bulleted(&text));
+ assert!(toggle_bullet_list(&mut text));
+ assert!(is_bulleted(&text));
+ assert_eq!(text, "• First line\n• Second line\n\n• Third line");
+
+ // Toggling again removes bullets
+ assert!(toggle_bullet_list(&mut text));
+ assert!(!is_bulleted(&text));
+ assert_eq!(text, "First line\nSecond line\n\nThird line");
+ }
+
+ #[test]
+ fn numbered_list_toggles_and_preserves_content() {
+ let mut text = "Item A\nItem B\n\nItem C".to_string();
+ assert!(!is_numbered(&text));
+ assert!(toggle_numbered_list(&mut text));
+ assert!(is_numbered(&text));
+ assert_eq!(text, "1. Item A\n2. Item B\n\n3. Item C");
+
+ // Toggling again removes numbering
+ assert!(toggle_numbered_list(&mut text));
+ assert!(!is_numbered(&text));
+ assert_eq!(text, "Item A\nItem B\n\nItem C");
+ }
+
+ #[test]
+ fn superscript_and_subscript_conversion() {
+ let mut ed = LineEditor {
+ page: 0,
+ block: 0,
+ text: "E = mc2".to_string(),
+ original: "E = mc2".to_string(),
+ rect: egui::Rect::ZERO,
+ source_rect: [0.0; 4],
+ max_width: 100.0,
+ overflow: false,
+ selection: Some(6..7), // selecting '2'
+ font_resource: None,
+ fonts: std::collections::BTreeMap::new(),
+ source: None,
+ multiline: false,
+ size: 12.0,
+ family_chosen: false,
+ focus: true,
++ had_focus: false,
+ look: pdfcraft_engine::AddedText::default(),
+ look0: pdfcraft_engine::AddedText::default(),
+ extras: Extras::default(),
+ extras0: Extras::default(),
+ };
+
+ assert!(toggle_superscript(&mut ed));
+ assert_eq!(ed.text, "E = mc²");
+ // Toggling superscript again returns to normal '2'
+ assert!(toggle_superscript(&mut ed));
+ assert_eq!(ed.text, "E = mc2");
+
+ // Test subscript on H2O
+ ed.text = "H2O".to_string();
+ ed.selection = Some(1..2); // selecting '2'
+ assert!(toggle_subscript(&mut ed));
+ assert_eq!(ed.text, "H₂O");
+ assert!(toggle_subscript(&mut ed));
+ assert_eq!(ed.text, "H2O");
+ }
+
+ #[test]
+ fn value_based_line_spacing_in_style() {
+ let ed = LineEditor {
+ page: 0,
+ block: 0,
+ text: "Paragraph text".to_string(),
+ original: "Paragraph text".to_string(),
+ rect: egui::Rect::ZERO,
+ source_rect: [0.0; 4],
+ max_width: 100.0,
+ overflow: false,
+ selection: None,
+ font_resource: None,
+ fonts: std::collections::BTreeMap::new(),
+ source: None,
+ multiline: false,
+ size: 12.0,
+ family_chosen: false,
+ focus: true,
++ had_focus: false,
+ look: pdfcraft_engine::AddedText::default(),
+ look0: pdfcraft_engine::AddedText::default(),
+ extras: Extras { line_spacing: 1.33, underline: true, ..Default::default() },
+ extras0: Extras::default(),
+ };
+ let style = ed.style();
+ assert_eq!(style.line_spacing, Some(1.33));
+ assert_eq!(style.underline, Some(true));
+ }
}
diff --cc crates/ui-egui/src/editing.rs
index c2fc6f5b1,9a13d570d..9551564f3
--- a/crates/ui-egui/src/editing.rs
+++ b/crates/ui-egui/src/editing.rs
@@@ -1004,46 -1004,34 +1046,72 @@@ impl PdfCraftApp
self.shutdown_recovery();
}
}
+
+ /// Ask for the user's attention when the "save changes?" question opens while PdfCraft is in
+ /// the background (Quit in the Dock menu, logging out, or an agent quitting), and withdraw the
+ /// request once the user comes back or the question is answered.
+ ///
+ /// The question holds up the quit the user asked for, so the request is critical, as AppKit
+ /// makes it for a modal panel that an inactive app presents: the Dock icon bounces until
+ /// PdfCraft is active, Windows flashes the taskbar button until the window is in front, and
+ /// X11 sets the urgency hint, which stays until it is reset. A question that opens in front
+ /// asks nothing, and neither does leaving it open: the user has seen it. Each document asked
+ /// about when quitting is a new question, so one that opens in the background asks even after
+ /// a question the user saw; a request that still stands carries over to it.
+ pub(crate) fn attend_save_prompt(&mut self, ctx: &egui::Context) {
+ let open = self.close_request.is_some();
+ let focused = ctx.input(|i| i.focused);
+ if self.save_prompt_attention {
+ if focused || !open {
+ ctx.send_viewport_cmd(egui::ViewportCommand::RequestUserAttention(egui::UserAttentionType::Reset));
+ self.save_prompt_attention = false;
+ }
+ } else if open && !self.save_prompt_seen && !focused {
+ ctx.send_viewport_cmd(egui::ViewportCommand::RequestUserAttention(egui::UserAttentionType::Critical));
+ self.save_prompt_attention = true;
+ }
+ self.save_prompt_seen = open;
+ }
}
+fn re_resolve_image_selection(
+ view: &mut crate::DocView,
+ page: usize,
+ target: &pdfcraft_engine::PageImage,
+ ambiguous_before: bool,
+ page_images: &[pdfcraft_engine::PageImage],
+) {
+ let exact_matches: Vec<usize> = page_images
+ .iter()
+ .enumerate()
+ .filter(|(_, img)| img.name == target.name && img.object == target.object && img.rect == target.rect)
+ .map(|(idx, _)| idx)
+ .collect();
+ let new_idx = if !ambiguous_before && exact_matches.len() == 1 {
+ exact_matches.first().copied()
+ } else if !ambiguous_before && exact_matches.is_empty() {
+ let name_obj_matches: Vec<usize> =
+ page_images.iter().enumerate().filter(|(_, img)| img.name == target.name && img.object == target.object).map(|(idx, _)| idx).collect();
+ if name_obj_matches.len() == 1 {
+ name_obj_matches.first().copied()
+ } else if name_obj_matches.is_empty() {
+ let name_matches: Vec<usize> = page_images.iter().enumerate().filter(|(_, img)| img.name == target.name).map(|(idx, _)| idx).collect();
+ if name_matches.len() == 1 { name_matches.first().copied() } else { None }
+ } else {
+ None
+ }
+ } else {
+ None
+ };
+ if let Some(s) = view.image_selection.as_mut().filter(|s| s.page == page) {
+ if let Some(idx) = new_idx {
+ s.index = idx;
+ } else {
+ view.image_selection = None;
+ }
+ }
+}
+
/// The single page a content edit changes (`None` for other edits). Like comment edits,
/// these leave every other page's bytes, geometry and text alone, so their rasters stay valid.
fn content_page(edit: &Edit) -> Option<usize> {
diff --cc crates/ui-egui/src/i18n/ar.tsv
index bc85bc412,25ddac1d5..556a17b91
--- a/crates/ui-egui/src/i18n/ar.tsv
+++ b/crates/ui-egui/src/i18n/ar.tsv
@@@ -2758,25 -2766,19 +2766,38 @@@ certificate Version الإصدا�
Make properties default جعل الخصائص افتراضية
Pages selected الصفحات المحددة
Page properties خصائص الصفحة
+ Clear search مسح البحث
+ Pin تثبيت
+ Pin a tool… تثبيت أداة…
+ Pin to Home تثبيت في الصفحة الرئيسية
+ Pin tools to Home تثبيت الأدوات في الصفحة الرئيسية
+ Pin your favorite tools here for quick access. ثبّت أدواتك المفضلة هنا للوصول السريع.
+ Pinned مثبت
+ Pinned Tools الأدوات المثبتة
+ Search tools… البحث عن الأدوات…
+ Select tools to display on your Home page for quick access. حدد الأدوات المراد عرضها على صفحتك الرئيسية للوصول السريع.
+ Unpin from Home إلغاء التثبيت من الصفحة الرئيسية
+ Unpin tool إلغاء تثبيت الأداة
+ Transform image تحويل الصورة
+ Select Tool أداة التحديد
+ Hand Tool أداة اليد
+ Marquee Zoom تكبير بالتحديد
+ Edit this PDF تحرير هذا الملف PDF
+ Export this PDF تصدير هذا الملف PDF
+ Find text or tools البحث عن نص أو أدوات
+ Create & Edit الإنشاء والتحرير
+ Review & Compare المراجعة والمقارنة
+ Forms & Signatures النماذج والتوقيعات
+ Protect & Standardize الحماية والتوحيد القياسي
+ Customize & Automate التخصيص والأتمتة
+ No tools match your search. لا توجد أدوات تطابق بحثك.
+ Expand all tools توسيع كل الأدوات
+ Collapse all tools طي كل الأدوات
+ Attach a file… إرفاق ملف…
+ Delete attachment حذف المرفق
+ Attaching files is not available on the web yet إرفاق الملفات غير متاح على الويب بعد
+ Attach {name} إرفاق {name}
+ Delete attachment {key} حذف المرفق {key}
Bulleted list قائمة نقطية
Numbered list قائمة مرقمة
Alignment المحاذاة
@@@ -2810,10 -2812,7 +2831,14 @@@
field names can't contain a period: {name} لا يمكن أن تحتوي أسماء الحقول على نقطة: {name}
two cells would both be named {name} ستحمل خليتان الاسم نفسه {name}
a field named {name} already exists يوجد حقل باسم {name} بالفعل
+ Arrange image ترتيب الصورة
+ Bring forward إحضار للأمام
+ Bring to front إحضار إلى المقدمة
+ Crop قص
+ Remove crop إزالة القص
+ Send backward إرسال للخلف
+ Send to back إرسال إلى المؤخرة
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today اليوم
+ @plural {n} reply|{n} replies {n} رد|{n} رد|{n} ردّان|{n} ردود|{n} ردًا|{n} رد
diff --cc crates/ui-egui/src/i18n/bg.tsv
index dc6f76342,a8af8ed65..4e987896f
--- a/crates/ui-egui/src/i18n/bg.tsv
+++ b/crates/ui-egui/src/i18n/bg.tsv
@@@ -2444,26 -2452,19 +2452,39 @@@ animation effects Off Изключен�
Make properties default Задаване като свойства по подразбиране
Pages selected Избрани страници
Page properties Свойства на страницата
+ Clear search Изчистване на търсенето
+ Pin Закачане
+ Pin a tool… Закачане на инструмент…
+ Pin to Home Закачане към Начало
+ Pin tools to Home Закачане на инструменти към Начало
+ Pin your favorite tools here for quick access. Закачете любимите си инструменти тук за бърз достъп.
+ Pinned Закачено
+ Pinned Tools Закачени инструменти
+ Search tools… Търсене на инструменти…
+ Select tools to display on your Home page for quick access. Изберете инструменти за показване на началната страница за бърз достъп.
+ Unpin from Home Откачане от Начало
+ Unpin tool Откачане на инструмент
+ Transform image Трансформиране на изображение
+ Select Tool Инструмент за избор
+ Hand Tool Инструмент „Ръка“
+ Marquee Zoom Мащабиране с рамка
+ Paste Постави
+ Edit this PDF Редактирай този PDF
+ Export this PDF Експортирай този PDF
+ Find text or tools Търсене на текст или инструменти
+ Create & Edit Създаване и редактиране
+ Review & Compare Преглед и сравнение
+ Forms & Signatures Формуляри и подписи
+ Protect & Standardize Защита и стандартизация
+ Customize & Automate Персонализиране и автоматизация
+ No tools match your search. Няма инструменти, отговарящи на търсенето.
+ Expand all tools Разгъване на всички инструменти
+ Collapse all tools Свиване на всички инструменти
+ Attach a file… Прикачване на файл…
+ Delete attachment Изтриване на прикачения файл
+ Attaching files is not available on the web yet Прикачването на файлове още не е налично в уеб версията
+ Attach {name} Прикачване на {name}
+ Delete attachment {key} Изтриване на прикачения файл {key}
Font Шрифт
Bulleted list Списък с водещи символи
Numbered list Номериран списък
@@@ -2498,10 -2499,7 +2519,14 @@@
field names can't contain a period: {name} имената на полетата не може да съдържат точка: {name}
two cells would both be named {name} две клетки биха имали едно и също име {name}
a field named {name} already exists вече съществува поле с име {name}
+ Arrange image Подреждане на изображението
+ Bring forward Преместване напред
+ Bring to front Преместване най-отпред
+ Crop Изрязване
+ Remove crop Премахване на изрязването
+ Send backward Преместване назад
+ Send to back Преместване най-отзад
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Днес
+ @plural {n} reply|{n} replies {n} отговор|{n} отговора
diff --cc crates/ui-egui/src/i18n/ca.tsv
index 066510303,42b036d16..b3401e2a3
--- a/crates/ui-egui/src/i18n/ca.tsv
+++ b/crates/ui-egui/src/i18n/ca.tsv
@@@ -2774,30 -2789,15 +2789,42 @@@ theme Appearance Aspect
field names can't contain a period: {name} els noms dels camps no poden contenir cap punt: {name}
two cells would both be named {name} dues cel·les es dirien {name}
a field named {name} already exists ja existeix un camp anomenat {name}
+ Bring forward Porta endavant
+ Bring to front Porta al capdavant
+ Crop image Retalla la imatge
+ Remove crop Elimina el retall
+ Send backward Envia enrere
+ Send to back Envia al fons
+ Clear search Neteja la cerca
+ Edit this PDF Edita aquest PDF
+ Export this PDF Exporta aquest PDF
+ Find text or tools Cerca text o eines
+ Hand Tool Eina Mà
+ Marquee Zoom Zoom d'enquadrament
+ Pin Fixa
+ Pin a tool… Fixa una eina…
+ Pin to Home Fixa a l'Inici
+ Pin tools to Home Fixa eines a l'Inici
+ Pin your favorite tools here for quick access. Fixeu aquí les vostres eines preferides per a un accés ràpid.
+ Pinned Fixat
+ Pinned Tools Eines fixades
+ Search tools… Cerca eines…
+ Select Tool Eina Selecció
+ Select tools to display on your Home page for quick access. Seleccioneu les eines que es mostraran a la pàgina d'Inici per a un accés ràpid.
+ Transform image Transforma la imatge
+ Unpin from Home Desenganxa de l'Inici
+ Unpin tool Desenganxa l'eina
+ Arrange image Organitza la imatge
+ Crop Escapça
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Avui
+
+ # AI-assisted additions for restoring the last view (#1767) (2026-10-22); not reviewed by a native speaker.
+ Restore the last view (page, zoom and page display) when a document is opened again Restaura l'última vista (pàgina, zoom i visualització de pàgina) quan es torna a obrir un document
+ Attach a file… Adjunta un fitxer…
+ Attach {name} Adjunta {name}
+ Attaching files is not available on the web yet Encara no es poden adjuntar fitxers al web
+ Delete attachment Elimina l'adjunt
+ Delete attachment {key} Elimina l'adjunt {key}
+ @plural {n} reply|{n} replies {n} resposta|{n} respostes
diff --cc crates/ui-egui/src/i18n/ckb.tsv
index 876a4eabe,845f43784..13991ee06
--- a/crates/ui-egui/src/i18n/ckb.tsv
+++ b/crates/ui-egui/src/i18n/ckb.tsv
@@@ -2713,10 -2720,15 +2720,22 @@@ certificate Version وەشا�
Make properties default کردنی تایبەتمەندییەکان بە بنەڕەتی
Pages selected پەڕە هەڵبژێردراوەکان
Page properties تایبەتمەندییەکانی پەڕە
+ Arrange image ڕێکخستنی وێنە
+ Bring forward هێنانە پێشەوە
+ Bring to front هێنانە پێشەوەی سەرەکی
+ Crop بڕینەوە
+ Remove crop لابردنی بڕینەوە
+ Send backward ناردنە دواوە
+ Send to back ناردنە دواوەی سەرەکی
+ Create & Edit دروستکردن و دەستکاریکردن
+ Review & Compare پێداچوونەوە و بەراوردکردن
+ Forms & Signatures فۆڕمەکان و واژووەکان
+ Protect & Standardize پاراستن و ستانداردکردن
+ Customize & Automate تایبەتکردن و خۆکارکردن
+ No tools match your search. هیچ ئامرازێک لەگەڵ گەڕانەکەت ناگونجێت.
+ Expand all tools فراوانکردنی هەموو ئامرازەکان
+ Collapse all tools کۆکردنەوەی هەموو ئامرازەکان
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today ئەمڕۆ
+ @plural {n} reply|{n} replies {n} وەڵام|{n} وەڵام
diff --cc crates/ui-egui/src/i18n/cs.tsv
index 0946c03c4,3cadb98e3..7f380583b
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@@ -2555,26 -2563,19 +2563,39 @@@ animation effects Off Vypnut
Make properties default Nastavit vlastnosti jako výchozí
Pages selected Vybrané stránky
Page properties Vlastnosti stránky
+ Clear search Vymazat hledání
+ Pin Připnout
+ Pin a tool… Připnout nástroj…
+ Pin to Home Připnout na domovskou stránku
+ Pin tools to Home Připnout nástroje na domovskou stránku
+ Pin your favorite tools here for quick access. Připněte si sem oblíbené nástroje pro rychlý přístup.
+ Pinned Připnuto
+ Pinned Tools Připnuté nástroje
+ Search tools… Hledat nástroje…
+ Select tools to display on your Home page for quick access. Vyberte nástroje, které se mají zobrazovat na domovské stránce pro rychlý přístup.
+ Unpin from Home Odepnout z domovské stránky
+ Unpin tool Odepnout nástroj
+ Transform image Transformovat obrázek
+ Select Tool Nástroj pro výběr
+ Hand Tool Nástroj ručička
+ Marquee Zoom Zvětšit vybranou oblast
+ Paste Vložit
+ Edit this PDF Upravit toto PDF
+ Export this PDF Exportovat toto PDF
+ Find text or tools Hledat text nebo nástroje
+ Create & Edit Vytváření a úpravy
+ Review & Compare Revize a porovnání
+ Forms & Signatures Formuláře a podpisy
+ Protect & Standardize Ochrana a standardizace
+ Customize & Automate Přizpůsobení a automatizace
+ No tools match your search. Hledání neodpovídá žádný nástroj.
+ Expand all tools Rozbalit všechny nástroje
+ Collapse all tools Sbalit všechny nástroje
+ Attach a file… Připojit soubor…
+ Delete attachment Odstranit přílohu
+ Attaching files is not available on the web yet Připojování souborů zatím na webu není k dispozici
+ Attach {name} Připojit {name}
+ Delete attachment {key} Odstranit přílohu {key}
Font Písmo
Bulleted list Odrážkový seznam
Numbered list Číslovaný seznam
@@@ -2841,11 -2843,7 +2862,15 @@@ certificate Version Verz
field names can't contain a period: {name} názvy polí nesmějí obsahovat tečku: {name}
two cells would both be named {name} dvě buňky by se jmenovaly {name}
a field named {name} already exists pole s názvem {name} už existuje
+ Bring forward Přenést blíž
+ Bring to front Přenést do popředí
+ Crop image Oříznout obrázek
+ Remove crop Odebrat oříznutí
+ Send backward Přenést dál
+ Send to back Přenést do pozadí
+ Arrange image Uspořádat obrázek
+ Crop Oříznout
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Dnes
+ @plural {n} reply|{n} replies {n} odpověď|{n} odpovědi|{n} odpovědí
diff --cc crates/ui-egui/src/i18n/de.tsv
index 896566923,7b9dcc06f..871755c71
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@@ -2482,26 -2490,19 +2490,39 @@@ animation effects Off Au
Make properties default Eigenschaften als Standard festlegen
Pages selected Ausgewählte Seiten
Page properties Seiteneigenschaften
+ Clear search Suche löschen
+ Pin Anheften
+ Pin a tool… Werkzeug anheften…
+ Pin to Home An Start anheften
+ Pin tools to Home Werkzeuge an Start anheften
+ Pin your favorite tools here for quick access. Heften Sie Ihre bevorzugten Werkzeuge hier an, um schnell darauf zuzugreifen.
+ Pinned Angeheftet
+ Pinned Tools Angeheftete Werkzeuge
+ Search tools… Werkzeuge suchen…
+ Select tools to display on your Home page for quick access. Wählen Sie Werkzeuge für den Schnellzugriff auf Ihrer Startseite aus.
+ Unpin from Home Von Start lösen
+ Unpin tool Werkzeug lösen
+ Transform image Bild transformieren
+ Select Tool Auswahl-Werkzeug
+ Hand Tool Hand-Werkzeug
+ Marquee Zoom Auswahlrahmen-Zoom
+ Paste Einfügen
+ Edit this PDF Dieses PDF bearbeiten
+ Export this PDF Dieses PDF exportieren
+ Find text or tools Text oder Werkzeuge suchen
+ Create & Edit Erstellen & Bearbeiten
+ Review & Compare Prüfen & Vergleichen
+ Forms & Signatures Formulare & Signaturen
+ Protect & Standardize Schützen & Standardisieren
+ Customize & Automate Anpassen & Automatisieren
+ No tools match your search. Keine Werkzeuge entsprechen Ihrer Suche.
+ Expand all tools Alle Werkzeuge ausklappen
+ Collapse all tools Alle Werkzeuge einklappen
+ Attach a file… Datei anhängen…
+ Delete attachment Anhang löschen
+ Attaching files is not available on the web yet Dateien anhängen ist im Web noch nicht verfügbar
+ Attach {name} {name} anhängen
+ Delete attachment {key} Anhang {key} löschen
Font Schrift
Bulleted list Aufzählung
Numbered list Nummerierte Liste
@@@ -2536,10 -2537,7 +2557,14 @@@
field names can't contain a period: {name} Feldnamen dürfen keinen Punkt enthalten: {name}
two cells would both be named {name} zwei Zellen hätten beide den Namen {name}
a field named {name} already exists ein Feld namens {name} ist bereits vorhanden
+ Arrange image Bild anordnen
+ Bring forward Nach vorne bringen
+ Bring to front In den Vordergrund
+ Crop Zuschneiden
+ Remove crop Zuschnitt entfernen
+ Send backward Nach hinten senden
+ Send to back In den Hintergrund
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Heute
+ @plural {n} reply|{n} replies {n} Antwort|{n} Antworten
diff --cc crates/ui-egui/src/i18n/el.tsv
index 0b60f48e6,dbe796917..fab307a08
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@@ -2487,26 -2495,19 +2495,39 @@@ animation effects Off Ανενεργ�
Make properties default Ορισμός ιδιοτήτων ως προεπιλογή
Pages selected Επιλεγμένες σελίδες
Page properties Ιδιότητες σελίδας
+ Clear search Εκκαθάριση αναζήτησης
+ Pin Καρφίτσωμα
+ Pin a tool… Καρφίτσωμα εργαλείου…
+ Pin to Home Καρφίτσωμα στην Αρχική
+ Pin tools to Home Καρφίτσωμα εργαλείων στην Αρχική
+ Pin your favorite tools here for quick access. Καρφιτσώστε τα αγαπημένα σας εργαλεία εδώ για γρήγορη πρόσβαση.
+ Pinned Καρφιτσωμένο
+ Pinned Tools Καρφιτσωμένα εργαλεία
+ Search tools… Αναζήτηση εργαλείων…
+ Select tools to display on your Home page for quick access. Επιλέξτε εργαλεία για εμφάνιση στην Αρχική σας για γρήγορη πρόσβαση.
+ Unpin from Home Ξεκαρφίτσωμα από την Αρχική
+ Unpin tool Ξεκαρφίτσωμα εργαλείου
+ Transform image Μετασχηματισμός εικόνας
+ Select Tool Εργαλείο επιλογής
+ Hand Tool Εργαλείο χεριού
+ Marquee Zoom Μεγέθυνση επιλεγμένης περιοχής
+ Paste Επικόλληση
+ Edit this PDF Επεξεργασία αυτού του PDF
+ Export this PDF Εξαγωγή αυτού του PDF
+ Find text or tools Εύρεση κειμένου ή εργαλείων
+ Create & Edit Δημιουργία και επεξεργασία
+ Review & Compare Αναθεώρηση και σύγκριση
+ Forms & Signatures Φόρμες και υπογραφές
+ Protect & Standardize Προστασία και τυποποίηση
+ Customize & Automate Προσαρμογή και αυτοματοποίηση
+ No tools match your search. Κανένα εργαλείο δεν ταιριάζει με την αναζήτησή σας.
+ Expand all tools Ανάπτυξη όλων των εργαλείων
+ Collapse all tools Σύμπτυξη όλων των εργαλείων
+ Attach a file… Επισύναψη αρχείου…
+ Delete attachment Διαγραφή συνημμένου
+ Attaching files is not available on the web yet Η επισύναψη αρχείων δεν είναι ακόμη διαθέσιμη στον ιστό
+ Attach {name} Επισύναψη {name}
+ Delete attachment {key} Διαγραφή συνημμένου {key}
Font Γραμματοσειρά
Bulleted list Λίστα με κουκκίδες
Numbered list Αριθμημένη λίστα
@@@ -2541,10 -2542,7 +2562,14 @@@
field names can't contain a period: {name} τα ονόματα πεδίων δεν μπορούν να περιέχουν τελεία: {name}
two cells would both be named {name} δύο κελιά θα είχαν το ίδιο όνομα {name}
a field named {name} already exists υπάρχει ήδη πεδίο με όνομα {name}
+ Arrange image Διάταξη εικόνας
+ Bring forward Μεταφορά εμπρός
+ Bring to front Μεταφορά σε πρώτο πλάνο
+ Crop Περικοπή
+ Remove crop Κατάργηση περικοπής
+ Send backward Μεταφορά πίσω
+ Send to back Μεταφορά σε δεύτερο πλάνο
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Σήμερα
+ @plural {n} reply|{n} replies {n} απάντηση|{n} απαντήσεις
diff --cc crates/ui-egui/src/i18n/es.tsv
index d079659d7,951a3dd8c..d03d5269f
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@@ -2644,25 -2653,11 +2660,30 @@@ animation effects Off Desactivado
# Historical snapshot notice bar (View signed version / View revision).
You are viewing the signed version of “{from}” (revision {rev}). It is a snapshot: changes here won't affect the original. Estás viendo la versión firmada de «{from}» (revisión {rev}). Es una instantánea: los cambios aquí no afectarán al original.
You are viewing revision {rev} of “{from}”. It is a snapshot: changes here won't affect the original. Estás viendo la revisión {rev} de «{from}». Es una instantánea: los cambios aquí no afectarán al original.
+ Clear search Borrar búsqueda
+ Pin Anclar
+ Pin a tool… Anclar una herramienta…
+ Pin to Home Anclar en Inicio
+ Pin tools to Home Anclar herramientas en Inicio
+ Pin your favorite tools here for quick access. Ancla tus herramientas favoritas aquí para un acceso rápido.
+ Pinned Anclado
+ Pinned Tools Herramientas ancladas
+ Search tools… Buscar herramientas…
+ Select tools to display on your Home page for quick access. Selecciona las herramientas que se mostrarán en la página de Inicio para un acceso rápido.
+ Unpin from Home Desanclar de Inicio
+ Unpin tool Desanclar herramienta
+ Select Tool Herramienta Selección
+ Hand Tool Herramienta Mano
+ Marquee Zoom Zoom por selección
+ Paste Pegar
+ Edit this PDF Editar este PDF
+ Export this PDF Exportar este PDF
+ Find text or tools Buscar texto o herramientas
+ Attach a file… Adjuntar un archivo…
+ Delete attachment Eliminar adjunto
+ Attaching files is not available on the web yet Adjuntar archivos aún no está disponible en la web
+ Attach {name} Adjuntar {name}
+ Delete attachment {key} Eliminar adjunto {key}
Thumbnail size Tamaño de las miniaturas
Smaller thumbnails Miniaturas más pequeñas
Larger thumbnails Miniaturas más grandes
@@@ -2863,5 -2859,7 +2884,9 @@@ theme Appearance Aspect
field names can't contain a period: {name} los nombres de campo no pueden contener un punto: {name}
two cells would both be named {name} dos celdas se llamarían {name}
a field named {name} already exists ya existe un campo llamado {name}
+ Arrange image Organizar imagen
+ Crop Recortar
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Hoy
+ @plural {n} reply|{n} replies {n} respuesta|{n} respuestas
diff --cc crates/ui-egui/src/i18n/fi.tsv
index 8576ad9b5,cd5a8040d..71884866a
--- a/crates/ui-egui/src/i18n/fi.tsv
+++ b/crates/ui-egui/src/i18n/fi.tsv
@@@ -2783,30 -2798,15 +2798,42 @@@ theme Appearance Teem
field names can't contain a period: {name} kenttien nimissä ei voi olla pistettä: {name}
two cells would both be named {name} kahdella solulla olisi sama nimi {name}
a field named {name} already exists kenttä nimeltä {name} on jo olemassa
+ Bring forward Tuo eteenpäin
+ Bring to front Tuo etualalle
+ Crop image Rajaa kuva
+ Remove crop Poista rajaus
+ Send backward Vie taaksepäin
+ Send to back Vie taustalle
+ Clear search Tyhjennä haku
+ Edit this PDF Muokkaa tätä PDF-tiedostoa
+ Export this PDF Vie tämä PDF-tiedosto
+ Find text or tools Etsi tekstiä tai työkaluja
+ Hand Tool Käsityökalu
+ Marquee Zoom Alueen zoomaus
+ Pin Kiinnitä
+ Pin a tool… Kiinnitä työkalu…
+ Pin to Home Kiinnitä Aloitus-näkymään
+ Pin tools to Home Kiinnitä työkaluja Aloitus-näkymään
+ Pin your favorite tools here for quick access. Kiinnitä suosikkityökalusi tähän nopeaa käyttöä varten.
+ Pinned Kiinnitetty
+ Pinned Tools Kiinnitetyt työkalut
+ Search tools… Etsi työkaluja…
+ Select Tool Valintatyökalu
+ Select tools to display on your Home page for quick access. Valitse Aloitus-sivulla näytettävät työkalut nopeaa käyttöä varten.
+ Transform image Muunna kuvaa
+ Unpin from Home Irrota Aloitus-näkymästä
+ Unpin tool Irrota työkalu
+ Arrange image Järjestä kuva
+ Crop Rajaa
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Tänään
+
+ # AI-assisted additions for restoring the last view (#1767) (2026-10-22); not reviewed by a native speaker.
+ Restore the last view (page, zoom and page display) when a document is opened again Palauta viimeisin näkymä (sivu, zoomaus ja sivunäyttö), kun asiakirja avataan uudelleen
+ Attach a file… Liitä tiedosto…
+ Attach {name} Liitä {name}
+ Attaching files is not available on the web yet Tiedostojen liittäminen ei ole vielä käytettävissä verkossa
+ Delete attachment Poista liite
+ Delete attachment {key} Poista liite {key}
+ @plural {n} reply|{n} replies {n} vastaus|{n} vastausta
diff --cc crates/ui-egui/src/i18n/fr.tsv
index ebf2b4db4,ea6008039..f641884ae
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@@ -2481,26 -2489,19 +2489,39 @@@ animation effects Off Désactivé
Make properties default Définir comme propriétés par défaut
Pages selected Pages sélectionnées
Page properties Propriétés de la page
+ Clear search Effacer la recherche
+ Pin Épingler
+ Pin a tool… Épingler un outil…
+ Pin to Home Épingler à l'Accueil
+ Pin tools to Home Épingler des outils à l'Accueil
+ Pin your favorite tools here for quick access. Épinglez vos outils préférés ici pour un accès rapide.
+ Pinned Épinglé
+ Pinned Tools Outils épinglés
+ Search tools… Rechercher des outils…
+ Select tools to display on your Home page for quick access. Sélectionnez les outils à afficher sur votre page d'Accueil pour un accès rapide.
+ Unpin from Home Désépingler de l'Accueil
+ Unpin tool Désépingler l'outil
+ Transform image Transformer l'image
+ Select Tool Outil Sélection
+ Hand Tool Outil Main
+ Marquee Zoom Zoom par sélection
+ Paste Coller
+ Edit this PDF Modifier ce PDF
+ Export this PDF Exporter ce PDF
+ Find text or tools Rechercher du texte ou des outils
+ Create & Edit Créer et modifier
+ Review & Compare Réviser et comparer
+ Forms & Signatures Formulaires et signatures
+ Protect & Standardize Protéger et normaliser
+ Customize & Automate Personnaliser et automatiser
+ No tools match your search. Aucun outil ne correspond à votre recherche.
+ Expand all tools Développer tous les outils
+ Collapse all tools Réduire tous les outils
+ Attach a file… Joindre un fichier…
+ Delete attachment Supprimer la pièce jointe
+ Attaching files is not available on the web yet Joindre des fichiers n'est pas encore disponible sur le web
+ Attach {name} Joindre {name}
+ Delete attachment {key} Supprimer la pièce jointe {key}
Font Police
Bulleted list Liste à puces
Numbered list Liste numérotée
@@@ -2800,10 -2802,7 +2821,14 @@@ certificate Version Versio
field names can't contain a period: {name} les noms de champ ne peuvent pas contenir de point : {name}
two cells would both be named {name} deux cellules porteraient le nom {name}
a field named {name} already exists un champ nommé {name} existe déjà
+ Arrange image Organiser l'image
+ Bring forward Avancer
+ Bring to front Mettre au premier plan
+ Crop Recadrer
+ Remove crop Supprimer le recadrage
+ Send backward Reculer
+ Send to back Mettre à l'arrière-plan
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Aujourd'hui
+ @plural {n} reply|{n} replies {n} réponse|{n} réponses
diff --cc crates/ui-egui/src/i18n/hi.tsv
index 76c53dd24,7f403caba..4798320d1
--- a/crates/ui-egui/src/i18n/hi.tsv
+++ b/crates/ui-egui/src/i18n/hi.tsv
@@@ -2750,28 -2765,15 +2765,40 @@@ theme Appearance स्वरू�
field names can't contain a period: {name} फ़ील्ड के नामों में पूर्ण विराम (.) नहीं हो सकता: {name}
two cells would both be named {name} दो सेल का नाम {name} हो जाएगा
a field named {name} already exists {name} नाम का फ़ील्ड पहले से मौजूद है
+ Clear search खोज साफ़ करें
+ Edit this PDF इस PDF को संपादित करें
+ Export this PDF इस PDF को निर्यात करें
+ Find text or tools पाठ या उपकरण ढूंढें
+ Hand Tool हैंड टूल
+ Marquee Zoom मार्की ज़ूम
+ Pin पिन करें
+ Pin a tool… उपकरण पिन करें…
+ Pin to Home होम पर पिन करें
+ Pin tools to Home होम पर उपकरण पिन करें
+ Pin your favorite tools here for quick access. त्वरित पहुँच के लिए अपने पसंदीदा उपकरण यहाँ पिन करें।
+ Pinned पिन किया गया
+ Pinned Tools पिन किए गए उपकरण
+ Search tools… उपकरण खोजें…
+ Select Tool चयन उपकरण
+ Select tools to display on your Home page for quick access. त्वरित पहुँच के लिए अपने होम पेज पर प्रदर्शित करने हेतु उपकरण चुनें।
+ Unpin from Home होम से अनपिन करें
+ Unpin tool उपकरण अनपिन करें
+ Arrange image छवि व्यवस्थित करें
+ Bring forward आगे लाएँ
+ Bring to front सबसे आगे लाएँ
+ Crop क्रॉप करें
+ Remove crop क्रॉप हटाएँ
+ Send backward पीछे भेजें
+ Send to back सबसे पीछे भेजें
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today आज
+
+ # AI-assisted additions for restoring the last view (#1767) (2026-10-22); not reviewed by a native speaker.
+ Restore the last view (page, zoom and page display) when a document is opened again दस्तावेज़ फिर से खोलने पर पिछला दृश्य (पृष्ठ, ज़ूम और पृष्ठ प्रदर्शन) पुनर्स्थापित करें
+ Attach a file… फ़ाइल संलग्न करें…
+ Attach {name} {name} संलग्न करें
+ Attaching files is not available on the web yet वेब पर अभी फ़ाइलें संलग्न करना उपलब्ध नहीं है
+ Delete attachment अनुलग्नक हटाएँ
+ Delete attachment {key} अनुलग्नक {key} हटाएँ
+ @plural {n} reply|{n} replies {n} जवाब
diff --cc crates/ui-egui/src/i18n/hu.tsv
index 0152faa38,33ced9925..5cb6dd126
--- a/crates/ui-egui/src/i18n/hu.tsv
+++ b/crates/ui-egui/src/i18n/hu.tsv
@@@ -2480,26 -2488,19 +2488,39 @@@ animation effects Off K
Make properties default Tulajdonságok beállítása alapértelmezettként
Pages selected Kijelölt oldalak
Page properties Oldaltulajdonságok
+ Clear search Keresés törlése
+ Pin Rögzítés
+ Pin a tool… Eszköz rögzítése…
+ Pin to Home Rögzítés a Kezdőlapra
+ Pin tools to Home Eszközök rögzítése a Kezdőlapra
+ Pin your favorite tools here for quick access. Rögzítse ide kedvenc eszközeit a gyors eléréshez.
+ Pinned Rögzítve
+ Pinned Tools Rögzített eszközök
+ Search tools… Eszközök keresése…
+ Select tools to display on your Home page for quick access. Válassza ki a Kezdőlapon megjelenítendő eszközöket a gyors eléréshez.
+ Unpin from Home Rögzítés feloldása a Kezdőlapról
+ Unpin tool Eszköz rögzítésének feloldása
+ Transform image Kép transzformálása
+ Select Tool Kijelölő eszköz
+ Hand Tool Kéz eszköz
+ Marquee Zoom Kijelölő nagyítás
+ Paste Beillesztés
+ Edit this PDF Ezen PDF szerkesztése
+ Export this PDF Ezen PDF exportálása
+ Find text or tools Szöveg vagy eszközök keresése
+ Create & Edit Létrehozás és szerkesztés
+ Review & Compare Áttekintés és összehasonlítás
+ Forms & Signatures Űrlapok és aláírások
+ Protect & Standardize Védelem és szabványosítás
+ Customize & Automate Testreszabás és automatizálás
+ No tools match your search. Egy eszköz sem felel meg a keresésnek.
+ Expand all tools Az összes eszköz kibontása
+ Collapse all tools Az összes eszköz összecsukása
+ Attach a file… Fájl csatolása…
+ Delete attachment Melléklet törlése
+ Attaching files is not available on the web yet Fájlok csatolása a weben még nem érhető el
+ Attach {name} {name} csatolása
+ Delete attachment {key} {key} melléklet törlése
Font Betűtípus
Bulleted list Felsorolás
Numbered list Számozott lista
@@@ -2534,10 -2535,7 +2555,14 @@@
field names can't contain a period: {name} a mezőnevek nem tartalmazhatnak pontot: {name}
two cells would both be named {name} két cella neve is {name} lenne
a field named {name} already exists már van {name} nevű mező
+ Arrange image Kép elrendezése
+ Bring forward Előrébb hozás
+ Bring to front Előrehozás
+ Crop Körülvágás
+ Remove crop Körülvágás eltávolítása
+ Send backward Hátrébb küldés
+ Send to back Hátraküldés
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Ma
+ @plural {n} reply|{n} replies {n} válasz|{n} válasz
diff --cc crates/ui-egui/src/i18n/id.tsv
index 16d8c594f,422fac279..54a9b8c17
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@@ -2751,28 -2766,15 +2766,40 @@@ theme Appearance Tampila
field names can't contain a period: {name} nama kolom tidak boleh berisi titik: {name}
two cells would both be named {name} dua sel akan sama-sama bernama {name}
a field named {name} already exists kolom bernama {name} sudah ada
+ Clear search Bersihkan pencarian
+ Edit this PDF Edit PDF ini
+ Export this PDF Ekspor PDF ini
+ Find text or tools Temukan teks atau alat
+ Hand Tool Alat Tangan
+ Marquee Zoom Zoom Bidang
+ Pin Sematkan
+ Pin a tool… Sematkan alat…
+ Pin to Home Sematkan ke Beranda
+ Pin tools to Home Sematkan alat ke Beranda
+ Pin your favorite tools here for quick access. Sematkan alat favorit Anda di sini untuk akses cepat.
+ Pinned Disematkan
+ Pinned Tools Alat yang Disematkan
+ Search tools… Cari alat…
+ Select Tool Alat Pemilih
+ Select tools to display on your Home page for quick access. Pilih alat untuk ditampilkan di halaman Beranda Anda untuk akses cepat.
+ Unpin from Home Lepas sematan dari Beranda
+ Unpin tool Lepas sematan alat
+ Arrange image Atur gambar
+ Bring forward Maju Selangkah
+ Bring to front Bawa ke Depan
+ Crop Pangkas
+ Remove crop Hapus pangkasan
+ Send backward Mundur Selangkah
+ Send to back Kirim ke Belakang
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Hari ini
+
+ # AI-assisted additions for restoring the last view (#1767) (2026-10-22); not reviewed by a native speaker.
+ Restore the last view (page, zoom and page display) when a document is opened again Pulihkan tampilan terakhir (halaman, zoom, dan tampilan halaman) saat dokumen dibuka lagi
+ Attach a file… Lampirkan file…
+ Attach {name} Lampirkan {name}
+ Attaching files is not available on the web yet Melampirkan file belum tersedia di web
+ Delete attachment Hapus lampiran
+ Delete attachment {key} Hapus lampiran {key}
+ @plural {n} reply|{n} replies {n} balasan
diff --cc crates/ui-egui/src/i18n/it.tsv
index 69d5c71d7,60ecf2de3..59cb1e7e5
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@@ -2693,26 -2701,19 +2701,39 @@@ certificate Key usage Utilizzo chiav
certificate Self-signed Autofirmato
certificate SHA-1 digest Impronta SHA-1
certificate SHA-256 digest Impronta SHA-256
+ Clear search Cancella ricerca
+ Pin Fissa
+ Pin a tool… Fissa uno strumento…
+ Pin to Home Fissa sulla Home
+ Pin tools to Home Fissa strumenti sulla Home
+ Pin your favorite tools here for quick access. Fissa qui i tuoi strumenti preferiti per un accesso rapido.
+ Pinned Fissato
+ Pinned Tools Strumenti fissati
+ Search tools… Cerca strumenti…
+ Select tools to display on your Home page for quick access. Seleziona gli strumenti da visualizzare nella pagina Home per un acceso rapido.
+ Unpin from Home Rimuovi da Home
+ Unpin tool Rimuovi strumento
+ Transform image Trasforma immagine
+ Select Tool Strumento Selezione
+ Hand Tool Strumento Mano
+ Marquee Zoom Ingrandimento selettivo
+ Paste Incolla
+ Edit this PDF Modifica questo PDF
+ Export this PDF Esporta questo PDF
+ Find text or tools Trova testo o strumenti
+ Create & Edit Crea e modifica
+ Review & Compare Revisione e confronto
+ Forms & Signatures Moduli e firme
+ Protect & Standardize Proteggi e standardizza
+ Customize & Automate Personalizza e automatizza
+ No tools match your search. Nessuno strumento corrisponde alla ricerca.
+ Expand all tools Espandi tutti gli strumenti
+ Collapse all tools Comprimi tutti gli strumenti
+ Attach a file… Allega un file…
+ Delete attachment Elimina allegato
+ Attaching files is not available on the web yet Allegare file non è ancora disponibile sul web
+ Attach {name} Allega {name}
+ Delete attachment {key} Elimina allegato {key}
Font Carattere
Bulleted list Elenco puntato
Numbered list Elenco numerato
@@@ -2767,10 -2768,7 +2788,14 @@@
field names can't contain a period: {name} i nomi dei campi non possono contenere un punto: {name}
two cells would both be named {name} due celle si chiamerebbero entrambe {name}
a field named {name} already exists esiste già un campo chiamato {name}
+ Arrange image Disponi immagine
+ Bring forward Porta avanti
+ Bring to front Porta in primo piano
+ Crop Ritaglia
+ Remove crop Rimuovi ritaglio
+ Send backward Porta indietro
+ Send to back Porta in secondo piano
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Oggi
+ @plural {n} reply|{n} replies {n} risposta|{n} risposte
diff --cc crates/ui-egui/src/i18n/ja.tsv
index 15214a9b1,db338ebb1..2b5b73183
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@@ -2481,26 -2489,19 +2489,39 @@@ animation effects Off オ�
Make properties default プロパティをデフォルトに設定
Pages selected 選択したページ
Page properties ページのプロパティ
+ Clear search 検索をクリア
+ Pin ピン留め
+ Pin a tool… ツールをピン留め…
+ Pin to Home ホームにピン留め
+ Pin tools to Home ツールをホームにピン留め
+ Pin your favorite tools here for quick access. よく使うツールをここにピン留めして、すばやくアクセスできるようにします。
+ Pinned ピン留め済み
+ Pinned Tools ピン留めしたツール
+ Search tools… ツールを検索…
+ Select tools to display on your Home page for quick access. すばやくアクセスできるように、ホームに表示するツールを選択します。
+ Unpin from Home ホームからピン留めを解除
+ Unpin tool ツールのピン留めを解除
+ Transform image 画像を変換
+ Select Tool 選択ツール
+ Hand Tool 手のひらツール
+ Marquee Zoom 範囲指定ズーム
+ Paste 貼り付け
+ Edit this PDF この PDF を編集
+ Export this PDF この PDF を書き出す
+ Find text or tools テキストまたはツールを検索
+ Create & Edit 作成と編集
+ Review & Compare レビューと比較
+ Forms & Signatures フォームと署名
+ Protect & Standardize 保護と標準化
+ Customize & Automate カスタマイズと自動化
+ No tools match your search. 検索に一致するツールはありません。
+ Expand all tools すべてのツールを展開
+ Collapse all tools すべてのツールを折りたたむ
+ Attach a file… ファイルを添付…
+ Delete attachment 添付ファイルを削除
+ Attaching files is not available on the web yet Web 版ではまだファイルを添付できません
+ Attach {name} {name} を添付
+ Delete attachment {key} 添付ファイル {key} を削除
Font フォント
Bulleted list 箇条書き
Numbered list 番号付きリスト
@@@ -2535,10 -2536,7 +2556,14 @@@
field names can't contain a period: {name} フィールド名にピリオドは使えません: {name}
two cells would both be named {name} 2 つのセルが同じ名前 {name} になります
a field named {name} already exists {name} という名前のフィールドは既にあります
+ Arrange image 画像を配置
+ Bring forward 前面へ移動
+ Bring to front 最前面へ移動
+ Crop 切り抜き
+ Remove crop 切り抜きを解除
+ Send backward 背面へ移動
+ Send to back 最背面へ移動
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today 今日
+ @plural {n} reply|{n} replies {n} 件の返信
diff --cc crates/ui-egui/src/i18n/kk.tsv
index 23cc3bbf1,ea0d0d0fb..f102bc2af
--- a/crates/ui-egui/src/i18n/kk.tsv
+++ b/crates/ui-egui/src/i18n/kk.tsv
@@@ -2479,26 -2487,19 +2487,39 @@@ animation effects Off Өшірул�
Make properties default Қасиеттерді әдепкі ету
Pages selected Таңдалған беттер
Page properties Бет қасиеттері
+ Clear search Іздеуді тазалау
+ Pin Бекіту
+ Pin a tool… Құралды бекіту…
+ Pin to Home Басты бетке бекіту
+ Pin tools to Home Құралдарды басты бетке бекіту
+ Pin your favorite tools here for quick access. Жылдам қол жеткізу үшін таңдаулы құралдарды осында бекітіңіз.
+ Pinned Бекітілген
+ Pinned Tools Бекітілген құралдар
+ Search tools… Құралдарды іздеу…
+ Select tools to display on your Home page for quick access. Жылдам қол жеткізу үшін басты бетте көрсетілетін құралдарды таңдаңыз.
+ Unpin from Home Басты беттен алып тастау
+ Unpin tool Құралды алып тастау
+ Transform image Кескінді түрлендіру
+ Select Tool Таңдау құралы
+ Hand Tool Қол құралы
+ Marquee Zoom Аймақты масштабтау
+ Paste Қою
+ Edit this PDF Осы PDF файлын түзету
+ Export this PDF Осы PDF файлын экспорттау
+ Find text or tools Мәтінді немесе құралдарды табу
+ Create & Edit Жасау және өңдеу
+ Review & Compare Шолу және салыстыру
+ Forms & Signatures Пішіндер және қолтаңбалар
+ Protect & Standardize Қорғау және стандарттау
+ Customize & Automate Баптау және автоматтандыру
+ No tools match your search. Іздеуге сәйкес құралдар жоқ.
+ Expand all tools Барлық құралдарды жаю
+ Collapse all tools Барлық құралдарды жию
+ Attach a file… Файл тіркеу…
+ Delete attachment Тіркемені жою
+ Attaching files is not available on the web yet Вебте файл тіркеу әзірге қолжетімсіз
+ Attach {name} {name} тіркеу
+ Delete attachment {key} {key} тіркемесін жою
Font Қаріп
Bulleted list Таңбалауыш тізім
Numbered list Нөмірленген тізім
@@@ -2533,10 -2534,7 +2554,14 @@@
field names can't contain a period: {name} өріс атауларында нүкте болмауы керек: {name}
two cells would both be named {name} екі ұяшықтың да атауы {name} болар еді
a field named {name} already exists {name} атты өріс бар
+ Arrange image Суретті реттеу
+ Bring forward Алға жылжыту
+ Bring to front Алдыңғы планға шығару
+ Crop Қию
+ Remove crop Қиюды алып тастау
+ Send backward Артқа жылжыту
+ Send to back Артқы планға жіберу
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Бүгін
+ @plural {n} reply|{n} replies {n} жауап|{n} жауап
diff --cc crates/ui-egui/src/i18n/ko.tsv
index 046c6d4ed,a9ee5b487..a0d751e65
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@@ -2750,28 -2765,15 +2765,40 @@@ theme Appearance 모�
field names can't contain a period: {name} 필드 이름에는 마침표를 쓸 수 없습니다: {name}
two cells would both be named {name} 두 셀의 이름이 모두 {name}이(가) 됩니다
a field named {name} already exists {name}(이)라는 필드가 이미 있습니다
+ Clear search 검색 지우기
+ Edit this PDF 이 PDF 편집
+ Export this PDF 이 PDF 내보내기
+ Find text or tools 텍스트 또는 도구 찾기
+ Hand Tool 손 도구
+ Marquee Zoom 영역 확대/축소
+ Pin 고정
+ Pin a tool… 도구 고정…
+ Pin to Home 홈에 고정
+ Pin tools to Home 홈에 도구 고정
+ Pin your favorite tools here for quick access. 빠른 액세스를 위해 즐겨찾는 도구를 여기에 고정하세요.
+ Pinned 고정됨
+ Pinned Tools 고정된 도구
+ Search tools… 도구 검색…
+ Select Tool 선택 도구
+ Select tools to display on your Home page for quick access. 빠른 액세스를 위해 홈 페이지에 표시할 도구를 선택하세요.
+ Unpin from Home 홈에서 고정 해제
+ Unpin tool 도구 고정 해제
+ Arrange image 이미지 정렬
+ Bring forward 앞으로 가져오기
+ Bring to front 맨 앞으로 가져오기
+ Crop 자르기
+ Remove crop 자르기 제거
+ Send backward 뒤로 보내기
+ Send to back 맨 뒤로 보내기
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today 오늘
+
+ # AI-assisted additions for restoring the last view (#1767) (2026-10-22); not reviewed by a native speaker.
+ Restore the last view (page, zoom and page display) when a document is opened again 문서를 다시 열 때 마지막 보기(페이지, 확대/축소, 페이지 표시) 복원
+ Attach a file… 파일 첨부…
+ Attach {name} {name} 첨부
+ Attaching files is not available on the web yet 웹에서는 아직 파일을 첨부할 수 없습니다
+ Delete attachment 첨부 파일 삭제
+ Delete attachment {key} 첨부 파일 {key} 삭제
+ @plural {n} reply|{n} replies 답글 {n}개
diff --cc crates/ui-egui/src/i18n/lo.tsv
index 24ed6fd5f,3b702756b..f49d942a0
--- a/crates/ui-egui/src/i18n/lo.tsv
+++ b/crates/ui-egui/src/i18n/lo.tsv
@@@ -2429,10 -2436,15 +2436,22 @@@ animation effects Off ປິ�
Make properties default ກຳນົດຄຸນສົມບັດເປັນຄ່າເລີ່ມຕົ້ນ
Pages selected ໜ້າທີ່ເລືອກ
Page properties ຄຸນສົມບັດໜ້າ
+ Arrange image ຈັດຮູບພາບ
+ Bring forward ນຳມາທາງໜ້າ
+ Bring to front ນຳມາໄວ້ໜ້າສຸດ
+ Crop ຕັດຂອບ
+ Remove crop ຍົກເລີກການຕັດຂອບ
+ Send backward ສົ່ງໄປທາງຫຼັງ
+ Send to back ສົ່ງໄປໄວ້ຫຼັງສຸດ
+ Create & Edit ສ້າງ & ແກ້ໄຂ
+ Review & Compare ກວດກາຄືນ & ປຽບທຽບ
+ Forms & Signatures ຟອມ & ລາຍເຊັນ
+ Protect & Standardize ປ້ອງກັນ & ມາດຕະຖານ
+ Customize & Automate ປັບແຕ່ງ & ອັດຕະໂນມັດ
+ No tools match your search. ບໍ່ມີເຄື່ອງມືທີ່ກົງກັບການຄົ້ນຫາຂອງທ່ານ.
+ Expand all tools ຂະຫຍາຍເຄື່ອງມືທັງໝົດ
+ Collapse all tools ຫຍໍ້ເຄື່ອງມືທັງໝົດເຂົ້າ
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today ມື້ນີ້
+ @plural {n} reply|{n} replies ການຕອບກັບ {n} ລາຍການ
diff --cc crates/ui-egui/src/i18n/lt.tsv
index 5fd56bdf3,058bbe905..d9d74db40
--- a/crates/ui-egui/src/i18n/lt.tsv
+++ b/crates/ui-egui/src/i18n/lt.tsv
@@@ -2731,12 -2739,15 +2739,20 @@@ key Space Tarpa
Make properties default Nustatyti ypatybes kaip numatytąsias
Pages selected Pasirinkti puslapiai
Page properties Puslapio ypatybės
+ Bring forward Perkelti į priekį
+ Bring to front Iškelti į priekį
+ Crop image Apkarpyti paveikslėlį
+ Remove crop Pašalinti apkarpymą
+ Send backward Perkelti atgal
+ Send to back Nukelti į galą
+ Create & Edit Kūrimas ir redagavimas
+ Review & Compare Peržiūra ir palyginimas
+ Forms & Signatures Formos ir parašai
+ Protect & Standardize Apsauga ir standartizavimas
+ Customize & Automate Pritaikymas ir automatizavimas
+ No tools match your search. Paieškos neatitinka joks įrankis.
+ Expand all tools Išskleisti visus įrankius
+ Collapse all tools Suskleisti visus įrankius
-
# AI-assisted additions for concurrently merged UI features (2026-10-15).
# These additions have not had separate native-speaker review.
Mouse wheel scroll speed Pelės ratuko slinkimo greitis
@@@ -2744,25 -2755,11 +2760,30 @@@
The password must have at least 6 characters. Slaptažodį turi sudaryti bent 6 simboliai.
This file changed on disk. Reload it to see the new version; your unsaved changes will be lost. Šis failas diske pasikeitė. Įkelkite jį iš naujo, kad pamatytumėte naują versiją; neįrašyti pakeitimai bus prarasti.
theme Appearance Išvaizda
+ Clear search Išvalyti paiešką
+ Pin Prisegti
+ Pin a tool… Prisegti įrankį…
+ Pin to Home Prisegti pradžioje
+ Pin tools to Home Prisegti įrankius pradžioje
+ Pin your favorite tools here for quick access. Prisekite mėgstamus įrankius čia, kad greitai pasiektumėte.
+ Pinned Prisegta
+ Pinned Tools Prisegti įrankiai
+ Search tools… Ieškoti įrankių…
+ Select tools to display on your Home page for quick access. Pasirinkite įrankius, kuriuos norite rodyti pradžios puslapyje.
+ Unpin from Home Atsegti nuo pradžios
+ Unpin tool Atsegti įrankį
+ Transform image Transformuoti paveikslėlį
+ Select Tool Pasirinkimo įrankis
+ Hand Tool Rankos įrankis
+ Marquee Zoom Didinti pažymėtą sritį
+ Edit this PDF Redaguoti šį PDF
+ Export this PDF Eksportuoti šį PDF
+ Find text or tools Rasti tekstą arba įrankius
+ Attach a file… Pridėti failą…
+ Delete attachment Ištrinti priedą
+ Attaching files is not available on the web yet Failų pridėjimas žiniatinklyje dar negalimas
+ Attach {name} Pridėti {name}
+ Delete attachment {key} Ištrinti priedą {key}
Bulleted list Sąrašas su ženkleliais
Numbered list Numeruotas sąrašas
Alignment Lygiuotė
@@@ -2800,5 -2797,7 +2821,9 @@@
a table has 1 to {max} columns lentelėje gali būti nuo 1 iki {max} stulpelių
the first row number can be at most {max} pirmosios eilutės numeris gali būti ne didesnis nei {max}
the area, the spacing and the column widths must be numbers, the spacing 0 or more and each width more than 0 sritis, tarpai ir stulpelių pločiai turi būti skaičiai, tarpai – 0 arba daugiau, o kiekvienas plotis – daugiau nei 0
+ Arrange image Tvarkyti vaizdą
+ Crop Apkarpyti
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Šiandien
+ @plural {n} reply|{n} replies {n} atsakymas|{n} atsakymai|{n} atsakymų
diff --cc crates/ui-egui/src/i18n/nb.tsv
index 721b833da,bc5fc98f5..f7b76c42e
--- a/crates/ui-egui/src/i18n/nb.tsv
+++ b/crates/ui-egui/src/i18n/nb.tsv
@@@ -2694,10 -2709,10 +2709,17 @@@ key Space Mellomro
# Page gaps (AI-assisted, not separately native-reviewed)
Show gaps between pages Vis mellomrom mellom sidene
Hide gaps to join page edges. Margins inside the PDF remain unchanged. Skjul mellomrommene slik at sidekantene møtes. Margene inne i PDF-en endres ikke.
+ Arrange image Ranger bilde
+ Bring forward Flytt fremover
+ Bring to front Plasser lengst frem
+ Crop Beskjær
+ Remove crop Fjern beskjæring
+ Send backward Flytt bakover
+ Send to back Plasser lengst bak
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today I dag
+
+ # AI-assisted additions for restoring the last view (#1767) (2026-10-22); not reviewed by a native speaker.
+ Restore the last view (page, zoom and page display) when a document is opened again Gjenopprett den siste visningen (side, zoom og sidevisning) når et dokument åpnes igjen
+ @plural {n} reply|{n} replies {n} svar|{n} svar
diff --cc crates/ui-egui/src/i18n/pl.tsv
index 83f81db08,056ca7d40..0877a9842
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@@ -2457,26 -2465,19 +2465,39 @@@ animation effects Off Wyłączon
Make properties default Ustaw właściwości jako domyślne
Pages selected Zaznaczone strony
Page properties Właściwości strony
+ Clear search Wyczyść wyszukiwanie
+ Pin Przypnij
+ Pin a tool… Przypnij narzędzie…
+ Pin to Home Przypnij do strony głównej
+ Pin tools to Home Przypnij narzędzia do strony głównej
+ Pin your favorite tools here for quick access. Przypnij tutaj ulubione narzędzia, aby mieć do nich szybki dostęp.
+ Pinned Przypięte
+ Pinned Tools Przypięte narzędzia
+ Search tools… Szukaj narzędzi…
+ Select tools to display on your Home page for quick access. Wybierz narzędzia do wyświetlenia na stronie głównej, aby mieć do nich szybki dostęp.
+ Unpin from Home Odepnij od strony głównej
+ Unpin tool Odepnij narzędzie
+ Transform image Przekształć obraz
+ Select Tool Narzędzie Zaznaczanie
+ Hand Tool Narzędzie Rączka
+ Marquee Zoom Powiększ zaznaczony obszar
+ Paste Wklej
+ Edit this PDF Edytuj ten plik PDF
+ Export this PDF Eksportuj ten plik PDF
+ Find text or tools Znajdź tekst lub narzędzia
+ Create & Edit Tworzenie i edycja
+ Review & Compare Recenzja i porównanie
+ Forms & Signatures Formularze i podpisy
+ Protect & Standardize Ochrona i standaryzacja
+ Customize & Automate Dostosowanie i automatyzacja
+ No tools match your search. Żadne narzędzie nie pasuje do wyszukiwania.
+ Expand all tools Rozwiń wszystkie narzędzia
+ Collapse all tools Zwiń wszystkie narzędzia
+ Attach a file… Dołącz plik…
+ Delete attachment Usuń załącznik
+ Attaching files is not available on the web yet Dołączanie plików nie jest jeszcze dostępne w wersji webowej
+ Attach {name} Dołącz {name}
+ Delete attachment {key} Usuń załącznik {key}
Font Czcionka
Bulleted list Lista punktowana
Numbered list Lista numerowana
@@@ -2631,10 -2632,7 +2652,14 @@@
field names can't contain a period: {name} nazwy pól nie mogą zawierać kropki: {name}
two cells would both be named {name} dwie komórki miałyby nazwę {name}
a field named {name} already exists pole o nazwie {name} już istnieje
+ Arrange image Rozmieść obraz
+ Bring forward Przesuń do przodu
+ Bring to front Przesuń na wierzch
+ Crop Przytnij
+ Remove crop Usuń przycięcie
+ Send backward Przesuń do tyłu
+ Send to back Przesuń pod spód
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Dzisiaj
+ @plural {n} reply|{n} replies {n} odpowiedź|{n} odpowiedzi|{n} odpowiedzi
diff --cc crates/ui-egui/src/i18n/pt-br.tsv
index d6acb2fb8,1434c7c6e..5182a1550
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@@ -2495,25 -2503,19 +2503,38 @@@ animation effects Off Desativado
Make properties default Tornar propriedades padrão
Pages selected Páginas selecionadas
Page properties Propriedades da página
+ Clear search Limpar pesquisa
+ Pin Fixar
+ Pin a tool… Fixar uma ferramenta…
+ Pin to Home Fixar no Início
+ Pin tools to Home Fixar ferramentas no Início
+ Pin your favorite tools here for quick access. Fixe suas ferramentas favoritas aqui para acesso rápido.
+ Pinned Fixado
+ Pinned Tools Ferramentas fixadas
+ Search tools… Pesquisar ferramentas…
+ Select tools to display on your Home page for quick access. Selecione ferramentas para exibir na página Início para acesso rápido.
+ Unpin from Home Desafixar do Início
+ Unpin tool Desafixar ferramenta
+ Transform image Transformar imagem
+ Select Tool Ferramenta Seleção
+ Hand Tool Ferramenta Mão
+ Marquee Zoom Zoom por seleção
+ Edit this PDF Editar este PDF
+ Export this PDF Exportar este PDF
+ Find text or tools Localizar texto ou ferramentas
+ Create & Edit Criar e editar
+ Review & Compare Revisar e comparar
+ Forms & Signatures Formulários e assinaturas
+ Protect & Standardize Proteger e padronizar
+ Customize & Automate Personalizar e automatizar
+ No tools match your search. Nenhuma ferramenta corresponde à pesquisa.
+ Expand all tools Expandir todas as ferramentas
+ Collapse all tools Recolher todas as ferramentas
+ Attach a file… Anexar um arquivo…
+ Delete attachment Excluir anexo
+ Attaching files is not available on the web yet Anexar arquivos ainda não está disponível na web
+ Attach {name} Anexar {name}
+ Delete attachment {key} Excluir anexo {key}
# Remaining keys from the current catalog union, translated from their English meaning (2026-10-21).
on page {label} na página {label}
@@@ -2819,11 -2821,7 +2840,15 @@@ theme Appearance Aparênci
a table has 1 to {max} columns uma tabela tem de 1 a {max} colunas
the first row number can be at most {max} o número da primeira linha pode ser no máximo {max}
the area, the spacing and the column widths must be numbers, the spacing 0 or more and each width more than 0 a área, o espaçamento e as larguras das colunas devem ser números, o espaçamento 0 ou mais e cada largura maior que 0
+ Bring forward Avançar
+ Bring to front Trazer para a frente
+ Crop image Cortar imagem
+ Remove crop Remover corte
+ Send backward Recuar
+ Send to back Enviar para trás
+ Arrange image Organizar imagem
+ Crop Cortar
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Hoje
+ @plural {n} reply|{n} replies {n} resposta|{n} respostas
diff --cc crates/ui-egui/src/i18n/ro.tsv
index eadaa2f84,7c739932e..407fdde08
--- a/crates/ui-egui/src/i18n/ro.tsv
+++ b/crates/ui-egui/src/i18n/ro.tsv
@@@ -2774,30 -2789,15 +2789,42 @@@ theme Appearance Aspec
field names can't contain a period: {name} numele câmpurilor nu pot conține punct: {name}
two cells would both be named {name} două celule s-ar numi amândouă {name}
a field named {name} already exists există deja un câmp numit {name}
+ Bring forward Aduce mai în față
+ Bring to front Aduce în prim-plan
+ Crop image Decupare imagine
+ Remove crop Elimină decuparea
+ Send backward Trimite mai în spate
+ Send to back Trimite în fundal
+ Clear search Golește căutarea
+ Edit this PDF Editează acest PDF
+ Export this PDF Exportă acest PDF
+ Find text or tools Găsește text sau instrumente
+ Hand Tool Instrumentul Mână
+ Marquee Zoom Zoom cadru
+ Pin Fixează
+ Pin a tool… Fixează un instrument…
+ Pin to Home Fixează la Pagina de pornire
+ Pin tools to Home Fixează instrumente la Pagina de pornire
+ Pin your favorite tools here for quick access. Fixează instrumentele preferate aici pentru acces rapid.
+ Pinned Fixat
+ Pinned Tools Instrumente fixate
+ Search tools… Caută instrumente…
+ Select Tool Instrumentul Selecție
+ Select tools to display on your Home page for quick access. Selectează instrumentele de afișat pe Pagina de pornire pentru acces rapid.
+ Transform image Transformare imagine
+ Unpin from Home Anulează fixarea la Pagina de pornire
+ Unpin tool Anulează fixarea instrumentului
+ Arrange image Aranjează imaginea
+ Crop Decupare
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Astăzi
+
+ # AI-assisted additions for restoring the last view (#1767) (2026-10-22); not reviewed by a native speaker.
+ Restore the last view (page, zoom and page display) when a document is opened again Restabilește ultima vizualizare (pagina, zoomul și afișarea paginilor) când un document este redeschis
+ Attach a file… Atașare fișier…
+ Attach {name} Atașare {name}
+ Attaching files is not available on the web yet Atașarea fișierelor nu este încă disponibilă pe web
+ Delete attachment Ștergere atașament
+ Delete attachment {key} Ștergere atașament {key}
+ @plural {n} reply|{n} replies {n} răspuns|{n} răspunsuri|{n} de răspunsuri
diff --cc crates/ui-egui/src/i18n/ru.tsv
index 4f65e6bce,bea98cd79..3b2dba29d
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@@ -2394,26 -2402,19 +2402,39 @@@ animation effects Off Вык�
Make properties default Сделать свойства стандартными
Pages selected Выделенные страницы
Page properties Свойства страницы
+ Clear search Очистить поиск
+ Pin Закрепить
+ Pin a tool… Закрепить инструмент…
+ Pin to Home Закрепить на Главной
+ Pin tools to Home Закрепить инструменты на Главной
+ Pin your favorite tools here for quick access. Закрепите здесь избранные инструменты для быстрого доступа.
+ Pinned Закреплено
+ Pinned Tools Закрепленные инструменты
+ Search tools… Поиск инструментов…
+ Select tools to display on your Home page for quick access. Выберите инструменты для отображения на Главной странице для быстрого доступа.
+ Unpin from Home Открепить от Главной
+ Unpin tool Открепить инструмент
+ Transform image Трансформировать изображение
+ Select Tool Инструмент «Выделение»
+ Hand Tool Инструмент «Рука»
+ Marquee Zoom Масштаб выделением
+ Paste Вставить
+ Edit this PDF Редактировать этот PDF
+ Export this PDF Экспортировать этот PDF
+ Find text or tools Найти текст или инструменты
+ Create & Edit Создание и редактирование
+ Review & Compare Рецензирование и сравнение
+ Forms & Signatures Формы и подписи
+ Protect & Standardize Защита и стандартизация
+ Customize & Automate Настройка и автоматизация
+ No tools match your search. Нет инструментов, соответствующих запросу.
+ Expand all tools Развернуть все инструменты
+ Collapse all tools Свернуть все инструменты
+ Attach a file… Прикрепить файл…
+ Delete attachment Удалить вложение
+ Attaching files is not available on the web yet Прикрепление файлов в веб-версии пока недоступно
+ Attach {name} Прикрепить {name}
+ Delete attachment {key} Удалить вложение {key}
Font Шрифт
Bulleted list Маркированный список
Numbered list Нумерованный список
@@@ -2448,10 -2449,7 +2469,14 @@@
field names can't contain a period: {name} имена полей не могут содержать точку: {name}
two cells would both be named {name} две ячейки получили бы одно имя {name}
a field named {name} already exists поле с именем {name} уже существует
+ Arrange image Упорядочить изображение
+ Bring forward Переместить вперед
+ Bring to front На передний план
+ Crop Обрезать
+ Remove crop Убрать обрезку
+ Send backward Переместить назад
+ Send to back На задний план
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Сегодня
+ @plural {n} reply|{n} replies {n} ответ|{n} ответа|{n} ответов
diff --cc crates/ui-egui/src/i18n/sl.tsv
index de5194b2f,ccbb42d57..ab712526e
--- a/crates/ui-egui/src/i18n/sl.tsv
+++ b/crates/ui-egui/src/i18n/sl.tsv
@@@ -2486,26 -2494,19 +2494,39 @@@ animation effects Off Izklopljen
Make properties default Nastavi lastnosti kot privzete
Pages selected Izbrane strani
Page properties Lastnosti strani
+ Clear search Počisti iskanje
+ Pin Pripni
+ Pin a tool… Pripni orodje…
+ Pin to Home Pripni na domov
+ Pin tools to Home Pripni orodja na domov
+ Pin your favorite tools here for quick access. Tukaj pripnite svoja priljubljena orodja za hiter dostop.
+ Pinned Pripeto
+ Pinned Tools Pripeta orodja
+ Search tools… Išči orodja…
+ Select tools to display on your Home page for quick access. Izberite orodja za prikaz na domači strani za hiter dostop.
+ Unpin from Home Odpni z domače strani
+ Unpin tool Odpni orodje
+ Transform image Preoblikuj sliko
+ Select Tool Orodje za izbiro
+ Hand Tool Orodje z roko
+ Marquee Zoom Povečava z okvirjem
+ Paste Prilepi
+ Edit this PDF Uredi ta PDF
+ Export this PDF Izvozi ta PDF
+ Find text or tools Poišči besedilo ali orodja
+ Create & Edit Ustvarjanje in urejanje
+ Review & Compare Pregled in primerjava
+ Forms & Signatures Obrazci in podpisi
+ Protect & Standardize Zaščita in standardizacija
+ Customize & Automate Prilagajanje in avtomatizacija
+ No tools match your search. Iskanju ne ustreza nobeno orodje.
+ Expand all tools Razširi vsa orodja
+ Collapse all tools Strni vsa orodja
+ Attach a file… Priloži datoteko…
+ Delete attachment Izbriši prilogo
+ Attaching files is not available on the web yet Prilaganje datotek na spletu še ni na voljo
+ Attach {name} Priloži {name}
+ Delete attachment {key} Izbriši prilogo {key}
Font Pisava
Bulleted list Označen seznam
Numbered list Oštevilčen seznam
@@@ -2540,10 -2541,7 +2561,14 @@@
field names can't contain a period: {name} imena polj ne smejo vsebovati pike: {name}
two cells would both be named {name} dve celici bi imeli enako ime {name}
a field named {name} already exists polje z imenom {name} že obstaja
+ Arrange image Uredi sliko
+ Bring forward Premakni naprej
+ Bring to front Postavi v ospredje
+ Crop Obreži
+ Remove crop Odstrani obrezovanje
+ Send backward Premakni nazaj
+ Send to back Postavi v ozadje
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Danes
+ @plural {n} reply|{n} replies {n} odgovor|{n} odgovora|{n} odgovori|{n} odgovorov
diff --cc crates/ui-egui/src/i18n/sq.tsv
index 9b1affbca,a720a5333..7fcf8f4d8
--- a/crates/ui-egui/src/i18n/sq.tsv
+++ b/crates/ui-egui/src/i18n/sq.tsv
@@@ -2500,29 -2515,15 +2515,41 @@@ animation effects Off Joakti
field names can't contain a period: {name} emrat e fushave nuk mund të përmbajnë pikë: {name}
two cells would both be named {name} dy qeliza do të kishin të dyja emrin {name}
a field named {name} already exists ekziston tashmë një fushë me emrin {name}
+ Clear search Pastro kërkimin
+ Edit this PDF Redakto këtë PDF
+ Export this PDF Eksporto këtë PDF
+ Find text or tools Gjej tekst ose mjete
+ Hand Tool Mjeti Dorë
+ Marquee Zoom Zmadhim me kornizë
+ Paste Ngjit
+ Pin Fikso
+ Pin a tool… Fikso një mjet…
+ Pin to Home Fikso në Ballinë
+ Pin tools to Home Fikso mjetet në Ballinë
+ Pin your favorite tools here for quick access. Fiksoni mjetet tuaja të preferuara këtu për qasje të shpejtë.
+ Pinned I fiksuar
+ Pinned Tools Mjete të fiksuara
+ Search tools… Kërko mjete…
+ Select Tool Mjeti Përzgjedhje
+ Select tools to display on your Home page for quick access. Zgjidhni mjetet për t'u shfaqur në faqen tuaj të Ballinës për qasje të shpejtë.
+ Unpin from Home Hiq fiksimin nga Ballina
+ Unpin tool Hiq fiksimin e mjetit
+ Arrange image Rregullo figurën
+ Bring forward Kalo përpara
+ Bring to front Sille përpara
+ Crop Crop
+ Remove crop Remove Crop
+ Send backward Kalo prapa
+ Send to back Dërgo mbrapa
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Sot
+
+ # AI-assisted additions for restoring the last view (#1767) (2026-10-22); not reviewed by a native speaker.
+ Restore the last view (page, zoom and page display) when a document is opened again Rikthe pamjen e fundit (faqen, zmadhimin dhe shfaqjen e faqeve) kur një dokument hapet përsëri
+ Attach a file… Bashkëngjit një skedar…
+ Attach {name} Bashkëngjit {name}
+ Attaching files is not available on the web yet Bashkëngjitja e skedarëve nuk është ende e disponueshme në ueb
+ Delete attachment Fshi bashkëngjitjen
+ Delete attachment {key} Fshi bashkëngjitjen {key}
+ @plural {n} reply|{n} replies {n} përgjigje|{n} përgjigje
diff --cc crates/ui-egui/src/i18n/te.tsv
index ac15d93f2,317d47f9b..dc864bc0d
--- a/crates/ui-egui/src/i18n/te.tsv
+++ b/crates/ui-egui/src/i18n/te.tsv
@@@ -2390,26 -2398,19 +2398,39 @@@ animation effects Off ఆఫ�
Make properties default లక్షణాలను డిఫాల్ట్‌గా చేయి
Pages selected ఎంచుకున్న పేజీలు
Page properties పేజీ లక్షణాలు
+ Clear search శోధనను తీసివేయి
+ Pin పిన్ చేయి
+ Pin a tool… ఒక సాధనాన్ని పిన్ చేయి…
+ Pin to Home హోమ్‌కు పిన్ చేయి
+ Pin tools to Home సాధనాలను హోమ్‌కు పిన్ చేయి
+ Pin your favorite tools here for quick access. త్వరిత ప్రాప్యత కోసం మీకు ఇష్టమైన సాధనాలను ఇక్కడ పిన్ చేయండి.
+ Pinned పిన్ చేయబడింది
+ Pinned Tools పిన్ చేసిన సాధనాలు
+ Search tools… సాధనాలను శోధించండి…
+ Select tools to display on your Home page for quick access. త్వరిత ప్రాప్యత కోసం మీ హోమ్ పేజీలో ప్రదర్శించడానికి సాధనాలను ఎంచుకోండి.
+ Unpin from Home హోమ్ నుండి అన్‌పిన్ చేయి
+ Unpin tool సాధనాన్ని అన్‌పిన్ చేయి
+ Transform image చిత్రాన్ని రూపాంతరం చేయండి
+ Select Tool ఎంపిక సాధనం
+ Hand Tool హ్యాండ్ సాధనం
+ Marquee Zoom ఎంచుకున్న ప్రాంతానికి జూమ్
+ Paste అతికించు
+ Edit this PDF ఈ PDFను సవరించు
+ Export this PDF ఈ PDFను ఎగుమти చేయి
+ Find text or tools వచనం లేదా సాధనాలను కనుగొనండి
+ Create & Edit సృష్టించు & సవరించు
+ Review & Compare సమీక్షించు & పోల్చు
+ Forms & Signatures ఫారమ్‌లు & సంతకాలు
+ Protect & Standardize రక్షించు & ప్రామాణీకరించు
+ Customize & Automate అనుకూలీకరించు & ఆటోమేట్ చేయి
+ No tools match your search. మీ శోధనకు సరిపోలే సాధనాలు లేవు.
+ Expand all tools అన్ని సాధనాలను విస్తరించు
+ Collapse all tools అన్ని సాధనాలను కుదించు
+ Attach a file… ఫైల్‌ను జోడించు…
+ Delete attachment జోడింపును తొలగించు
+ Attaching files is not available on the web yet వెబ్‌లో ఫైల్‌లను జోడించడం ఇంకా అందుబాటులో లేదు
+ Attach {name} {name}ను జోడించు
+ Delete attachment {key} జోడింపు {key}ను తొలగించు
Font ఫాంట్
Bulleted list బుల్లెట్ జాబితా
Numbered list సంఖ్యల జాబితా
@@@ -2444,10 -2445,7 +2465,14 @@@
field names can't contain a period: {name} ఫీల్డ్ పేర్లలో చుక్క ఉండకూడదు: {name}
two cells would both be named {name} రెండు గడులకూ {name} అనే పేరు వస్తుంది
a field named {name} already exists {name} అనే ఫీల్డ్ ఇప్పటికే ఉంది
+ Arrange image చిత్రాన్ని అమర్చు
+ Bring forward ముందుకు తీసుకురా
+ Bring to front అందరికంటే ముందుకు తీసుకురా
+ Crop కత్తిరించు
+ Remove crop కత్తిరింపును తీసివేయి
+ Send backward వెనుకకు పంపు
+ Send to back అందరికంటే వెనుకకు పంపు
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today ఈరోజు
+ @plural {n} reply|{n} replies {n} ప్రత్యుత్తరం|{n} ప్రత్యుత్తరాలు
diff --cc crates/ui-egui/src/i18n/th.tsv
index 1deeacbf7,92bb15f1a..085ed3293
--- a/crates/ui-egui/src/i18n/th.tsv
+++ b/crates/ui-egui/src/i18n/th.tsv
@@@ -2679,12 -2686,20 +2686,27 @@@ key Space Spac
Make properties default ตั้งคุณสมบัติเป็นค่าเริ่มต้น
Pages selected หน้าที่เลือก
Page properties คุณสมบัติหน้า
+ Create & Edit สร้างและแก้ไข
+ Review & Compare ตรวจทานและเปรียบเทียบ
+ Forms & Signatures แบบฟอร์มและลายเซ็น
+ Protect & Standardize ป้องกันและกำหนดมาตรฐาน
+ Customize & Automate ปรับแต่งและทำงานอัตโนมัติ
+ No tools match your search. ไม่มีเครื่องมือที่ตรงกับการค้นหาของคุณ
+ Expand all tools ขยายเครื่องมือทั้งหมด
+ Collapse all tools ยุบเครื่องมือทั้งหมด
The password must have at least 8 characters. รหัสผ่านต้องมีอย่างน้อย 8 ตัวอักษร
theme Appearance ลักษณะที่ปรากฏ
+ Arrange image จัดเรียงรูปภาพ
+ Bring forward นำไปข้างหน้า
+ Bring to front นำไปไว้ข้างหน้าสุด
+ Crop ครอบตัด
+ Remove crop เอาการครอบตัดออก
+ Send backward ส่งไปข้างหลัง
+ Send to back ส่งไปไว้ข้างหลังสุด
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today วันนี้
+
+ # AI-assisted additions for restoring the last view (#1767) (2026-10-22); not reviewed by a native speaker.
+ Restore the last view (page, zoom and page display) when a document is opened again คืนค่ามุมมองล่าสุด (หน้า การซูม และการแสดงหน้า) เมื่อเปิดเอกสารอีกครั้ง
+ @plural {n} reply|{n} replies การตอบกลับ {n} รายการ
diff --cc crates/ui-egui/src/i18n/tr.tsv
index fba2bd381,bcdfe9a90..852e0c9de
--- a/crates/ui-egui/src/i18n/tr.tsv
+++ b/crates/ui-egui/src/i18n/tr.tsv
@@@ -2477,26 -2485,19 +2485,39 @@@ animation effects Off Kapal�
Make properties default Özellikleri varsayılan yap
Pages selected Seçilen sayfalar
Page properties Sayfa özellikleri
+ Clear search Aramayı temizle
+ Pin Sabitle
+ Pin a tool… Bir aracı sabitle…
+ Pin to Home Giriş'e sabitle
+ Pin tools to Home Araçları Giriş'e sabitle
+ Pin your favorite tools here for quick access. Hızlı erişim için favori araçlarınızı buraya sabitleyin.
+ Pinned Sabitlendi
+ Pinned Tools Sabitlenen Araçlar
+ Search tools… Araçları ara…
+ Select tools to display on your Home page for quick access. Hızlı erişim için Giriş sayfanızda görüntülenecek araçları seçin.
+ Unpin from Home Giriş'ten sabitlemeyi kaldır
+ Unpin tool Aracın sabitlemesini kaldır
+ Transform image Görüntüyü dönüştür
+ Select Tool Seçim Aracı
+ Hand Tool El Aracı
+ Marquee Zoom Seçim yakınlaştırma
+ Paste Yapıştır
+ Edit this PDF Bu PDF'i düzenle
+ Export this PDF Bu PDF'i dışa aktar
+ Find text or tools Metin veya araç bul
+ Create & Edit Oluştur ve Düzenle
+ Review & Compare İncele ve Karşılaştır
+ Forms & Signatures Formlar ve İmzalar
+ Protect & Standardize Koru ve Standartlaştır
+ Customize & Automate Özelleştir ve Otomatikleştir
+ No tools match your search. Aramanızla eşleşen araç yok.
+ Expand all tools Tüm araçları genişlet
+ Collapse all tools Tüm araçları daralt
+ Attach a file… Dosya ekle…
+ Delete attachment Eki sil
+ Attaching files is not available on the web yet Dosya eklemek web'de henüz kullanılamıyor
+ Attach {name} {name} ekle
+ Delete attachment {key} {key} ekini sil
Font Yazı tipi
Bulleted list Madde işaretli liste
Numbered list Numaralı liste
@@@ -2531,10 -2532,7 +2552,14 @@@
field names can't contain a period: {name} alan adları nokta içeremez: {name}
two cells would both be named {name} iki hücrenin de adı {name} olurdu
a field named {name} already exists {name} adlı bir alan zaten var
+ Arrange image Resmi düzenle
+ Bring forward Öne getir
+ Bring to front En öne getir
+ Crop Kırp
+ Remove crop Kırpmayı kaldır
+ Send backward Arkaya gönder
+ Send to back En arkaya gönder
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Bugün
+ @plural {n} reply|{n} replies {n} yanıt
diff --cc crates/ui-egui/src/i18n/uk.tsv
index 46c26d6c0,599b4b63a..d8c9d59f1
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@@ -2503,26 -2511,19 +2511,39 @@@ animation effects Off Вимкнен�
Make properties default Зробити властивості типовими
Pages selected Вибрані сторінки
Page properties Властивості сторінки
+ Clear search Очистити пошук
+ Pin Закріпити
+ Pin a tool… Закріпити інструмент…
+ Pin to Home Закріпити на Головній
+ Pin tools to Home Закріпити інструменти на Головній
+ Pin your favorite tools here for quick access. Закріпіть улюблені інструменти тут для швидкого доступу.
+ Pinned Закріплено
+ Pinned Tools Закріплені інструменти
+ Search tools… Шукати інструменти…
+ Select tools to display on your Home page for quick access. Виберіть інструменти для відображення на Головній для швидкого доступу.
+ Unpin from Home Відкріпити від Головної
+ Unpin tool Відкріпити інструмент
+ Transform image Трансформувати зображення
+ Select Tool Інструмент виділення
+ Hand Tool Інструмент «Рука»
+ Marquee Zoom Масштабувати виділену область
+ Paste Вставити
+ Edit this PDF Редактировать цей PDF
+ Export this PDF Експортувати цей PDF
+ Find text or tools Знайти текст або інструменти
+ Create & Edit Створення й редагування
+ Review & Compare Рецензування й порівняння
+ Forms & Signatures Форми й підписи
+ Protect & Standardize Захист і стандартизація
+ Customize & Automate Налаштування й автоматизація
+ No tools match your search. Немає інструментів, що відповідають пошуку.
+ Expand all tools Розгорнути всі інструменти
+ Collapse all tools Згорнути всі інструменти
+ Attach a file… Прикріпити файл…
+ Delete attachment Видалити вкладення
+ Attaching files is not available on the web yet Прикріплення файлів у веб-версії поки недоступне
+ Attach {name} Прикріпити {name}
+ Delete attachment {key} Видалити вкладення {key}
Font Шрифт
Bulleted list Маркований список
Numbered list Нумерований список
@@@ -2557,10 -2558,7 +2578,14 @@@
field names can't contain a period: {name} імена полів не можуть містити крапку: {name}
two cells would both be named {name} дві клітинки мали б однакове ім'я {name}
a field named {name} already exists поле з іменем {name} уже існує
+ Arrange image Упорядкувати зображення
+ Bring forward Перемістити вперед
+ Bring to front На передній план
+ Crop Обрізати
+ Remove crop Прибрати обрізання
+ Send backward Перемістити назад
+ Send to back На задній план
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Сьогодні
+ @plural {n} reply|{n} replies {n} відповідь|{n} відповіді|{n} відповідей
diff --cc crates/ui-egui/src/i18n/vi.tsv
index 620a6a9e0,048f78f62..bea96ed08
--- a/crates/ui-egui/src/i18n/vi.tsv
+++ b/crates/ui-egui/src/i18n/vi.tsv
@@@ -2669,12 -2676,14 +2676,20 @@@ key Space Spac
Redact Image Xóa nội dung nhạy cảm của hình ảnh
Create Link… Tạo liên kết…
Recognize Text… Nhận dạng văn bản…
+ Bring forward Chuyển lên trước
+ Bring to front Đưa lên trước cùng
+ Crop image Cắt hình ảnh
+ Remove crop Xóa cắt
+ Send backward Chuyển về sau
+ Send to back Đưa về sau cùng
+ Create & Edit Tạo và chỉnh sửa
+ Review & Compare Xem xét và so sánh
+ Forms & Signatures Biểu mẫu và chữ ký
+ Protect & Standardize Bảo vệ và chuẩn hóa
+ Customize & Automate Tùy chỉnh và tự động hóa
+ No tools match your search. Không có công cụ nào khớp với tìm kiếm.
+ Expand all tools Mở rộng tất cả công cụ
+ Collapse all tools Thu gọn tất cả công cụ
# AI-assisted additions for concurrently merged UI features (2026-10-15).
# These additions have not had separate native-speaker review.
@@@ -2754,25 -2763,11 +2769,30 @@@
# Historical snapshot notice bar (View signed version / View revision).
You are viewing the signed version of “{from}” (revision {rev}). It is a snapshot: changes here won't affect the original. Bạn đang xem phiên bản đã ký của “{from}” (bản sửa đổi {rev}). Đây là ảnh nhanh: các thay đổi ở đây không được áp dụng đến bản gốc.
You are viewing revision {rev} of “{from}”. It is a snapshot: changes here won't affect the original. Bạn đang xem bản sửa đổi {rev} của “{from}”. Đây là ảnh nhanh: các thay đổi ở đây không được áp dụng đến bản gốc.
+ Clear search Xóa tìm kiếm
+ Pin Ghim
+ Pin a tool… Ghim công cụ…
+ Pin to Home Ghim vào Trang chủ
+ Pin tools to Home Ghim công cụ vào Trang chủ
+ Pin your favorite tools here for quick access. Ghim các công cụ yêu thích của bạn vào đây để truy cập nhanh.
+ Pinned Đã ghim
+ Pinned Tools Công cụ đã ghim
+ Search tools… Tìm kiếm công cụ…
+ Select tools to display on your Home page for quick access. Chọn các công cụ hiển thị trên Trang chủ để truy cập nhanh.
+ Unpin from Home Bỏ ghim khỏi Trang chủ
+ Unpin tool Bỏ ghim công cụ
+ Transform image Chuyển đổi hình ảnh
+ Select Tool Công cụ chọn
+ Hand Tool Công cụ bàn tay
+ Marquee Zoom Thu phóng theo vùng chọn
+ Edit this PDF Chỉnh sửa PDF này
+ Export this PDF Xuất PDF này
+ Find text or tools Tìm văn bản hoặc công cụ
+ Attach a file… Đính kèm tệp…
+ Delete attachment Xóa tệp đính kèm
+ Attaching files is not available on the web yet Chưa thể đính kèm tệp trên web
+ Attach {name} Đính kèm {name}
+ Delete attachment {key} Xóa tệp đính kèm {key}
Thumbnail size Kích thước hình thu nhỏ
Smaller thumbnails Giảm kích thước hình thu nhỏ
Larger thumbnails Tăng kích thước hình thu nhỏ
@@@ -2805,5 -2800,10 +2825,12 @@@
a table has 1 to {max} columns một bảng có từ 1 đến {max} cột
the first row number can be at most {max} số hàng đầu tiên tối đa là {max}
the area, the spacing and the column widths must be numbers, the spacing 0 or more and each width more than 0 vùng, khoảng cách và độ rộng cột phải là số, khoảng cách từ 0 trở lên và mỗi độ rộng lớn hơn 0
+ Arrange image Sắp xếp hình ảnh
+ Crop Xén
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today Hôm nay
+
+ # AI-assisted additions for restoring the last view (#1767) (2026-10-16); not reviewed by a native speaker.
+ Restore the last view (page, zoom and page display) when a document is opened again Khôi phục chế độ xem gần nhất (trang, thu phóng và hiển thị trang) khi mở lại tài liệu
+ @plural {n} reply|{n} replies {n} câu trả lời
diff --cc crates/ui-egui/src/i18n/zh-hans.tsv
index e48841d0b,7ea3ca941..51c4b0ff0
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@@ -2445,26 -2453,19 +2453,39 @@@ animation effects Off �
Make properties default 将属性设为默认
Pages selected 选定的页面
Page properties 页面属性
+ Clear search 清除搜索
+ Pin 固定
+ Pin a tool… 固定工具…
+ Pin to Home 固定到主页
+ Pin tools to Home 将工具固定到主页
+ Pin your favorite tools here for quick access. 将常用的工具固定在此处以便快速访问。
+ Pinned 已固定
+ Pinned Tools 已固定的工具
+ Search tools… 搜索工具…
+ Select tools to display on your Home page for quick access. 选择要在主页上显示的工具以便快速访问。
+ Unpin from Home 从主页取消固定
+ Unpin tool 取消固定工具
+ Transform image 变换图像
+ Select Tool 选择工具
+ Hand Tool 手形工具
+ Marquee Zoom 选框缩放
+ Paste 粘贴
+ Edit this PDF 编辑此 PDF
+ Export this PDF 导出此 PDF
+ Find text or tools 查找文本或工具
+ Create & Edit 创建和编辑
+ Review & Compare 审阅和比较
+ Forms & Signatures 表单和签名
+ Protect & Standardize 保护和标准化
+ Customize & Automate 自定义和自动化
+ No tools match your search. 没有与搜索匹配的工具。
+ Expand all tools 展开所有工具
+ Collapse all tools 折叠所有工具
+ Attach a file… 附加文件…
+ Delete attachment 删除附件
+ Attaching files is not available on the web yet 网页版尚不支持附加文件
+ Attach {name} 附加 {name}
+ Delete attachment {key} 删除附件 {key}
Font 字体
Bulleted list 项目符号列表
Numbered list 编号列表
@@@ -2499,10 -2500,7 +2520,14 @@@
field names can't contain a period: {name} 字段名称不能包含句点:{name}
two cells would both be named {name} 两个单元格的名称都会是 {name}
a field named {name} already exists 已存在名为 {name} 的字段
+ Arrange image 排列图像
+ Bring forward 上移一层
+ Bring to front 置于顶层
+ Crop 裁剪
+ Remove crop 移除裁剪
+ Send backward 下移一层
+ Send to back 置于底层
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today 今天
+ @plural {n} reply|{n} replies {n} 条回复
diff --cc crates/ui-egui/src/i18n/zh-hant.tsv
index 7d7b9e70a,b34cb787c..92cfb4cde
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@@ -2431,26 -2439,19 +2439,39 @@@ animation effects Off �
Make properties default 將內容設為預設
Pages selected 選取的頁面
Page properties 頁面屬性
+ Clear search 清除搜尋
+ Pin 釘選
+ Pin a tool… 釘選工具…
+ Pin to Home 釘選到首頁
+ Pin tools to Home 將工具釘選到首頁
+ Pin your favorite tools here for quick access. 將常用的工具釘選在此處以便快速存取。
+ Pinned 已釘選
+ Pinned Tools 已釘選的工具
+ Search tools… 搜尋工具…
+ Select tools to display on your Home page for quick access. 選取要在首頁上顯示的工具以便快速存取。
+ Unpin from Home 從首頁取消釘選
+ Unpin tool 取消釘選工具
+ Transform image 變換影像
+ Select Tool 選取工具
+ Hand Tool 手形工具
+ Marquee Zoom 選取範圍縮放
+ Paste 貼上
+ Edit this PDF 編輯此 PDF
+ Export this PDF 匯出此 PDF
+ Find text or tools 尋找文字或工具
+ Create & Edit 建立與編輯
+ Review & Compare 審閱與比較
+ Forms & Signatures 表單與簽名
+ Protect & Standardize 保護與標準化
+ Customize & Automate 自訂與自動化
+ No tools match your search. 沒有符合搜尋的工具。
+ Expand all tools 展開所有工具
+ Collapse all tools 摺疊所有工具
+ Attach a file… 附加檔案…
+ Delete attachment 刪除附件
+ Attaching files is not available on the web yet 網頁版尚不支援附加檔案
+ Attach {name} 附加 {name}
+ Delete attachment {key} 刪除附件 {key}
Font 字型
Bulleted list 項目符號清單
Numbered list 編號清單
@@@ -2485,10 -2486,7 +2506,14 @@@
field names can't contain a period: {name} 欄位名稱不能包含句點:{name}
two cells would both be named {name} 兩個儲存格的名稱都會是 {name}
a field named {name} already exists 已有名為 {name} 的欄位
+ Arrange image 排列影像
+ Bring forward 上移一層
+ Bring to front 移到最上層
+ Crop 裁切
+ Remove crop 移除裁切
+ Send backward 下移一層
+ Send to back 移到最下層
+
+ # Date picker: Today button (#4274) (AI-assisted, not separately native-reviewed)
+ Today 今天
+ @plural {n} reply|{n} replies {n} 則回覆
diff --cc crates/ui-egui/src/lib.rs
index aaf72a5c7,0300afd46..07133a7d2
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@@ -101,9 -100,9 +102,11 @@@ mod home
mod icon_data;
pub mod icons;
pub mod last_session;
+ pub mod last_view;
pub mod motion;
+#[cfg(not(target_arch = "wasm32"))]
+mod os_clipboard;
+ mod page_pointer;
mod page_selection_ui;
mod pageboxes;
mod palette;
@@@ -2534,16 -2731,10 +2790,19 @@@ impl PdfCraftApp
if let Some(on) = v["reload_changed_files"].as_bool() {
self.reload_changed_files = on;
}
+ if let Some(on) = v["show_secured_notice"].as_bool() {
+ self.show_secured_notice = on;
+ }
self.pinned.restore(&v["pinned_folders"]);
+ if let Some(items) = v.get("pinned_tools").and_then(serde_json::Value::as_array) {
+ let mut tools = Vec::new();
+ for item in items.iter().filter_map(serde_json::Value::as_str) {
+ if pdfcraft_engine::catalog::group(item).is_some() && !tools.contains(&item.to_string()) {
+ tools.push(item.to_string());
+ }
+ }
+ self.pinned_tools = tools;
+ }
if let Ok(preference) = serde_json::from_value::<ThemePreference>(v["theme"].clone()) {
self.set_theme_preference(preference);
}
@@@ -2621,9 -2812,10 +2880,12 @@@
}
if let Some(hide) = v["hide_empty_highlight_hover"].as_bool() {
self.comment_prefs.hide_empty_highlight_hover = hide;
+ } else if let Some(display) = v["display_author_hover_no_comment"].as_bool() {
+ self.comment_prefs.hide_empty_highlight_hover = !display;
}
+ if let Some(pinned) = v["comment_tool_pinned"].as_bool() {
+ self.comment_prefs.pinned = pinned;
+ }
// Per-tool comment styles (#340): each field goes through its clamping setter, so a
// malformed or hostile entry is clamped or ignored rather than trusted.
if let Some(styles) = v["comment_styles"].as_array() {
@@@ -2972,14 -3186,15 +3256,22 @@@
_ => return Err("hide-empty-highlight-hover must be true or false".into()),
};
}
+ ("display-author-hover-no-comment", _) => {
+ self.comment_prefs.hide_empty_highlight_hover = match value {
+ "true" => false,
+ "false" => true,
+ _ => return Err("display-author-hover-no-comment must be true or false".into()),
+ };
+ }
("ui-scale", _) => self.ui_scale = ui_scale::parse(value)?,
+ // `--secured-notice false`: no notice above the pages that a document is secured.
+ ("secured-notice", _) => {
+ self.show_secured_notice = match value {
+ "true" => true,
+ "false" => false,
+ _ => return Err("secured-notice must be true or false".into()),
+ };
+ }
("system-title-bar", _) => {
self.system_title_bar = match value {
"true" => true,
diff --cc crates/ui-egui/src/object_ui.rs
index 0320615ad,8d7d64e47..c0d82f4a6
--- a/crates/ui-egui/src/object_ui.rs
+++ b/crates/ui-egui/src/object_ui.rs
@@@ -160,17 -169,12 +169,15 @@@ pub(crate) fn page_input
if view.objects.input_blocked {
return true;
}
+ if resp.context_menu_opened() || egui::Popup::is_any_open(ui.ctx()) {
+ return false;
+ }
if view.content.draft.is_some() || view.line_editor.as_ref().is_some_and(|e| e.has_changes()) {
let blocked = view.objects.blocked_page == Some(page);
- let modifier_press = ui.input(|i| i.pointer.primary_pressed())
- && modified(ui)
- && ui.input(|i| i.pointer.interact_pos()).is_some_and(|p| xf.rect.contains(p) && ui.clip_rect().contains(p));
+ let modifier_press = ptr.pressed().is_some() && modified(ui) && ptr.pos.is_some_and(|p| xf.rect.contains(p) && ui.clip_rect().contains(p));
if blocked || modifier_press {
view.objects.hold_editor = true;
- view.objects.blocked_page = ui.input(|i| i.pointer.primary_down()).then_some(page);
+ view.objects.blocked_page = ptr.primary_down.then_some(page);
if modifier_press {
view.objects.notice = Some(tl!("Finish or discard the text being edited before selecting several objects.").into());
}
diff --cc crates/ui-egui/tests/it/editing.rs
index 5ab98604f,a6523184a..03e664faa
--- a/crates/ui-egui/tests/it/editing.rs
+++ b/crates/ui-egui/tests/it/editing.rs
@@@ -7242,248 -6466,32 +7716,278 @@@ fn mode_tabs_keep_the_hand_over_a_parag
assert_eq!(h.state().mode, pdfcraft_ui_egui::Mode::Convert, "the tab takes the click, not the paragraph's editor");
}
+#[test]
+fn copy_pasted_image_discards_coordinates_and_moves_without_offset() {
+ let mut png = Vec::new();
+ image::RgbImage::from_pixel(60, 60, image::Rgb([100, 150, 200])).write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap();
+
+ let mut h = harness(1, |_| {});
+ h.state_mut().system_clipboard = false;
+ h.run_steps(4);
+
+ // 1. Add image to page 0
+ h.state_mut().add_image("test_img.png".into(), png);
+ h.run_steps(3);
+
+ let id = h.state().views[0].id;
+ let images_before = h.state().session.get(id).unwrap().page_images(0);
+ assert_eq!(images_before.len(), 1);
+
+ // 2. Copy the image from page 0
+ assert!(h.state_mut().copy_page_image(0, 0));
+ // Verify coordinates data was discarded during copy!
+ assert!(h.state().last_copied_image_rect.is_none(), "coordinates data must be discarded during copy");
+ assert!(h.state().last_copied_image.is_some(), "image pixel data is kept");
+
+ // 3. Paste the image via Ctrl+V (paste_image with rect: None)
+ assert!(h.state_mut().paste_image(0, None));
+ h.run_steps(3);
+
+ // Verify after paste that coordinates data remains None
+ assert!(h.state().last_copied_image_rect.is_none());
+
+ let images_after_paste = h.state().session.get(id).unwrap().page_images(0);
+ assert_eq!(images_after_paste.len(), 2, "second image pasted");
+
+ // The pasted image should be centered on the page, not offset by (+20, -20) from the first image
+ let img1 = &images_after_paste[0];
+ let img2 = &images_after_paste[1];
+ assert_eq!(img1.rect, img2.rect, "pasted image placed using natural page centering");
+
+ // 4. Move the pasted image by an explicit Move change
+ let target = [50.0, 50.0, 110.0, 110.0];
+ h.state_mut().apply_edit(pdfcraft_engine::Edit::EditPageImage { page: 0, index: 1, change: pdfcraft_engine::ImageEdit::Move(target) });
+ h.run_steps(3);
+
+ let images_after_move = h.state().session.get(id).unwrap().page_images(0);
+ assert_eq!(images_after_move[1].rect, target, "moved image rect matches target exactly without offset");
+}
+
+#[test]
+fn clicking_after_image_context_menu_action_resets_menu_state_and_updates_selection() {
+ let mut png = Vec::new();
+ image::RgbImage::from_pixel(80, 40, image::Rgb([200, 40, 40])).write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap();
+ let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |_cc| {
+ let mut app = PdfCraftApp::new();
+ app.set_option("language", "en").unwrap();
+ app.open_bytes("picture.png", None, png.clone()).expect("opens");
+ app
+ });
+ h.run_steps(4);
+ let id = h.state().views[0].id;
+ // Move the first image to left side: [10.0, 10.0, 30.0, 30.0]
+ h.state_mut().apply_edit(pdfcraft_engine::Edit::EditPageImage {
+ page: 0,
+ index: 0,
+ change: pdfcraft_engine::ImageEdit::Move([10.0, 10.0, 30.0, 30.0]),
+ });
+ // Add second image to right side: [50.0, 10.0, 70.0, 30.0]
+ let mut png2 = Vec::new();
+ image::RgbImage::from_pixel(20, 20, image::Rgb([40, 200, 40])).write_to(&mut std::io::Cursor::new(&mut png2), image::ImageFormat::Png).unwrap();
+ h.state_mut().apply_edit(pdfcraft_engine::Edit::AddImage {
+ page: 0,
+ rect: Some([50.0, 10.0, 70.0, 30.0]),
+ name: "img2.png".into(),
+ bytes: std::sync::Arc::new(png2),
+ });
+ h.run_steps(4);
+
+ assert!(h.state_mut().execute("edit.edit_text"));
+ h.run_steps(2);
+
+ let r = h.state().views[0].page_screen_rect(0).expect("on screen");
+ let user_to_screen = |u: [f64; 2]| {
+ let info = &h.state().session.get(id).unwrap().info.pages[0];
+ let v = info.user_to_view(u[0] as f32, u[1] as f32);
+ let scale = r.width() / info.width;
+ egui::pos2(r.left() + v[0] * scale, r.top() + v[1] * scale)
+ };
+
+ let p0 = user_to_screen([20.0, 20.0]);
+ let p1 = user_to_screen([60.0, 20.0]);
+ let p_empty = user_to_screen([40.0, 35.0]);
+
+ // 1. Select image 0
+ h.hover_at(p0);
+ h.run_steps(1);
+ h.drag_at(p0);
+ h.run_steps(1);
+ h.drop_at(p0);
+ h.run_steps(2);
+ assert_eq!(h.state().views[0].image_selection.as_ref().map(|s| s.index), Some(0), "image 0 selected");
+
+ // 2. Select image 1 (switches selection)
+ h.hover_at(p1);
+ h.run_steps(1);
+ h.drag_at(p1);
+ h.run_steps(1);
+ h.drop_at(p1);
+ h.run_steps(2);
+ assert_eq!(h.state().views[0].image_selection.as_ref().map(|s| s.index), Some(1), "image 1 selected");
+
+ // 3. Click empty space (clears selection)
+ h.hover_at(p_empty);
+ h.run_steps(1);
+ h.drag_at(p_empty);
+ h.run_steps(1);
+ h.drop_at(p_empty);
+ h.run_steps(2);
+ assert!(h.state().views[0].image_selection.is_none(), "empty page clears selection");
+
+ // 4. Select image 0 again
+ h.hover_at(p0);
+ h.run_steps(1);
+ h.drag_at(p0);
+ h.run_steps(1);
+ h.drop_at(p0);
+ h.run_steps(2);
+ assert_eq!(h.state().views[0].image_selection.as_ref().map(|s| s.index), Some(0), "image 0 selected again");
+
+ // 5. Right-click image 0 to open context menu
+ h.hover_at(p0);
+ h.run_steps(1);
+ h.event(egui::Event::PointerButton { pos: p0, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });
+ h.event(egui::Event::PointerButton { pos: p0, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });
+ h.run_steps(2);
+
+ // 6. Click "Flip horizontal"
+ h.get_by_label("Flip horizontal").click();
+ h.run_steps(3);
+
+ let flag_persisted = h.ctx.data_mut(|d| d.get_persisted::<bool>(egui::Id::new("image-menu")));
+ assert_eq!(flag_persisted, Some(false), "image-menu flag should be reset to false");
+
+ // 7. Click image 1: should switch selection to image 1
+ h.hover_at(p1);
+ h.run_steps(1);
+ h.drag_at(p1);
+ h.run_steps(1);
+ h.drop_at(p1);
+ h.run_steps(2);
+ assert_eq!(
+ h.state().views[0].image_selection.as_ref().map(|s| s.index),
+ Some(1),
+ "clicking other image switches selection after context menu action"
+ );
+
+ // 8. Click empty space: should clear selection
+ h.hover_at(p_empty);
+ h.run_steps(1);
+ h.drag_at(p_empty);
+ h.run_steps(1);
+ h.drop_at(p_empty);
+ h.run_steps(2);
+ assert!(h.state().views[0].image_selection.is_none(), "clicking empty page clears selection after context menu action");
+}
+
+#[test]
+fn format_panel_shows_selection_size_and_updates_after_font_applied() {
+ let mut objs: Vec<String> = vec![
+ "<< /Type /Catalog /Pages 2 0 R >>".into(),
+ "<< /Type /Pages /Kids [4 0 R] /Count 1 /MediaBox [0 0 200 300] >>".into(),
+ "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>".into(),
+ "<< /Type /Page /Parent 2 0 R /Contents 5 0 R /Resources << /Font << /F1 3 0 R >> >> >>".into(),
+ ];
+ let body = "BT /F1 24 Tf 20 200 Td (Heading) Tj /F1 12 Tf 0 -25 Td (Paragraph) Tj ET";
+ objs.push(format!("<< /Length {} >>\nstream\n{body}\nendstream", body.len()));
+ let mut pdf = Vec::from(b"%PDF-1.7\n");
+ let mut xref = Vec::new();
+ for (i, o) in objs.iter().enumerate() {
+ xref.push(pdf.len());
+ pdf.extend_from_slice(format!("{} 0 obj\n{o}\nendobj\n", i + 1).as_bytes());
+ }
+ let xref_pos = pdf.len();
+ pdf.extend_from_slice(format!("xref\n0 {}\n0000000000 65535 f \n", objs.len() + 1).as_bytes());
+ for o in xref {
+ pdf.extend_from_slice(format!("{o:010} 00000 n \n").as_bytes());
+ }
+ pdf.extend_from_slice(format!("trailer\n<< /Size {} /Root 1 0 R >>\nstartxref\n{xref_pos}\n%%EOF\n", objs.len() + 1).as_bytes());
+
+ let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |_cc| {
+ let mut app = PdfCraftApp::new();
+ app.set_option("language", "en").unwrap();
+ app.open_bytes("test.pdf", None, pdf).expect("fixture opens");
+ app
+ });
+ h.run_steps(4);
+
+ assert!(h.state_mut().execute("edit.edit_text"));
+ h.run_steps(2);
+
+ let r = h.state().views[0].page_screen_rect(0).expect("on screen");
+ let at = egui::pos2(r.left() + 40.0 / 200.0 * r.width(), r.top() + (300.0 - 180.0) / 300.0 * r.height());
+ h.hover_at(at);
+ h.run_steps(1);
+ h.drag_at(at);
+ h.run_steps(1);
+ h.drop_at(at);
+ h.run_steps(3);
+
+ assert!(h.state().views[0].line_editor.is_some(), "editor opened");
+ let text = h.state().views[0].line_editor.as_ref().unwrap().text.clone();
+ assert!(text.contains("Paragraph"), "text is {text}");
+
+ // Select the 12 pt paragraph text "Paragraph" via keyboard selection in the TextEdit
+ h.key_press_modifiers(Modifiers::COMMAND, Key::ArrowRight);
+ h.run_steps(1);
+ for _ in 0.."Paragraph".len() {
+ h.key_press_modifiers(Modifiers::SHIFT, Key::ArrowLeft);
+ h.run_steps(1);
+ }
+ use egui::accesskit::Role;
+ let size_node = h.get_by_role_and_label(Role::ComboBox, "Font size");
+ assert_eq!(size_node.value().as_deref(), Some("12"), "size combo box value is 12");
+
+ let font_node = h.get_by_role_and_label(Role::ComboBox, "Font");
+ assert_eq!(font_node.value().as_deref(), Some("Helvetica"), "initial font is Helvetica");
+
+ // Apply Times to the selection
+ font_node.click();
+ h.run_steps(2);
+ h.get_by_label("Times").click();
+ h.run_steps(4);
+
+ // Font combo box for the whole block is now Mixed because Heading is Helvetica and Paragraph is Times
+ let font_node = h.get_by_role_and_label(Role::ComboBox, "Font");
+ assert_eq!(font_node.value().as_deref(), Some("Mixed"), "whole block has mixed fonts");
+
+ // Apply Times to the whole block
+ font_node.click();
+ h.run_steps(2);
+ h.get_by_label("Times").click();
+ h.run_steps(4);
+
+ // Now all text is Times, so font combo box updates to Times
+ let font_node = h.get_by_role_and_label(Role::ComboBox, "Font");
+ assert_eq!(font_node.value().as_deref(), Some("Times"), "font combo box updates to Times");
+}
++
+ /// A paragraph selected by its frame goes with one Delete (or Backspace), as in Acrobat, instead
+ /// of being emptied a typed character at a time, and undo brings it back.
+ #[test]
+ fn a_paragraph_selected_by_its_frame_deletes_with_one_key() {
+ for key in [Key::Delete, Key::Backspace] {
+ let mut h = harness(2, |_| {});
+ assert!(h.state_mut().execute("edit.edit_text"));
+ h.run_steps(2);
+ let id = h.state().views[0].id;
+ let blocks = |h: &Harness<'static, PdfCraftApp>| h.state().session.get(id).unwrap().text_blocks(0);
+ let r = h.state().views[0].page_screen_rect(0).expect("on screen");
+ let k = r.width() / 200.0;
+ let screen = |x: f64, y: f64| egui::pos2(r.left() + x as f32 * k, r.top() + (300.0 - y as f32) * k);
+ let b = blocks(&h)[0].clone();
+ click_at(&mut h, screen((b.rect[0] + b.rect[2]) / 2.0, (b.rect[1] + b.rect[3]) / 2.0));
+ assert!(h.state().views[0].line_editor.is_some(), "a click on the text opens it for typing");
+ click_at(&mut h, screen((b.rect[0] + b.rect[2]) / 2.0, b.rect[3]) - egui::vec2(0.0, 4.0));
+ assert!(h.state().views[0].line_editor.is_none(), "the frame selects the box");
+ press(&mut h, Modifiers::NONE, key);
+ assert!(blocks(&h).is_empty(), "{key:?} deletes the whole paragraph: {:?}", blocks(&h));
+ assert!(h.state().views[0].line_editor.is_none(), "no empty editor is left behind");
+ assert!(h.query_all_by_label_contains("object selected").next().is_none(), "the deleted paragraph is no longer selected");
+ assert_eq!(h.state().session.get(id).unwrap().text_blocks(1)[0].text, "Page 2", "the next page keeps its text");
+ assert_eq!(h.state().session.get(id).unwrap().info.pages.len(), 2, "Delete removed the paragraph, not a page");
+ assert!(h.state_mut().execute("edit.undo"));
+ h.run_steps(2);
+ assert_eq!(blocks(&h).iter().map(|b| b.text.as_str()).collect::<Vec<_>>(), ["Page 1"], "undo restores it");
+ }
+ }