So Weird, I am generating a PDF using FlyingSaucer, then adding a footer to the PDF. The footer works in Chrome and FF, but not IE. But if I download the PDF, even from Chrome, where the text is there, open it locally with Adobe, it is not... I dont get it.
Code:
ByteArrayOutputStream os = originalPDF.getOutputStream();
ByteArrayOutputStream newos = new ByteArrayOutputStream();
PdfReader reader = new PdfReader(os.toByteArray());
PdfStamper stamper = new PdfStamper(reader, newos);
for(int i=1; i<= reader.getNumberOfPages(); i++){
Rectangle pageSize = reader.getPageSize(i);
PdfContentByte content = stamper.getUnderContent(i);
BaseFont baseFont = BaseFont.createFont(BaseFont.HELVETICA, "utf8", false);
content.setFontAndSize(baseFont, 15);
content.setRGBColorFill(0, 0, 0);
content.showTextAligned(PdfContentByte.ALIGN_LEFT, "Page "+i, 3, 5, 0);
content.showTextAligned(PdfContentByte.ALIGN_RIGHT, " - Printed: "+DateUtil.date2str_MM_dd_yyyy(new Date()), pageSize.getWidth()-3, 5, 0);
}
stamper.close();
request.getSession().setAttribute("file", newos.toByteArray());
Any Ideas?
@mkl EDIT: I cannot post the PDF, sensitive information and all that BUT, if I change the code to:
PdfContentByte content = stamper.getUnderContent(i);
String msg = "Page "+i+" - Printed: "+DateUtil.datetime2str_MM_dd_yyyy_h_mm_a(new Timestamp(new Date().getTime()));
ColumnText.showTextAligned(content, PdfContentByte.ALIGN_CENTER, new Phrase(msg), center, 5, 0);
It works on all browsers and Adobe. So clearly my font and/or encoding is wrong. Any suggestions for proper encoding?