Visualize with good format the PDF generated with JAVA

0

Good, I have an application made on a dealer, I have a jtabbedpane with a reports tab where I make queries or by customer code or by registration and I visualize it in a texArea in this way:

The issue is that when I click on the button to print and generate a PDF with the text I pick from the textArea, it shows me the content of this, but all in one line, without applying the format I want.

Image of the generated PDF:

Print class code:

public class ImprimirPDF
{  
   public Font fuenteInforme = new Font("Dialog", Font.PLAIN, 10);
   public PrintJob pj;
   public Graphics paginaInforme;

    public ImprimirPDF()
    {
        pj = Toolkit.getDefaultToolkit().getPrintJob(new Frame(), "Informe", null);
    }

    public void realizarImpresion(String textoImprimir)
    {
        try
        {
            paginaInforme = pj.getGraphics();           
            paginaInforme.setFont(fuenteInforme);
            paginaInforme.setColor(Color.black);

            paginaInforme.drawString(textoImprimir, 60, 80);            

            paginaInforme.dispose();
            pj.end();
        }catch(Exception e){JOptionPane.showMessageDialog(null, "Impresión cancelada");}
    }    
}
    
asked by Mario Guiber 23.10.2017 в 22:13
source

0 answers