how to print pdf format

how to print pdf format

Hi every body iam doing school project iam using backend as oracle front end java .how to print student marks list /attendence in pdf format. please help me. thanks in advance.

View Answers

June 23, 2012 at 4:28 PM

Here is a code that will store the database data into pdf table. We have used itext api:

<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%@page import="com.lowagie.text.*"%>
<%@page import=" com.lowagie.text.pdf.*"%>
<%
Document document=new Document();
       PdfWriter.getInstance(document,new FileOutputStream("C:/data.pdf"));
       document.open();
       PdfPTable table=new PdfPTable(2);
       table.addCell("Name");
       table.addCell("Address");
       Class.forName("com.mysql.jdbc.Driver");
       Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
       Statement st=con.createStatement();
       ResultSet rs=st.executeQuery("Select * from data");
       while(rs.next()){

       table.addCell(rs.getString("name"));
       table.addCell(rs.getString("address"));
       }
       document.add(table);
       document.close();
       %>

June 23, 2012 at 6:22 PM

thanks alot


December 17, 2012 at 12:33 PM

hey bro, need little help in this. it prints all records in pdf. i want only the displayed results from resultset to be printed in pdf...ofcourse there will be "where" clause in sql query ..but am not getting as how should i use that where clause in sql. please help ASAP! thanks in advance.









Related Tutorials/Questions & Answers:
how to print pdf format
how to print pdf format  Hi every body iam doing school project iam using backend as oracle front end java .how to print student marks list /attendence in pdf format. please help me. thanks in advance.   Here
How to print this Format exactly?
How to print this Format exactly?   * * * & reverse
Advertisements
pdf format - JSP-Servlet
pdf format  hi Sir, how to convert text format into PDF format. thanks & regards, vijayababu.m
how to display the database values in pdf format
how to display the database values in pdf format   in struts how to display the values in pdf format when clicking a button in jsp page   jsp code using itext api: <%@page import="java.io.*"%> <%@page import
Print the following format
Print the following format  how to print the following format given string "00401121" in java 0-** 1-* 2-* 3- 4
print array in following format
print array in following format  i want print two array in following format first array= 1,2,3,4,5,6,7,8,9 second array=11,12,13,14,15,16,17,18,19 i want output as: 1 2 3 11 12 13 4 5 6 14 15 16 7 8 9 17 18 19  
Displaying database values in pdf format
database values should be shown as pdf or excel format. Thanks in advance...Displaying database values in pdf format  Hi All, I am developing a struts application.I am having one registration form when i am submitting
To save table format data in pdf/excel in jsp
To save table format data in pdf/excel in jsp  Hello, I am doing web... table. So my question is ,I want so save this html format data in pdf/excel format... can save html table data in pdf/excel format.Your inputs are valuable to me
Print pdf file in JavaScript - IE and Chrome
Print pdf file in JavaScript - IE and Chrome  <!DOCTYPE html>...') { //Wait until PDF is ready to print if (typeof...; PRINT PDF IN IE AND CHROME <table> <tr> <td> <
Print pdf file in JavaScript - IE and Chrome
Print pdf file in JavaScript - IE and Chrome   <!DOCTYPE html>...') { //Wait until PDF is ready to print if (typeof...; PRINT PDF IN IE AND CHROME <table> <tr> <td> <
how to load pdf on html
how to load pdf on html  how to load pdf on html
How create csv format in jsf ?
How create csv format in jsf ?  Dear Friends , Good morning to all of you? I have a problem to create .CSV format in jsf. Actully I have... the pdf file now I want to create .csv format using this data ? Please Help me
how to print the server time
how to print the server time  how to print the server time in jsp and update time in fix interval
how can i display a pdf file in a jtextarea
how can i display a pdf file in a jtextarea  I need to display a pdf... have a button and while clicking on it ,i need to choose the pdf file and need to displat it in my jframe.Also i need to edit it and i have to take the print
how to generate pdf file in struts
how to generate pdf file in struts  I am developing a struts application.I am having one registration form when i am submitting the form the values... be shown as pdf or excel format
how to generate pdf file in struts
how to generate pdf file in struts  I am developing a struts application.I am having one registration form when i am submitting the form the values... be shown as pdf or excel format
How to print this in java?
How to print pattern in Java?  How to print a particular pattern in Java...;  How to print this in java
how to print the server time
how to print the server time  i want to print database time in clintside and update time in every secound without creating connection to database for each time. how can i do
how to print String as pattern ?
how to print String as pattern ?  i have a one String name ="rajesh" i want to print pattern like r * ra ** raj raje rajes rajesh please help me
How to format number in Java?
How to format number in Java?  Hi, What is the best way to format a number in Java? How to format number in Java? Thanks   Hi, To format number in Java you can use the class java.text.NumberFormat. Here is simple
How to print current time in r?
How to print current time in r?  Hi, I am learning and want to print current date and time on console. How to print current time in R Programming... and time in R Programming language: > format(Sys.time(), "%c") [1] "Tue Jun 27 00
how to print - Java Beginners
how to print  how to print something on console without using System.out.print() method ?  Hi Friend, You can use PrintWriter to write anything on the console. import java.io.*; public class Print{ public static
How to print UIButton id
How to print UIButton id  How to get the id of the button in the IOS application? Thanks   Hi, You can use the following code: - (IBAction)btnClicked:(id)sender { UIButton *button = (UIButton *)sender; int
how to dispaly pdf file on browser
how to dispaly pdf file on browser  In my project i have created one pdf file(by pdfwriter) into my local mechine . after that it need to display in browser as a pdf file . but in jsp i can't display by tag can anyone give me
how to print the following pattern
how to print the following pattern  Hello hEllo heLlo helLo hellO pls reply soon its an emergency   class StringPattern { public static void main(String[] args) { String st="hello
How to get the position of the comments in the pdf
How to get the position of the comments in the pdf  how to get the postion of comments, in the extracted xml, from pdf
How to get the position of the comments in the pdf
How to get the position of the comments in the pdf  how to get the postion of comments, in the extracted xml, from pdf
How to design a foot print on the sand, print on the sand, print
How to design a foot print on the sand       You might have seen foot prints on the sand field. Do you think, it can be design in the photoshop, yes I have done here. I have used
pdf generation.
pdf generation.  i want to generate the data which is stored in mysql data base in pdf format with php. how i will do
how to display pdf file on browser
how to display pdf file on browser   In my project i have created one pdf file(by pdfwriter) into my local mechine . after that it need to display in browser as a pdf file . but in jsp i can't display by iframe tag can anyone
Insert pages pdf
Insert pages pdf       In this program we..., com.lowagie.text.pdf.PdfWriter class is used to write the document on a pdf file,. To make the program for changing the pdf version firstly we will make
how to print JInternal frame component ?
how to print JInternal frame component ?  hello sir, i devalop a swing application .but problem is that how display report & print it. some data prefech from database & keep to jtable but how it is print with table
how to print spark dataframe data
how to print spark dataframe data  Hi, I have a dataframe in spark and i want to print all the data on console. How it can be done. how to print... is in "data" variable and you want to print it. Its simple and one line function to print
how to print spark dataframe data
how to print spark dataframe data  Hi, I have a dataframe in spark and i want to print all the data on console. How it can be done. how to print... is in "data" variable and you want to print it. Its simple and one line function to print
How to convert EBCDIC format value into ASCII format value in java
How to convert EBCDIC format value into ASCII format value in java  how to convert EBCDIC data format into ASCII format data using java Use Case:I my file contains ASCII format values as well as EBCDIC format values.I need
How to print like printf in python
How to print like printf in python  Hi, I am from C background and there used to be printf function. Jow to print like printf in python? The printf function is C/C++ is very useful. So, looking for some line printf in Python
How to convert a swing form to PDF
How to convert a swing form to PDF  Sir, I want to know about how convert a swing form containing textbox,JTable,JPanel,JLabel, Seperator etc swing menus to a PDF file using java code
How can print integer in method
How can print integer in method   a method call process public process(int jobid,int remain){ } how to print int jobid ,int remain in for loop jobid in proc[0],remain in proc[1],both show in text file how to print proc[0
How to print the following pattern in java?
How to print the following pattern in java?  How to print the following pattern in java? he he is he is going he is going in   import java.io.*; class StringPattern { public static void main(String[] args
print
print  How to print JFrame All Componant?   Please visit the following link: http://www.roseindia.net/java/example/java/swing/Print.shtml
How to insert a single page PDF file into another multipage PDF file using iText? - Java Beginners
How to insert a single page PDF file into another multipage PDF file using iText?  Hi ALL: I have two PDF files. PDF-A.pdf is a multipage PDF file. PDF-B.pdf is a single page PDF file. I want to insert PDF-B into PDF-A only
How to parse data in JSON format
How to parse data in JSON format  Hi, I want to parse following json string in Python and get values from it. user = {"user":"testuser", "password":"testpass", "isactive":"Yes"} How to parse data in JSON format? Thanks
how to create pdf file using java and itextjar
how to create pdf file using java and itextjar  How to create pdf file having paragraphs and alignments done using java and itextjar 5.10 version.? hope i get quick response
how to create pdf file using java and itextjar
how to create pdf file using java and itextjar  How to create pdf file having paragraphs and alignments done using java and itextjar 5.10 version.? hope i get quick response
How to format json String in Java
How to format json String in Java  Hi, How to format json String in Java? I have an object of HashMap how to convert it to formatted output? Thanks   Hi, You can use the com.google.gson.Gson class of Google Gson
How to format json String in Java
How to format json String in Java  Hi, How to format json String in Java? I have an object of HashMap how to convert it to formatted output? Thanks   Hi, You can use the com.google.gson.Gson class of Google Gson
how to print all colors using awt
how to print all colors using awt  how to print all colors using awt
how to print of hours and minutes of 8725 seconds
how to print of hours and minutes of 8725 seconds  how to print of hours and minutes of 8725 seconds
How to print a webpage without url and date in jsp ?
How to print a webpage without url and date in jsp ?  How to print a webpage without url and date in jsp
How to pretty print XML from Java?
How to pretty print XML from Java?  How to pretty print XML from Java

Ads