-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated dependencies, php compatibility, no longer tied to phantomjs * Added docs for puppeteer * Use composer's phpunit for travis * Fixed phpunit test case namespace * Fixed psr4 config
- Loading branch information
Showing
15 changed files
with
136 additions
and
229 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
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
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
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 was deleted.
Oops, something went wrong.
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
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,48 @@ | ||
# Add puppeteer | ||
|
||
`yarn add puppeteer` or `npm i puppeteer` | ||
|
||
# Create a script | ||
- **Symfony 4:** assets/rasterize.js | ||
- **Symfony 3:** web/rasterize.js | ||
|
||
```js | ||
const puppeteer = require('puppeteer'); | ||
const fs = require('fs'); | ||
|
||
let stdinBuffer = fs.readFileSync(0 /* STDIN_FILENO */, 'utf8'); | ||
let html = stdinBuffer.toString(); | ||
|
||
const args = process.argv; | ||
const format = args[2]; | ||
|
||
(async () => { | ||
const browser = await puppeteer.launch({ | ||
ignoreHTTPSErrors: true | ||
}); | ||
const page = await browser.newPage(); | ||
|
||
// https://github.com/GoogleChrome/puppeteer/issues/728 | ||
// await page.setContent(html); | ||
// await page.waitForNavigation({ waitUntil: 'networkidle0' }); | ||
|
||
await page.goto('data:text/html,' + html, { waitUntil: 'networkidle0' }); | ||
|
||
if (format == 'pdf') { | ||
await page.pdf({ | ||
path: 1, // STDOUT_FILENO | ||
format: 'A4', | ||
printBackground: true, | ||
margin: { top: '1cm', right: '1cm', bottom: '1cm', left: '1cm' } | ||
}); | ||
} else { | ||
await page.screenshot({ | ||
path: 1, // STDOUT_FILENO | ||
type: format, | ||
quality: 100, | ||
}); | ||
} | ||
|
||
await browser.close(); | ||
})(); | ||
``` |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.