PHP Classes

File: test.php

Recommend this page to a friend!
  Packages of Select Pdf   SelectPdf Online REST API PHP PDF Library Client   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Example script
Class: SelectPdf Online REST API PHP PDF Library Client
Manipulate PDF documents using the SelectPDF API
Author: By
Last change:
Date: 4 years ago
Size: 806 bytes
 

 

Contents

Class file image Download
<?php
require("SelectPdf.Api.php");

$url = 'https://selectpdf.com';
$outFile = "test.pdf";

try {
    $api = new SelectPdf\Api\HtmlToPdfClient("Your key here");

    $api
        ->setPageSize(SelectPdf\Api\PageSize::A4)
        ->setPageOrientation(SelectPdf\Api\PageOrientation::Portrait)
        ->setMargins(0)
        ->setNavigationTimeout(30)
        ->setShowPageNumbers(false)
        ->setPageBreaksEnhancedAlgorithm(true)
    ;

    echo ("Starting conversion ...");
    
    $api->convertUrlToFile($url, $outFile);

    echo ("Conversion finished successfully!");

    $usage = new \SelectPdf\Api\UsageClient("Your key here");
    $info = $usage->getUsage(true);
    echo("Conversions left this month: " . $info["available"]);

}
catch (Exception $ex) {
    echo "An error occurred: " . $ex;
}
?>