How to Extract Text While Preserving Layout from a PDF Using PDF.co and Zapier
This tutorial explains how to use PDF.co and Zapier to extract text from a PDF while retaining its visual spacing and layout as closely as possible.
The workflow monitors a cloud-storage folder for new PDFs, sends each document to PDF.co, and returns a text file that can be saved or passed to another Zapier action.
Requirements
Before beginning, make sure you have:
- A Zapier account
- A PDF.co account
- A PDF containing text or scanned pages
- A cloud-storage application such as Google Drive or Dropbox
- A destination for the extracted text, if it must be stored permanently
This tutorial uses Google Drive as the example source, but another application that supplies an accessible file can be used.
Step 1: Create the Zap
Sign in to Zapier and create a new Zap.
For the trigger application, select Google Drive.
Choose New File in Folder or New File in Folder (Realtime), depending on which event is available for your account.
Connect your Google Drive account, then select the drive and folder that will receive the source PDFs.
Test the trigger and choose a sample PDF. Confirm that Zapier retrieves the file and its associated information.
If the folder might contain other file types, add a Filter by Zapier step. Continue only when the filename ends in .pdf or the MIME type is application/pdf.
Step 2: Add the PDF.co Action
Add an action and select PDF.co.
Choose PDF to Anything Converter as the action event.
Connect your PDF.co account through OAuth:
- Select Connect a new account.
- Sign in to PDF.co if prompted.
- Review and authorize Zapier’s access.
- Return to Zapier and select the connected PDF.co account.
Do not copy an API key into the Zapier connection.
Step 3: Configure Text Extraction
Configure the PDF.co action using the following settings:
- Output Format: Select Plain Text.
- Source File URL: Map the PDF file from the Google Drive trigger.
- Page Selection: Leave blank to process the entire document, or enter the required page indexes.
- OCR Language: Select the document language if the PDF contains scanned pages.
- Enable Line Grouping: Enable this when it improves the grouping of related lines or table content.
- Unwrap: Leave disabled when preserving the document’s original line structure is important.
- File Name: Enter an output name if the field is available.
PDF.co uses zero-based page indexing. For example:
0processes the first page.0,2processes the first and third pages.0-2processes the first three pages.- An empty value processes all pages.
When mapping a Google Drive file, use the file output supplied by the trigger whenever possible. If PDF.co requires a URL, use a direct downloadable URL that PDF.co can access—not a browser preview page.
Step 4: Preserve the Text Layout
To retain the original spacing and text arrangement more closely, enter the following in Custom Profiles:
{
"TrimSpaces": true,
"PreserveFormattingOnTextExtraction": true
}This setting asks PDF.co to preserve formatting during text extraction. The result is still a plain-text file, so it cannot retain visual elements such as fonts, colors, images, or exact PDF positioning. It can, however, preserve spacing and line structure more effectively than unformatted extraction.
If your downstream system needs structured text objects, coordinates, font information, or tables rather than a plain-text representation, select an appropriate JSON or CSV output instead.
Step 5: Test the PDF.co Action
Test the action and review the response.
A successful result should include:
- A successful status
- The output filename
- A URL for the extracted text
- The number of processed pages
- Information about the output link’s expiration
Open the output URL and verify that:
- The expected pages were processed.
- The text is readable.
- Lines and columns are arranged acceptably.
- OCR recognized text from scanned pages correctly.
- Important content is not missing.
If the document contains scanned pages and little or no text is returned, verify the OCR language and try a suitable OCR configuration.
Step 6: Save or Use the Extracted Text
PDF.co returns a temporary output URL. Add another Zapier action if the extracted text must be kept permanently.
For example, add Google Drive – Upload File and configure:
- Drive: Select the destination drive.
- Folder: Select the output folder.
- File: Map the result URL returned by PDF.co.
- File Name: Enter a name ending in
.txt.
You can also pass the extracted text to another step, such as:
- Google Sheets
- Gmail
- A database
- A document-management system
- An AI analysis or summarization action
Use a different destination folder from the trigger folder to avoid accidentally starting the Zap again.
Step 7: Publish the Zap
After every step tests successfully, publish or turn on the Zap.
Upload a new PDF to the monitored folder and confirm that:
- The trigger detects the PDF.
- PDF.co extracts the text.
- The output preserves an acceptable amount of the original layout.
- The extracted text is saved or sent to the intended destination.
Step 8: Troubleshooting
PDF.co Cannot Access the PDF
Map the actual file output from the trigger. If you must use a URL, confirm that it is directly downloadable and does not require an interactive sign-in.
Text Is Missing from Scanned Pages
Select the appropriate OCR language. If necessary, configure a custom OCR mode through Custom Profiles.
Columns Are Not Preserved Correctly
Try enabling line grouping. For complex tables, consider CSV or JSON output instead of plain text.
Unwanted Spaces Appear in the Output
Keep TrimSpaces enabled. If the remaining spaces are required to preserve columns, avoid additional cleanup that collapses all whitespace.
The Output Link No Longer Works
PDF.co result links are temporary. Add a storage action to copy the text file to Google Drive, Dropbox, or another permanent destination.
About XPS Files
The current PDF.co PDF-to-Text documentation describes PDF documents and scanned images as supported inputs. If your source is an XPS file, convert it to PDF first using a compatible conversion action, then pass the resulting PDF to PDF to Anything Converter for text extraction.
Conclusion
You have created a Zap that extracts text from PDF documents with PDF.co while preserving the original spacing and layout where possible. The extracted text can be saved as a text file or passed directly to another automation step for storage, analysis, or processing.
Related Tutorials

