Archive for the ‘HTML print’ Tag

ASP.NET print HTML report in A4 Paper

work in ASP.net project again. currently working on report module.  I need to print all members notification letter in once.  the best way for web printing of course is generate PDF file, but my company no provide me PDF library, and I can’t find any free PDF library for ASP.net. So, the only method is use the javaScript, Window.print() function to print my report.

I used repeater web control to generate the report and in HTML form.

I need fix all in A4 size, if my repeater generate 4 member notification  letter, then I need exactly print 4 letters in A4 paper.

0

But you may face this problem:

1

when the first page content cannot fix in entire A4 paper, the second page content will move up. or maybe :

2

the first page content too long, and extend to second page.

that’s not really possible to control,  because it depending on content. But I found out the IE8( or IE7) have a function call “shrink-to-fit”that can solve my problem.

I need to explain my situation,

1st, I build management system for a company but not create website for company. So, I can force my client using which browser to operate the system. 2nd, client no require cross browser capability . 3rd, my company no provide any printing library for me.

first of all, you need write all the page content(report content) within the <div> , 210mm X 297mm is A4 paper size.

3

2nd, setting IE:

left click on “Page Setup… (menu item)”

image

change the page size to A4 size.

image

Tick the Enable Shink-to-Fit

image

Done. Now you can print your report nicely. kindly Email me, if you face any problem in ASP.net printing issue.

you can download my solution file here.

加关注

Get every new post delivered to your Inbox.