You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a library for creating PDFs from HTML rendered with the SkPDF backend via Chrome. In order to do this, you can opt to use one of the supported drivers:
If you are planning to use the [`chrome-pdf`](https://github.com/SynergiTech/chrome-pdf) driver to render PDFs locally, you should also make sure to install this from npm.
17
18
18
-
### browserless
19
-
If you are planning to use the [browserless](https://www.browserless.io/) driver to render PDFs remotely, you should register for an API key. Remember that local assets cannot be rendered by browserless.
19
+
### Browserless
20
+
If you are planning to use the [Browserless](https://www.browserless.io/) driver to render PDFs remotely or take screenshots, you should register for an API key. Remember that local assets cannot be rendered by Browserless.
20
21
21
22
## Usage
22
23
A common interface is provided via AbstractPDF. The options presented via this class will be available from all drivers.
@@ -33,5 +34,31 @@ $pdf = new Browserless('your-api-key');
33
34
$pdf->renderContent('<h1>test</h1>');
34
35
```
35
36
37
+
### Advanced Browserless Usage
38
+
39
+
You can optionally use specific endpoints when you create a client.
40
+
41
+
```php
42
+
use SynergiTech\ChromePDF\Browserless;
43
+
44
+
$pdf = new Browserless('your-api-key', Browserless\EndpointsEnum::London);
45
+
```
46
+
47
+
As this library essentially functions as an API client for Browserless, we have also implemented the screenshot API.
48
+
49
+
```php
50
+
use SynergiTech\ChromePDF\Browserless;
51
+
52
+
// For information on options, see https://www.browserless.io/docs/screenshot#custom-options.
53
+
// `render()` defaults to using png and fullPage set to false
54
+
// but jpegs will get a quality of 75 set if you don't set one
55
+
$file = new Browserless\Screenshot('your-api-key');
56
+
$file->render('https://example.com');
57
+
$file->render('https://example.com', [
58
+
'fullPage' => true,
59
+
'type' => 'jpeg',
60
+
]);
61
+
```
62
+
36
63
## Examples
37
64
Some examples can be found in the `examples` folder.
0 commit comments