Skip to content

Commit

Permalink
[example] Add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Menghuan1918 committed Nov 18, 2024
1 parent 78e9d8d commit 768fbbd
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
19 changes: 19 additions & 0 deletions examples/convert_folder_pdfs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This is an example of how to convert all PDF files in a folder to DOCX files.
# 这是一个将文件夹中的所有 PDF 文件转换为 DOCX 文件的示例。

from pdfdeal import Doc2X

# gets API Key from environment variable DOC2X_APIKEY, or you can pass it as a string to the apikey parameter
# 从环境变量 DOC2X_APIKEY 获取 API Key, 或者您可以将其作为字符串传递给 apikey 参数

# client = Doc2X(apikey="Your API key",debug=True)
client = Doc2X(debug=True)

success, failed, flag = client.pdf2file(
pdf_file="tests/pdf/test",
output_path="./Output",
output_format="docx",
)
print(success)
print(failed)
print(flag)
19 changes: 19 additions & 0 deletions examples/convert_pdfs_multiple_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This is an example of how to convert all PDF files in a folder to multiple types of files.
# 这是一个将文件夹中的所有 PDF 文件转换为多种类型文件的示例。

from pdfdeal import Doc2X

# gets API Key from environment variable DOC2X_APIKEY, or you can pass it as a string to the apikey parameter
# 从环境变量 DOC2X_APIKEY 获取 API Key, 或者您可以将其作为字符串传递给 apikey 参数

# client = Doc2X(apikey="Your API key",debug=True)
client = Doc2X(debug=True)

success, failed, flag = client.pdf2file(
pdf_file="/home/menghuan/文档/Test/pdf",
output_path="./Output",
output_format="docx,md",
)
print(success)
print(failed)
print(flag)
19 changes: 19 additions & 0 deletions examples/convert_single_pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This is an example of how to convert a single PDF file to a single DOCX file.
# 这是一个将单个 PDF 文件转换为单个 DOCX 文件的示例。

from pdfdeal import Doc2X

# gets API Key from environment variable DOC2X_APIKEY, or you can pass it as a string to the apikey parameter
# 从环境变量 DOC2X_APIKEY 获取 API Key, 或者您可以将其作为字符串传递给 apikey 参数

# client = Doc2X(apikey="Your API key",debug=True)
client = Doc2X(debug=True)

success, failed, flag = client.pdf2file(
pdf_file="tests/pdf/sample.pdf",
output_path="Output",
output_format="docx",
)
print(success)
print(failed)
print(flag)
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pdfdeal"
version = "0.4.8"
version = "0.4.9"
authors = [{ name = "Menghuan1918", email = "[email protected]" }]
description = "A python wrapper for the Doc2X API and comes with native texts processing (to improve texts recall in RAG)."
readme = "README.md"
Expand All @@ -13,8 +13,8 @@ classifiers = [
dependencies = ["httpx[http2]>=0.23.1, <1", "pypdf"]

[project.optional-dependencies]
rag = ["emoji", "Pillow", "reportlab", "oss2", "boto3"]
dev = ["pytest", "emoji", "Pillow", "reportlab", "oss2", "boto3"]
rag = ["emoji", "Pillow", "reportlab", "oss2", "boto3", "minio"]
dev = ["pytest", "emoji", "Pillow", "reportlab", "oss2", "boto3", "minio"]

[project.urls]
Issues = "https://github.com/Menghuan1918/pdfdeal/issues"
Expand Down

0 comments on commit 768fbbd

Please sign in to comment.