Skip to main content

PdfPreprocessor

Struct PdfPreprocessor 

Source
pub struct PdfPreprocessor { /* private fields */ }
Expand description

PDF Preprocessor with pluggable backend

Processes PDF documents through two stages:

  1. Backend extraction: PDF bytes → Blazegraph XHTML
  2. XHTML parsing: Blazegraph XHTML → PreprocessorOutput

Implementations§

Source§

impl PdfPreprocessor

Source

pub fn new_with_jni( jre_path: &Path, jar_path: &Path, ) -> Result<PdfPreprocessor, Error>

Create PdfPreprocessor with JNI backend (default JVM settings)

§Arguments
  • jre_path - Path to JRE directory
  • jar_path - Path to blazing-tika.jar
Source

pub fn new_with_jni_args( jre_path: &Path, jar_path: &Path, jvm_args: &[String], ) -> Result<PdfPreprocessor, Error>

Create PdfPreprocessor with JNI backend and custom JVM arguments

§Arguments
  • jre_path - Path to JRE directory
  • jar_path - Path to blazing-tika.jar
  • jvm_args - Additional JVM arguments (e.g., “-Xmx4g”, “-XX:+UseG1GC”)
§Example
let jvm_args = vec![
    "-Xms1g".to_string(),
    "-Xmx4g".to_string(),
    "-XX:+UseG1GC".to_string(),
    "-XX:MaxGCPauseMillis=100".to_string(),
];
let preprocessor = PdfPreprocessor::new_with_jni_args(&jre_path, &jar_path, &jvm_args)?;
Source

pub fn backend_name(&self) -> &str

Get the backend name for logging

Source

pub fn is_healthy(&self) -> bool

Check if the backend is healthy

Trait Implementations§

Source§

impl Preprocessor for PdfPreprocessor

Source§

fn parse_pdf_to_markup_language( &self, pdf_bytes: &[u8], ) -> Result<String, Error>

Step 1: Extract PDF to XHTML via backend

Source§

fn parse_markup_to_preprocessor_output( &self, markup: &str, ) -> Result<PreprocessorOutput, Error>

Step 2: Parse XHTML to PreprocessorOutput

Source§

fn name(&self) -> &str

Get preprocessor name for debugging/logging
Source§

fn supports_file_type(&self, path: &Path) -> bool

Check if preprocessor supports the given file type
Source§

fn process(&self, document_bytes: &[u8]) -> Result<PreprocessorOutput, Error>

Convenience method: Full document processing (combines both steps) Read more
Source§

fn process_file(&self, input: &Path) -> Result<PreprocessorOutput, Error>

Convenience method: Process from file path Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.