最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

将文本附加到现有的PDF File电子node.js

IT培训 admin 3浏览 0评论

将文本附加到现有的PDF File电子node.js

我正在从电子中的选定文本生成pdf文件。但是我想在此pdf文件中添加文字,但每次都会覆盖该文件。是否可以通过任何方式将文本附加到PDF文件的末尾?

win.once('ready-to-show', () => {
                  win.webContents.printToPDF(pdfSettings(), function(err, data) {
                            win.close();
                            if (err) {
                                //do whatever you want
                                return;
                            }
                            try{
                                fs.writeFileSync(filename, data);
                                console.log("save");
                            }catch(err){
                                //unable to save pdf..
                                console.log("unable to save" + err);
                            }
                        })
                });
回答如下:

尝试使用fs.appendFileSync()代替fs.writeFileSync

将文本附加到现有的PDF File电子node.js

我正在从电子中的选定文本生成pdf文件。但是我想在此pdf文件中添加文字,但每次都会覆盖该文件。是否可以通过任何方式将文本附加到PDF文件的末尾?

win.once('ready-to-show', () => {
                  win.webContents.printToPDF(pdfSettings(), function(err, data) {
                            win.close();
                            if (err) {
                                //do whatever you want
                                return;
                            }
                            try{
                                fs.writeFileSync(filename, data);
                                console.log("save");
                            }catch(err){
                                //unable to save pdf..
                                console.log("unable to save" + err);
                            }
                        })
                });
回答如下:

尝试使用fs.appendFileSync()代替fs.writeFileSync

发布评论

评论列表 (0)

  1. 暂无评论