From 71e73f9053e580d352b90bd1268537bfa2fe4e4d Mon Sep 17 00:00:00 2001 From: Laurenz Stampfl Date: Tue, 17 Dec 2024 14:38:17 +0100 Subject: [PATCH] Extract finish into custom method --- crates/typst-pdf/src/krilla.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/typst-pdf/src/krilla.rs b/crates/typst-pdf/src/krilla.rs index c03749e66..6ec609fcb 100644 --- a/crates/typst-pdf/src/krilla.rs +++ b/crates/typst-pdf/src/krilla.rs @@ -15,7 +15,7 @@ use krilla::path::PathBuilder; use krilla::surface::Surface; use krilla::validation::ValidationError; use krilla::version::PdfVersion; -use krilla::{PageSettings, SerializeSettings, SvgSettings}; +use krilla::{Document, PageSettings, SerializeSettings, SvgSettings}; use std::collections::{BTreeMap, HashMap, HashSet}; use std::ops::Range; use std::sync::Arc; @@ -337,6 +337,10 @@ pub fn pdf( document.set_outline(build_outline(&gc)); document.set_metadata(build_metadata(&gc)); + finish(document, gc) +} + +fn finish(document: Document, gc: GlobalContext) -> SourceResult> { match document.finish() { Ok(r) => Ok(r), Err(e) => match e { @@ -352,7 +356,7 @@ pub fn pdf( // We can only produce 1 error, so just take the first one. let prefix = format!( "validated export for {} failed:", - options.validator.as_str() + gc.options.validator.as_str() ); match &ve[0] { ValidationError::TooLongString => {