Merge main into fix/ocg-auto-state-view; renumber its patch to (103)

Main took hayro-interpret patch (76) for non-embedded Arial and Times New Roman
CIDs, so the View auto state becomes patch (103) in the ledger and the code
comments. The view.layers-panel note no longer lists the Print event's auto
state as missing: main applies it when printing (print.print-ready-pdf).
This commit is contained in:
mtlcl410 committed 2026-11-09 11:50:10 +08:00
commit f51eaa86e3
63 files changed
+7550 -346

No files matched your search

+2 -5
View File
@@ -763,9 +763,8 @@ pub(crate) fn same_pages(a: &[pdfcraft_render::PageInfo], b: &[pdfcraft_render::
}
/// Each document-information field of `info` with its value in `cos` (`/Info`, else XMP), read
/// the way the full inspection reads them: NULs and spaces trimmed, empty is none, dates shown as
/// [`pdfcraft_render::pretty_date`] shows them.
pub(crate) fn info_fields<'a>(info: &'a mut DocInfo, cos: &pdfcraft_cos::Document) -> [(&'a mut Option<String>, Option<String>); 8] {
/// the way the full inspection reads them: NULs and spaces trimmed, empty is none.
pub(crate) fn info_fields<'a>(info: &'a mut DocInfo, cos: &pdfcraft_cos::Document) -> [(&'a mut Option<String>, Option<String>); 6] {
let read = |key| pdfcraft_organize::info(cos, key).map(|v| v.trim_matches('\0').trim().to_string()).filter(|v| !v.is_empty());
[
(&mut info.title, read("Title")),
@@ -774,8 +773,6 @@ pub(crate) fn info_fields<'a>(info: &'a mut DocInfo, cos: &pdfcraft_cos::Documen
(&mut info.keywords, read("Keywords")),
(&mut info.creator, read("Creator")),
(&mut info.producer, read("Producer")),
(&mut info.created, read("CreationDate").map(|d| pdfcraft_render::pretty_date(&d))),
(&mut info.modified, read("ModDate").map(|d| pdfcraft_render::pretty_date(&d))),
]
}
+19
View File
@@ -11870,6 +11870,25 @@ fn imported_bookmarks_undo_in_one_step() {
assert!(s.get(id).unwrap().info.outline.is_empty());
}
/// PDF/A-2 6.1.2 through the ordinary save: Save as PDF/A on a file without a binary comment, or
/// with a 2.0 header, saves a file whose header verifies.
#[test]
fn save_as_pdfa_saves_a_compliant_file_header() {
let plain = fixture(1);
assert!(plain.starts_with(b"%PDF-1.7\n1 0 obj"), "the fixture has no binary comment");
let mut newer = plain.clone();
newer.splice(5..8, *b"2.0");
for bytes in [plain, newer] {
let mut s = Session::new();
let id = s.open("x.pdf", None, Arc::new(bytes), None).unwrap();
s.apply(id, Edit::ConvertPdfA { level: pdfcraft_preflight::Level::A2b }).unwrap();
let saved = s.save_bytes(id).unwrap();
assert!(saved.starts_with(b"%PDF-1.7\n%\xE2\xE3\xCF\xD3\n"), "{:?}", String::from_utf8_lossy(&saved[..20]));
let reopened = pdfcraft_cos::Document::open(saved).unwrap();
assert!(pdfcraft_preflight::verify(&reopened, pdfcraft_preflight::Level::A2b).iter().all(|i| i.clause != "6.1.2"));
}
}
/// ISO 32000-2 §7.6.6, Table 25: a document whose only encryption is for its embedded files,
/// authorised when one is opened (`/AuthEvent /EFOpen`), opens without a password, lists its
/// attachment, and saves with the attachment still encrypted.