HOW TO PRINT IN JAVA?
Hi everyone,
i made a page in jsp in which there is a combobox which contain different users like admin,faiyaz,ali etc....
question is that when i select 'admin' from combobox and click on 'generate report' button.new page opens which show report of 'admin' activities.there is a one PRINT link on page.when click on print report will be printed...
how can i print particular report page which is opened?
help me regarding this problem...
thnxs in advance
with regards
create a CSS file called print.css for example then add it to your JSPs like that
<html>
<head>
<link rel="stylesheet" media="print" href="<%=request.getContextPath()%>/print.css" type="text/css" />
...
</head>
<html>
In this CSS file, add code that hides links and other things you want to hide(or show) when printing
Use javascript window print function like this:
<a href="javascript:window.print()">Print</a>
NB: This is a web question and has nothing with Java
> i want to print that report on client side...
Not really a Java problem, then.
~
You should probably consider generating a PDF document on the server side, using a library like PDFBox. That gives you the kind of layout control you need for printed reports, with pagination, headers and footers etc. to suit.
Open this in a new window (IE has problems openning PDF in an existing window).