gpt4 book ai didi

node.js - createWriteStream 和路径不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 01:25:47 25 4
gpt4 key购买 nike

我正在尝试创建发票,但由于某种原因,下面的行不起作用:

document.pdfkitDoc.pipe(fs.createWriteStream('./file.pdf')) 

也许是语法问题,我真的不知道它是从 npm 复制的有什么建议 ?

这是我的代码:

var fs = require('fs')
var pdfInvoice = require('pdf-invoice')

router.post('/add', function(req, res) {

const document = pdfInvoice({
company: {
phone: '(99) 9 9999-9999',
email: 'company@evilcorp.com',
address: 'Av. Companhia, 182, Água Branca, Piauí',
name: 'Evil Corp.',
},
customer: {
name: 'Elliot Raque',
email: 'raque@gmail.com',
},
items: [
{amount: 50.0, name: 'XYZ', description: 'Lorem ipsum dollor sit amet', quantity: 12},
{amount: 12.0, name: 'ABC', description: 'Lorem ipsum dollor sit amet', quantity: 12},
{amount: 127.72, name: 'DFE', description: 'Lorem ipsum dollor sit amet', quantity: 12},
],
})



docucment.generate() // triggers rendering
document.pdfkitDoc.pipe(fs.createWriteStream('./file.pdf'))
});

最佳答案

docucment.generate()行有一个拼写错误,它应该是document.generate()

关于node.js - createWriteStream 和路径不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57552909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com