How to parse from url for document parser API in Powershell and PDF.co Web API

Step By Step Instructions on how to parse from url for document parser API in Powershell

Writing of the code to parse from url in Powershell can be done by developers of any level using PDF.co Web API. PDF.co Web API was designed to assist document parser API in Powershell. PDF.co Web API is the Rest API that provides set of data extraction functions, tools for documents manipulation, splitting and merging of pdf files. Includes built-in OCR, images recognition, can generate and read barcodes from images, scans and pdf.

Powershell code snippet like this for PDF.co Web API works best when you need to quickly implement document parser API in your Powershell application. For implementation of this functionality, please copy and paste the code below into your app using code editor. Then compile and run your app. Check Powershell sample code examples to see if they respond to your needs and requirements for the project.

Trial version of ByteScout is available for free download from our website. This and other source code samples for Powershell and other programming languages are available.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

MultiPageTable-template1.yml
      
--- # Template that demonstrates parsing of multi-page table using only # regular expressions for the table start, end, and rows. # If regular expression cannot be written for every table row (for example, # if the table contains empty cells), try the second method demonstrated # in 'MultiPageTable-template2.yml' template. templateVersion: 2 templatePriority: 0 sourceId: Multipage Table Test detectionRules: keywords: - Sample document with multi-page table fields: total: expression: TOTAL {{DECIMAL}} tables: - name: table1 start: # regular expression to find the table start in document expression: Item\s+Description\s+Price\s+Qty\s+Extended Price end: # regular expression to find the table end in document expression: TOTAL\s+\d+\.\d\d row: # regular expression to find table rows expression: '^\s*(?<itemNo>\d+)\s+(?<description>.+?)\s+(?<price>\d+\.\d\d)\s+(?<qty>\d+)\s+(?<extPrice>\d+\.\d\d)' columns: - name: itemNo type: integer - name: description type: string - name: price type: decimal - name: qty type: integer - name: extPrice type: decimal multipage: true

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit PDF.co Web API Home Page

Explore PDF.co Web API Documentation

Explore Samples

Sign Up for PDF.co Web API Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

ParseFromUrl.ps1
      
# The authentication key (API Key). # Get your own by registering at https://app.pdf.co/documentation/api $API_KEY = "***********************************" # Source PDF file url $SourceFileUrl = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/document-parser/MultiPageTable.pdf" # Destination JSON file name $DestinationFile = ".\result.json" try { # Parse url # Template text. Use Document Parser SDK (https://bytescout.com/products/developer/documentparsersdk/index.html) # to create templates. # Read template from file: $templateContent = [IO.File]::ReadAllText(".\MultiPageTable-template1.yml") # Prepare URL for `Document Parser` API call $query = "https://api.pdf.co/v1/pdf/documentparser" # Content $Body = @{ "url" = $SourceFileUrl; "template" = $templateContent; } # Execute request $jsonResponse = Invoke-RestMethod -Method 'Post' -Headers @{ "x-api-key" = $API_KEY } -Uri $query -Body ($Body|ConvertTo-Json) -ContentType "application/json" if ($jsonResponse.error -eq $false) { # Get URL of generated HTML file $resultFileUrl = $jsonResponse.url; # Download output file Invoke-WebRequest -Headers @{ "x-api-key" = $API_KEY } -OutFile $DestinationFile -Uri $resultFileUrl Write-Host "Generated output file saved as `"$($DestinationFile)`" file." } else { # Display service reported error Write-Host $jsonResponse.message } } catch { # Display request error Write-Host $_.Exception }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit PDF.co Web API Home Page

Explore PDF.co Web API Documentation

Explore Samples

Sign Up for PDF.co Web API Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

run.bat
      
@echo off powershell -NoProfile -ExecutionPolicy Bypass -Command "& .\ParseFromUrl.ps1" echo Script finished with errorlevel=%errorlevel% pause

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit PDF.co Web API Home Page

Explore PDF.co Web API Documentation

Explore Samples

Sign Up for PDF.co Web API Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit PDF.co Web API Home Page

Explore PDF.co Web API Documentation

Explore Samples

Sign Up for PDF.co Web API Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Related Samples: