
Automate Factur-X and ZUGFeRD e-Invoices in Python with PDF.co
15 MIN READ
19 MIN READ
This tutorial explains how to convert a Google Sheets report into PDF, extract its text automatically, analyze the report with ChatGPT, create a second PDF containing the analysis, and send both documents through Gmail.
The completed workflow is:
Google Sheets → PDF.co report PDF → PDF.co text extraction → ChatGPT analysis → PDF.co analysis PDF → Gmail
This produces two useful documents:
Before starting, make sure you have:
Organize the report data in a worksheet with descriptive column headers. Remove unnecessary blank rows and columns, and format the spreadsheet as you want it to appear in the original report PDF.
Before creating the Zap, decide what should initiate the workflow:
The following steps use New Spreadsheet, matching the original workflow.
Create a Zap and select Google Sheets as the trigger app.
Choose New Spreadsheet as the trigger event. Connect your Google account, then select the Google Drive location Zapier should monitor.
Test the trigger. Zapier should return a recently created spreadsheet and its available file, download, or export links.
If Zapier does not find suitable test data, create a sample spreadsheet in the selected drive and test the trigger again.
Add PDF.co as the next app and select Anything to PDF Converter.
Connect your PDF.co account using the API key available in your PDF.co dashboard.
Configure the action:
spreadsheet-report.pdf.0. Leave the field empty to process all worksheets.If the Google Sheets trigger supplies only a native spreadsheet link rather than a downloadable file, add a Google Drive Export File action before PDF.co. Export the spreadsheet as XLSX, then map the exported file into PDF.co.
Test the PDF.co action. A successful response should include a temporary URL for the generated report PDF.
Open the URL and verify:
Keep the output URL from this step. It will be used for text extraction and can also be attached to the final email.
Add another PDF.co action and select PDF to Anything Converter.
This step eliminates the need to open the report manually and copy its text into ChatGPT.
Configure the action:
Enabling inline output returns the extracted text directly to Zapier instead of returning only a text-file URL.
Test the action and confirm that the response body contains readable text from the report.
Add the ChatGPT (OpenAI) app and select the current Conversation action. Do not select Conversation (Legacy).
Connect your OpenAI account and select one of the currently supported models available in Zapier.
Enter the following instructions:
You are a business-report analyst.
Analyze only the report data provided by the user. Identify important
metrics, trends, changes, outliers, risks, and opportunities. Preserve
important dates, figures, categories, and labels.
Do not invent missing information. If the report does not contain enough
information to support a conclusion, say so clearly.
Return only a simple, valid HTML report. Use headings, paragraphs, tables,
and lists. Do not return Markdown or include code fences.In User Message, enter:
Analyze the following report.
Include:
- An executive summary
- Key metrics
- Important trends
- Unusual or concerning results
- Risks and opportunities
- Recommended follow-up actions
- Any data-quality limitations
Report text:
[Map the inline text returned by the PDF.co extraction step here]If this workflow repeatedly analyzes reports for the same customer, enter a stable, customer-specific value in the Memory Key field. This allows the ChatGPT action to retain conversational context between workflow runs and produce analysis informed by earlier interactions.
Use a unique internal customer identifier, such as:
customer-report-[Customer ID]Map the customer ID dynamically when the same Zap serves multiple customers. Avoid using sensitive personal information directly in the Memory Key.
Leave this field blank when each report should be analyzed independently. A Memory Key is also unnecessary for one-time reports or when previous analyses should not influence the current result.
Test the ChatGPT action and review the response carefully. Confirm that all important names, dates, figures, and conclusions agree with the original report.
For reports requiring exact totals, percentages, averages, or financial calculations, calculate those values in Google Sheets before generating the report. Use ChatGPT primarily to interpret and explain the supplied results.
Add another PDF.co action and select HTML to PDF Converter.
In the HTML input, add a document template and map the ChatGPT response into the body:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Report Analysis</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.5;
margin: 40px;
color: #222;
}
h1 {
border-bottom: 2px solid #333;
padding-bottom: 10px;
}
h2 {
margin-top: 28px;
}
table {
width: 100%;
border-collapse: collapse;
margin: 16px 0;
}
th,
td {
border: 1px solid #ccc;
padding: 8px;
text-align: left;
vertical-align: top;
}
th {
background: #f2f2f2;
}
</style>
</head>
<body>
<h1>Report Analysis</h1>
[Map the ChatGPT response here]
</body>
</html>Configure the remaining options:
report-analysis.pdf.Test the action. Open the returned PDF URL and check every page for missing content, clipped tables, formatting problems, and inaccurate analysis.
You should now have two PDF URLs:
Add Gmail as the final app and select Send Email.
Configure the email:
Spreadsheet Report and Analysis.Example email body:
Attached are the original spreadsheet report and the accompanying
analysis report.
The analysis was generated automatically and should be reviewed before
being used for consequential business decisions.Test the Gmail action. Confirm that the email arrives with both PDF files attached and that each attachment opens correctly.
PDF.co output URLs are temporary. Gmail retrieves the files when sending the email, but the URLs should not be treated as permanent storage.
If the reports must be retained, add storage actions before the Gmail step. Save both PDFs to Google Drive, Dropbox, OneDrive, Box, or your document-management system.
Consider storing the files with distinct names, such as:
spreadsheet-report.pdfspreadsheet-report-analysis.pdfYou can include a date, customer name, reporting period, or another identifier in each filename.
Run one final test of the complete workflow and verify that:
Publish the Zap after the complete test succeeds. The workflow will now create the original spreadsheet report PDF, generate a separate analysis PDF, and deliver both documents automatically.
In this tutorial, you created an automated workflow that converts a Google Sheets report into PDF, extracts its text for analysis, and sends the content to ChatGPT without manual copying. You then used PDF.co’s HTML to PDF Converter to create a separate analysis report and Gmail to deliver both PDFs as email attachments.
This workflow preserves the original spreadsheet report while providing an additional AI-generated analysis. It can also be extended to store the reports in Google Drive, Dropbox, OneDrive, or another document-management system for future access.
Create an account, get an API key and test a request.