mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-17 16:16:34 +00:00
fix(render): a page whose MediaBox or CropBox encloses no area shows its content (hayro-syntax patch 38)
A /MediaBox without area ([0 0 0 0]) is read as a missing one (the default page), and a /CropBox without area, or with none in common with the media box, as a missing one (the media box, ISO 32000-2 §14.11.2, Table 33). Kept, the page's visible region had no area: nothing was drawn and no text was extracted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
This commit is contained in:
1 parent
9f04acccef
commit
142283f4f8
65 files changed
+527
-11271
No files matched your search
@@ -54,7 +54,7 @@ fn validate(root: &Path) -> Result<()> {
|
||||
let docs: Documents = toml::from_str(&text).context("parsing LICENSES.toml")?;
|
||||
let attribution = assets::load(root)?;
|
||||
let mut problems = check(root, &docs, &attribution);
|
||||
let ocr_source = std::fs::read_to_string(root.join("crates/ocr/src/ocrs.rs")).context("reading OCR model filename constants")?;
|
||||
let ocr_source = std::fs::read_to_string(root.join("crates/ocr/src/lib.rs")).context("reading OCR model filename constants")?;
|
||||
problems.extend(check_required_ocr_metadata(&ocr_source, &attribution)?);
|
||||
if !problems.is_empty() {
|
||||
bail!("source licensing errors:\n{}", problems.join("\n"));
|
||||
@@ -72,7 +72,7 @@ fn check_required_ocr_metadata(source: &str, attribution: &assets::Manifest) ->
|
||||
let file = declarations.first().and_then(|value| value.strip_suffix("\";"));
|
||||
let Some(file) = file.filter(|file| declarations.len() == 1 && safe_path(file) && !file.contains('/')) else {
|
||||
bail!(
|
||||
"OCR constant {name}: expected one literal filename declaration in crates/ocr/src/ocrs.rs; update the source validator if its syntax changed"
|
||||
"OCR constant {name}: expected one literal filename declaration in crates/ocr/src/lib.rs; update the source validator if its syntax changed"
|
||||
);
|
||||
};
|
||||
let entries: Vec<_> = attribution.fetched.iter().filter(|f| f.file == file).collect();
|
||||
@@ -407,7 +407,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn required_ocr_models_cannot_be_missing() {
|
||||
let source = include_str!("../../crates/ocr/src/ocrs.rs");
|
||||
let source = include_str!("../../crates/ocr/src/lib.rs");
|
||||
let original = assets::load(&assets::root()).unwrap();
|
||||
assert_eq!(original.fetched.iter().filter(|f| f.kind == "model").count(), 2);
|
||||
assert!(check_required_ocr_metadata(source, &original).unwrap().is_empty());
|
||||
@@ -420,7 +420,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn required_ocr_models_cannot_be_misclassified() {
|
||||
let source = include_str!("../../crates/ocr/src/ocrs.rs");
|
||||
let source = include_str!("../../crates/ocr/src/lib.rs");
|
||||
let original = assets::load(&assets::root()).unwrap();
|
||||
assert_eq!(original.fetched.iter().filter(|f| f.kind == "model").count(), 2);
|
||||
for model in original.fetched.iter().filter(|f| f.kind == "model") {
|
||||
|
||||
@@ -39,7 +39,6 @@ pub const SCENES: &[(&str, &str, &str, &[&str])] = &[
|
||||
"README: layouts",
|
||||
&["--layout", "two-up", "--mode", "read", "--page", "4", "--theme", "dark", "--notice", "off"],
|
||||
),
|
||||
("pdfcraft-ocr-verify", "OCR Verify screen", "README: OCR review", &["--size", "1680x1000", "--ocr-verify", "on"]),
|
||||
];
|
||||
|
||||
const PDF: &str = "dist/demo/pdfcraft-showcase.pdf";
|
||||
@@ -110,10 +109,7 @@ fn update_attribution(root: &Path) -> Result<()> {
|
||||
// The home screen shows the ArtCraft mark: say so (it is a Storyteller trademark, not open
|
||||
// source; AGENTS.md §1.2), so the screenshot's licence is not read as covering it.
|
||||
let shows_home = scene.is_some_and(|(.., args)| args.windows(2).any(|w| w[0] == "--home" && w[1] == "on"));
|
||||
let shows_ocr = scene.is_some_and(|(.., args)| args.windows(2).any(|w| w[0] == "--ocr-verify" && w[1] == "on"));
|
||||
let contents = if shows_ocr {
|
||||
"Shows only PdfCraft UI, its Lucide icons and a synthetic scanned page built from the embedded fonts, with a real recognition (the OCR models) loaded into the Verify screen"
|
||||
} else if shows_home {
|
||||
let contents = if shows_home {
|
||||
"Shows PdfCraft UI, Lucide icons, the showcase PDF built from the [[fetched]] OFL fonts, and the ArtCraft mark (Storyteller trademark from docs/brand/, not covered by this licence)"
|
||||
} else {
|
||||
"Shows only PdfCraft UI, Lucide icons and the showcase PDF built from the [[fetched]] OFL fonts"
|
||||
|
||||
Reference in new issue
Block a user