How to PDF text search API in PowerShell with PDF.co Web API
This tutorial will show how to PDF text search API in PowerShell
With this source code sample you may quickly learn how to PDF text search API in PowerShell. PDF.co Web API is the flexible Web API that includes full set of functions from e-signature requests to data extraction, OCR, images recognition, pdf splitting and pdf splitting. Can also generate barcodes and read barcodes from images, scans and pdf. It can be used to PDF text search API using PowerShell.
PowerShell code samples for PowerShell developers help to speed up coding of your application when using PDF.co Web API. Follow the instructions from the scratch to work and copy the PowerShell code. Enjoy writing a code with ready-to-use sample PowerShell codes.
PDF.co Web API free trial version is available on our website. PowerShell and other programming languages are supported.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
GetPdfTextSearchFromUrl.ps1
# The authentication key (API Key). # Get your own by registering at https://app.pdf.co/documentation/api $API_KEY = "***********************************" # Direct URL of PDF file to get information $SourceFileURL = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-to-text/sample.pdf" # Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'. $Pages = "" # PDF document password. Leave empty for unprotected documents. $Password = "" # Search string. $SearchString = '\d{1,}\.\d\d' #Regular expression to find numbers like '100.00' # Enable regular expressions (Regex) $RegexSearch = 'True' # Prepare URL for PDF text search API call. # See documentation: https://app.pdf.co/documentation/api/1.0/pdf/find.html $query = "https://api.pdf.co/v1/pdf/find" # Prepare request body (will be auto-converted to JSON by Invoke-RestMethod) # See documentation: https://apidocs.pdf.co $body = @{ "password" = $Password "pages" = $Pages "url" = $SourceFileURL "searchString" = $SearchString "regexSearch" = $RegexSearch } | ConvertTo-Json try { # Execute request $response = Invoke-WebRequest -Method Post -Headers @{ "x-api-key" = $API_KEY; "Content-Type" = "application/json" } -Body $body -Uri $query $jsonResponse = $response.Content | ConvertFrom-Json if ($jsonResponse.error -eq $false) { # Display search information foreach ($item in $jsonResponse.body) { Write-Host "Found text $($item.text) at coordinates $($item.left), $($item.top)" } } else { # Display service reported error Write-Host $jsonResponse.message } } catch { # Display request error Write-Host $_.Exception }
run.bat
@echo off powershell -NoProfile -ExecutionPolicy Bypass -Command "& .\GetPdfTextSearchFromUrl.ps1" echo Script finished with errorlevel=%errorlevel% pause
VIDEO
ON-PREMISE OFFLINE SDK
See also:
ON-DEMAND REST WEB API
Get Your API Key
See also:
PDF-co-Web-API-PowerShell-PDF-Text-Search-from-URL.pdf