Header And Footer of PDF File, Aspose Java

780 views Asked by At

ASPOSE PDF Java version --> 11.8

I am trying to add the Header to the each of the pages of the PDF file using HeaderFooter class. Below is the code,

is -- This variable stream holding the streaming content of HTML.
htmlOptions -- for setting the margin for the generating the file.

Document pdfDocument = new Document( is, htmloptions );

            Iterator<Page> pages = pdfDocument.getPages().iterator();
            while( pages.hasNext() ){

                Page pageCollection = pages.next();

                HeaderFooter header = new HeaderFooter();
                Paragraphs headParagraph = new Paragraphs();

                HtmlFragment headfragment = new HtmlFragment( pdfHeaderContent );
                headfragment.setVerticalAlignment( VerticalAlignment.Top );
                MarginInfo marginInfo = new MarginInfo();
                marginInfo.setLeft( 10d );
                marginInfo.setRight( 10d );
                marginInfo.setBottom( 10d );
                marginInfo.setTop( 10d );
                header.setMargin( marginInfo );
                headParagraph.add( headfragment );
                header.setParagraphs( headParagraph );

                pageCollection.setHeader( header );

            }

Please let me know how to set the height for the Header?

0

There are 0 answers