mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-25 02:29:31 -06:00
* M3: harden render and CLI failure surfaces Make content truncation observable, reject unknown CLI options, expose deterministic render work counters, and scope render failures to exact requests. Refuse silently reduced whole-page export rasters while preserving tiled rendering, and add heavy-vector and CLI regression coverage. Co-authored-by: Codex <noreply@openai.com> * Render: remember a failed render by page and kind again A key with scale and tag made every zoom level and tile a new key: a pathological page tied up a worker for the watchdog limit per request (exhausting worker replacements) and was re-parsed each time. The repeated-parsing check asks for a new generation and scale again. * Export: pages too large at the chosen dpi export at the most the renderer allows, and say so #669 made every Exporter refuse oversized whole-page renders, which reached File > Export to image, doc_export_* and OCR: at 600 dpi any page side over 13.65 in (Legal, A3, Tabloid) failed instead of exporting. The exporter clamps again; Exporter::dpi_used reports the resolution a page is drawn at, which the Export dialog's message and doc_export_png's lower_dpi list mention. A source with reject_oversize still refuses (CLI render keeps its strict config). * doc_export_images: describe lower_dpi * Render: ContentTruncated is reported once per page; the hayro-interpret patch is recorded Nested forms, Type 3 glyphs and patterns are interpreted again and each reported the exhausted budget; pdfcraft-render now keeps one. The warning is part of hayro-interpret patch (18) (the page content budget): marked in the code and described in vendor/README.md. * CLI render: print render warnings (skipped content) to stderr * CLI: the option check refuses unknown options only; commands report missing values themselves text's own --page parsing (and its test on main) says what a page value must be; the generic "needs a value" pre-empted it. --------- Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
28 lines
1.2 KiB
Rust
28 lines
1.2 KiB
Rust
//! Every command rejects misspelled long options before opening or writing a file.
|
|
|
|
use std::process::Command;
|
|
|
|
const BIN: &str = env!("CARGO_BIN_EXE_pdfcraft-cli");
|
|
|
|
#[test]
|
|
fn non_edit_commands_reject_unknown_options_before_io() {
|
|
for args in [
|
|
vec!["info", "missing.pdf", "--passwrod", "secret"],
|
|
vec!["text", "missing.pdf", "--pgae", "1"],
|
|
vec!["combine", "a.pdf", "b.pdf", "--ot", "out.pdf"],
|
|
vec!["extract", "missing.pdf", "--pgaes", "1", "--out", "out.pdf"],
|
|
vec!["split", "missing.pdf", "--ever", "2"],
|
|
vec!["render", "missing.pdf", "--dppi", "96", "--out", "out.png"],
|
|
vec!["check-one", "missing.pdf", "--edti"],
|
|
vec!["check", "missing.pdf", "--timout", "2"],
|
|
vec!["run", "doc_open", "--roto", "/tmp"],
|
|
vec!["ui", "--contro", "control.json", "state"],
|
|
] {
|
|
let unknown = args.iter().find(|arg| arg.starts_with("--")).expect("test option");
|
|
let out = Command::new(BIN).args(&args).output().expect("run cli");
|
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
|
assert!(!out.status.success(), "{args:?} unexpectedly succeeded");
|
|
assert!(stderr.contains("unknown option") && stderr.contains(unknown), "{args:?}: {stderr}");
|
|
}
|
|
}
|