Problemas ao utilizar iText para conversão

3 respostas
N

Estou convertendo um HTML para PDF, porém estou com o seguinte problema:

Quanto tenho uma tag no HTML a biblioteca não está convertendo corretamente, segue exemplo:

www.google.com.br * Funciona corretamente

Google * Não funciona

Alguém teve esse problema?

Segue código da classe:
package br.com.grupow.htmldoc;

import com.lowagie.text.DocumentException;
import java.io.*;
import org.w3c.tidy.Tidy;
import org.xhtmlrenderer.pdf.ITextRenderer;

public class Html2Pdf
{

    public Html2Pdf()
    {
    }

    public static void convert(String input, String output)
        throws DocumentException, FileNotFoundException, IOException
    {
        OutputStream out = new FileOutputStream(output);
        convert(((InputStream) (new ByteArrayInputStream(input.getBytes()))), out);
    }

    public static void convert(String input, OutputStream out)
        throws DocumentException, IOException
    {
        convert(((InputStream) (new ByteArrayInputStream(input.getBytes()))), out);
    }

    public static void convert(InputStream input, OutputStream out)
        throws DocumentException, IOException
    {
        Tidy tidy = new Tidy();
        org.w3c.dom.Document doc = tidy.parseDOM(input, null);
        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocument(doc, null);
        renderer.layout();
        renderer.createPDF(out);
        renderer.finishPDF();
        out.close();
    }

    
}

3 Respostas

N

Ninguém tem ideia do que pode ser? ;/

UMC

Troca a biblioteca pra ver!

vlw

N

Pois é, até ja pensei nessa possibilidade, mas essa biblioteca já está em produção, queria antes dar uma verificada se encontro a solução.

Criado 4 de maio de 2010
Ultima resposta 5 de mai. de 2010
Respostas 3
Participantes 2