Good afternoon, I created a PDF.java, which has the function of generating a pdf, and in another file (FormularioHoteleriosController.java) by clicking on a particular button, I instantiate the PDF.java file in order to generate and open pdf , however, I need when I click the button that is in the FormulasHotelControler.java, retrieve values from EditText's located in it, and then print the results in the PDF. Thank you !!
FILE GENERATING PDF:
public class Pdf {
public static final String IMAGE = "imagens/boleto.png";
public static final String DEST = "results/images/boleto.pdf";
public static void main(String[] args) throws IOException, DocumentException {
File file = new File(DEST);
file.getParentFile().mkdirs();
new Pdf().createPdf(DEST);
}
public void createPdf(String dest) throws IOException, DocumentException {
Document document = new Document(PageSize.A4.rotate());
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(dest));
document.open();
PdfContentByte canvas = writer.getDirectContentUnder();
Image image = Image.getInstance(IMAGE);
image.scaleAbsolute(PageSize.A4.rotate());
image.setAbsolutePosition(0, 0);
canvas.addImage(image);
document.close();
Desktop.getDesktop().open(new File("results/images/boleto.pdf"));
}
}
FILE CALLING INSTANCIA PDF.AJVA BY CLICKING THE BUTTON:
@FXML public void gerarPdf(){
try {
Pdf.main(null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}