IText showing string as blank in new document

Any ideas why this function would write a string to a document that cannot be seen?

the input file from which baos is created is smaller than the output file that is finally created from using this function.  In addition if I select the text from both documents I can see the text difference in a tool like 'Beyond Campare'. so the text is there just not visible to my eyes. Any suggestions on what I could do to show it?

   public static void addPageTimestampFooter(ByteArrayOutputStream baos) throws Exception {
        PdfReader reader = new PdfReader(baos.toByteArray());
        PdfStamper stamper = new PdfStamper(reader, baos);
        int numOfPages = reader.getNumberOfPages();
        String timestamp = " - Printed: "+DateUtil.datetime2MM_dd_yyyy_h_mm_a(
                new Timestamp(System.currentTimeMillis()));
        for (int i=1; i<=numOfPages; i++)
            ColumnText.showTextAligned(
                    stamper.getUnderContent(i),
                    PdfContentByte.ALIGN_CENTER,
                    new Phrase("Page "+i+timestamp),
                    reader.getPageSize(i).getWidth()/2,
                    5,
                    0);
     
        stamper.close();
        reader.close();
    }
onaled777Asked:
Who is Participating?
 
krakatoaCommented:
Why are you calling a Reader on an Outputstream?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.