-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
262 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
//include the autoloader | ||
require_once('../vendor/autoload.php'); | ||
//if manual installation has been used comment line that requires the autoload and uncomment this line: | ||
//require_once('../init.php'); | ||
|
||
|
||
use Ilovepdf\HtmlpdfTask; | ||
|
||
|
||
// you can call task class directly | ||
// to get your key pair, please visit https://developer.ilovepdf.com/user/projects | ||
$myTask = new HtmlpdfTask('project_public_id','project_secret_key'); | ||
|
||
// file var keeps info about server file id, name... | ||
// it can be used latter to cancel file | ||
$file = $myTask->addUrl('https://ilovepdf.com'); | ||
|
||
// set page margin | ||
$myTask->setPageMargin(20); | ||
|
||
// set one large page | ||
$myTask->setSinglePage(true); | ||
|
||
// and set name for output file. | ||
// the task will set the correct file extension for you. | ||
$myTask->setOutputFilename('ilovepdf_web'); | ||
|
||
// process files | ||
$myTask->execute(); | ||
|
||
// and finally download file. If no path is set, it will be downloaded on current folder | ||
$myTask->download('path/to/download'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
//include the autoloader | ||
require_once('../vendor/autoload.php'); | ||
//if manual installation has been used comment line that requires the autoload and uncomment this line: | ||
//require_once('../init.php'); | ||
|
||
use Ilovepdf\HtmlpdfTask; | ||
|
||
|
||
// you can call task class directly | ||
// to get your key pair, please visit https://developer.ilovepdf.com/user/projects | ||
$myTask = new HtmlpdfTask('project_public_id','project_secret_key'); | ||
|
||
// file var keeps info about server file id, name... | ||
// it can be used latter to cancel file | ||
$file = $myTask->addUrl('https://ilovepdf.com'); | ||
|
||
// process files | ||
$myTask->execute(); | ||
|
||
// and finally download file. If no path is set, it will be downloaded on current folder | ||
$myTask->download(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
|
||
namespace Ilovepdf; | ||
|
||
/** | ||
* Class CompressTask | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<?php | ||
|
||
namespace Ilovepdf; | ||
|
||
/** | ||
* Class CompressTask | ||
* Class ExtractTask | ||
* | ||
* @package Ilovepdf | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
<?php | ||
|
||
namespace Ilovepdf; | ||
/** | ||
* Class Ilovepdf | ||
* | ||
* @package Ilovepdf | ||
*/ | ||
class HtmlpdfTask extends Task | ||
{ | ||
/** | ||
* Viewer width | ||
* @var integer | ||
*/ | ||
public $view_width = 1920; | ||
|
||
/** | ||
* Viewer height | ||
* @var integer | ||
*/ | ||
public $view_height; | ||
|
||
/** | ||
* Time to waith for page response | ||
* - default is 10 | ||
* | ||
* @var integer | ||
*/ | ||
public $navigation_timeout = 10; | ||
|
||
/** | ||
* Time to wait for javscript execution in page | ||
* - value must be between 0 and 5 | ||
* - default is 2 | ||
* | ||
* @var integer | ||
*/ | ||
public $delay = 2; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $page_size; | ||
|
||
private $pageSizeValues = ['A3', 'A4', 'A5', 'A6', 'Letter']; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $page_orientation; | ||
|
||
private $pageOrientationyValues = ['portrait', 'landscape']; | ||
|
||
/** | ||
* Pixels for page margin | ||
* @var integer | ||
*/ | ||
public $page_margin = 0; | ||
|
||
/** | ||
* Remove z-index (high value) based elements | ||
* | ||
* @var boolean | ||
*/ | ||
public $remove_popups; | ||
|
||
/** | ||
* @var boolean | ||
*/ | ||
public $single_page; | ||
|
||
/** | ||
* AddnumbersTask constructor. | ||
* | ||
* @param null|string $publicKey Your public key | ||
* @param null|string $secretKey Your secret key | ||
* @param bool $makeStart Set to false for chained tasks, because we don't need the start | ||
*/ | ||
function __construct($publicKey, $secretKey, $makeStart = true) | ||
{ | ||
$this->tool = 'htmlpdf'; | ||
parent::__construct($publicKey, $secretKey, $makeStart); | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* @param int $view_width | ||
* @return HtmlpdfTask | ||
*/ | ||
public function setViewWidth(int $view_width): HtmlpdfTask | ||
{ | ||
$this->view_width = $view_width; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param int $view_height | ||
* @return HtmlpdfTask | ||
*/ | ||
public function setViewHeight(int $view_height): HtmlpdfTask | ||
{ | ||
$this->view_height = $view_height; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param int $navigation_timeout | ||
* @return HtmlpdfTask | ||
*/ | ||
public function setNavigationTimeout(int $navigation_timeout): HtmlpdfTask | ||
{ | ||
if ($navigation_timeout < 0 && $navigation_timeout > 20) { | ||
new \InvalidArgumentException('Delay must be under 5 seconds'); | ||
} | ||
$this->navigation_timeout = $navigation_timeout; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param int $delay | ||
* @return HtmlpdfTask | ||
*/ | ||
public function setDelay(int $delay): HtmlpdfTask | ||
{ | ||
if ($delay < 0 && $delay > 5) { | ||
new \InvalidArgumentException('Delay must be under 5 seconds'); | ||
} | ||
$this->delay = $delay; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param string $page_size | ||
* @return HtmlpdfTask | ||
*/ | ||
public function setPageSize(string $page_size): HtmlpdfTask | ||
{ | ||
$this->checkValues($page_size, $this->pageSizeValues); | ||
$this->page_size = $page_size; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param string $page_orientation | ||
* @return HtmlpdfTask | ||
*/ | ||
public function setPageOrientation(string $page_orientation): HtmlpdfTask | ||
{ | ||
$this->checkValues($page_orientation, $this->pageOrientationyValues); | ||
|
||
$this->page_orientation = $page_orientation; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param int $page_margin | ||
* @return HtmlpdfTask | ||
*/ | ||
public function setPageMargin(int $page_margin): HtmlpdfTask | ||
{ | ||
$this->page_margin = $page_margin; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param bool $remove_popups | ||
* @return HtmlpdfTask | ||
*/ | ||
public function setRemovePopups(bool $remove_popups): HtmlpdfTask | ||
{ | ||
$this->remove_popups = $remove_popups; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param bool $single_page | ||
* @return HtmlpdfTask | ||
*/ | ||
public function setSinglePage(bool $single_page): HtmlpdfTask | ||
{ | ||
$this->single_page = $single_page; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Add an url to process. | ||
* | ||
* @param string $url | ||
* @return File|mixed | ||
*/ | ||
public function addUrl($url) | ||
{ | ||
return $this->addFileFromUrl($url); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
|
||
/** | ||
* Class Ilovepdf | ||
* Class ImagepdfTask | ||
* | ||
* @package Ilovepdf | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
namespace Ilovepdf; | ||
/** | ||
* Class CompressTask | ||
* Class PdfaTask | ||
* | ||
* @package Ilovepdf | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
namespace Ilovepdf; | ||
/** | ||
* Class LockTask | ||
* Class ProtectTask | ||
* | ||
* @package Ilovepdf | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
namespace Ilovepdf; | ||
/** | ||
* Class CompressTask | ||
* Class ValidatepdfaTask | ||
* | ||
* @package Ilovepdf | ||
*/ | ||
|