INNER CODE UNIT · Rust

extract_text_with_positions_and_rotations

firecrawl/pdf-inspector · napi/src/lib.rs:603

pub fn extract_text_with_positions_and_rotations(buffer: Buffer) -> Result<PositionedText> {
    let bytes: Vec<u8> = buffer.to_vec();
    catch_panic("extract_text_with_positions_and_rotations", move || {
        let (items, rotations) =
            pdf_inspector::extract_text_with_positions_and_rotations_mem(&bytes)
                .map_err(|e| to_napi_err(e, "extract_text_with_positions_and_rotations"))?;
        let mut page_rotations: Vec<PageRotation> = rotations
            .into_iter()
            .filter_map(|(page, rotation)| {
                let rotation = match rotation {
                    pdf_inspector::PageRotation::Upright => return None,
                    pdf_inspector::PageRotation::Ccw => "ccw",
                    pdf_inspector::PageRotation::Cw => "cw",
                };
                Some(PageRotation {
                    page,
                    rotation: rotation.to_string(),
                })

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…