[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2135
  • Last Modified:

Print PDF and set page break from html

Hi expert,
I generated  several HTML tables for displaing a report( code in Aspx.vb  page). I want create PDF file from report and set some nice break, so pdf file will look nice,  break between tables. How I can do it?
Or if I can use other way to dispaly report for setting nice break?

thanks.

shi
0
dshi15
Asked:
dshi15
  • 3
  • 2
1 Solution
 
evguenCommented:
Hello dshi15,

There is a way to create page breaks in HTML using CSS.
You can do it this way :

<table ...>
</table>

<DIV style="page-break-after:always"></DIV>

<table ...>
</table>

If you wan a page break before each heading title, you can specify a style for H1 titles. For example, put in your .css file :

<style type="text/css">
h1{
page-break-before: always;
}
</style>

This way, for every text in H1 style, there will be a pagebreak before. But be careful, because there will be a page break before the first occurence of H1 title.

About creating PDF files, I assume that if you display HTML reports, then you want the user to be able to view your file on PDF format.
On windiws, you can download and install PDFCreator, which is a free software that works like a printer. It accepts any type of file format, and instead of printing it will ask you for a location of the PDF file to be saved.

Best regards


<style type="text/css">
h1{
page-break-before: always;
}
</style>
 
<HTML>
<BODY>
 
<H1>Fructs</H1>
	<table border='1'>
		<tr>
			<td>banana</td>
			<td>coco</td>
			<td>apple</td>
		</tr>
	</table>
 
<H1>Drinks</H1>
 
	<table border='1'>
		<tr>
			<td>water</td>
			<td>coffee</td>
			<td>tea</td>
		</tr>
	</table>
 
</BODY>
</HTML>

Open in new window

0
 
dshi15Author Commented:
Thank you very much, I will try it tonight and let you know.
0
 
dshi15Author Commented:
Hi,

I don't know I explained my question clearly. For example., I have a report like a link bellow, I want a button called CreatePDF , then this page will automatically create to PDF? How I can do it? Do I need download PDFCreator?

http://shopping.yahoo.com/b:Coupons%20&%26%20Deals:784709445:cat=Computers;_ylt=AlgIue1Zv7qDl3E1_oX6.3Jm8ksB;_ylu=X3oDMTBsZm9qb2kxBF9zAzc4NDcxMTY2MwRzZWMDYm5hdg--


Thanks.
0
 
evguenCommented:
Hello,

First, about PDFCreator - it is a .exe you download and install on your computer. Please notice that I advise "PDFCreator" (in one word) which is free. There is also "PDF Creator" (2 words) - which is not free. PDFCretor installs a virtual printer on your computer allowing you  to "print" out any type of file. When you select this printer, instead of printing, it will edit your file in PDF format you can save on your computer.
This solution does not allow you to put a button on your webpage. You can only ask your browser to print the document and select the PDFCreator printer as a printer device.

If you want to have a button on your webpage, this a little more complicated. It also depends on your server technologies. I saw that you have generated your page in VB and I imagine your server is a Windows server. Could you please give more details on versions of softwares you use? Unfortunately I'm not a Microsoft expert, but I will try to do my best to put you on the right way.

Best regards



0
 
dshi15Author Commented:
Thanks,

The site is public and I can not let client to install software on their computer to see the pdf report.
Our company server is Windows server and running IIS and I used Microsoft Visual web developer 2005 express Edition (code is ASP.net 2.0,VB.net)

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now