where is the "merged.pdf" saved ?
Closed this issue · 3 comments
I try to merged some PDFs which i get as Base64 String first. I convert them with the "atob()"-Function and try then to merge them. But i dont get any Response after the save of the "merged.pdf". Where is this saved PDF and how can i download it ? Can someone help me ?
const PDFMerger = require("pdf-merger-js");
var merger = new PDFMerger();
JsonPDFs.forEach((element) => {
atob(element);
});
(async () => {
JsonPDFs.forEach((element) => {
merger.add(element);
await merger.save("merged.pdf");
});
})();
("JsonPDFS" is a Json array with all PDFs to merge as Base64 Strings)
@flecke-anaptis I would recommend something like the following code:
const PDFMerger = require("pdf-merger-js");
(async () => {
var merger = new PDFMerger();
JsonPDFs
.map(data => atob(data))
.forEach(data => {
merger.add(element);
});
await merger.save("./merged.pdf");
})();
@mojoaxel
i have a new Problem. My Programm is throwing an error at the point i want to add the PDFs to the merger. I get the following errormessage:
i dont really understand what the Problem is. I import the fs module and set a variable with it. Here's my code (The import is at the beginning of the .js-File) :
function MergeSelectedPDF(JsonPDFs) {
const PDFMerger = require("pdf-merger-js");
var fs = require("fs");
const merger = new PDFMerger();
(async () => {
var merger = new PDFMerger();
JsonPDFs.map((data) => atob(data)).forEach((data) => {
merger.add(data);
});
await merger.save("./merged.pdf");
})();
}
- This issue tracker is not a support forum! Please use stackoverflow or something like this if you have programming questions!
- Also adding me directly takes time out of my day to react to it. Why should I be interested in you problems? Please don't add me!
- Your comment has nothing to do with the issue #50. Please add a new issue if you think you encountered a bug in the library!
- If you create a new issue please mention witch version you are using.