Open simon-dk opened 5 years ago
So, small progress. I made some adjustments and have a somewhat working code now, only one caveat: Each iteration makes an overlay, so page 1 looks fine page 2 = page 1 + 2 page 3 = page 1 + 2 +3 What am I doing wrong here?
var hummus = require('hummus');
var pdfWriter = require('hummus').createWriter(__dirname + '/output/PDFEmbedTest.PDF');
var formIDs = pdfWriter.createFormXObjectsFromPDF(__dirname + '/template/input.PDF',hummus.ePDFPageBoxMediaBox);
var font = pdfWriter.getFontForFile('./fonts/Roboto-Regular.ttf');
var textOptions = {font:font,size:14,colorspace:'gray',color:0x00};
var page = pdfWriter.createPage(0,0,595,842);
for (i=0; i < 5; ++i) {
pdfWriter.startPageContentContext(page)
.doXObject(page.getResourcesDictionary().addFormXObjectMapping(formIDs[0]))
.writeText('Test message on page ' + i, 75, 750, textOptions)
pdfWriter.writePage(page);
}
pdfWriter.end();
Hi, Have been starring hopelessly for hours now, so hope somebody can help me out.
I'm trying to accomplish a simple thing:
I have tried all kinds of different variations but am unsure if I need to use merge pdf, a formxobject or something else. Hope to get a helping hand here, not sure if i'm even close to producing the desired result!