try{
PDDocument doc = PDDocument.load( file );
PDPage page = doc.getPages().get( 1 );
COSDictionary pageDict = page.getCOSObject();
int pagesToBeAdded = pagesToBeAdded(merchandiseLineItemsCount);
for(int i=0;i<pagesToBeAdded;i++){
COSDictionary newPageDict = new COSDictionary(pageDict);
//newPageDict.removeItem(COSName.ANNOTS);
PDPage newPage = new PDPage(newPageDict);
doc.addPage(newPage);
}
return doc;
}
So this is how I am adding the page to a template doc .. and I am facing a problem that I can't get the PDfields for the newly added page when I iterate over that page for setting the value of those PDFields. I am also changing the text of the page added by checking the "TJ" operator and setting the value of COSString