N.P. SINGH
N.P. SINGH

Reputation: 303

How Can I Export a HTML page into PDF format with a Automated Page format which include a header and footer

NOTE:- PLEASE DON'T PROVIDE ANY SOLUTION WHICH USES JAVASCRIPT, THIS IS MY LIMITATION THAT I CAN USE ONLY CSS or HTML, NOTHING ELSE.

I have a questions and wants your response and your suggestion on it, basically I have a tabular list of data in the HTML, Now I want to implement a functionality by which I want to export this HTML page into a PDF. This HTML page is containing a tabular list of data, which is based on the dynamic content, means the data may be in 50 rows or can be in 100 rows.
Now I want to give a functionality there that the user can export the data into PDf format, but the problem is I want to use a format while exporting this data into PDF, means every page should be contain header image and a footer image format;
Well I can accomplished this format by following code:--

.page_format{
 width:8in;
 height:11in;
 padding-top:100px;
 padding-bottom:100px;
 background-image: url (''); /* It is a page image which contains a header and footer */
 position:relative;
 }

 <!-- Code which we will use at HTML body side -->
 <div class="page_format">
 <!-- code start here for dynamic tables -->
</div>

Well the actual problem is, I couldn't understand how can I achieve a dynamic format on every page, means as the table rows increased then automatically the pages increased and every row should not be cropped into pages, means a row should not be divided into multiple pages. So please provide me a solution, I am conclude my question here again:-

--> I want a feature in which a HTML pages should be exported in a formatted PDF format, which include a header and a footer on every page.

--> The exported PDF should be automatically formatted as according to the dynamic content of tables rows.

--> The table data shouldn't be cropped or divided into page break.

The table data is dynamic, so as the content increased and a new page is started then that new page should be include the same formatting as first page included (means the header and footer). right now the header and footer formatting applies to first page of the output pdf, it is not comes in the every page of the pdf export.

Remember again, We can only use CSS or HTML, no other method can be used here.

Upvotes: 1

Views: 3184

Answers (1)

Kailash Ahirwar
Kailash Ahirwar

Reputation: 769

I would recommend using the print media type in the main stylesheet:

@media print
{
/* style sheet for print goes here */
}

Or you can separate the print styles in it's own stylesheet:

<link href="style.css" media="print" rel="stylesheet" type="text/css" />

this will work for File->Print in browser - will convert the layout from print to PDF (or Microsoft XPS Document Writer)

Upvotes: 0

Related Questions