Merge XDV document information in shipout order
This commit is contained in:
1 parent
6826efbeb1
commit
dd695a8945
9 files changed
+251
-21
No files matched your search
@@ -92,14 +92,22 @@ impl Executor {
|
||||
return Ok(Some(graphics));
|
||||
}
|
||||
let body = data.strip_prefix(b"pdf:").map(<[u8]>::trim_ascii_start);
|
||||
let Some(mut body) =
|
||||
body.and_then(|body| body.strip_prefix(b"literal"))
|
||||
.filter(|body| {
|
||||
!body
|
||||
.first()
|
||||
.is_some_and(|b| b.is_ascii_alphanumeric() || *b == b'_' || *b == b':')
|
||||
})
|
||||
else {
|
||||
if let Some(dictionary) = body.and_then(|body| xdv_operand(body, b"docinfo")) {
|
||||
use crate::pdf_device::xdv_document::merge_docinfo;
|
||||
let (entries, warnings) = merge_docinfo(&self.state.pdf_info, dictionary)
|
||||
.map_err(|error| self.error(error, special.span))?;
|
||||
if entries.len() > self.limits.tokens {
|
||||
return self.fail("native PDF information payload limit exceeded");
|
||||
}
|
||||
for warning in warnings {
|
||||
files.observe_diagnostic(WriteDestination::TerminalAndLog, &warning)
|
||||
.map_err(|error| self.error(error, special.span))?;
|
||||
}
|
||||
self.reads.insert(Dependency::PdfInfoState);
|
||||
self.state.pdf_info = entries;
|
||||
return Ok(None);
|
||||
}
|
||||
let Some(mut body) = body.and_then(|body| xdv_operand(body, b"literal")) else {
|
||||
let name = data
|
||||
.split(|b| b.is_ascii_whitespace())
|
||||
.next()
|
||||
@@ -142,6 +150,12 @@ impl Executor {
|
||||
}
|
||||
}
|
||||
|
||||
fn xdv_operand<'a>(data: &'a [u8], command: &[u8]) -> Option<&'a [u8]> {
|
||||
data.strip_prefix(command).filter(|rest| {
|
||||
!rest.first().is_some_and(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b':'))
|
||||
})
|
||||
}
|
||||
|
||||
fn xdv_transform(data: &[u8]) -> Result<Option<PdfGraphics>, &'static str> {
|
||||
let Some(separator) = data.iter().position(|&byte| byte == b':') else {
|
||||
return Ok(None);
|
||||
|
||||
@@ -420,6 +420,7 @@ pub enum Dependency {
|
||||
MagnificationState,
|
||||
PdfFileState,
|
||||
PdfCatalogState,
|
||||
PdfInfoState,
|
||||
PdfObjects,
|
||||
PdfImages,
|
||||
PdfLastPosition,
|
||||
|
||||
Reference in new issue
Block a user