[英]I am trying to replace a BufferedImage in my code with an animated gif
[英]I am trying to get my Borderpane's center data and turn it to a BufferedImage or an Image
我正在FXML scenebuilder中進行編碼,並且嘗試獲取TableView(在borderpane中心)並將其放入PDF中。 我正在使用iText並創建PDF,在其中添加了一些圖像,但無法獲取Borderpane的數據或TableView。
@FXML
TableView<ItemList> table;
@FXML
TableColumn<ItemList, String> tableName;
@FXML
TableColumn<ItemList, String> tableCount;
@FXML
TableColumn<ItemList, String> tablePrice;
@FXML
TableColumn<ItemList, String> tableTotal;
@FXML
private BorderPane dneme;
我的桌子在邊框的中央。 我嘗試了dneme.getCenter()。getScene()。getWindow()或table.getScene()。getWindow()我也嘗試了沒有getCenter(),getScene()或getWindow()的情況。
我的程序有一個表格,數據將添加到表格中,我只想獲取表格並將其放入PDF。 只有表格位於邊框的中心。 在此處輸入圖片說明
謝謝你的幫助。 我在嘗試時發現了同樣的東西,這對我來說最有效。 我的問題是,它獲得了屏幕快照,但不適合我的pdf框架。 我削減了一部分,但正如我所說,它確實有效。 我用了
WritableImage image = dneme.getCenter().snapshot(new SnapshotParameters(), null);
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("ImagesBOTTOMPDF.pdf"));
document.open();
File outputfile = new File("d.png");
ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", outputfile);
Image imageRight = Image.getInstance("d.png");
document.add(imageRight);
} catch (FileNotFoundException | DocumentException i) {
System.err.println(i.getMessage());
}
document.close();
我想我稍微改變一下框架就可以解決問題。 它變成了我的快照的png文件,並且png看起來不錯,但是當導出為pdf時,它會更改框架。 (對不起,我的英語不好)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.