Skip to content

Document

Excel, PDF, and Word document read/write/convert.

8 modules

ModuleDescription
อ่าน Excelอ่านข้อมูลจากไฟล์ Excel (xlsx, xls)
เขียน Excelเขียนข้อมูลลงไฟล์ Excel (xlsx)
กรอกฟอร์ม PDFกรอกฟิลด์ฟอร์ม PDF ด้วยข้อมูลและแทรกรูปภาพ (ไม่บังคับ)
สร้าง PDFสร้างไฟล์ PDF จากเนื้อหา HTML หรือข้อความ
แปลง PDFดึงข้อความและ metadata จากไฟล์ PDF
PDF เป็น Wordแปลงไฟล์ PDF เป็นเอกสาร Word (.docx)
แปลงเอกสาร Wordดึงข้อความและเนื้อหาจากเอกสาร Word (.docx)
Word เป็น PDFแปลงเอกสาร Word (.docx) เป็นไฟล์ PDF

Modules

อ่าน Excel

excel.read

อ่านข้อมูลจากไฟล์ Excel (xlsx, xls)

Parameters:

NameTypeRequiredDefaultDescription
pathstringYes-Path to the Excel file
sheetstringNo-Sheet name (default: first sheet)
header_rownumberNo1Row number for headers (1-based, 0 for no headers)
rangestringNo-Cell range to read (e.g., "A1:D10")
as_dictbooleanNoTrueReturn rows as dictionaries (using headers as keys)

Output:

FieldTypeDescription
dataarrayแถวข้อมูลที่ดึงออกมา
headersarrayแถวข้อมูลที่ดึงออกมา
row_countnumberแถวข้อมูลที่ดึงออกมา
sheet_namesarrayหัวคอลัมน์

Example: Read entire sheet

yaml
path: /tmp/data.xlsx
as_dict: true

เขียน Excel

excel.write

เขียนข้อมูลลงไฟล์ Excel (xlsx)

Parameters:

NameTypeRequiredDefaultDescription
pathstringYes-Path to the Excel file
dataarrayYes-Data to write (array of arrays or array of objects)
headersarrayNo-Column headers (auto-detected from objects if not provided)
sheet_namestringNoSheet1Name of the worksheet
auto_widthbooleanNoTrueAutomatically adjust column widths

Output:

FieldTypeDescription
pathstringพาธไปยังไฟล์ Excel ที่สร้าง
row_countnumberพาธไปยังไฟล์ Excel ที่สร้าง
sizenumberพาธไปยังไฟล์ Excel ที่สร้าง

Example: Write data to Excel

yaml
path: /tmp/output.xlsx
data: [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]

กรอกฟอร์ม PDF

pdf.fill_form

กรอกฟิลด์ฟอร์ม PDF ด้วยข้อมูลและแทรกรูปภาพ (ไม่บังคับ)

Parameters:

NameTypeRequiredDefaultDescription
templatestringYes-Path to the PDF template file
outputstringYes-Path for the output document
fieldsobjectNo{}Key-value pairs of form field names and values
imagesarrayNo[]List of images to insert with position info
flattenbooleanNoTrueFlatten form fields (make them non-editable)

Output:

FieldTypeDescription
output_pathstringพาธไปยัง PDF ที่กรอกแล้ว
fields_fillednumberพาธไปยัง PDF ที่กรอกแล้ว
images_insertednumberพาธไปยัง PDF ที่กรอกแล้ว
file_size_bytesnumberจำนวนรูปภาพที่แทรก

Example: Fill form with text fields

yaml
template: /templates/form.pdf
output: /output/filled.pdf
fields: {"name": "John Doe", "id_number": "A123456789", "date": "2024-01-01"}

Example: Fill form with photo

yaml
template: /templates/id_card.pdf
output: /output/id_card_filled.pdf
fields: {"name": "Jane Doe"}
images: [{"file": "/photos/jane.jpg", "page": 1, "x": 50, "y": 650, "width": 100, "height": 120}]

สร้าง PDF

pdf.generate

สร้างไฟล์ PDF จากเนื้อหา HTML หรือข้อความ

Parameters:

