Skip to content

Commit 27a170d

Browse files
committed
Updated README
1 parent 4966378 commit 27a170d

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
PHPHeadlessChrome
22
===============
33

4+
[![Latest Stable Version](https://poser.pugx.org/daandesmedt/phpheadlesschrome/v/stable)](https://packagist.org/packages/daandesmedt/phpheadlesschrome)
5+
[![Total Downloads](https://poser.pugx.org/daandesmedt/phpheadlesschrome/downloads)](https://packagist.org/packages/daandesmedt/phpheadlesschrome)
6+
[![License](https://poser.pugx.org/daandesmedt/phpheadlesschrome/license)](https://packagist.org/packages/daandesmedt/phpheadlesschrome)
7+
8+
49
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.
510

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

105110
print 'Screenshot saved to : ' . $headlessChromer->getFilePath();
111+
```
112+
113+
114+
115+
## HTML local file to PDF
116+
117+
```php
118+
<?php
119+
120+
require __DIR__ . '/../vendor/autoload.php';
121+
122+
use daandesmedt\PHPHeadlessChrome\HeadlessChrome;
123+
124+
$headlessChromer = new HeadlessChrome();
125+
$headlessChromer->setBinaryPath('C:\Program Files (x86)\Google\Chrome\Application\chrome');
126+
$headlessChromer->setOutputDirectory(__DIR__);
127+
$headlessChromer->setHTMLFile(__DIR__ . '\assets\HTMLFile.html');
128+
$headlessChromer->toPDF('output.pdf');
129+
130+
print 'PDF generated to : ' . $headlessChromer->getFilePath();
131+
```
132+
133+
134+
## HTML local file to Screenshot (image)
135+
136+
```php
137+
<?php
138+
139+
require __DIR__ . '/../vendor/autoload.php';
140+
141+
use daandesmedt\PHPHeadlessChrome\HeadlessChrome;
142+
143+
$headlessChromer = new HeadlessChrome();
144+
$headlessChromer->setBinaryPath('C:\Program Files (x86)\Google\Chrome\Application\chrome');
145+
$headlessChromer->setOutputDirectory(__DIR__);
146+
$headlessChromer->setHTMLFile(__DIR__ . '\assets\HTMLFile.html');
147+
$headlessChromer->toScreenShot('output.jpg');
148+
149+
print 'Screenshot saved to : ' . $headlessChromer->getFilePath();
150+
```
151+
152+
153+
## Set mobile mode
154+
155+
```php
156+
$headlessChromer->useMobile();
157+
```
158+
159+
## Set window size
160+
161+
```php
162+
$headlessChromer->setWindowSize(375, 667);
106163
```

0 commit comments

Comments
 (0)