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

[519 byte] By [FaiyazAziza] at [2007-11-27 11:12:27]
# 1

> how can i print particular report page which is opened?

http://www.google.com/search?q=java+print+api+tutorial

~

yawmarka at 2007-7-29 13:54:44 > top of Java-index,Java Essentials,Java Programming...
# 2

where do you want to print the report?

on the client side or on the server side?

java_2006a at 2007-7-29 13:54:44 > top of Java-index,Java Essentials,Java Programming...
# 3

i want to print that report on client side...

FaiyazAziza at 2007-7-29 13:54:44 > top of Java-index,Java Essentials,Java Programming...
# 4

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

java_2006a at 2007-7-29 13:54:44 > top of Java-index,Java Essentials,Java Programming...
# 5

> i want to print that report on client side...

Not really a Java problem, then.

~

yawmarka at 2007-7-29 13:54:44 > top of Java-index,Java Essentials,Java Programming...
# 6

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).

malcolmmca at 2007-7-29 13:54:44 > top of Java-index,Java Essentials,Java Programming...