To convert Html to pdf in java

To convert Html to pdf in java

View Answers

October 24, 2009 at 3:29 PM

Hi Friend,

Try the following code:

import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.html.HtmlWriter;
import com.lowagie.text.pdf.PdfWriter;

public class ConvertHTMLToPDF{
public static void main(String[]args){
try{
File file = new File("applet.html");
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
String st="";
while (dis.available() != 0) {
st+=dis.readLine().toString()+"\n";
}
System.out.println(st);
Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("Hello.pdf"));
document.open();
document.add(new Paragraph(st));
document.close();
bis.close();
dis.close();
}
catch(Exception e){}
}
}

Thanks









Related Tutorials/Questions & Answers:
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 and i want to be able to generate it to html page as well. How to go about
to convert html to pdf in java - Java Beginners
to convert html to pdf in java  HI all, i want to convert html to pdf using java. actually i dont need as the tags in the html. but the tags should be removed and i need only the text in that. Thanks in advance
Advertisements
To convert Html to pdf in java - Java Beginners
To convert Html to pdf in java  Hi all, I want to convert html file to pdf file using java. can any one help me out. Thanks & Regards Santhosh Ejanthkar  Hi Friend, Try the following code: import
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
How to Convert PDF into rtf File Java
the online example of Java Convert PDF into rtf File. Thanks...How to Convert PDF into rtf File Java  Hi, How could in covert the PDF file to rtf file in Java Programming. Please suggest any online example
Displaying html code in pdf with itext - Java Beginners
in the database i need to display this data in the pdf . i am using itext to create the pdf . i am using HTMLWorker to convert the html data . but styles...Displaying html code in pdf with itext   Hi , I am
convert Html to Xhtml - Java Beginners
convert Html to Xhtml  Hi All, I am trying to convert html to xhtml in java. to do this i am using htmlcleaner api. i am not able to do with it.i ve not even got basic example on that so please can u send some example
how to load pdf on html
how to load pdf on html  how to load pdf on html
Convert PDF to XML in Java
Convert PDF to XML File in Java In this Java tutorial section, you will learn how to convert pdf file to xml using java program. We have used itext api for this purpose. To read hello.pdf file, we have used PDFReader class. The data
converting html file into pdf - Struts
converting html file into pdf  i want to convert html file into pdf file using java code please help me
convert excel into pdf
convert excel into pdf  How to convert excel into pdf files
convert data from pdf to text file - Java Beginners
convert data from pdf to text file   how to read the data from pdf file and put it into text file(.txt
convert word document to pdf
convert word document to pdf  Hi, Could you please help me write a java code that converts the word docuemnt into PDF? I have to save the generated..."); f.convert(fos,"pdf"); I would also want to know, what does "OfficeFile" in the code
Convert pdf to rtf file using Java
Convert pdf to rtf file using Java In this section, you will learn how to convert .pdf file to .rtf file in java programming language. We have used itext api for this purpose. To read resume.pdf  file, we have used PDFReader class
Convert pdf to text file using Java
How to Convert pdf to text file in Java In this section, you will learn how to convert pdf file to text file in Java Programming. We have used itext api for this purpose. To read resume.pdf  file, we have used PDFReader class
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
Convert BLOB to PDF and save it to a location
Convert BLOB to PDF and save it to a location  I have a requirement to convert blob(stored in a DB table) back to .pdf in the UI(for the users... it has to convert each blob to a pdf and zip it, which the user should be able
Java convert jtable data to pdf file
Java convert jtable data to pdf file In this tutorial, you will learn how to convert jtable data to pdf file. Here is an example where we have created... have fetched the data from the jtable and save the data to pdf file. Example
Convert Text File to PDF file
Convert Text File to PDF file  Here is the way how to covert your Text file to PDF File, public class TextFileToPDF { private static void...(inLine); System.out.println("Text is inserted into pdf file
how to convert doc file into html using java swing
how to convert doc file into html using java swing  i want to convert doc file into html and display it on jtextarea please help me and give the sample code
Convert Text File to PDF file
Convert Text File to PDF file  import java.io.BufferedReader; import java.io.FileOutputStream; import java.io.FileReader; import...); System.out.println("Text is inserted into pdf file"); document.close
Convert pdf to rtf and txt - XML
Convert pdf to rtf and txt  Can we convert PDF to RTF and TXT, and how?  Hi Friend, Try the following codes: 1)Convert PDF to RTF...) {} } } 2)Convert PDF to TEXT import java.io.*; import java.util.
CONVERT JTable DATA TO PDF FILE
CONVERT JTable DATA TO PDF FILE  HOW TO CONVERT JTable DATA TO .PDF... the jtable data from the jframe and stored the data into the pdf file in the form...); button=new JButton("Save to pdf"); button.addActionListener(new ActionListener
ModuleNotFoundError: No module named 'j-html-pdf'
ModuleNotFoundError: No module named 'j-html-pdf'  Hi, My Python...-html-pdf' How to remove the ModuleNotFoundError: No module named 'j-html-pdf' error? Thanks   Hi, In your python environment you
convert this html form to jsp
convert this html form to jsp  <html> <head> <script language="javascript" src="images/validationm.js"></script> <... includes html tags so you may change an extension. Please visit the following links
convert html to excel using jsp
convert html to excel using jsp   i want to convert a html page into mcrosoft excel page using jsp.how i do
convert html website into wordpress theme
convert html website into wordpress theme  i am trying to convert an html site into wordpress.and i have divided my html website into 4 parts i.e. index.php,header.php,footer.php and side bars.php.when i am trying to run
Convert Text to HTML
Convert Text to HTML       In this section, We are discussing the conversion of text into html file...:\corejava>java TextToHTML This is text to html convertor program
How to convert entity character to html character
How to convert entity character to html character  Please help me to "convert entity character to html character" in java. If possible please provide source code which take String as input and return as String
How to convert entity character to html character
How to convert entity character to html character  How to convert entity character to html character
Creating PDF in JAVA
Creating PDF in JAVA  How create pdf in java ? Take value from database for particular PDF
Convert Text To PDF
Convert Text To PDF       Here we are discussing the convertion of a text file into a pdf file... C:\convert\completed>java TextToPDF Enter text: Hi, I am
PDF to Word Conversion - Java Beginners
PDF to Word Conversion  Hello, Can we convert a PDF document to Microsoft word document thru Java. If its not possible in Java, is it possible in any other language
PDF to Image
PDF to Image  Java code to convert PDF to Image
Convert ZIP To PDF
Convert ZIP To PDF       Lets discuss the conversion of a zipped file into pdf file..., unzip it and then store it into a byte array. Convert this array of byte
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
form field mapping with pdf file using java
form field mapping with pdf file using java   Hai all, I have one requirement that i have one html form.i have to map the form fields with pdf... related to the field in pdf file should marked with a color. can any one give
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, it receives high praise. I understand it uses iText but I am having a problem
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, it receives high praise. I understand it uses iText but I am having a problem
'Hello World' file from a servlet (PDF, HTML or RTF).
 'Hello World' file from a servlet (PDF, HTML or RTF...; In this program we are going to tell you how we can create three file rtf,pdf and html files.And we are printing here Hello Word on PDF, HTML, And RTF formate
JAVA with HTML
JAVA with HTML  Hello I want an JAVA example that would convert any UNICODE character OR STRING into its Equivalent HTML Numeric[ASCII] values... Like for character ? it's equivalent value is آ like all the other
PDF creation in JAVA - JSP-Servlet
PDF creation in JAVA  HI! Good morning.... I want to create pdf file and i want to write something into pdf file....before creation. Upto creation i have done but how to write data into pdf. File Writer is not working
java with html
java with html  actually we use html code in the java programs........ why we are using like please tell me the reason.. please reply me soon
converting html to ppt,pptx - Java Beginners
converting html to ppt,pptx   Hi, i convert html to .doc format.But i want to convert the html to ppt,xml,pptx,docx,pdf.. Is there any possibility to solve this problem
converting html to ppt,pptx - Java Beginners
converting html to ppt,pptx   Hi, i convert html to .doc format.But i want to convert the html to ppt,xml,pptx,docx,pdf.. Is there any possibility to solve this problem
itext pdf - Java Interview Questions
itext pdf  sample program to modify the dimensions of image file in itext in java  HiIf you want to know deep knowledge then click here and get more information about itext pdf program.http://www.roseindia.net/java
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
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