← Back to Skills Marketplace
aitanjp

Invoice-Recognition

by aitanjp · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
258
Downloads
1
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install invoice-extractor
Description
Extract invoice information from images and PDF files using Baidu OCR API, export to Excel. Supports single file, multiple files, or entire directory process...
README (SKILL.md)

\r \r

Invoice Extractor\r

\r Extract invoice information from images (PNG, JPG) and PDF files, then export to Excel format.\r \r

Capabilities\r

\r

  • Multi-format support: PNG, JPG, JPEG, BMP, TIFF, PDF\r
  • High accuracy: Uses Baidu OCR API specialized for invoice recognition\r
  • Complete fields: Extracts all invoice fields including buyer/seller info, amounts, items\r
  • Excel export: Formatted Excel output with summary and detail sheets\r
  • Flexible input: Single file, multiple files, or entire directory processing\r
  • Batch processing: Process hundreds of invoices in one command\r
  • Preview mode: List files before processing\r \r

Prerequisites\r

\r

  1. Baidu Cloud OCR API credentials (free tier: 50,000 requests/day)\r
  2. Python environment with required packages\r \r

Quick Start\r

\r

1. Setup Baidu OCR\r

\r Get API credentials from https://cloud.baidu.com/product/ocr:\r

  1. Register/login to Baidu Cloud\r
  2. Create an application\r
  3. Get API Key and Secret Key\r \r

2. Configure\r

\r Create config.txt in the project root:\r

BAIDU_API_KEY=your_api_key_here\r
BAIDU_SECRET_KEY=your_secret_key_here\r
```\r
\r
Or run the setup wizard:\r
```bash\r
python main_baidu.py --setup\r
```\r
\r
### 3. Run\r
\r
**Process a single file:**\r
```bash\r
python main_baidu.py -f invoice.pdf\r
```\r
\r
**Process multiple files:**\r
```bash\r
python main_baidu.py -f invoice1.pdf -f invoice2.png\r
```\r
\r
**Process entire directory:**\r
```bash\r
python main_baidu.py -i ./fp\r
```\r
\r
**Mixed mode (directory + extra files):**\r
```bash\r
python main_baidu.py -i ./fp -f extra_invoice.pdf\r
```\r
\r
Output will be saved to `output/` directory as Excel file.\r
\r
## Workflow\r
\r
```\r
Task Progress:\r
- [ ] Check prerequisites (Baidu API credentials)\r
- [ ] Choose input method (single file / multiple files / directory)\r
- [ ] Scan and collect invoice files\r
- [ ] Preview files (optional with --list)\r
- [ ] Process each file with Baidu OCR\r
- [ ] Parse invoice fields\r
- [ ] Export to Excel\r
- [ ] Verify output\r
```\r
\r
## Input Methods\r
\r
### Single File\r
Process one specific invoice file:\r
```bash\r
python main_baidu.py -f invoice.pdf\r
python main_baidu.py -f "path/to/invoice.png"\r
```\r
\r
### Multiple Files\r
Process several specific files:\r
```bash\r
python main_baidu.py -f file1.pdf -f file2.png -f file3.jpg\r
```\r
\r
### Entire Directory\r
Process all invoice files in a directory (recursive):\r
```bash\r
python main_baidu.py -i ./my_invoices\r
python main_baidu.py -i "/path/to/invoice/folder"\r
```\r
\r
### Mixed Mode\r
Combine directory and individual files:\r
```bash\r
python main_baidu.py -i ./fp -f ./extra/invoice.pdf\r
```\r
\r
### Preview Mode\r
List files without processing:\r
```bash\r
python main_baidu.py -i ./fp --list\r
```\r
\r
## Extracted Fields\r
\r
### Basic Information\r
- Invoice code (发票代码)\r
- Invoice number (发票号码)\r
- Invoice date (开票日期)\r
- Invoice type (发票类型)\r
\r
### Buyer Information\r
- Name (购买方名称)\r
- Tax number (纳税人识别号)\r
- Address and phone (地址电话)\r
- Bank account (开户行及账号)\r
\r
### Seller Information\r
- Name (销售方名称)\r
- Tax number (纳税人识别号)\r
- Address and phone (地址电话)\r
- Bank account (开户行及账号)\r
\r
### Amounts\r
- Total amount (合计金额)\r
- Total tax (合计税额)\r
- Amount with tax (价税合计)\r
\r
### Items\r
- Product name (货物名称)\r
- Specification (规格型号)\r
- Unit (单位)\r
- Quantity (数量)\r
- Unit price (单价)\r
- Amount (金额)\r
- Tax rate (税率)\r
- Tax amount (税额)\r
\r
## Command Line Options\r
\r
```bash\r
python main_baidu.py [options]\r
\r
Input Options:\r
  -f FILE, --file FILE     Specify invoice file (can be used multiple times)\r
  -i DIR, --input DIR      Input directory (default: fp)\r
\r
Output Options:\r
  -o DIR, --output DIR     Output directory (default: output)\r
  -n NAME, --name NAME     Output filename prefix (default: 发票信息)\r
\r
Authentication Options:\r
  --api-key KEY            Baidu API Key\r
  --secret-key KEY         Baidu Secret Key\r
\r
Other Options:\r
  --setup                  Run configuration wizard\r
  --list                   List files to be processed without processing\r
  -h, --help              Show help\r
```\r
\r
## Usage Examples\r
\r
### Example 1: Single File\r
```bash\r
python main_baidu.py -f "invoice.pdf"\r
```\r
\r
### Example 2: Multiple Files\r
```bash\r
python main_baidu.py -f "1.pdf" -f "2.png" -f "3.jpg"\r
```\r
\r
### Example 3: Entire Directory\r
```bash\r
python main_baidu.py -i "./2024_invoices"\r
```\r
\r
### Example 4: Preview Before Processing\r
```bash\r
python main_baidu.py -i ./fp --list\r
# Then process:\r
python main_baidu.py -i ./fp\r
```\r
\r
### Example 5: Mixed Input\r
```bash\r
python main_baidu.py -i ./fp -f ./urgent/invoice.pdf -o ./output -n "March_2024"\r
```\r
\r
### Example 6: Custom Output\r
```bash\r
python main_baidu.py -i ./fp -o ./reports -n "Q1_Invoice_Summary"\r
```\r
\r
## Project Structure\r
\r
```\r
.\r
├── fp/                      # Place invoice files here\r
├── output/                  # Excel output directory\r
├── src/\r
│   ├── main_baidu.py       # Main entry point\r
│   ├── baidu_ocr_extractor.py  # Baidu OCR wrapper\r
│   ├── invoice_model.py    # Data models\r
│   ├── excel_exporter.py   # Excel export\r
│   └── config.py           # Configuration\r
├── scripts/                 # Utility scripts\r
│   ├── batch_process.py    # Batch processing helper\r
│   └── verify_export.py    # Verify Excel export\r
├── config.txt              # API credentials\r
├── requirements.txt        # Dependencies\r
├── SKILL.md                # This file\r
├── setup.md                # Detailed setup guide\r
└── examples.md             # Usage examples\r
```\r
\r
## Utility Scripts\r
\r
### Batch Processing Helper\r
```bash\r
python scripts/batch_process.py /path/to/invoices\r
```\r
\r
### Verify Export\r
```bash\r
python scripts/verify_export.py output/invoice_info.xlsx\r
```\r
\r
## Error Handling\r
\r
Common issues and solutions:\r
\r
**"Baidu OCR authentication failed"**\r
- Check API Key and Secret Key in config.txt\r
- Verify credentials are correct in Baidu Cloud console\r
\r
**"No invoice files found"**\r
- Ensure files are in the specified directory\r
- Check file formats (supported: png, jpg, jpeg, bmp, tiff, pdf)\r
- Use `--list` to see what files are detected\r
\r
**"Image format error"**\r
- PDF files are automatically converted to images\r
- Ensure PDF is not corrupted or password-protected\r
\r
**"File not found"**\r
- Check file path is correct\r
- Use quotes for paths with spaces: `"path/to/file name.pdf"`\r
\r
## Advanced Usage\r
\r
### Environment Variables\r
Set credentials via environment:\r
```bash\r
export BAIDU_API_KEY="your_key"\r
export BAIDU_SECRET_KEY="your_secret"\r
```\r
\r
### Batch Processing Script\r
Create a script for monthly processing:\r
```bash\r
#!/bin/bash\r
MONTH=$(date +%Y%m)\r
python main_baidu.py \\r
  -i "/invoices/$MONTH" \\r
  -o "/reports/$MONTH" \\r
  -n "Invoice_Report_$MONTH"\r
