PDF Export
Exports a Google Docs document as a PDF file.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Document Id - The ID of the Google Docs document to export as PDF.
- File Path - The local file path where the PDF should be saved.
Options
- Credentials - Google Docs credentials used to authenticate with the service.
How It Works
The PDF Export node integrates with Google Docs to export a document as a PDF file. When executed, the node:
- Validates the provided inputs (Document Id, File Path)
- Authenticates with Google Docs using the provided credentials
- Exports the specified Google Docs document as a PDF
- Saves the PDF file to the specified local file path
Requirements
- Valid Google Docs credentials
- A valid Google Docs document ID
- A valid local file path for saving the PDF
- Valid Google Docs permissions to access the document
- Write permissions to the specified local file path
Error Handling
The node will return specific errors in the following cases:
- Empty or invalid Document Id
- Empty or invalid File Path
- Empty or invalid Google Docs credentials
- Google Docs service errors
- Insufficient permissions to access the document
- Unable to write to the specified file path
Usage Notes
- The Document Id can be found in the URL of the Google Docs document
- The File Path should be a valid local path where the PDF will be saved
- If a file already exists at the specified path, it will be overwritten
- The node requires appropriate permissions to access the specified document
- The exported PDF will maintain the formatting of the original Google Docs document
- This node is useful for creating PDF versions of Google Docs documents for sharing or archiving
Practical Examples
Example 1: Export Document to PDF
Export a document to a local PDF file:
Inputs:
- Document Id:
$.document_id - File Path:
"/home/user/reports/monthly_report.pdf"
Result: PDF file is created at the specified path with all document formatting preserved
Example 2: Export with Dynamic File Name
Export PDF with date-stamped filename:
Inputs:
- Document Id:
$.document_id - File Path:
"/reports/report_" + $.date + ".pdf"
Example: Creates /reports/report_2024-01-15.pdf
Example 3: Export Multiple Documents
Export multiple documents in a loop:
Workflow:
For Each doc in document_list:
1. Open Document (URL: $.doc.url)
↓
2. PDF Export
Document Id: $.document_id
File Path: "/exports/" + $.doc.name + ".pdf"
Example 4: Complete Report Workflow
Generate, modify, and export document:
Workflow:
1. Create Document (Title: "Monthly Report")
↓
2. Insert Text (Report content)
↓
3. Add Header (Company name)
↓
4. Add Footer (Page numbers)
↓
5. PDF Export (File Path: "/reports/monthly.pdf")
Example 5: Archive Documents
Export documents for archival:
Inputs:
- File Path:
"/archive/" + $.year + "/" + $.month + "/" + $.doc_name + ".pdf"
Use Case: Organize PDFs in year/month folder structure
Example 6: Export and Email
Export PDF then send via email:
Workflow:
1. PDF Export (save to temp location)
↓
2. Send Email (attach PDF file)
↓
3. Delete File (cleanup temp file)
Tips for Effective Use
- Use absolute paths - Specify full file paths to avoid confusion:
/home/user/file.pdf - Create directories first - Ensure destination folders exist before exporting
- Dynamic naming - Include dates, IDs, or names in filenames for organization
- Check permissions - Verify write access to destination folder
- Overwrite handling - Be aware existing files are overwritten without warning
- Formatting preserved - Headers, footers, images, and formatting are all included
- File size - PDFs with many images may be large; consider storage space
Common Errors and Solutions
Error: "Document ID cannot be empty"
Cause: Document ID is missing or undefined
Solution:
- Use Open Document or Create Document before PDF Export
- Verify
$.document_idvariable is set - Check previous nodes executed successfully
Error: "File Path cannot be empty"
Cause: File Path input is missing
Solution:
- Provide a valid file path
- Use absolute paths like
/home/user/file.pdf - Verify variable contains a path value
Error: "Failed to create local file"
Cause: Cannot write to specified path
Solution:
- Check folder exists (create it first if needed)
- Verify write permissions on destination folder
- Ensure path is valid (no invalid characters)
- Check disk space is available
- On Windows, use:
C:\\Users\\Name\\file.pdforC:/Users/Name/file.pdf
Error: "Failed to export document as PDF"
Cause: Google Drive API error or permission issue
Solution:
- Verify account has access to the document
- Check Google Drive API is enabled (required for export)
- Ensure credentials are valid
- Try re-opening the document
- Check for API rate limits
Error: "ErrCredentials" - Missing credentials
Cause: Credentials not provided in Options
Solution:
- Select credentials in the Options field
- Verify OAuth2 or Service Account credentials are configured
- Re-authenticate if using OAuth2
File path issues on different OS
Cause: Path format differs between Windows and Linux
Solution:
- Linux/Mac: Use
/home/user/folder/file.pdf - Windows: Use
C:/Users/Name/folder/file.pdforC:\\Users\\Name\\folder\\file.pdf - Avoid spaces in filenames or use quotes
- Use forward slashes
/for cross-platform compatibility
Integration Patterns
Pattern 1: Automated Report Distribution
Generate and distribute PDFs:
1. Create Document (report template)
↓
2. Insert Text / Replace Text (populate with data)
↓
3. PDF Export (save to shared folder)
↓
4. Send Email (with PDF attachment)
Pattern 2: Document Archive System
Archive documents as PDFs:
For Each document in archive_list:
1. Open Document
↓
2. PDF Export (to archive folder)
↓
3. Log export to database
↓
4. Move to "Archived" status
Pattern 3: Batch PDF Generation
Create multiple PDFs from data:
For Each record in dataset:
1. Create Document (personalized title)
↓
2. Replace Text (fill template with record data)
↓
3. PDF Export (File: record_id + ".pdf")
↓
4. Store PDF path in database
Pattern 4: Backup and Version Control
Create PDF snapshots of documents:
1. Open Document (master document)
↓
2. PDF Export (File: "backup_" + timestamp + ".pdf")
↓
3. Upload to cloud storage
↓
4. Keep last 30 days of backups
Pattern 5: Print-Ready Documents
Generate PDFs for printing:
1. Open Document
↓
2. Add Header (company logo, title)
↓
3. Add Footer (page numbers, date)
↓
4. PDF Export (high-quality for printing)
↓
5. Send to printer or print service
PDF Export Details
What's Included in PDF:
- All text content with formatting (bold, italic, underline, fonts, colors)
- Headers and footers
- Images and drawings
- Tables with formatting
- Hyperlinks (clickable in PDF)
- Page breaks and section breaks
- Document margins and page setup
File Characteristics:
- Format: PDF (Portable Document Format)
- Quality: High-quality, suitable for printing
- Size: Depends on content (images increase size)
- Compatibility: Opens in any PDF reader
- Security: No password protection (add separately if needed)
Platform-Specific Paths
Linux:
/home/username/documents/report.pdf
/var/reports/monthly.pdf
/tmp/export.pdf
Windows:
C:/Users/Username/Documents/report.pdf
D:/Reports/monthly.pdf
C:/Temp/export.pdf
Mac:
/Users/username/Documents/report.pdf
/Users/username/Desktop/export.pdf
Best Practices
- Organize exports - Use folder structures:
/year/month/filename.pdf - Naming conventions - Include dates and identifiers:
report_2024-01-15_ID123.pdf - Check before export - Verify document is ready (all content added)
- Handle errors - Use Try-Catch for export failures
- Cleanup - Delete temporary PDFs after use
- Version control - Keep timestamped versions if needed
- Test paths - Verify file paths work before production use