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

      
templateName: Multipage Table Test templateVersion: 4 templatePriority: 0 detectionRules: keywords: - Sample document with multi-page table objects: - name: total objectType: field fieldProperties: fieldType: macros expression: TOTAL{{Spaces}}({{Number}}) regex: true dataType: decimal - name: table1 objectType: table tableProperties: start: expression: Item{{Spaces}}Description{{Spaces}}Price regex: true end: expression: TOTAL{{Spaces}}{{Number}} regex: true row: expression: '{{LineStart}}{{Spaces}}(?<itemNo>{{Digits}}){{Spaces}}(?<description>{{SentenceWithSingleSpaces}}){{Spaces}}(?<price>{{Number}}){{Spaces}}(?<qty>{{Digits}}){{Spaces}}(?<extPrice>{{Number}})' regex: true columns: - name: itemNo dataType: integer - name: description dataType: string - name: price dataType: decimal - name: qty dataType: integer - name: extPrice dataType: decimal multipage: true

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 }

run.bat

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

VIDEO

ON-PREMISE OFFLINE SDK

Get 60 Day Free Trial

See also:

ON-DEMAND REST WEB API

Get Your API Key

See also:

Related Samples: