Library / Documents, PDF & OCR
Documents, PDF & OCR
Extract invoice and PO data from Gmail PDFs into XML, CSV and JSON
On manual run, parses PDF invoices and purchase orders from Gmail with rule-based extraction, validates totals and duplicates, and saves XML, CSV and JSON files to Google Drive.
What it does
## Extract invoice and PO data from Gmail PDFs Turn PDF invoices and purchase orders from Gmail into clean XML, CSV and JSON files, with no AI model, API key or per-document cost. What makes it different: - Rule-based parsing: predictable, transparent regex extraction you can tune per vendor, instead of an AI black box. - Built-in validation: checks required fields, line math (qty x price), subtotal + tax = total, and duplicates before anything is exported. - ERP-ready XML alongside CSV and JSON, optionally saved to Google Drive. - Human review: documents that fail validation are emailed to a reviewer instead of being exported. ### Who's it for Finance, accounts payable and procurement teams, bookkeepers, and small businesses that receive invoices or purchase orders by email and need structured data for an ERP, accounting tool or spreadsheet. ### How it works 1. Watch Gmail for Invoice PDFs finds unread emails with PDF attachments. 2. Each PDF is split out and its text is extracted. 3. A Code node parses the number, dates, vendor, currency, line items and totals. 4. Validation checks required fields, line math, subtotal plus tax, and duplicates. Duplicate detection only works in production (active workflow) runs, not manual tests. 5. Valid documents become .xml, .csv and .json files, optionally uploaded to Google Drive. Invalid ones go to the review branch. 6. After processing, the email is marked as read so it is not picked up again. ### Setup 1. Click Test with Sample Invoice to try it with no credentials. 2. Add your Gmail credential to Watch Gmail for Invoice PDFs, Email Review Request and Mark Email as Read, then edit the trigger's search filter. The trigger checks Gmail every 15 minutes by default. 3. In Workflow Configuration, set uploadToDrive, driveFolderId and reviewerEmail. 4. Add Google Drive credentials if you upload files. 5. Activate the workflow. ### Requirements - A Gmail account (OAuth2 credential) - A Google Drive account (optional, only for uploading output files) - PDF invoices or POs with a selectable text layer ### Customization tips Edit the regex in Parse Document Fields to match your vendors' labels. PDFs must have a text layer. For scanned files, add OCR or an AI extraction node.
The steps
- Test with Sample Invoice
- Sample Invoice Text
- Parse Document Fields
- Validate Document
- Workflow Configuration
- Is Valid?
- Build XML CSV JSON Files
- Upload to Drive Enabled?
- Upload to Google Drive
- Reviewer Email Set?
- Email Review Request
- Only Gmail Messages
- Mark Email as Read
- Watch Gmail for Invoice PDFs
17 steps in total.
Similar automations
Building Blocks & UtilitiesConvert Webhook JSON to XML4 stepsDocuments, PDF & OCRExtract text from PDFs and images into CSV with Gemini and Google Drive12 stepsDocuments, PDF & OCRExtract text from Google Drive PDFs and images with Gemini into CSV12 stepsData Sync & ETLConvert CocktailDB JSON Data to XML4 steps