ByteScout Cloud API Server - PDF To Image API - PowerShell - Convert PDF To JPEG From URL Asynchronously - ByteScout

ByteScout Cloud API Server – PDF To Image API – PowerShell – Convert PDF To JPEG From URL Asynchronously

  • Home
  • /
  • Articles
  • /
  • ByteScout Cloud API Server – PDF To Image API – PowerShell – Convert PDF To JPEG From URL Asynchronously

How to convert PDF to JPEG from URL asynchronously for PDF to image API in PowerShell using ByteScout Cloud API Server

Step By Step Instructions on how to convert PDF to JPEG from URL asynchronously for PDF to image API in PowerShell

Quick guide:Learn how to convert PDF to JPEG from URL asynchronously in PowerShell. ByteScout Cloud API Server helps with PDF to image API in PowerShell. ByteScout Cloud API Server is API server that is ready to use and can be installed and deployed in less than 30 minutes on your own Windows server or server in a cloud. It can save data and files on your local server-based file storage or in Amazon AWS S3 storage. Data is processed solely on the API server and is powered by ByteScout engine, no cloud services or Internet connection is required for data processing..

Use the code displayed below in your application to save a lot of time on writing and testing code. For implementation of this functionality, please copy and paste the code below into your app using code editor. Then compile and run your app. Easy to understand tutorials are available along with installed ByteScout Cloud API Server if you’d like to learn more about the topic and the details of the API.

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)

ConvertPdfToJpegFromUrlAsynchronously.ps1
      
# Please NOTE: In this sample we're assuming Cloud Api Server is hosted at "https://localhost". # If it's not then please replace this with with your hosting url. # Cloud API asynchronous "PDF To JPEG" job example. # Allows to avoid timeout errors when processing huge or scanned PDF documents. # Direct URL of source PDF file. $SourceFileUrl = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-to-image/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 = "" # (!) Make asynchronous job $Async = $true # Prepare URL for `PDF To JPEG` API call $query = "https://localhost/pdf/convert/to/jpg?password={0}&pages={1}&url={2}&async={3}" -f ` $Password, $Pages, $SourceFileUrl, $Async $query = [System.Uri]::EscapeUriString($query) try { # Execute request $jsonResponse = Invoke-RestMethod -Method Get -Uri $query if ($jsonResponse.error -eq $false) { # Asynchronous job ID $jobId = $jsonResponse.jobId # URL of generated JSON file available after the job completion; it will contain URLs of result PDF files. $resultJsonFileUrl = $jsonResponse.url # Check the job status in a loop. do { $statusCheckUrl = "https://localhost/job/check?jobid=" + $jobId $jsonStatus = Invoke-RestMethod -Method Get -Uri $statusCheckUrl # Display timestamp and status (for demo purposes) Write-Host "$(Get-date): $($jsonStatus.status)" if ($jsonStatus.status -eq "success") { # Download JSON file with URLs of result PDF files $jsonJpegUrls = Invoke-RestMethod -Method Get -Uri $resultJsonFileUrl # Download generated JPEG files $part = 1; foreach ($url in $jsonJpegUrls) { $localFileName = ".\page$($part).jpg" Invoke-WebRequest -OutFile $localFileName -Uri $url Write-Host "Downloaded `"$($localFileName)`"" $part++ } break } elseif ($jsonStatus.status -eq "working") { # Pause for a few seconds Start-Sleep -Seconds 3 } else { Write-Host $jsonStatus.status break } } while ($true) } 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 ByteScout Cloud API Server Home Page

Explore ByteScout Cloud API Server Documentation

Explore Samples

Sign Up for ByteScout Cloud API Server 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 "& .\ConvertPdfToJpegFromUrlAsynchronously.ps1" echo Script finished with errorlevel=%errorlevel% pause

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Cloud API Server Home Page

Explore ByteScout Cloud API Server Documentation

Explore Samples

Sign Up for ByteScout Cloud API Server 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 Cloud API Server Home Page

Explore ByteScout Cloud API Server Documentation

Explore Samples

Sign Up for ByteScout Cloud API Server Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next