Link to home
Start Free TrialLog in
Avatar of onaled777
onaled777Flag for United States of America

asked on

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();
    }
ASKER CERTIFIED SOLUTION
Avatar of krakatoa
krakatoa
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial