Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanDeSmedt committed Nov 20, 2017
1 parent 4966378 commit 27a170d
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
PHPHeadlessChrome
===============

[![Latest Stable Version](https://poser.pugx.org/daandesmedt/phpheadlesschrome/v/stable)](https://packagist.org/packages/daandesmedt/phpheadlesschrome)
[![Total Downloads](https://poser.pugx.org/daandesmedt/phpheadlesschrome/downloads)](https://packagist.org/packages/daandesmedt/phpheadlesschrome)
[![License](https://poser.pugx.org/daandesmedt/phpheadlesschrome/license)](https://packagist.org/packages/daandesmedt/phpheadlesschrome)


Headless Chrome is shipping in Chrome 59. It's a way to run the Chrome browser in a headless environment. Essentially, running Chrome without chrome! It brings all modern web platform features provided by Chromium and the Blink rendering engine to the command line.

PHPHeadlessChrome provides a simple usage helper class to create PDF and / or screenshots using Headless Chrome.
Expand Down Expand Up @@ -103,4 +108,56 @@ $headlessChromer->setHTML('<h1>Headless Chrome PHP example</h1><h3>HTML to PDF</
$headlessChromer->toScreenShot('output.jpg');

print 'Screenshot saved to : ' . $headlessChromer->getFilePath();
```



## HTML local file to PDF

```php
<?php

require __DIR__ . '/../vendor/autoload.php';

use daandesmedt\PHPHeadlessChrome\HeadlessChrome;

$headlessChromer = new HeadlessChrome();
$headlessChromer->setBinaryPath('C:\Program Files (x86)\Google\Chrome\Application\chrome');
$headlessChromer->setOutputDirectory(__DIR__);
$headlessChromer->setHTMLFile(__DIR__ . '\assets\HTMLFile.html');
$headlessChromer->toPDF('output.pdf');

print 'PDF generated to : ' . $headlessChromer->getFilePath();
```


## HTML local file to Screenshot (image)

```php
<?php

require __DIR__ . '/../vendor/autoload.php';

use daandesmedt\PHPHeadlessChrome\HeadlessChrome;

$headlessChromer = new HeadlessChrome();
$headlessChromer->setBinaryPath('C:\Program Files (x86)\Google\Chrome\Application\chrome');
$headlessChromer->setOutputDirectory(__DIR__);
$headlessChromer->setHTMLFile(__DIR__ . '\assets\HTMLFile.html');
$headlessChromer->toScreenShot('output.jpg');

print 'Screenshot saved to : ' . $headlessChromer->getFilePath();
```


## Set mobile mode

```php
$headlessChromer->useMobile();
```

## Set window size

```php
$headlessChromer->setWindowSize(375, 667);
```

0 comments on commit 27a170d

Please sign in to comment.