Check Whether a PDF Needs OCR Using PDF.co and Zapier

Build a workflow that checks a PDF for extractable text and sends files without text through optical character recognition (OCR).

This is a basic screening method: finding text does not guarantee that every page is searchable. PDFs containing both text and scanned pages need page-by-page checking.

Step 1: Set Up the Google Drive Trigger

Create a Zap with Google Drive → New File in Folder.

Connect your account and select the folder containing incoming PDFs. Test the trigger with a sample file.

Step 2: Check for Existing Text

Add PDF.co → Custom API Call. Connect your PDF.co account using OAuth by signing in and authorizing access.

Configure the action:

  • PDF.co API Endpoint: v1/pdf/convert/to/text-simple
  • URL Input Parameter Override: Map the File value from Google Drive.
  • Input JSON: Enter:
{
  "inline": true,
  "async": false
}

This endpoint extracts existing text without performing OCR, making it suitable for the initial check. Omitting the pages parameter checks all pages. See the PDF to Text (Simple) documentation.

Test the action and confirm that the response is successful. The extracted text appears in the body field. See the Custom API Call documentation for the action settings.

Step 3: Evaluate the Extracted Text

Add Code by Zapier → Run JavaScript.

Under Input Data, create a field named text and map the PDF.co response’s body value to it.

Enter:

const text = String(inputData.text || "").trim();

return {
  textStatus: text.length > 0 ? "text_found" : "no_text"
};

This removes surrounding whitespace before checking for text. Only evaluate successful extraction responses; an API error should not be treated as an empty document.

Step 4: Create Two Paths

Add Paths by Zapier and configure two branches.

Path A: No Text Found

Set the condition so textStatus exactly matches no_text.

Add PDF.co → Convert Scanned PDF to Searchable PDF and configure:

  • Source File URL: Map the original Google Drive File.
  • OCR Language: Select the document’s language.
  • Output File Name: Enter searchable.pdf.

Test the action and open its output URL to confirm that the document’s text can be searched or selected. Refer to the searchable PDF action documentation.

Add Google Drive → Upload File and map the OCR action’s output url to File to save the result.

Path B: Text Found

Set the condition so textStatus exactly matches text_found.

Add Google Drive → Upload File and map the original trigger’s File value to save a copy without running OCR.

Use an output folder separate from the watched input folder for both paths.

Step 5: Test and Publish

Test with an image-only scanned PDF and a PDF containing selectable text. Confirm that each follows the expected path, then publish the Zap.

In this tutorial, you learned how to check if PDF requires OCR using PDF.co and Zapier. You learned how to build a path with different steps and rules. You also learned how to make scanned PDFs searchable.

Related Tutorials

See Related Tutorials