简体   繁体   中英

Append text to existing PDF File electron node.js

I am generating pdf file from selected text in electron. But I want to append text in this pdf file but it overwrites the file each time. Is there any way that text will be appended to PDF file at end?

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);
                            }
                        })
                });

Try using fs.appendFileSync() instead of fs.writeFileSync

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM