Java Code to Convert PDF Using Itext jar
Introduction
This article specifies a simple Java code to convert any kind of files to a PDF using iText jar. First let me give a small intro about the usage of iText jar, which is an open source library used for creating and manipulating PDF, RDF and HTML files with the use of Java code. Thats Ok!! Let us come to the point, this article is consecrated for the peoples who wants to convert their files in to a PDF format using Java code. Download the latest iText jar here.
Categories: itext, Java
Java, Java and iText, Java code to convert PDF, PDF using iText
Hi Shunmuga,
Good post. But it will be great if you can explain that in small steps that will help the users to understand the iText api.
Thank you very much for your valuable comments, As per your suggestion I had updated in the article!!
hi,
i tried this code, but it is not taking ppt files, doc with tables, excel etc..
Is there any library available which can convert any file to pdf using java
Hello Mr. Shanmuga Krishna,
The above is converting html to PDF with the html tags..plz tell me how to convert html to PDF without displaying tags in the PDF..i want to display HTML page as PDF not the code.
Thanks in advance.
Hi sreekar,
Thanks for your comments and your question is substantive. I will find a work around for your query in Java code and surely I will update in my next article. For the time being if you worked in a web based project means, you can use Primefaces Data Exporter. I hope the following link would be helpful to do so!!
http://97.107.138.40:8080/prime-showcase/ui/exporter.jsf
Hi shunmuga,
Plz tell me how to convert the jsp page data into pdf format.That data is getting from DB.
Bruno (the guy who wrote much of Itext) has a new version of IText in Action coming out. The first few chapters are available to read online and the book is a brilliant resource if you are looking to make the most of IText.
Hello Shunmuga,
The above code i use but it gives error in line 46
pdfDocument.add(new Paragraph(org.apache.commons.io.FileUtils.readFileToString(file)));
can u please help me why it is give error over there…?
Hi Arpita,
You can resolve this issue by
Download the appache commons io jar from the below link and add the jar file in your library
http://commons.apache.org/downloads/download_io.cgi
I worked with this code,but in pdf file the whole image is not displayed.can you help me for this.thanx.
Hi Geethani,
Your question is substantive, I guess your image size is more than 1.5MB. For this, you need to set the page size by invoking the following code.
package com.sample.pdfconvertor; import com.lowagie.text.Document; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfWriter; import java.io.File; import java.io.FileOutputStream; /** * * @author shunmuga */ public class PDFConversion { /** * This method is used to convert the given file to a PDF format * @param inputFile - Name and the path of the file * @param outputFile - Name and the path where the PDF file to be saved * @param isPictureFile */ private void createPdf(String inputFile, String outputFile, boolean isPictureFile) { /** * Set the page size for the image */ Rectangle pageSize = new Rectangle(2780, 2525); Document pdfDocument = new Document(pageSize); String pdfFilePath = outputFile; try { FileOutputStream fileOutputStream = new FileOutputStream(pdfFilePath); PdfWriter writer = null; writer = PdfWriter.getInstance(pdfDocument, fileOutputStream); writer.open(); pdfDocument.open(); /** * Proceed if the file given is a picture file */ if (isPictureFile) { pdfDocument.add(com.lowagie.text.Image.getInstance(inputFile)); } /** * Proceed if the file given is (.txt,.html,.doc etc) */ else { File file = new File(inputFile); pdfDocument.add(new Paragraph(org.apache.commons.io.FileUtils.readFileToString(file))); } pdfDocument.close(); writer.close(); } catch (Exception exception) { System.out.println("Document Exception!" + exception); } } public static void main(String args[]) { PDFConversion pdfConversion = new PDFConversion(); pdfConversion.createPdf("C:/shunmuga/tajmahal.jpg", "C:/shunmuga/tajmahal.pdf", true); // For other files // pdfConversion.createPdf("C:/shunmuga/sample.html", //"C:/shunmuga/sample.pdf", false); } }I hope this one helps!!
thanx a lot
Thanks a lot..
you’re welcome.
Here Problem with this code is that,,
Newly created Pdf is not opened in my system while i am traying to create it from HTML file..
Give me solution for that
Hello Shunmuga,
thanks for your guide,
i add commons-io-1.4-bin.tar,commons-io-1.4-src,commons-io-1.4-src.tar,commons-io-1.4-bin jar files in my library but error in line 46
pdfDocument.add(new Paragraph(org.apache.commons.io.FileUtils.readFileToString(file)));
is not resolve.
plz help….
Hello Shunmuga,
thanks for your guide.
But I need to convert contents of browser into pdf…….
The given code converting the html code to pdf….. help me out for the browser contents….
Hi Surendar,
Thanks for your comments,If you are using JSF framework for your development, you can refer the following link
http://shunmugakrishna.wordpress.com/2009/11/27/data-exporting-in-jsf-using-primefaces/
Hello Shunmuga,
thanks alot….
according to your suggesion i do but at run time it gives error
Document Exception!java.io.IOException: file:/D:/itext/workgroup/iText/WebContent/Demo.jsp is not a recognized imageformat.
plz help me
why it gives such kind of error….
Hi Arpita,
you are trying to convert a jsp file in to pdf, its not an image file.
//for image file
pdfConversion.createPdf("C:/shunmuga/tajmahal.jpg", "C:/shunmuga/tajmahal.pdf", true);//for other files
pdfConversion.createPdf("C:/shunmuga/sample.txt", "C:/shunmuga/sample.pdf", false);I hope this one helps!!
is there any other way to do that?
thanks alot….
Shunmuga
with this I want to convert it to image pdf….. its giving me only the text pdf….
and also let me know the other way for that browser content pdf…
Hey Shunmugam
thanks for this article. really good. i just wanted to know that is there any way by which we can just convert first page of the doc file into pdf ? please explain if API allows such methods.
thanks
Hey Shunmuga,
it seems it is not working with doc files. when i am trying to convert doc to pdf then it is adding some junk characters in the start and end of the pdf. do u have any idea why it may happen ?
Hey Shunmuga,
thanks for this program. i have some issues here. when i am generating the pdf from doc its adding some junk chars in the start and end of the pdf file. so u have any idea why its happening? do we have any way to remove such junk chars from pdf.
kindly help.
thanks
Hi Sajid!!
I am also facing the same issue..i know this thing is now 2 years ago.but tell me did u get any response or how did u solved your problem????
Thanks in anticipation
Monty Khurana
hello, thanks for help.
i wanted to know that is there any way to write
createPdf(String htmlCode, String outputFile, boolean isPictureFile) this function?
e.g.: htmlCode=”Test”
html code in string instead of input file??
please help.
thanks again
Ravi
Hi Ravi,
Thanks for your comment ,you want convert html output as pdf or html code in to pdf?
Here i m only consider about html code in to pdf …. now let me know whats your probs?
Hello,Shunmuga:
Wanted to know how to generate a pdf with an image and data from db in the header of the pdf doc.I am trying to generate pdf on the fly.
Thanks in advance.
-Surabhi
Hi Surabhi,
Thanks for your comment ,you may try this following example .
import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.Element; import com.lowagie.text.HeaderFooter; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.Phrase; import com.lowagie.text.Rectangle; import com.lowagie.text.pdf.PdfWriter; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author shunmuga */ public class PDFHeader { private void createPDF() throws DocumentException { try { File inputFile = new File("tajmahal.JPG"); Document document = new Document(PageSize.A2.rotate()); PdfWriter.getInstance(document, new FileOutputStream("C:\\Users\\shunmuga\\Desktop" + File.separator + "SamplePicture.pdf")); HeaderFooter header = new HeaderFooter(new Phrase("Wonders"), false); header.setBorder(Rectangle.NO_BORDER); header.setAlignment(Element.ALIGN_CENTER); document.setHeader(header); HeaderFooter footer = new HeaderFooter(new Phrase("Page no: "), true); footer.setBorder(Rectangle.NO_BORDER); footer.setAlignment(Element.ALIGN_CENTER); document.setFooter(footer); document.open(); document.add(new Paragraph("Tajmahal:")); document.add(com.lowagie.text.Image.getInstance(inputFile.getName())); document.close(); } catch (IOException ex) { Logger.getLogger(PDFHeader.class.getName()).log(Level.SEVERE, null, ex); } } public static void main(String[] args) { try { PDFHeader pdfHeader = new PDFHeader(); pdfHeader.createPDF(); } catch (DocumentException ex) { Logger.getLogger(PDFHeader.class.getName()).log(Level.SEVERE, null, ex); } } }I hope this one helps…
Hi, Shunmuga :
Thank you . Do we have to create a XXX.pdf to generate the pdf on fly.
I am using JSF. when i click on preview notice button it has to generate the message in .pdf format with the company’s logo on the top left corner and some other info from database on the top right end corner of the pdf.
Thanks in advance.
-Surabhi.
Hello, Shunmuga :
the latest version of itext.jar doesn’t have import com.lowagie.text.HeaderFooter;
It only has import com.itextpdf.text.Header;
How do i handle this?
Thank You.
-Surabhi.
Hi,
Can you please tell me how to call this code in a servlet.
-Surabhi.
hi pavan,
this exception shows when i convert txt,docx,xls file to pdf.
Document Exception!java.io.IOException: file:/C:/Documents%20and%20Settings/Om/Desktop/_UpgradeReport_Files/pdftext.txt is not a recognized imageformat.
and i also change the file path as you suggest its below.
pdfConversion.createPdf(“C:\\Documents and Settings\\Om\\Desktop\\_UpgradeReport_Files\\pdftext.txt”, “C:\\Documents and Settings\\Om\\Desktop\\_UpgradeReport_Files\\cs4.pdf”, true);
Hi Shanmuga,
I have a jsp page which printout a web page which dynamic table fields(rows,columns) coming from the database.The requirement is to convert it to pdf on the fly with the help of a button.
How would I do that?
Any suggestion is gladly appreciated?
Hi,
Will it convert textbox, checkbox & radio button as well???
Thanks in advance
Hi,
Will it convert textbox, checkbox & radio buttons while converting as a pdf from html???
Thanks in advance
hi,
i want to convert Applet program into pdf file
hi,
The Applet program in which i have wrote jgraph code that want to convert pdf form can you help me.
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.ajax4jsf.org.w3c.tidy.Tidy;
import org.w3c.dom.Document;
import org.xhtmlrenderer.pdf.ITextRenderer;
public class NoticeRenderer {
private OutputStream out;
private NoticeSettings settings = null;
private StringBuffer buffer = new StringBuffer();
public NoticeRenderer(OutputStream out, NoticeSettings settings) {
this.out = out;
this.settings = settings;
}
public void start() {
addHtml(“”);
addDefaultStyleSheet();
}
public void end() {
addHtml(“”);
}
public void startBody() {
addHtml(“”);
}
public void endBody() {
addHtml(“”);
}
public void addPageBreak() {
addHtml(“”);
}
private void addHtml(String html) {
buffer.append(html);
}
public void addDefaultStyleSheet() {
String pageSize = “size: ” + settings.getPageWidth() + “in ”
+ settings.getPageHeight() + “in;\n”;
String pageMargin = “margin: ” + settings.getPageBorderWidth() + “;\n”;
String header = “” + “” + “@page { \n”
+ pageSize
+ pageMargin
+ (settings.isIncludePageBorderLine() ? “border: thin solid black;\n”
: “”) + “padding: 1em;\n” + “}\n”
+ “table#addresslist, td#addresslist_td , th#addresslist_th\n”
+ “{\n” + ” border-color: #600;\n”
+ ” border-style: solid;\n” + “}\n” +
“table#addresslist\n” + “{\n”
+ ” border-width: 1px 1px 1px 1px;\n”
+ ” border-spacing: 0;\n”
+ ” border-collapse: collapse;\n” + “}\n” +
“td#addresslist_td\n” + “{\n” + ” margin: 0;\n”
+ ” padding: 4px;\n” + ” border-width: 1px 1px 0 0;\n”
+ ” background-color: #FFC;\n” + “}\n”
+ “th#addresslist_th\n” + “{\n” + ” margin: 0;\n”
+ ” padding: 4px;\n” + ” border-width: 0 0 1px 1px;\n”
+ ” background-color: #FFC;\n” + “}\n”
+ “” + “” + “”;
addHtml(header);
}
public void addLogoAndHeader() {
if (settings == null)
return;
String top = “”;
if (settings.getClientLogo() != null
&& settings.getClientLogo().length > 0) {
//top += ” 200 ? 200: true); max-height: 100px; height: expression(this.height > 100 ? 100: true);\” src=\”"
top += “”;
}
if (settings.getNoticeHeader() != null
&& settings.getNoticeHeader().length() > 0) {
top += “” + settings.getNoticeHeader() + “”;
}
top += “”;
addHtml(“” + top + “”);
}
public void addFooter() {
if (settings == null)
return;
String bottom = “”;
if (settings.getNoticeFooter() != null
&& settings.getNoticeFooter().length() > 0) {
bottom += settings.getNoticeFooter();
}
addHtml(“” + bottom + “”);
}
public void addReportPageContent(String reportText) {
addHtml(reportText);
}
public void render() {
Tidy tidy = new Tidy();
tidy.setTidyMark(false);
tidy.setDocType(“auto”);
tidy.setWrapScriptlets(true);
tidy.setOnlyErrors(false);
tidy.setXHTML(true);
tidy.setEncloseText(true);
tidy.setXmlTags(true);
ByteArrayOutputStream os = new ByteArrayOutputStream();
String data = buffer.toString();
tidy.parseDOM(new ByteArrayInputStream(data.getBytes()), os);
String newString = new String(os.toByteArray());
int errorCount = tidy.getParseErrors();
if (errorCount == 0)
newString = new String(os.toByteArray());
if (newString.trim().length() == 0)
newString = data;
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
Document doc = builder.parse(new ByteArrayInputStream(newString
.getBytes(“UTF-8″)));
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(doc, HttpSessionHelper.getServerURL() + “/”);
renderer.layout();
renderer.createPDF(out);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void renderNotice(String reportText, OutputStream out,
NoticeSettings settings) {
NoticeRenderer renderer = new NoticeRenderer(out, settings);
renderer.start();
renderer.startBody();
renderer.addLogoAndHeader();
renderer.addReportPageContent(reportText);
// renderer.addFooter();
renderer.addPageBreak();
renderer.endBody();
renderer.end();
renderer.render();
}
}
I have used NoticeRenderer.java and previewnotice.jsp to generate a pdf doc on the fly when i click on “PreviewNotice” button.
I want to convert a java file directly instead of using the HTML conversion i have used in NoticeRenderer.java
i tried doing the same in java with the help of code given by you.
this is all i could manage :
//PDFHeader.java
// import java.awt.Color;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.HeaderFooter;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
// import com.lowagie.text.pdf.draw.LineSeparator;
// import com.lowagie.text.pdf.draw.VerticalPositionMark;
/**
*
* @author Sushma P
*/
public class PDFHeader
{
private void createPDF() throws DocumentException
{
try
{
File inputFile = new File(“tomcat.gif”);
Document document = new Document(PageSize.A4);
// VerticalPositionMark separator = new LineSeparator(1, 80, Color.RED, Element.ALIGN_RIGHT, -2);
PdfWriter.getInstance(document, new FileOutputStream(“/home/sushma/Desktop” + File.separator + “SamplePicture.pdf”));
String address = “#263, \n Himagiri Meadows, \n BG Road, \n Blr-83″;
HeaderFooter header = new HeaderFooter(new Phrase(address), false);
header.setBorder(Rectangle.NO_BORDER);
header.setAlignment(Element.ALIGN_RIGHT);
document.setHeader(header);
// VerticalPositionMark separator = new LineSeparator(1, 80, Color.RED, Element.ALIGN_RIGHT, -2);
HeaderFooter footer = new HeaderFooter(new Phrase(“Page no: “), true);
footer.setBorder(Rectangle.NO_BORDER);
footer.setAlignment(Element.ALIGN_CENTER);
document.setFooter(footer);
Image img = Image.getInstance(inputFile.getName());
img.setAlignment(Element.ALIGN_LEFT);
img.setAbsolutePosition(0 , 825 – img.getScaledHeight());
document.open();
document.add(img);
document.add(new Paragraph(“Helloo:”));
document.close();
} catch (IOException ex)
{
Logger.getLogger(PDFHeader.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void main(String[] args)
{
try
{
PDFHeader pdfHeader = new PDFHeader();
pdfHeader.createPDF();
} catch (DocumentException ex)
{
Logger.getLogger(PDFHeader.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Could you please help me out .
Thanks in advance.
-Surabhi.
Notice
i want to generate the pdf in the format of a company’s letterhead. with logo and some info in the header region and a footer with info and body with some data.
Thanks You.
-Surabhi.
Hello Shunmuga,
thanks for your guide,
But i’ve an error in line 46
pdfDocument.add(new Paragraph(org.apache.commons.io.FileUtils.readFileToString(file)));
is not resolve.what i do
plz help….
And also how is use this code in GWT project,
plz help me
-kasthuri
i’m execute my program for image file without 46th line,
i have an exception,
that exception is Exception!java.io.FileNotFoundException
Hi kasthuri,
If you want to convert image file in to pdf means you may try following codes
package samplePDF; import com.lowagie.text.Document; import com.lowagie.text.pdf.PdfWriter; import java.io.FileOutputStream; /** * * @author shunmuga */ public class PDFImageConversion { private void createPdf(String inputFile, String outputFile, boolean isPictureFile) { /** * Create a new instance for Document class */ Document pdfDocument = new Document(); String pdfFilePath = outputFile; try { FileOutputStream fileOutputStream = new FileOutputStream(pdfFilePath); PdfWriter writer = null; writer = PdfWriter.getInstance(pdfDocument, fileOutputStream); writer.open(); pdfDocument.open(); /** * Proceed if the file given is a picture file */ if (isPictureFile) { pdfDocument.add(com.lowagie.text.Image.getInstance(inputFile)); } pdfDocument.close(); writer.close(); } catch (Exception exception) { System.out.println("Document Exception!" + exception); } } public static void main(String args[]) { PDFImageConversion pdfConversion = new PDFImageConversion(); pdfConversion.createPdf("C:/Users/shunmuga/Desktop/DSCN1320.JPG", "C:/Users/shunmuga/Desktop/ss.pdf", true); } }it may helps……..
Please guide me how to generate invoice using itext
Hi shanmuga,
thanks for ur guide.
i got the output for converting text and image file to pdf format.
Now i want, how to generate the invoice and appropriate code in java(with GWT or without)
With regards
kasthuri.D
hi………… ur code is really useful 4 me….. wen i convert html page to pdf. it shows only page code . how to show html page as pdf
Thankyou Sir.
we have a comand button on form(using jsf) coantaing datatable of records from database,for pdf-download. How can we do that
hi..
could you pls tell me how to produce a pdf docuemnt from xml having an dtd associated with it using itext
Dear All,
I have a requirement for converting a pdf file to a tiff file format, Can any one give me some clue like how we can create that using itext or anyother opensource?
Thanks,
Anil Sahu
hi,
could u please help me, i have html text in the database of data type ntext now my need is how to present this html text in a pdf report using iText
Hello Shunmuga,
thanks for your guide,
i add commons-io-1.4-bin.tar,commons-io-1.4-src,commons-io-1.4-src.tar,commons-io-1.4-bin jar files in my library but error in line 46
pdfDocument.add(new Paragraph(org.apache.commons.io.FileUtils.readFileToString(file)));
is not resolve.
plz help….
and
the HTML data like
(Regd. ; Head Office : ererer-444444)HR DEPARTMENT Ref: >REFERENCENUMBER> Date: >Date>
Dear Sir,
Sub: Domestic Enquiry against >Staff Name> (charge sheet)
- E.C. >EC Number>
You are hereby requested to appear before the Enquiry Officer, Shri >Enq.Off Name>, at the time, date and place mentioned below, to give evidence in the above case:
Time>EO Time>Date>EO Date>Place>EO Place>.
You are also requested to meet >MR Name> HR ;IR Dept., Head Office, the Management Representative in the above case at the time, date and place mentioned below:
Time>MR Time>Date>MR Date>Place>MR Place>
Yours faithfully, CHIEF MANAGER(HR) cc to: The Assistant General Manager – Inspection and Audit Department, HO.
With a request to arrange for delivering the original to the member under acknowledgment and intimate us the date of service of the original.Please relieve/permit the above member at appropriate time to enable him/her to attendthe enquiry. this data input to the PDF then automatic
convert to PDF please help me
hello sir,
i have project in clg on file conversion..
so i use this code.but there is an error abt
the import com.lowagie.text.Document can not be resolved
theimport com.lowagie.text.Paragraph can not be resolved
thr import com.lowagie.text.pdf.PdfWriter can not be resolved
can u plz help me…
waiting for ur reply…
HI Dear Shanmuga !
I need some help for my academic project.. i need to process research papers and want to retrieve data like title of the paper, author name, key words from from each pdf document… when i gone through many itext examples everything is about writing to pdf.. but i need to read these data from PDfs.. i need ur concerned help. pls help me and if possible give me some sample codes. thanks in Advance
Regards,
Mahesh
hi …..
can u plz suggest or pass some code how i convert word doc to pdf file using itext…
I have been google it since 4 / 5 dys but didnt get a clue…plz help
Hi Shunmugakrishna,
Any assistance in converting PDF to image(jpg) using iText java?
Thanks.
Hi Shanmuga,
can i use your Code to convert html to pdf without html-tags?
Can you help me plz?
Currently I’m using the code, but i’m getting pdf with html-tags…
Thanx.
regards,
Ewald
Hi Shunmuga,
your Example converts html-code into a pdf-file.
I need urgently a Funkction, that converts html-output into a pdf-file…
Plz help me…
Thanx in advance.
Hi shunmugakrishna,
I tried to use your code to create PDF file from doc file. But it is dumpling lot of garbage into the pdf…Apart from that everything is good from your code. Can you please let me know how to avoid that. How ever when I am converting the txt file to pdf it is working fine…..Only problem is with doc file to pdf…please suggest….
Hi Shunmugakrishna,
I am looking for a way to convert any file into PDF. For example user can upload a doc file, .html file, .png file, .txt file or any thing. Is it possible to do it using iText API or is there any limitation on the file type.
Thanks
Saj.
Is it possible to convert PS to PDF using java code
Hi…i want to convert .PS files into PDF is any API’s present in JAVA to do this
Please HELP
Thanks in Advance,
Bhargav
How to convert PS to PDF using java
How to Replace the Link annotation uri in pdf using iTextSharp )(iTextpdf 5.1.1)using JAVA?
im having one task please help me on this…. Consider a PDF file named sample.pdf containing 72 pages.Now using iTextSharp library I had split the PDF pages into 72 separate file and saved with the name as 1.pdf,2.pdf….72.pdf. So in the 4.pdf when clicking that hyperlinks I need to make the PDF navigate to 24.pdf,27.pdf,28.pdf. how to do it in JAVA?
please provide me the sample code….
Thank you, Sathya:
How to Replace the Link annotation uri in pdf using iTextSharp )(iTextpdf 5.1.1)using JAVA?
im having one task please help me on this…. Consider a PDF file named sample.pdf containing 72 pages.Now using iTextSharp library I had split the PDF pages into 72 separate file and saved with the name as 1.pdf,2.pdf….72.pdf. So in the 4.pdf when clicking that hyperlinks I need to make the PDF navigate to 24.pdf,27.pdf,28.pdf. how to do it in JAVA?
please provide me the sample code….
Thank you, Sathya
Hi Shunmuga,
I m working in Online Exam Portal in B.E.I wan convert the Database of MySql into PDF file in JSP.Plz help me for this problem..
Hi, Can any help me to convert PDF to TXT.
Thanx for code…
how can i convert a doc to pdf? when i use the code, convert sucessful, but the ouput pdf has Garbled…..
Hi Shunmuga,
By using that code it is able to convert my html page into pdf in a html text format. But i need html output into pdf as it is with css. do u know any solutions for that.
Hi Shunmuga thanks for your code. I have one requirement for my project . There I have one link on jsp page ‘link to pdf’ on click of this I need to show the same jsp look and feel which currently showing. On that jsp I have few frames which calls different servlets from there. Is there any solution for this ? I am thinking it’s better to handle this requirement from client side like with Java Script rather than Server side.
Hi
In my file I have written code to display table,list and image in order inside a table using itext.jar
when Pdf is generated the vertical borders of the pdf is overridden by the image,is there anyway to get the lines.(Meaning the border lines are missed only in the image.
Kindly guide.
Hi
I used the above code for converting fiile to pdf but i got the following error
The declared package “com.sample.pdfconvertor” does not match the expected package
The import com.lowagie cannot be resolved
org.apache cannot be resolved
please me out….
hi,
is there any way to convert pdf file to word file with formatting?please help if possible.