-
-
Notifications
You must be signed in to change notification settings - Fork 127
Description
I am currently using this crate to create new PDFs, which works very well. A new task requires me to use an existing PDF and add text to it (not a form, a simple PDF). So I adopted the code to parse the PDF, get the page ops and add to it.
Unfortunately, the entire page was just black after saving it.
So I removed my code to add ops to the page and simply do this:
let mut warnings: Vec<PdfWarnMsg> = Vec::new();
let mut pdf = PdfDocument::parse(
original_pdf,
&PdfParseOptions {
fail_on_error: true,
},
&mut warnings,
)
.map_err(|err| anyhow!(err))?;
error!("warnings: {:?}", warnings);
// remove all pages but the first
pdf.pages = pdf.pages.iter().take(1).map(|page| page.clone()).collect();
let mut page = pdf.pages[0].clone();
pdf.pages = vec![];
// add content to page - currently disabled
// return the result
Ok(pdf
.with_pages(vec![page])
.save(&PdfSaveOptions::default(), &mut Vec::new()))expecting the saved PDF to be the first page of the original PDF. However, the page is still fully black:

In the above code the following parser warnings are returned:
warnings: [
PdfWarnMsg { page: 0, op_id: 0, severity: Warning, msg: "Type0 font C2_0 missing DescendantFonts" },
PdfWarnMsg { page: 0, op_id: 0, severity: Warning, msg: "Unknown base font: FKZKQC+UniversLTStd-Bold" },
PdfWarnMsg { page: 0, op_id: 0, severity: Warning, msg: "Unknown base font: FKZKQC+UniversLTStd" },
PdfWarnMsg { page: 0, op_id: 0, severity: Warning, msg: "Unknown base font: FKZKQC+UniversLTStd-Cn" },
PdfWarnMsg { page: 1, op_id: 0, severity: Warning, msg: "Unknown base font: FKZKQC+UniversLTStd-Bold" },
PdfWarnMsg { page: 1, op_id: 0, severity: Warning, msg: "Unknown base font: FKZKQC+UniversLTStd" },
PdfWarnMsg { page: 0, op_id: 0, severity: Error, msg: "Info: unhandled operator 'K'" },
PdfWarnMsg { page: 0, op_id: 978, severity: Error, msg: "Info: unhandled operator 'k'" },
PdfWarnMsg { page: 0, op_id: 986, severity: Error, msg: "Info: unhandled operator 'k'" },
PdfWarnMsg { page: 0, op_id: 1034, severity: Error, msg: "Warning: 'EMC' with no current_layer" },
PdfWarnMsg { page: 0, op_id: 1044, severity: Error, msg: "Warning: 'EMC' with no current_layer" },
PdfWarnMsg { page: 0, op_id: 1054, severity: Error, msg: "Warning: 'EMC' with no current_layer" },
PdfWarnMsg { page: 0, op_id: 1065, severity: Error, msg: "Warning: 'EMC' with no current_layer" },
PdfWarnMsg { page: 0, op_id: 1076, severity: Error, msg: "Warning: 'EMC' with no current_layer" },
PdfWarnMsg { page: 0, op_id: 1093, severity: Error, msg: "Warning: 'EMC' with no current_layer" },
PdfWarnMsg { page: 1, op_id: 0, severity: Error, msg: "Info: unhandled operator 'K'" },
PdfWarnMsg { page: 1, op_id: 28, severity: Error, msg: "Info: unhandled operator 'k'" },
PdfWarnMsg { page: 1, op_id: 41, severity: Error, msg: "Warning: 'EMC' with no current_layer" },
PdfWarnMsg { page: 1, op_id: 43, severity: Error, msg: "Info: unhandled operator 'k'" },
PdfWarnMsg { page: 1, op_id: 52, severity: Error, msg: "Info: unhandled operator 'k'" },
PdfWarnMsg { page: 1, op_id: 60, severity: Error, msg: "Warning: 'EMC' with no current_layer" },
PdfWarnMsg { page: 1, op_id: 62, severity: Error, msg: "Info: unhandled operator 'k'" },
PdfWarnMsg { page: 1, op_id: 70, severity: Error, msg: "Info: unhandled operator 'k'" },
PdfWarnMsg { page: 1, op_id: 78, severity: Error, msg: "Warning: 'EMC' with no current_layer" },
PdfWarnMsg { page: 1, op_id: 80, severity: Error, msg: "Info: unhandled operator 'k'" },
PdfWarnMsg { page: 1, op_id: 88, severity: Error, msg: "Info: unhandled operator 'k'" },
PdfWarnMsg { page: 1, op_id: 102, severity: Error, msg: "Warning: 'EMC' with no current_layer" },
PdfWarnMsg { page: 1, op_id: 104, severity: Error, msg: "Info: unhandled operator 'k'" },
PdfWarnMsg { page: 1, op_id: 112, severity: Error, msg: "Info: unhandled operator 'k'" }
]
My first impression is, that an outline around the page is missing its width, causing it to be infinite and therefore covering the entire page. What would be the best way to troubleshoot this? Is this more a lopdf issue?
I can provide the PDF in question, but not in a public space.
Thank you for your advice.