2

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?

Hareesh
  • 694
  • 6
  • 18
  • Currently, there is no such property or method that Aspose.Pdf for java supports, in order to set height of the Header inside PDF page. However, height of the header depends upon the content which you are displaying inside it. In case if you are facing content overlapping or alignment issues while doing that, please share your sample HTML file along with sample HTML Header content with us. We will test the scenario in our environment and address it accordingly. My name is Asad and I am support evangelist at Aspose. – Asad Ali Sep 05 '17 at 19:21
  • The question was asked long back but I'm still searching for same answer. Is there a way to omit header & footer of PDF while converting to HTML? – Saurabhcdt Nov 29 '22 at 13:27

0 Answers0