ozsparkhub's picture
Create PDF table extraction API
92fea71 verified
|
Raw History Blame Contribute Delete
2.94 kB
---
title: PDF to Excel Converter API
emoji: πŸ“Š
colorFrom: green
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
license: mit
---
# PDF to Excel Converter API
Extract tables from text-based PDF files to Excel (XLSX) or CSV format.
## Features
βœ… **Direct Table Extraction** - Uses pdfplumber first for text-based PDFs
βœ… **Dual Format Support** - Export as Excel (.xlsx) or CSV (.csv)
βœ… **Multiple Tables** - Creates separate sheets for each table (XLSX)
βœ… **Markdown Fallback** - Falls back to Markdown table parsing when direct extraction is not enough
βœ… **Free & Unlimited** - No API limits or costs
βœ… **100% Privacy** - Files processed temporarily, not stored
## How It Works
1. **PDF β†’ Tables** - pdfplumber extracts rows and columns from text-based PDFs
2. **Fallback β†’ Markdown Tables** - A document parser is used when direct extraction finds no tables
3. **Tables β†’ Excel/CSV** - pandas creates spreadsheet files
## API Usage
### JavaScript/TypeScript
```javascript
const API_URL = "https://ozsparkhub-pdf-to-excel-api.hf.space";
async function convertPdfToExcel(pdfFile, format = "xlsx") {
const formData = new FormData();
formData.append('file', pdfFile);
formData.append('output_format', format);
const response = await fetch(`${API_URL}/call/convert`, {
method: 'POST',
body: formData
});
const result = await response.json();
return result.file_data; // base64 Excel/CSV data
}
```
### Python
```python
import requests
with open("path/to/file.pdf", "rb") as pdf:
response = requests.post(
"https://ozsparkhub-pdf-to-excel-api.hf.space/call/convert",
files={"file": pdf},
data={"output_format": "xlsx"},
)
print(response.json())
```
## Technical Stack
- **pdfplumber** - Direct table extraction for text-based PDFs
- **Document parser fallback** - Markdown table fallback
- **pandas** - Data manipulation and Excel generation
- **openpyxl** - Excel file creation engine
- **FastAPI** - API interface
## Use Cases
πŸ“Š **Data Extraction** - Extract financial tables from PDF reports
πŸ’Ό **Business Analytics** - Convert invoices and statements to Excel
πŸ“ˆ **Research Data** - Extract scientific tables for analysis
🏒 **Document Processing** - Automate PDF table extraction workflows
πŸ“‘ **Report Generation** - Convert PDF reports to editable spreadsheets
## Limitations
- Maximum file size: 10MB
- Works best with text-based PDFs, not scanned/image-only documents
- Complex merged cells may need manual adjustment
- Borderless or heavily designed tables may need manual cleanup
## Credits
Created by [OzSparkHub Business Tools](https://biz.ozsparkhub.com.au)
Powered by:
- [pdfplumber](https://github.com/jsvine/pdfplumber)
- [pandas](https://pandas.pydata.org/)
- [openpyxl](https://openpyxl.readthedocs.io/)
- [FastAPI](https://fastapi.tiangolo.com/)
## License
MIT License - Free for commercial and personal use