We are using iText Pdf API version 5.5.3 and we are trying to merge pdf documents which sometimes contain checkboxes , we write pdf document in servlet output stream and displays in iframe.
It works well in IE(tried in 11) but checkbox doesn't appear in Chrome(tried in 52).
Below is the sample code we use to display PDF.
InputStream in = docFile.getImage()
.getBinaryStream();
reader = new PdfReader(in);
pdfReaderList.add(reader);
document = new Document(PageSize.A4);
byteArrayOutputStream = new ByteArrayOutputStream();
PdfCopy copy = new PdfCopy(document, byteArrayOutputStream);
document.setMargins(35, 35, 48, 75);
document.open();
copy.setMargins(35, 35, 48, 75);
// add a document
Iterator<PdfReader> pdfReader = pdfReaderList.iterator();
while (pdfReader.hasNext()){
PdfImportedPage page;
reader = MCPDFFileWriter.unlockPdf(pdfReader.next());
for (int currentPage = 1; currentPage <= reader.getNumberOfPages(); currentPage++) {
page = copy.getImportedPage(reader, currentPage);
pageNum++;
copy.addPage(page);
footerNamesList.add(fileName);
footerMap.put(footerMap.size() + 1, fileName);
}
}
document.close ();
reader.close();
copy.close();
I also gone through this Link and given solution seems to be working when I use below code -
InputStream in = docFile.getImage()
.getBinaryStream();
reader = new PdfReader(in);
pdfReaderList.add(reader);
document = new Document(PageSize.A4);
byteArrayOutputStream = new ByteArrayOutputStream();
PdfCopy copy = new PdfCopy(document, byteArrayOutputStream);
document.setMargins(35, 35, 48, 75);
document.open();
copy.setMargins(35, 35, 48, 75);
**copy.setMergeFields();**
// add a document
**copy.addDocument(reader);**
document.close ();
reader.close();
copy.close();
However I sometimes face OutOfMemoryError and looking for some idea if there is any known issue with copy.setMergeFields();copy.addDocument(reader);
and how it can be overcome ?
A bug was also reported in chrome ( in the thought of plugin issue) and sample pdf are attached there