Below is an end-to-end example of submitting a Convert request using Perl programming language:


# Simple script to make and process the results of a Conversion request to the LEADTOOLS CloudServices.
# In order to run this script, the following changes will need to be added:
#	1) Place your Application ID in the $appId variable.
#	2) Place your Application Password in the $password variable
# The script will perform the following operations in order:
#	1)Perform a Conversion request to the LEADTOOLS CloudServices.  A successfully made request will return a unique identifier.
#	2)We will then query the services using the GUID -- if the file is finished processing, the body will contain all the 
#	  request data.
#	3)We will take the json data that was returned, parse it, and display all the information that was returned.     
#
#
# This script makes use of the following Perl libraries:
#	1) Http-Message - http://search.cpan.org/~oalders/HTTP-Message-6.15/
#	2) libwww-perl  - http://search.cpan.org/~oalders/libwww-perl-6.33/
#	3) JSON-Parse   - http://search.cpan.org/~bkb/JSON-Parse-0.55/
#	4) Try-Tiny     - http://search.cpan.org/~ether/Try-Tiny-0.30/

use base 'HTTP::Message';
use HTTP::Request::Common;
use LWP::UserAgent ();
use JSON::Parse ':all';
use Try::Tiny;

require HTTP::Request;
require HTTP::Headers;

my $servicesUrl = "https://azure.leadtools.com/api/";

#The first page in the file to mark for processing
my $firstPage = 1;

#Sending a value of -1 will indicate to the services that the rest of the pages in the file should be processed.
my $lastPage = -1;

#Enum corresponding to the output format for the file. For the purposes of this script, we will be converting to tif.
my $format = 3;

my $appId = 'Replace with Application ID';
my $password = 'Replace with Application Password';

#If uploading via a URL,  the Content_length needs to be set to 0.
#If you are passing a file as multi-part content, the Content_Length does not need to be predefined.
my $headers = HTTP::Headers->new(
    Content_Length => 0
);
$headers->authorization_basic($appId, $password);

#The User Agent to be used when making requests
my $ua = LWP::UserAgent->new;

#We will be uploading the file via a URL.  Files can also be passed by adding a PostFile to the request.  Only 1 file will be accepted per request.
#The services will use the following priority when determining what a request is trying to do GUID > URL > Request Body Content
my $fileURL = 'https://demo.leadtools.com/images/pdf/leadtools.pdf';
my $conversionUrl = $servicesUrl . 'Conversion/Convert?firstPage=' . $firstPage . '&lastPage=' . $lastPage . '&format=' . $format . '&fileurl=' . $fileURL;
my $request = POST $conversionUrl,
   Content =>[];

#If uploading a file as multi-part content:
#my $conversionUrl = $servicesUrl . 'Conversion/Convert?firstPage=' . $firstPage . '&lastPage=' . $lastPage . '&format=' . $format;
#my $request = POST $conversionUrl,
#    Content_Type => 'form-data',
#    Content=>[
#        FILE => [ "path/to/input/file" ]
#    ];

$request->authorization_basic($appId, $password);

my $response = $ua->request($request);
if(!$response->is_success){
    print STDERR $response->status_line, "\n";
    exit;
}

$guid = $response->decoded_content;
print("Unique ID returned by the services: " . $guid . "\n");


my $queryUrl = $servicesUrl . 'Query?id=' . $guid;
while(true){
    $request = HTTP::Request->new(POST => $queryUrl, $headers);
    $response = $ua->request($request);

    $returnedData = parse_json($response->decoded_content);
    if($returnedData->{'FileStatus'} != 100 && $returnedData->{'FileStatus'} != 123){
        last;
    }
    sleep(5);
}

print("File finished processing with file status: " . $returnedData->{'FileStatus'} . "\n");


try{
    # The file did not process successfully.  Refer to our documentation for the full list of File Statuses and their associated meanings.
    if($returnedData->{'FileStatus'} != 200){
        exit;
    }
    print("Results: \n");  
    $parsedResponse = $returnedData->{'RequestData'};
    foreach my $serviceResults (@$parsedResponse){
        print "Service Type: " . $serviceResults->{'ServiceType'} . "\n";
        $urls = $serviceResults->{'urls'}; 
        print "URL List: \n";
        foreach my $url (@$urls){
            print $url . "\n";
        }       
    }
}catch{
    print "Failed to parse JSON: " . 

Perl Conversion Tutorial

Below is an end-to-end example of submitting a Convert request using Perl programming language:

; }