Created
March 20, 2021 09:43
-
-
Save OtayNacef/eb4cebb038456f2a7e336a7bff4af023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FXML | |
private void telecharger(ActionEvent event) throws SQLException { | |
Reservation_hotes res = new Reservation_hotes(); | |
res = table_reserv.getSelectionModel().getSelectedItem(); | |
ReservationPdf pdf = new ReservationPdf(); | |
pdf.Reservation( | |
res.getNumero_reservation(), | |
res.getDate_debut(), | |
res.getNb_jours(), | |
res.getNb_personne(), | |
res.getPrix() | |
); | |
Alert alert = new Alert(Alert.AlertType.INFORMATION); | |
alert.setTitle("Information"); | |
alert.setHeaderText("Pdf Reservation "); | |
alert.setContentText("votre pdf est telecharger avec succès"); | |
alert.showAndWait(); | |
if (Desktop.isDesktopSupported()) { | |
File myFile = new File("C:\\xampp\\htdocs\\Pidev Desktop/Reservation" + res.getNumero_reservation() + ".pdf"); | |
try { | |
Desktop.getDesktop().open(myFile); | |
} catch (IOException ex) { | |
Logger.getLogger(AfficherReservationController.class.getName()).log(Level.SEVERE, null, ex); | |
} | |
} | |
} | |
####### | |
public void reservationPdf(int numRes,Date dateDeb,int nb_jours, int nb_pers,Double totaleprix ) throws SQLException { | |
Document document = new Document(PageSize.A4); | |
try{ | |
PdfWriter.getInstance(document, new FileOutputStream("Reservation"+numRes+".pdf")); | |
document.open(); | |
/*Rectangle pageSize = new Rectangle(216, 720); | |
pageSize.setBackgroundColor(new BaseColor(0xFF, 0xFF, 0xDE)); | |
*/ | |
Paragraph p1 = new Paragraph("Reservation N° : "+numRes); | |
Paragraph p2 = new Paragraph("----------------------------"); | |
Paragraph p3 = new Paragraph(" "); | |
Paragraph p4 = new Paragraph("Date de début : "+ dateDeb); | |
Paragraph p5 = new Paragraph ("Nombre de jours : "+ nb_jours + " jour(s)"); | |
Paragraph p6 = new Paragraph("Nombre de personnes : "+ nb_pers + " personne(s) "); | |
Paragraph Prix = new Paragraph("Prix Totale : "+ totaleprix + " $"); | |
Paragraph p7 = new Paragraph("Scanner le QR_Code pour connaitre le nom de la maison d'hôte :"); | |
//QR_Code | |
BarcodeQRCode my_code = new BarcodeQRCode(num(numRes),numRes,numRes,null); | |
Paragraph p8 = new Paragraph("------------------------------------------------------------------"); | |
Image qr_image = my_code.getImage(); | |
document.add(p1); | |
document.add(p2); | |
document.add(p3); | |
document.add(p7); | |
document.add(qr_image); | |
document.add(p8); | |
document.add(p4); | |
document.add(p3); | |
document.add(p5); | |
document.add(p3); | |
document.add(p6); | |
document.add(p3); | |
document.add(Prix); | |
document.add(p3); | |
} | |
catch(DocumentException | FileNotFoundException e){ | |
System.out.println(e); | |
} | |
document.close(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment