Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use alternate PDF parser backend? #28

Open
Ankush-Chander opened this issue Feb 3, 2025 · 1 comment
Open

How to use alternate PDF parser backend? #28

Ankush-Chander opened this issue Feb 3, 2025 · 1 comment
Labels
docling Related to Docling library and models usage

Comments

@Ankush-Chander
Copy link

Hi team,

Appreciate the work done in this repo.
Was curious how I can I use a different backend(PyPdfiumDocumentBackend) other than default backend(docling-parse).

I am trying it as follows but doesnt see much difference in timing or output.

import spacy
from spacy_layout import spaCyLayout
from docling.backend.pypdfium2_backend import PyPdfiumDocumentBackend
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import PdfPipelineOptions
from docling.document_converter import DocumentConverter, PdfFormatOption

source = "path/to/document.pdf"

nlp = spacy.blank("en")
pipeline_options = PdfPipelineOptions()
pipeline_options.do_ocr = False
pipeline_options.do_table_structure = True
pipeline_options.table_structure_options.do_cell_matching = False
layout = spaCyLayout(nlp, docling_options={
     "format_options":{
        InputFormat.PDF: PdfFormatOption(
            pipeline_options=pipeline_options, backend=PyPdfiumDocumentBackend
        )
    }
})
doc = layout(source)
@ines ines added usage docling Related to Docling library and models labels Feb 23, 2025
@herebepanda
Copy link

Try instantiate layout like this instead:

layout = spaCyLayout(nlp, docling_options= {
         InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options, backend=PyPdfiumDocumentBackend)
     }
 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docling Related to Docling library and models usage
Projects
None yet
Development

No branches or pull requests

3 participants