2

I am working on a task in which I need to arrage certain data in a particular format on asp.net web page. The asp.net page looks more like a plain report page. Then I need to allow user to take a print out of the same page in standard A4 format. If the data to be displayed on the page is more, the page is also supposed to handle page-breaks and display the page data on two (or more as required) A4 pages.

Is it possible to make a web page conform to A4 size print outs?

If yes, is it an advisable way to do so?

How can I make a web page conform to A4 size print outs?

Let me know if you need any other information on my task.

Thanks

Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110
Ali
  • 135
  • 2
  • 3
  • 12

2 Answers2

1

You can't. Websites are created for screens, not printers.

You can add a Print.css, to make the site print nicer, but you can't specify a paper size such as A4.

You can find more information about print stylesheets and how to use them here.

The best solution for printing, is to use PDFs, that's what they are for. Create a PDF that has the same data. You have full control over the print format in that case.

Reference : Oded Answer

Community
  • 1
  • 1
Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110
  • In my search I found that this is possible using the @page{} attribute. Hope this could aid in your endeavor to get an accurate sizing. https://stackoverflow.com/questions/3341485/how-to-make-a-html-page-in-a4-paper-size-pages – Reinhard Behrens Apr 09 '21 at 07:06
1

if you want this level of control on printing, iTextSharp can help. it supports regular pdf manipulation and templates. and the best of all, it's open source!

Ray Cheng
  • 12,230
  • 14
  • 74
  • 137