Create PDF from java

Ads
 

Create PDF from java

Good afternoon,

I have a problem how to create report. i want to create report in pdf file from my database in mysql. Now i use IReport too create pdf file, can't work...., pleas tell me a tutorial/source code to create pdf file from database call from java programming.

thank you,

Hendra

View Answers

February 14, 2011 at 3:43 PM

Create PDF from Java

import java.io.*;
import java.sql.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;

public class CreatePDF{
    public static void main(String arg[])throws Exception{
       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();
   }
}

For more information, visit the following link:

Itext Examples


February 16, 2011 at 1:17 PM

i have a problem again, please help me again....., i have a case, where my data is much field. i have 12 field, and my data have 10-30 character and more in 1 field. can you help me how to resize my data is good looking if i print in pdf. maybe make a landscape preview, thank you

Ads









Related Tutorials/Questions & Answers:
Create PDF from java
code to create pdf file from database call from java programming. thank you, Hendra   Create PDF from Java import java.io.*; import java.sql....Create PDF from java  Good afternoon, I have a problem how to create
create pdf from jsongrid
create pdf from jsongrid  i need to create pdf from jsongrid in java struts2.. otherwise i need to create pdf from result set
Advertisements
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
Creating PDF in JAVA
Creating PDF in JAVA  How create pdf in java ? Take value from database for particular PDF
Create list from array in Java
Create list from array in Java  Hi, I have an array with some data. How to Create list from array in Java? Thanks   Hi, Here is example of creating of creating an array: String[] names = new String[]{"Java", "JSP
How to read PDF files created from Java thru VB Script
How to read PDF files created from Java thru VB Script  We have created the PDF file thru APache FOP but when we are unable to read the data thru... file?   Java PDF Tutorials
pdf from i report
pdf from i report  I have a problem again with my report, i use I Report to make pdf file. but when the application running in java, pdf can't view. but in rtf format data can view. or can icon save like this to be dissapear
Extarct string from PDF
Extarct string from PDF  how can i search a particular character from pdf? also extarct string from a pdf document
pdf generate from jsp
pdf generate from jsp  how do i generate a pdf using jsp that should query the data from the database and write it into a pdf and download the same
reading from pdf
reading from pdf  how can i read specific words from pdf file?   Java Read pdf file import java.io.*; import java.util.*; import com.lowagie.text.*; import com.lowagie.text.pdf.*; public class ReadPDF { public
how to create xml schema from xml doc using java
how to create xml schema from xml doc using java  i want to create xml schema from xml document programatically using java... am using Netbeans IDE 7.0 i hav created the xml document for a table of data from Database... now i
java code to create xml document from DOM object
java code to create xml document from DOM object  Hey! After knowing the way we can create DOM objects and add elements to it-> then displaying it on the console ;is there a way I can output the same in xml document
Create Bar Graph from reading excel sheet in Java
Create Bar Graph from reading excel sheet in Java  I'm New to Java and I have to create a java program where I have to read data from multiple excel sheets say 4 sheets and sheet represents browsers (like FF, IE8, IE9 , chrome
Add Content of an iText PDF File using java code
documents from Java program. The iText is a open source library that provide facility to create pdf file from java application. iText is a freely available Java... Add Content of an iText PDF File using java code  
Create project from Maven Template
In this section, you will learn to create a simple Java web application project from Maven Template
Create a web application using java technology to display 10 most relevant tweets from Twitter in real-time for the keyword
Create a web application using java technology to display 10 most relevant tweets from Twitter in real-time for the keyword   Create a web application using java technology to display 10 most relevant tweets from Twitter in real
Java and converting a PDF to XML
Java and converting a PDF to XML  I reviewed your example - https://www.roseindia.net/tutorial/java/xml/pdftoXML.html - and on many users group... getting a response from them.Can you help me out ?? This project is very important
Java and converting a PDF to XML
Java and converting a PDF to XML  I reviewed your example - https://www.roseindia.net/tutorial/java/xml/pdftoXML.html - and on many users group... getting a response from them.Can you help me out ?? This project is very important
How to create pdf file in struts2.
How to create pdf file in struts2. In this example, you will see the how to create PDF in struts, and how to write message in generated PDF file in struts2.  For this, we requires a jar file iText.jar. It is used in java
Extracting position of a particular string from a PDF
Extracting position of a particular string from a PDF  I have a pdf form. I want to knw the exact position(location) of a particular string of that form. Using iText I have extracted all the string from the PDF form, but nt able
how to generate the pdf report from jsp
how to generate the pdf report from jsp  <%@page import... want to generate the pdf file from jsp page.I add the itext.jar to the libraries... not getting the pdf file.Any one please help me asap.Its very important
convert an pdf file to html in Java
convert an pdf file to html in Java  Hi all, How to convert an pdf file to html in Java? Currently all my data is generated into a report in pdf... implementing this, is there any source code in java? Thanks
Create text file at client's directory from server.
Create text file at client's directory from server.  Need java code to create text file at client's directory from server..... Please Help
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
Generate unicode malayalam PDF from JSP
Generate unicode malayalam PDF from JSP   Hi, I want to generate a malayalam report in PDF format.I have generated a report in jsp.Now I want the same report to be saved as PDF in unicode malayalam font.I have tried to generate
how to create notepad in java
how to create notepad in java  how to create notepad in java
Create xsd files from database tables
Create xsd files from database tables  Hi, I work on a Java JEE project. We have now introduced the creation of DTOs from xsd files with JAXB.... Does anyone knows of a tool that can create xsd automatically from given
open pdf file in same jsp page and the pdf file should retrieved from database
open pdf file in same jsp page and the pdf file should retrieved from database  Hai all, I need code to open a pdf file in same jsp page(browser) while click on hyperlink And the file was located in database table. Can any
ModuleNotFoundError: No module named 'aspose-pdf-java-for-jython'
ModuleNotFoundError: No module named 'aspose-pdf-java-for-jython'  Hi...: No module named 'aspose-pdf-java-for-jython' How to remove the ModuleNotFoundError: No module named 'aspose-pdf-java-for-jython' error? Thanks
ModuleNotFoundError: No module named 'aspose_pdf_java_for_python'
ModuleNotFoundError: No module named 'aspose_pdf_java_for_python'  Hi...: No module named 'aspose_pdf_java_for_python' How to remove the ModuleNotFoundError: No module named 'aspose_pdf_java_for_python' error? Thanks

Ads