Avatar of onaled777
onaled777
Flag 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

Java

Avatar of undefined
Last Comment
gurpsbassi

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mark Bullock

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
gurpsbassi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61