Hello, i Would like to know if i'm using the Recip object correctly. I want to loop over every page of my pdf document to add a text, for exmaple the page number to the document, but when im using the loop at the following example. The saved out put buffer is still the same. Im also using the createReader since i'm not able to get the page count over the recip.
const writeTest = (pdfBuffer: Buffer) => {
this.logger.log("write file")
fs.writeFileSync('./pdfs/BaseWithTestText.pdf', pdfBuffer);
}
const addPageNumber = (pdfBuffer: Buffer, skipFirstPage?: boolean) => {
//create readStream from Buffer
const readBuffer = new PDFRStreamForBuffer(pdfBuffer);
//create readStream to get Page Count
const pdfReader = createReader(readBuffer)
//create recipe
const recipe = new Recipe(pdfBuffer);
//loop over pages at index 1
for(let i = 1; i == pdfReader.getPagesCount(); i++) {
recipe.editPage(i).text("Test funktioniert das", 42, 42).endPage();
}
//save updated pdf to file system
recipe.endPDF((cb) => this.writeTest(cb));
}
const main = () => {
const buffer = fs.readFileSync('./pdfs/Base.pdf');
addPageNumber(buffer);
}
main();
Hello, i Would like to know if i'm using the Recip object correctly. I want to loop over every page of my pdf document to add a text, for exmaple the page number to the document, but when im using the loop at the following example. The saved out put buffer is still the same. Im also using the createReader since i'm not able to get the page count over the recip.