List of usage examples for com.itextpdf.text.pdf PdfWriter open
@Override public void open()
Document
has been opened and that Elements
can be added. From source file:qcas.StudentPerformanceController.java
@FXML public void exportToPdf() throws IOException, DocumentException { WritableImage image = performanceAnchorPane.snapshot(new SnapshotParameters(), null); //File file = new File("StudentPerformance.png"); ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); try {/*from www. j a v a 2s . co m*/ ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", byteArray); } catch (IOException e) { } Document document = new Document(); String output = "StudentPastPerformance.pdf"; try { int indentation = 0; FileOutputStream fos = new FileOutputStream(output); PdfWriter writer = PdfWriter.getInstance(document, fos); writer.open(); document.open(); Image newImage = Image.getInstance(byteArray.toByteArray()); newImage.scaleToFit(500, 450); document.add(newImage); document.close(); writer.close(); } catch (Exception e) { e.printStackTrace(); } pdfDownloadedLabel.setVisible(true); }
From source file:qcas.StudentTestResultController.java
@FXML public void exportToPdf() throws IOException, DocumentException { WritableImage image = performanceAnchorPane.snapshot(new SnapshotParameters(), null); //File file = new File("StudentPerformance.png"); ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); try {/* w ww.ja v a 2 s.co m*/ ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", byteArray); } catch (IOException e) { } Document document = new Document(); String output = "StudentQuizPerformance.pdf"; try { int indentation = 0; FileOutputStream fos = new FileOutputStream(output); PdfWriter writer = PdfWriter.getInstance(document, fos); writer.open(); document.open(); Image newImage = Image.getInstance(byteArray.toByteArray()); newImage.scaleToFit(500, 450); document.add(newImage); document.close(); writer.close(); } catch (Exception e) { e.printStackTrace(); } pdfDownloadedLabel.setVisible(true); }