We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding Header footer to page while creating PDF from HTML

Hello,


I am use Aspose.PDF 11 and creating PDF document from HTML string.
I am using the example under the link http://www.aspose.com/docs/display/pdfjava/Convert+HTML+to+PDF+Format

I have some more things that i need to do to the document.

1 - I want to fix the page size of the document. For this I did following code.

HtmlLoadOptions htmloptions = new HtmlLoadOptions(basePath);
PageInfo pp = new PageInfo();
MarginInfo info = new MarginInfo( 10, 10, 10, 10 );
pp.setMargin( info );
pp.setWidth( 800 );
pp.setHeight( 600 );

but the final document is larger than the dimension that is specified.
and also how can I specify standard page size directly like A4, A0 etc.

In the HTML I have table with fixed column widths whose summation of widths is greater than the width that is specified. Will this affect the dimensions ?

2 - I want to give some page header and footer to the pages that are created while conversion.

I did not find any way to do so.





mayekars91:

I am use Aspose.PDF 11 and creating PDF document from HTML string.

I have some more things that i need to do to the document.

1 - I want to fix the page size of the document. For this I did following code.

HtmlLoadOptions htmloptions = new HtmlLoadOptions(basePath);
PageInfo pp = new PageInfo();
MarginInfo info = new MarginInfo( 10, 10, 10, 10 );
pp.setMargin( info );
pp.setWidth( 800 );
pp.setHeight( 600 );

but the final document is larger than the dimension that is specified.
Hi Saurabh,

Thanks for contacting support.

In order to set page margin and dimensions, please try using PageInfo and Margin objects for HtmlLoadOptions instance.

[Java]

HtmlLoadOptions htmlload = new HtmlLoadOptions();<o:p></o:p>

htmlload.getPageInfo().setHeight(800);

htmlload.getPageInfo().setWidth(600);

htmlload.getPageInfo().getMargin().setLeft(10);

htmlload.getPageInfo().getMargin().setRight(10);

htmlload.getPageInfo().getMargin().setTop(10);

htmlload.getPageInfo().getMargin().setBottom(10);

Document doc = new Document("c:/pdftest/sample.html", htmlload);

// save resultant PDF

doc.save("c:/pdftest/HTMLConversiomn.pdf");


mayekars91:
and also how can I specify standard page size directly like A4, A0 etc.
You need to pass the dimensions values for A4, A0 etc pages to PageInfo object to generate desired output.

mayekars91:
In the HTML I have table with fixed column widths whose summation of widths is greater than the width that is specified. Will this affect the dimensions ?
Please share your input HTML, so that we can test the scenario in our environment.

mayekars91:
2 - I want to give some page header and footer to the pages that are created while conversion.
Once the PDF file is created, then you may consider following the instructions specified on following link on Adding Text in Header or Footer of PDF File