```\r
\r
## Additional Resources\r
\r
- For detailed setup instructions, see [setup.md](setup.md)\r
- For more examples, see [examples.md](examples.md)\r
- For API documentation, visit https://cloud.baidu.com/doc/OCR/index.html\r
Usage Guidance
This package mostly does what it says (uses Baidu OCR to extract invoice fields and export Excel), but take these precautions before installing or running: 1. Credentials: The tool requires BAIDU_API_KEY and BAIDU_SECRET_KEY though the registry metadata didn't declare them. Do not paste real production keys into examples or check them into version control. Inspect config.txt and setup.md and remove any example keys before use. 2. Review embedded credentials: setup.md contains a concrete-looking API Key/Secret pair in its manual configuration example — verify these are placeholders. If they are real, they must not be trusted and should be rotated. 3. Dependencies: install.sh runs 'pip install -r requirements.txt' (safe pattern), but the code imports paddleocr/local OCR packages that are not listed in requirements.txt. Be prepared to install paddleocr and its large models in an isolated environment if you need the local OCR fallback. Use a virtualenv or container. 4. Network access: The tool calls Baidu endpoints (aip.baidubce.com) and will send base64-encoded images to Baidu. Ensure you are comfortable with that network/data flow for the documents you will process (invoices contain sensitive PII). If you need offline processing, review and test the local OCR path. 5. Run in a sandbox: Until you've audited the code, run the installer and processing in a disposable VM/container or isolated account with minimal privileges and no sensitive files mounted. 6. Code review: Quick items to inspect before use — confirm there are no hardcoded remote endpoints other than Baidu, ensure config.load_from_file behavior meets your expectations (it searches multiple paths for config.txt), and check any utility scripts (emailing or batch scripts) so they don't accidentally send exports to third parties. If you want, I can point out the exact lines where credentials are read, where the Baidu endpoints are called, and where the example credentials appear so you can remove/replace them.
Capability Analysis
Type: OpenClaw Skill Name: invoice-extractor Version: 1.0.0 The invoice-extractor skill bundle is a legitimate tool designed to extract structured data from invoice images and PDFs using the Baidu OCR API or local OCR (PaddleOCR). The code follows standard practices for API authentication, file handling, and Excel generation (using pandas and openpyxl), with no evidence of data exfiltration, malicious execution, or prompt injection. All network and file system operations are strictly aligned with the stated purpose of processing invoices and managing configuration settings.
Capability Assessment
Purpose & Capability
The code and SKILL.md align with the stated purpose (Baidu OCR invoice extraction and Excel export). However the registry metadata lists no required environment variables or primary credential while the code and docs clearly require BAIDU_API_KEY and BAIDU_SECRET_KEY (config.txt or env). This mismatch is a documentation/metadata incoherence.
Instruction Scope
SKILL.md and the included scripts focus on scanning files, calling Baidu OCR, parsing invoice fields, and exporting Excel. There are no instructions in SKILL.md to read unrelated system files or exfiltrate arbitrary data. Example integration snippets and email/database examples are user-facing and not automatic. Overall the runtime instructions stay within the stated purpose.
Install Mechanism
There is no formal registry install spec, but the bundle contains an install.sh that runs 'pip install -r requirements.txt', creates directories, and copies a config template. The install script uses only the local requirements.txt (no external arbitrary downloads), which is low-to-moderate risk. The inconsistency (no registry install spec but an install script present) is worth noting.
Credentials
The tool legitimately needs Baidu OCR credentials, but the registry declares no required env vars while the code reads BAIDU_API_KEY / BAIDU_SECRET_KEY from config files or environment. Additionally, setup.md includes an explicit example config with concrete-looking API key/secret values — embedding credentials in docs is a bad practice and could leak sensitive keys if they are real or reused. Also code imports PaddleOCR (local OCR fallback) but requirements.txt does not list paddleocr, a mismatch that may force users to install extra packages manually.
Persistence & Privilege
Skill does not request always: true and does not modify unrelated skills. The installer creates local directories (fp, output, .temp) and writes/reads config.txt in the project — this is expected for a local CLI tool and is within normal scope.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install invoice-extractor
  3. After installation, invoke the skill by name or use /invoice-extractor
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release of the invoice-extractor skill. - Extracts key invoice data from image and PDF files using Baidu OCR, exporting results to Excel. - Supports multiple input modes: single file, multiple files, directory, or combination. - Batch processing enables handling of hundreds of invoices in one command. - Lists all extracted fields, including buyer, seller, item, and amount details. - Includes preview mode to list files before processing. - Provides command-line configuration, flexible output naming, and utility scripts for verification and batch runs.
Metadata
Slug invoice-extractor
Version 1.0.0
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is Invoice-Recognition?

Extract invoice information from images and PDF files using Baidu OCR API, export to Excel. Supports single file, multiple files, or entire directory process... It is an AI Agent Skill for Claude Code / OpenClaw, with 258 downloads so far.

How do I install Invoice-Recognition?

Run "/install invoice-extractor" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Invoice-Recognition free?

Yes, Invoice-Recognition is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Invoice-Recognition support?

Invoice-Recognition is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Invoice-Recognition?

It is built and maintained by aitanjp (@aitanjp); the current version is v1.0.0.

💬 Comments