Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ csv = "1.4.0"
flate2 = "1"
encoding_rs = "0.8.35"
log = "0.4"
pdf-inspector = "0.1.8"
pdf-inspector = "1.14.1"
quick-xml = "0.41.0"
zip = { version = "8.6.0", default-features = false, features = ["deflate"] }

Expand Down
8 changes: 6 additions & 2 deletions src/formats/pdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
//! image-only PDFs need OCR, which is out of scope here; they error as
//! unsupported. Pages flagged for OCR in an otherwise text-based document
//! degrade with a log, consistent with the crate-wide recovery policy.
//! Embedded images are retained as positioned Markdown placeholders.
//!
//! [pdf-inspector]: https://github.com/firecrawl/pdf-inspector

use crate::error::ConvertError;
use pdf_inspector::PdfError;
use pdf_inspector::{MarkdownOptions, PdfError, PdfOptions};

pub fn to_markdown(bytes: &[u8]) -> Result<String, ConvertError> {
let result = pdf_inspector::process_pdf_mem(bytes).map_err(map_error)?;
let markdown = MarkdownOptions { include_images: true, ..MarkdownOptions::default() };
let result =
pdf_inspector::process_pdf_mem_with_options(bytes, PdfOptions::new().markdown(markdown))
.map_err(map_error)?;
if !result.pages_needing_ocr.is_empty() {
log::warn!(
"{} of {} pages need OCR and were not extracted",
Expand Down
2 changes: 2 additions & 0 deletions tests/snapshots/snapshots__pdf__text.pdf.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ External link to example. Relative link to <u>a sibling file</u>. This plain par

## Objects

![Image: Im107](image)

Inline image: done.

### Inside the text box.
Expand Down