Skip to content

A python wrapper for the Doc2X API and comes with native PDF processing (to improve PDF recall in RAG). | Doc2X API的python封装,同时附带本地的PDF处理(提升PDF在RAG中的召回率)。

License

Notifications You must be signed in to change notification settings

Menghuan1918/pdfdeal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pdfdeal

Better RAG Effect!


Package tests on Ubuntu Package tests on Windows Package tests on MacOS

Downloads GitHub License PyPI - Version GitHub Repo stars


📄Documentation

🗺️ ENGLISH | 简体中文

Handle PDF more easily and simply, utilizing Doc2X's powerful document conversion capabilities for retained format file conversion/RAG enhancement.

Introduction

Doc2X Support

Doc2X is a new universal document OCR tool that can convert images or PDF files into Markdown/LaTeX text with formulas and text formatting. It performs better than similar tools in most scenarios. pdfdeal provides abstract packaged classes to use Doc2X for requests.

Processing PDFs

Use various OCR or PDF recognition tools to identify images and add them to the original text. You can set the output format to use PDF, which will ensure that the recognized text retains the same page numbers as the original in the new PDF. It also offers various practical file processing tools.

After conversion and pre-processing of PDF using Doc2X, you can achieve better recognition rates when used with knowledge base applications such as graphrag, Dify, and FastGPT.

Cases

graphrag

See how to use it with graphrag, its not supported to recognize pdf, but you can use the CLI tool doc2x to convert it to a txt document for use.

Fastgpt/Dify or other RAG system

Or for knowledge base applications, you can use pdfdeal's built-in variety of enhancements to documents, such as uploading images to remote storage services, adding breaks by paragraph, etc. See Integration with RAG applications.

RAG system plug-in integration

Documentation

For details, please refer to the documentation

Or check out the documentation repository pdfdeal-docs.

Quick Start

For details, please refer to the documentation

Installation

Install from PyPI:

pip install --upgrade pdfdeal

Using Doc2X as PDF deal tool

from pdfdeal import Doc2X
from pdfdeal import get_files

client = Doc2X()
file_list, rename = get_files(path="tests/pdf", mode="pdf", out="pdf")
success, failed, flag = client.pdfdeal(
    pdf_file=file_list,
    output_path="./Output/test/multiple/pdfdeal",
    output_names=rename,
)
print(success)
print(failed)
print(flag)

Using pytesseract as an OCR engine

When using "pytesseract", make sure that tesseract is installed first:

pip install 'pdfdeal[pytesseract]'
from pdfdeal import deal_pdf, get_files

files, rename = get_files("tests/pdf", "pdf", "md")
output_path, failed, flag = deal_pdf(
    pdf_file=files,
    output_format="md",
    ocr="pytesseract",
    language=["eng"],
    output_path="Output",
    output_names=rename,
)
for f in output_path:
    print(f"Save processed file to {f}")

See the online documentation for details.

About

A python wrapper for the Doc2X API and comes with native PDF processing (to improve PDF recall in RAG). | Doc2X API的python封装,同时附带本地的PDF处理(提升PDF在RAG中的召回率)。

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages