It is easy with itext. You have some problems because the HTMLParser doesn`t support all tags. The most important is that it doesn’t support hr tag and br tag is br /.

 

Here, you are a example:

            Document doc = new Document(PageSize.A4, 50, 50, 108, 80);// cuatro

           

OutputStream SalidaPdf = new FileOutputStream(SalidaPdfTemp

                             .getAbsoluteFile());        

                  PdfWriter writer = PdfWriter.getInstance(doc, SalidaPdf);             

                  writer.setPageEvent(this);

                 

                  doc.open();

                 

     

                  doc.resetPageCount();

                  try {

                  HtmlParser.parse(doc, new FileInputStream(temp.getAbsoluteFile()));

                  // doc is the file to create and FileInputStream is the file

            // with the HTML code

                  } catch (Exception e) {

                        e.printStackTrace();

                        System.out.println("error parse a pdf" + e.toString());

                  }

                  doc.close();

 

Pepe Caballero

Ingeniero Informatica


De: Ruben Bayemi Nloga [mailto:[EMAIL PROTECTED]
Enviado el: martes, 08 de junio de 2004 15:39
Para: [EMAIL PROTECTED]
Asunto: [iText-questions] HTML2PDF

 

hello,

I want to convert a document HTML (or JSP) to PDF, I don't know I do?

please can you help me or send me an example?

I visit the site of www.lowanie.com but I don't have a solution.

Thanks (sorry for my English. I am a francophone man!)

 

best regards!

Reply via email to