Move PDF printing setting in JS part.
This commit is contained in:
parent
c0a6cb69bf
commit
6e099af5fe
6 changed files with 64 additions and 83 deletions
|
@ -3,6 +3,9 @@ NavigationController = require './navigation-controller'
|
|||
binding = process.atomBinding 'web_contents'
|
||||
ipc = require 'ipc'
|
||||
|
||||
nextId = 0
|
||||
getNextId = -> ++nextId
|
||||
|
||||
wrapWebContents = (webContents) ->
|
||||
# webContents is an EventEmitter.
|
||||
webContents.__proto__ = EventEmitter.prototype
|
||||
|
@ -58,6 +61,46 @@ wrapWebContents = (webContents) ->
|
|||
Object.defineProperty event, 'sender', value: webContents
|
||||
ipc.emit channel, event, args...
|
||||
|
||||
webContents.printToPDF = (options, callback) ->
|
||||
printingSetting =
|
||||
pageRage:[],
|
||||
mediaSize:
|
||||
height_microns:297000,
|
||||
is_default:true,
|
||||
name:"ISO_A4",
|
||||
width_microns:210000,
|
||||
custom_display_name:"A4",
|
||||
landscape:false,
|
||||
color:2,
|
||||
headerFooterEnabled:false,
|
||||
marginsType:0,
|
||||
isFirstRequest:false,
|
||||
requestID: getNextId(),
|
||||
previewModifiable:true,
|
||||
printToPDF:true,
|
||||
printWithCloudPrint:false,
|
||||
printWithPrivet:false,
|
||||
printWithExtension:false,
|
||||
deviceName:"Save as PDF",
|
||||
generateDraftData:true,
|
||||
fitToPageEnabled:false,
|
||||
duplex:0,
|
||||
copies:1,
|
||||
collate:true,
|
||||
shouldPrintBackgrounds:false,
|
||||
shouldPrintSelectionOnly:false
|
||||
|
||||
if options.landscape
|
||||
printingSetting.landscape = options.landscape
|
||||
if options.marginsType
|
||||
printingSetting.marginsType = options.marginsType
|
||||
if options.printSelectionOnly
|
||||
printingSetting.shouldPrintSelectionOnly = options.printSelectionOnly
|
||||
if options.printCSSBackgrounds
|
||||
printingSetting.shouldPrintBackgrounds = options.printBackgrounds
|
||||
|
||||
webContents._printToPDF printingSetting, callback
|
||||
|
||||
webContents
|
||||
|
||||
binding._setWrapWebContents wrapWebContents
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue