Closed DarkKnight1992 closed 6 years ago
You will need to create a new PDFPageModifier
for the new page.
The usage is more like
const hummus = require('hummus');
const pdfWriter = hummus.createWriterToModify(INPUT_FILE, {
modifiedFilePath: OUTPUT_FILE
});
for (let i = 0; i < PAGE_COUNT; i++) {
const pageModifier = new hummus.PDFPageModifier(pdfWriter, i);
const cxt = pageModifier.startContext().getContext();
// DO your editing here
pageModifier.endContext().writePage();
};
pdfWriter.end();
If this one does not work for you, you may have to provide your full codes since the current trigger code does not match your function.
If you want to wrap hummus with your own class, you will probably need to take care of pausePageContentContext
later. Example
You can also take a look for other hummus wrapping library for some ideas link
Thanks @chunyenHuang, but issue has after appending the new file that i can't get context so i got away with doing something else.
First i created the no. of pages i needed for the pdf, by appending the existing pdf over and over again. Then i started pdf writer for it and had no issues with the context.
I think i had the context problem since when i intialized the writer it has only page and after appending the page the writer did not register the new page to be modified
Had same issue, this occurs if you appendPDFPagesFromPDF
from a pdf file to an empty one, and right after try to create a PDFPageModifier
on some of the appended pages.
Is that expected behaviour @galkahana ?
Hi Gal,
Cheers for creating a great library its very useful. Keep up the good work,
I am trying to append a pdf to an existing createWriterToModify file and file is appended without problem but when i try to startcontext on that page i can't do that maybe i missing something can you help me asap ?
error in console
Error in Hummus Log
Here's my code
This is here its triggered