Boa tarde, criei um PDF.java, que tem como função gerar um pdf, e em outro arquivo(FormularioHoteleriosController.java) ao clicar em um determinado botão, eu instancio o arquivo PDF.java para poder gerar e abrir o pdf, porém, eu necessito que quando eu clicar no botão que encontra-se no FormularioHoteleriosControler.java, resgate valores de EditText's localizados no mesmo, e então, imprimir os resultados no PDF. Obrigado!!
ARQUIVO QUE GERA O 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"));
}
}
ARQUIVO QUE CHAMA INSTANCIA O PDF.AJVA AO CLICAR NO BOTÃO:
@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();
}
}