• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Printing a JSP page

 
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,
i am developing an web application where customers and vendors can able to view a detailed report of what are all the product they purchase/sold. Here i need to print that report and not the whole page.. I think i am clear my point. Please help me do accomplish this.. I don't want my whole site design to be printed, instead print that particular table that contains the report... Thanks in advance. Waiting for reply from ranchers.... :roll:
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The usual way to accomplish that is to provide a "Print" link/button that opens a window containing just the parts you want to print. If you want to get fancy then that window could call the JavaScript print function in its onLoad handler, so that the user doesn't need to select the print menu.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are 2 options here, at least.

One is to print the displayed page, the other is to create a formatted report.

CSS has the wonderful capability that you can define styles that only take effect in certain environments, such as on a printed page. Quite a few sites take advantage of that these days. Some of them include the print styles as part of the basic page display. In this case, for example, you do things like specify a style that suppresses the page framing (menu sidebars, for example). By doing that, you eliminate the need for a separate "print this page" function - and a trip back to the server for a print-friendly page layout.

For things with more precise layouts, it's sometimes better to generate a true ready-for-print report, such as a PDF. There are a number of ways to do this in Java, either using PDF-creation libraries or XSL-FO (for example, Apache FOP).
 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tim Holloway:
There are 2 options here, at least.

One is to print the displayed page, the other is to create a formatted report.

CSS has the wonderful capability that you can define styles that only take effect in certain environments, such as on a printed page. Quite a few sites take advantage of that these days. Some of them include the print styles as part of the basic page display. In this case, for example, you do things like specify a style that suppresses the page framing (menu sidebars, for example). By doing that, you eliminate the need for a separate "print this page" function - and a trip back to the server for a print-friendly page layout.

For things with more precise layouts, it's sometimes better to generate a true ready-for-print report, such as a PDF. There are a number of ways to do this in Java, either using PDF-creation libraries or XSL-FO (for example, Apache FOP).





Sorry.. i ain't heard that before.. Its very helpful if you post some codes or steps involved there.. Please forgive me if this question is rubbish..
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Its very helpful if you post some codes or steps involved there.


This is what Tim's talking about, and I second that this approach is preferable to the one I mentioned.
 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the link Ulf.. The problem is i have a logo image with medium resolution on top of my page and i don't want it to be printed when i print the data that i need... How could i achieve this?.. When i put display:none its not even displayed in the page... Thanks in advance...
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you read the article? You'd have two stylesheets, one for display that shows the image, and one for printing which hides the image.
 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i do... Now i got it... The search box i embed within the picture is still shown up in the print preview.. So i try to make it invisible... ... I'd get my hands off that as soon as i get finished with that...
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

i am just trying to print the page as pdf using print preview function using itext. i couldn't get the page as it is. it is shrinked into two pages instea of one page. anyone help me?
 
jose raja
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends,


I want to change my SVN username and password. What are the steps to be followed to change my svn username and password.

Anyone please!!!

Thanks in advance.

 
jose raja
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to convert the html content into the pdf format.

How can i do this.

Here is my code that converts only the text items into the pdf and it omitted all the textboxes, textareas, checkboxes.....

import java.io.FileOutputStream;
import java.io.FileReader;
import java.util.ArrayList;

import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.html.simpleparser.HTMLWorker;
import com.lowagie.text.html.simpleparser.StyleSheet;
import com.lowagie.text.pdf.PdfWriter;

public class generatePdf {
public static void main(String[] args) throws Exception {
Document document = new Document();
StyleSheet st = new StyleSheet();
st.loadTagStyle("body", "leading", "16,0");
PdfWriter.getInstance(document, new FileOutputStream("c:/MissedVisit.pdf"));
document.open();
ArrayList p = HTMLWorker.parseToList(new FileReader("c:/MissedVisit.html"), st);
for (int k = 0; k < p.size(); ++k)
document.add((Element) p.get(k));
document.close();
System.out.println("Pdf Generated!");
}
}

Any pointers to this to get all the contents that are in Html.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic