From bf5d448e37086aba4e410a579cfc415636a59af5 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 1 Jun 2015 11:45:43 +0800 Subject: [PATCH] :memo: Add BrowserWindow.printToPDF API docs. --- docs/api/browser-window.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 11ac53096038..58e6fa73e35c 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -571,6 +571,32 @@ Calling `window.print()` in web page is equivalent to call doesn't need print feature, you can safely remove `pdf.dll` in saving binary size. +### BrowserWindow.printToPDF([options], callback) + +* `options` Object + * `marginsType` Integer - Specify the type of margins to use + * 0 - default + * 1 - none + * 2 - minimum + * `shouldPrintBackgrounds` Boolean - Whether to print CSS backgrounds. + * `shouldPrintSelectionOnly` Boolean - Whether to print selection only. + * `landscape` Boolean - `true` for landscape, `false` for portrait. + +* `callback` Function - `function(statusCode) {}` + * `statusCode` Integer + * 0 - Success. + * 1 - Fail to generate PDF file on renderer part. + * 2 - Fail to save PDF file on local disk. + * 3 - Users cancel the prompted save file dialog. + +Prints windows' web page as PDF with Chromium's preview printing custom +settings. The API will prompt a SaveDialog to allow user custom the file path +for saving the generated PDF file on disk. + +By default, the options will be +`{marginsType:0, shouldPrintBackgrounds:false, shouldPrintSelectionOnly:false, + landscape:false}`. + ### BrowserWindow.loadUrl(url, [options]) Same with `webContents.loadUrl(url, [options])`.