Merge pull request #2019 from atom/pdf-api-doc
Add usage sample code of printToPDF API.
This commit is contained in:
commit
3519dd96ee
1 changed files with 20 additions and 1 deletions
|
@ -980,10 +980,29 @@ size.
|
|||
Prints windows' web page as PDF with Chromium's preview printing custom
|
||||
settings.
|
||||
|
||||
By default, the options will be
|
||||
By default, an empty `options` will be regarded as
|
||||
`{marginsType:0, printBackgrounds:false, printSelectionOnly:false,
|
||||
landscape:false}`.
|
||||
|
||||
```javascript
|
||||
var BrowserWindow = require('browser-window');
|
||||
var fs = require('fs');
|
||||
|
||||
var win = new BrowserWindow({width: 800, height: 600});
|
||||
win.loadUrl("http://github.com");
|
||||
|
||||
win.webContents.on("did-finish-load", function() {
|
||||
// Use default printing options
|
||||
win.webContents.printToPDF({}, function(error, data) {
|
||||
if (error) throw error;
|
||||
fs.writeFile(dist, data, function(error) {
|
||||
if (err)
|
||||
alert('write pdf file error', error);
|
||||
})
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
### WebContents.send(channel[, args...])
|
||||
|
||||
* `channel` String
|
||||
|
|
Loading…
Reference in a new issue