diff --git a/crates/typst-cli/src/args.rs b/crates/typst-cli/src/args.rs index 093735cbb..7459be0f2 100644 --- a/crates/typst-cli/src/args.rs +++ b/crates/typst-cli/src/args.rs @@ -471,7 +471,6 @@ display_possible_values!(DiagnosticFormat); #[derive(Debug, Copy, Clone, Eq, PartialEq, ValueEnum)] pub enum Feature { Html, - PdfEmbedding, } display_possible_values!(Feature); diff --git a/crates/typst-cli/src/world.rs b/crates/typst-cli/src/world.rs index 34b0cef80..42083ef20 100644 --- a/crates/typst-cli/src/world.rs +++ b/crates/typst-cli/src/world.rs @@ -117,7 +117,6 @@ impl SystemWorld { .iter() .map(|&feature| match feature { Feature::Html => typst::Feature::Html, - Feature::PdfEmbedding => typst::Feature::PdfEmbedding, }) .collect(); diff --git a/crates/typst-library/src/lib.rs b/crates/typst-library/src/lib.rs index edbc182fa..025e997c6 100644 --- a/crates/typst-library/src/lib.rs +++ b/crates/typst-library/src/lib.rs @@ -237,7 +237,6 @@ impl FromIterator for Features { #[non_exhaustive] pub enum Feature { Html, - PdfEmbedding, } /// A group of related standard library definitions. diff --git a/crates/typst-library/src/visualize/image/mod.rs b/crates/typst-library/src/visualize/image/mod.rs index 2b66f625c..ec31e7a84 100644 --- a/crates/typst-library/src/visualize/image/mod.rs +++ b/crates/typst-library/src/visualize/image/mod.rs @@ -272,62 +272,53 @@ impl Packed { .within(loaded)?, ), ImageFormat::Vector(VectorFormat::Pdf) => { - if engine.world.library().features.is_enabled(Feature::PdfEmbedding) { - let document = match PdfDocument::new(loaded.data.clone()) { - Ok(doc) => doc, - Err(e) => match e { - LoadPdfError::Encryption => { - bail!( - span, - "the PDF is encrypted or password-protected"; - hint: "such PDFs are currently not supported"; - hint: "preprocess the PDF to remove the encryption" - ); - } - LoadPdfError::Invalid => { - bail!( - span, - "the PDF could not be loaded"; - hint: "perhaps the PDF file is malformed" - ); - } - }, - }; + let document = match PdfDocument::new(loaded.data.clone()) { + Ok(doc) => doc, + Err(e) => match e { + LoadPdfError::Encryption => { + bail!( + span, + "the PDF is encrypted or password-protected"; + hint: "such PDFs are currently not supported"; + hint: "preprocess the PDF to remove the encryption" + ); + } + LoadPdfError::Invalid => { + bail!( + span, + "the PDF could not be loaded"; + hint: "perhaps the PDF file is malformed" + ); + } + }, + }; - let page_num = self.page.get(styles); + let page_num = self.page.get(styles); - if page_num == 0 { - bail!( - span, - "{page_num} is not a valid page number"; - hint: "page numbers for PDF start at 1" - ) - }; - - // The user provides the page number start from 1, but further down the pipeline, - // page numbers are 0-based. - let page_idx = page_num - 1; - let num_pages = document.len(); - - let Some(pdf_image) = PdfImage::new(document, page_idx) else { - let pages = if num_pages == 1 { "page" } else { "pages" }; - - bail!( - span, - "page {page_num} doesn't exist"; - hint: "the document only has {num_pages} {pages}" - ); - }; - - ImageKind::Pdf(pdf_image) - } else { + if page_num == 0 { bail!( span, - "embedding PDFs is currently an experimental, opt-in feature"; - hint: "enable the corresponding feature to try it out"; - hint: "convert your PDF to SVG instead" + "{page_num} is not a valid page number"; + hint: "page numbers for PDF start at 1" + ) + }; + + // The user provides the page number start from 1, but further down the pipeline, + // page numbers are 0-based. + let page_idx = page_num - 1; + let num_pages = document.len(); + + let Some(pdf_image) = PdfImage::new(document, page_idx) else { + let pages = if num_pages == 1 { "page" } else { "pages" }; + + bail!( + span, + "page {page_num} doesn't exist"; + hint: "the document only has {num_pages} {pages}" ); - } + }; + + ImageKind::Pdf(pdf_image) } }; diff --git a/tests/src/world.rs b/tests/src/world.rs index e2f404dd5..85969700d 100644 --- a/tests/src/world.rs +++ b/tests/src/world.rs @@ -198,7 +198,7 @@ fn library() -> Library { // exactly 100pt wide. Page height is unbounded and font size is 10pt so // that it multiplies to nice round numbers. let mut lib = Library::builder() - .with_features([Feature::Html, Feature::PdfEmbedding].into_iter().collect()) + .with_features([Feature::Html].into_iter().collect()) .build(); // Hook up helpers into the global scope.