【发布时间】:2016-09-21 07:13:41
【问题描述】:
我正在尝试使用 Nightmarejs 从我的服务器下载一份 PDF。我已通过节点模块将其安装为:-
npm install nightmare
并写下以下代码:-
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: false})
nightmare
.goto(url) // url of my site
.size()
.type('[name=email]', '')
.type('[name=email]', 'test@gmail.com')
.type('[name=password]', 'test')
.click('#signInSubmit')
.wait(2000)
.pdf("test.pdf")
.evaluate(function () {
return document
})
.end()
.then(function (result) {
console.log(result)
})
.catch(function (error) {
console.error('Search failed:', error);
});
它会将 PDF 文件保存到我的当前目录中,但由于我还将电子设置为 false,它不会显示浏览器,但会显示打印机设置提示进行打印,我只是不需要出现该提示。我只想知道我怎样才能做到这一点。当我用谷歌搜索时,它会给我设置静默为真,但我不知道我应该在哪里设置静默真选项。
var nightmare = Nightmare({ show: false})
我的意思是如何以及在哪里配置噩梦 js 脚本文件中的电子设置。
【问题讨论】:
标签: node.js pdf-generation electron nightmare