Help with iText 5.5.12 (It does not capture a Text Area)

0

I have a problem in netbeans when trying to generate a PDF with iText 5.5.12. I select the route where I want the PDF to be downloaded and the route is saved, but when trying to generate the PDF file with the text captured in a Text Area it does not capture anything and sends an error, it only creates the document without anything.

private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {                                          
    // TODO add your handling code here:
    JFileChooser dlg = new JFileChooser();
    int option = dlg.showSaveDialog(this);
    if(option == JFileChooser.APPROVE_OPTION){
        File f= dlg.getSelectedFile();
        txtruta.setText( f.toString());
    }

}       

 private void btnpdfActionPerformed(java.awt.event.ActionEvent evt) {                                       
    // TODO add your handling code here:
    String ruta=txtruta.getText();
    String contenido=txtcontenido.getText();
    try{
        FileOutputStream archivo = new FileOutputStream(ruta+".pdf");
        Document doc = new Document();
        PdfWriter.getInstance(null, archivo);
        doc.open();
        doc.add(new Paragraph(contenido));
        doc.close();
        JOptionPane.showMessageDialog(null, "PDF Correctamente creado");

    }catch (Exception e){
        JOptionPane.showMessageDialog(null, "Error: No se pudo crear el archivo PDF " +e);
        System.out.println("Error: " +e);

    }

}              
    
asked by Envelope32 05.12.2018 в 04:40
source

0 answers