How can I print a JTextArea and have the text fit the print sheet?

0
public boolean imprimirTxtArea(boolean flag) {
        if (flag == true) {

            String Cabeza = "Titulo";
            String Pie = "pagina 1";

            try {
                //Mensaje de encabezado           
                MessageFormat header = new MessageFormat(Cabeza);
                MessageFormat footer = new MessageFormat(Pie);
                //Imprimir JTextArea
                jTextArea1.print(header, footer, true, null, null, true);                
                jTextArea1.setText("");

            } catch (PrinterException ex) {
                Logger.getLogger(V3.class.getName()).log(Level.SEVERE, null, ex);
                return false;
            } catch (IOException ex) {
                Logger.getLogger(V3.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return true;
    }

I have this method but when executing it the text that is in the jtextarea overflows the sheet when it is printed and appears in 2 sheets of impression.

How can I adjust the Text of the JtextArea so that it is printed on a single sheet?

    
asked by Devid 07.06.2018 в 21:50
source

0 answers