ByteScout PDF Suite - Powershell - Convert PDF To JSON with PDF Extractor SDK - ByteScout

ByteScout PDF Suite – Powershell – Convert PDF To JSON with PDF Extractor SDK

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Suite – Powershell – Convert PDF To JSON with PDF Extractor SDK

How to convert PDF to JSON with PDF extractor SDK in Powershell with ByteScout PDF Suite

This code in Powershell shows how to convert PDF to JSON with PDF extractor SDK with this how to tutorial

ByteScout simple and easy to understand tutorials are planned to describe the code for both Powershell beginners and advanced programmers. ByteScout PDF Suite can convert PDF to JSON with PDF extractor SDK. It can be applied from Powershell. ByteScout PDF Suite is the set that includes 6 SDK products to work with PDF from generating rich PDF reports to extracting data from PDF documents and converting them to HTML. This bundle includes PDF (Generator) SDK, PDF Renderer SDK, PDF Extractor SDK, PDF to HTML SDK, PDF Viewer SDK and PDF Generator SDK for Javascript.

These Powershell code samples for Powershell guide developers to speed up coding of the application when using ByteScout PDF Suite. Follow the instructions from scratch to work and copy the Powershell code. Enjoy writing a code with ready-to-use sample codes in Powershell.

Our website gives trial version of ByteScout PDF Suite for free. It also includes documentation and source code samples.

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

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

pdf-to-json.bat
      
@echo off if "%~1"=="" ( echo ----------------------------------------------------- echo Invalid parameter! echo ----------------------------------------------------- echo Usage: pdf-to-json.bat folder_path echo Example: pdf-to-json.bat "c:\documents" echo ----------------------------------------------------- if not "%NOPAUSE%"=="1" pause exit /b 1 ) powershell -NoProfile -ExecutionPolicy Bypass -Command "& .\pdf-to-json.ps1" "%1" echo Script finished with errorlevel=%errorlevel% pause

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

pdf-to-json.ps1
      
Param( [Parameter(Mandatory = $true)] [string] $InputFolder = "" ) # Add reference to Bytescout.PDFExtractor.dll assembly Add-Type -Path "c:\Program Files\Bytescout PDF Extractor SDK\net4.00\Bytescout.PDFExtractor.dll" # Check input folder exists if ((Test-Path $InputFolder) -eq $false) { Write-Host "Target folder does not exist." -ForegroundColor Red exit 0 } # Create and activate JSONExtractor instance $jsonExtractor = New-Object Bytescout.PDFExtractor.JSONExtractor $jsonExtractor.RegistrationName = "demo" $jsonExtractor.RegistrationKey = "demo" try { # Get PDF files from input folder $files = Get-ChildItem -Path $InputFolder -Recurse -Include "*.pdf" foreach ($file in $files) { Write-Host "Input file" $file.FullName # Construct output file name $jsonFileName = [System.IO.Path]::ChangeExtension($file.FullName, "json") Write-Host " Output file" $jsonFileName # Load PDF document $jsonExtractor.LoadDocumentFromFile($file.FullName) # Disable the formatting reconstruction $jsonExtractor.PreserveFormattingOnTextExtraction = $false # Extract first page to JSON $jsonExtractor.SaveJSONToFile(0, $jsonFileName) # Reset extractor $jsonExtractor.Reset() } } catch { Write-Host $_.Exception.Message } $jsonExtractor.Dispose()

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite 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 ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next