Honor PDF draft mode in native execution and publication
This commit is contained in:
1 parent
af19a26c23
commit
f14669ae39
13 files changed
+206
-30
No files matched your search
@@ -270,11 +270,38 @@ impl Executor {
|
||||
.map_err(|e| self.error(e, self.current))?;
|
||||
self.events.push(Event::Message { text, span: self.current });
|
||||
}
|
||||
let options = PdfHeaderOptions { major, minor: minor as u8, object_compression };
|
||||
let draft_mode = if self.state.input_profile() == InputProfile::TeX8Bit {
|
||||
let mode = self.read_parameter(Parameter::Pdfdraftmode).width();
|
||||
if !(0..=1).contains(&mode) {
|
||||
return self.fail("\\pdfdraftmode can only be changed before anything is written to the output");
|
||||
}
|
||||
mode == 1
|
||||
} else {
|
||||
false
|
||||
};
|
||||
if draft_mode {
|
||||
object_compression = 0;
|
||||
self.state.disable_draft_stream_compression();
|
||||
}
|
||||
let options = PdfHeaderOptions { major, minor: minor as u8, object_compression, draft_mode };
|
||||
self.state.pdf_header_options = Some(options);
|
||||
Ok(options)
|
||||
}
|
||||
|
||||
pub(super) fn prepare_pdf_draft_shipout(&mut self) -> Result<(), Error> {
|
||||
if self.state.input_profile() == InputProfile::TeX8Bit
|
||||
&& let Some(header) = self.state.pdf_header_options
|
||||
{
|
||||
if self.read_parameter(Parameter::Pdfdraftmode).width() != i32::from(header.draft_mode) {
|
||||
return self.fail("\\pdfdraftmode can only be changed before anything is written to the output");
|
||||
}
|
||||
if header.draft_mode {
|
||||
self.state.disable_draft_stream_compression();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn pdf_page_data(
|
||||
&mut self,
|
||||
files: &mut impl SourceProvider,
|
||||
@@ -307,7 +334,9 @@ impl Executor {
|
||||
pk_resolution: pk_resolution.clamp(72, 8000) as u32,
|
||||
});
|
||||
}
|
||||
let level = self.read_parameter(Parameter::Pdfcompresslevel).width();
|
||||
let level = if header.draft_mode { 0 } else {
|
||||
self.read_parameter(Parameter::Pdfcompresslevel).width()
|
||||
};
|
||||
if level > 9 {
|
||||
return self.fail("invalid native PDF compression level");
|
||||
}
|
||||
|
||||
@@ -323,6 +323,7 @@ impl Executor {
|
||||
}
|
||||
let job_magnification = self.prepare_magnification()?;
|
||||
let magnification = if for_form { 1000 } else { job_magnification };
|
||||
self.prepare_pdf_draft_shipout()?;
|
||||
let pdf = self.pdf_page_data(files)?;
|
||||
let unicode_pages = self.state.input_profile() != InputProfile::TeX8Bit;
|
||||
// The XDV driver uses a physical sheet and origin, then applies
|
||||
|
||||
@@ -513,6 +513,9 @@ impl Executor {
|
||||
let Some(tokens) = registered.attributes.take() else {
|
||||
return Ok(());
|
||||
};
|
||||
if self.state.pdf_draft_mode() {
|
||||
return Ok(());
|
||||
}
|
||||
let mut image = registered.image.clone();
|
||||
if image.image.has_imported_fonts() {
|
||||
let from = self.source_name(self.current);
|
||||
|
||||
Reference in new issue
Block a user