setPage() public method

Add a page object to the output
public setPage ( string $page ) : static
$page string either a URL, a HTML string or a filename
return static the Image instance for method chaining
コード例 #1
0
ファイル: ImageFactory.php プロジェクト: shlinkio/shlink
 /**
  * Create an object
  *
  * @param  ContainerInterface $container
  * @param  string $requestedName
  * @param  null|array $options
  * @return object
  * @throws ServiceNotFoundException if unable to resolve the service.
  * @throws ServiceNotCreatedException if an exception is raised when
  *     creating a service.
  * @throws ContainerException if any other error occurs
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $config = $container->get('config')['phpwkhtmltopdf'];
     $image = new Image(isset($config['images']) ? $config['images'] : null);
     if (isset($options) && isset($options['url'])) {
         $image->setPage($options['url']);
     }
     return $image;
 }
コード例 #2
0
ファイル: ImageTest.php プロジェクト: renatofb/phpwkhtmltopdf
 public function testCanUseXvfbRun()
 {
     $inFile = $this->getHtmlAsset();
     $outFile = $this->getOutFile('png');
     $binary = $this->getBinary();
     $image = new Image(array('binary' => $binary, 'commandOptions' => array('enableXvfb' => true)));
     $this->assertInstanceOf('mikehaertl\\wkhtmlto\\Image', $image->setPage($inFile));
     $this->assertTrue($image->saveAs($outFile));
     $tmpFile = $image->getImageFilename();
     $command = (string) $image->getCommand();
     $this->assertEquals("xvfb-run --server-args=\"-screen 0, 1024x768x24\" {$binary} '{$inFile}' '{$tmpFile}'", $command);
     unlink($outFile);
 }