NameTypeRequiredDefaultDescription
contentstringYes-HTML or text content to convert to PDF
output_pathstringYes-Path for the output document
titlestringNo-Document title (metadata)
authorstringNo-Document author (metadata)
page_sizeselect (A4, Letter, Legal, A3, A5)NoA4Page size format
orientationselect (portrait, landscape)NoportraitPage orientation
marginnumberNo20Page margin in millimeters
headerstringNo-Header text for each page
footerstringNo-Footer text for each page

Output:

FieldTypeDescription
output_pathstringพาธไปยัง PDF ที่สร้าง
page_countnumberพาธไปยัง PDF ที่สร้าง
file_size_bytesnumberจำนวนหน้าใน PDF

Example: Generate from HTML

yaml
content: <h1>Report</h1><p>Content here</p>
output_path: /path/to/report.pdf
title: Monthly Report

แปลง PDF

pdf.parse

ดึงข้อความและ metadata จากไฟล์ PDF

Parameters:

NameTypeRequiredDefaultDescription
pathstringYes-Path to the PDF file
pagesstringNoallPage range (e.g., "1-5", "1,3,5", or "all")
extract_imagesbooleanNoFalseExtract embedded images
extract_tablesbooleanNoFalseExtract tables as structured data

Output:

FieldTypeDescription
textstringเนื้อหาข้อความที่ดึง
pagesarrayเนื้อหาข้อความที่ดึง
metadataobjectเนื้อหาข้อความที่ดึง
page_countnumberเนื้อหาข้อความต่อหน้า

Example: Extract all text from PDF

yaml
path: /tmp/document.pdf
pages: all

PDF เป็น Word

pdf.to_word

แปลงไฟล์ PDF เป็นเอกสาร Word (.docx)

Parameters:

NameTypeRequiredDefaultDescription
input_pathstringYes-Path to the input document
output_pathstringNo-Path for the output document
preserve_formattingbooleanNoTruePreserve basic formatting
pagesstringNoallPage range (e.g., "1-5", "1,3,5", or "all")

Output:

FieldTypeDescription
output_pathstringพาธไปยังเอกสาร Word ที่สร้าง
page_countnumberพาธไปยังเอกสาร Word ที่สร้าง
file_sizenumberจำนวนหน้าที่แปลง

Example: Convert entire PDF to Word

yaml
input_path: /tmp/document.pdf

Example: Convert specific pages

yaml
input_path: /tmp/document.pdf
output_path: /tmp/output.docx
pages: 1-5

แปลงเอกสาร Word

word.parse

ดึงข้อความและเนื้อหาจากเอกสาร Word (.docx)

Parameters:

NameTypeRequiredDefaultDescription
file_pathstringYes-Path to the Word document (.docx)
extract_tablesbooleanNoTrueExtract tables as structured data
extract_imagesbooleanNoFalseExtract embedded images
images_output_dirstringNo-Directory to save extracted images
preserve_formattingbooleanNoFalsePreserve basic formatting

Output:

FieldTypeDescription
textstringเนื้อหาข้อความทั้งหมดของเอกสาร
paragraphsarrayเนื้อหาข้อความทั้งหมดของเอกสาร
tablesarrayเนื้อหาข้อความทั้งหมดของเอกสาร
imagesarrayรายการย่อหน้า
metadataobjectตารางที่ดึงออกมาเป็นอาร์เรย์

Example: Extract text from Word

yaml
file_path: /path/to/document.docx

Example: Extract with tables and images

yaml
file_path: /path/to/document.docx
extract_tables: true
extract_images: true
images_output_dir: /path/to/images/

Word เป็น PDF

word.to_pdf

แปลงเอกสาร Word (.docx) เป็นไฟล์ PDF

Parameters:

NameTypeRequiredDefaultDescription
input_pathstringYes-Path to the input document
output_pathstringNo-Path for the output document
methodselect (auto, libreoffice, docx2pdf)NoautoMethod to use for conversion

Output:

FieldTypeDescription
output_pathstringพาธไปยังไฟล์ PDF ที่สร้าง
file_sizenumberพาธไปยังไฟล์ PDF ที่สร้าง
method_usedstringขนาดไฟล์เอาต์พุตเป็นไบต์

Example: Convert Word to PDF

yaml
input_path: /tmp/document.docx

Example: Convert with specific output path

yaml
input_path: /tmp/document.docx
output_path: /tmp/output.pdf

Released under the Apache 2.0 License.