Link to home
Create AccountLog in
Avatar of onaled777
onaled777Flag for United States of America

asked on

Writing to a pdf document

How do I modify this method to write the contents of the modified document to a file name pdfOutput.  My aim is to get a document showing the modified changes so I can test the output:

    public static void addPageFooter(ByteArrayOutputStream baos) throws Exception {
        PdfReader reader = new PdfReader(baos.toByteArray());
        PdfStamper stamper = new PdfStamper(reader, baos);
        int numOfPages = reader.getNumberOfPages();
        for (int i=1; i<=numOfPages; i++)
            ColumnText.showTextAligned(
                    stamper.getUnderContent(i),
                    PdfContentByte.ALIGN_CENTER,
                    new Phrase("Page "+i),
                    reader.getPageSize(i).getWidth()/2,
                    5,
                    0);
        stamper.close();
        reader.close();
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mark Bullock
Mark Bullock
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account