The declaration line was built from the PDF/A identification alone, so a document that declares only PDF/UA-1 read "Declared conformance: none". It now lists PDF/UA next to PDF/A, and still says none when neither is declared. pdfa_dialog_shows_a_declared_pdfua fails before the change.
This commit is contained in:
parent
251917f685
commit
0372243ef2
|
|
@ -50,7 +50,9 @@ pub(crate) fn body(ui: &mut egui::Ui, app: &mut PdfCraftApp, t: &Tokens) -> bool
|
||||||
ui.label(egui::RichText::new("PDF/A").font(theme::semibold(18.0)));
|
ui.label(egui::RichText::new("PDF/A").font(theme::semibold(18.0)));
|
||||||
ui.add_space(6.0);
|
ui.add_space(6.0);
|
||||||
let declared = app.active_ids().and_then(|(_, id)| app.session.get(id)).map(|d| d.standards()).unwrap_or_default();
|
let declared = app.active_ids().and_then(|(_, id)| app.session.get(id)).map(|d| d.standards()).unwrap_or_default();
|
||||||
let shown = declared.pdfa.as_ref().map_or(tl!("none").to_string(), |(p, c)| format!("PDF/A-{p}{}", c.to_lowercase()));
|
let mut standards: Vec<String> = declared.pdfa.iter().map(|(p, c)| format!("PDF/A-{p}{}", c.to_lowercase())).collect();
|
||||||
|
standards.extend(declared.pdfua.map(|p| format!("PDF/UA-{p}")));
|
||||||
|
let shown = if standards.is_empty() { tl!("none").to_string() } else { standards.join(", ") };
|
||||||
ui.label(crate::i18n::fmt(tl!("Declared conformance: {shown}"), &[("shown", &shown)]));
|
ui.label(crate::i18n::fmt(tl!("Declared conformance: {shown}"), &[("shown", &shown)]));
|
||||||
if !declared.output_intents.is_empty() {
|
if !declared.output_intents.is_empty() {
|
||||||
ui.label(
|
ui.label(
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,54 @@ fn pdfa_dialog_verifies_and_converts() {
|
||||||
assert_eq!(h.state().session.get(id).unwrap().can_undo(), Some("Save as PDF/A-2b"));
|
assert_eq!(h.state().session.get(id).unwrap().can_undo(), Some("Save as PDF/A-2b"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A one-page PDF whose XMP declares the given `pdfaid`/`pdfuaid` attributes.
|
||||||
|
fn declaring(ids: &str) -> Vec<u8> {
|
||||||
|
let xmp = format!(
|
||||||
|
"<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"><rdf:Description rdf:about=\"\" \
|
||||||
|
xmlns:pdfaid=\"http://www.aiim.org/pdfa/ns/id/\" xmlns:pdfuaid=\"http://www.aiim.org/pdfua/ns/id/\" {ids}/></rdf:RDF>"
|
||||||
|
);
|
||||||
|
let objects = [
|
||||||
|
"<< /Type /Catalog /Pages 2 0 R /Metadata 4 0 R >>".to_string(),
|
||||||
|
"<< /Type /Pages /Kids [3 0 R] /Count 1 >>".to_string(),
|
||||||
|
"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 300] /Resources << >> >>".to_string(),
|
||||||
|
format!("<< /Type /Metadata /Subtype /XML /Length {} >>\nstream\n{xmp}\nendstream", xmp.len()),
|
||||||
|
];
|
||||||
|
let mut pdf = b"%PDF-1.7\n".to_vec();
|
||||||
|
let mut offsets = Vec::new();
|
||||||
|
for (i, o) in objects.iter().enumerate() {
|
||||||
|
offsets.push(pdf.len());
|
||||||
|
pdf.extend_from_slice(format!("{} 0 obj\n{o}\nendobj\n", i + 1).as_bytes());
|
||||||
|
}
|
||||||
|
let xref = pdf.len();
|
||||||
|
pdf.extend_from_slice(b"xref\n0 5\n0000000000 65535 f \n");
|
||||||
|
for o in offsets {
|
||||||
|
pdf.extend_from_slice(format!("{o:010} 00000 n \n").as_bytes());
|
||||||
|
}
|
||||||
|
pdf.extend_from_slice(format!("trailer\n<< /Size 5 /Root 1 0 R >>\nstartxref\n{xref}\n%%EOF\n").as_bytes());
|
||||||
|
pdf
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn pdfa_dialog_shows_a_declared_pdfua() {
|
||||||
|
// The dialog read only the PDF/A identification, so a PDF/UA-1 document showed "none" (#1309).
|
||||||
|
for (ids, shown) in [
|
||||||
|
("pdfuaid:part=\"1\"", "Declared conformance: PDF/UA-1"),
|
||||||
|
("pdfaid:part=\"2\" pdfaid:conformance=\"B\" pdfuaid:part=\"1\"", "Declared conformance: PDF/A-2b, PDF/UA-1"),
|
||||||
|
] {
|
||||||
|
let doc = declaring(ids);
|
||||||
|
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("ua.pdf", None, doc.clone()).unwrap();
|
||||||
|
app
|
||||||
|
});
|
||||||
|
h.run_steps(4);
|
||||||
|
assert!(h.state_mut().execute("standards.pdfa"));
|
||||||
|
h.run_steps(2);
|
||||||
|
h.get_by_label(shown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn export_to_word_html_and_rtf() {
|
fn export_to_word_html_and_rtf() {
|
||||||
let doc = Session::new().create_from_text("t", "Exported words").unwrap().to_vec();
|
let doc = Session::new().create_from_text("t", "Exported words").unwrap().to_vec();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue