[英]Add image in pdf using pdfbox at a particular cell
我正在使用pdfbox生成pdf。 我想做一個抬頭紙。 我無法在文檔末尾獲得pdf格式的圖像。 為什么它不在前面?
如果導航到該URL,您將看到標題為“表格”的部分。
如果選中該部分,將看到如何在PDF中創建自定義表格。 通過創建您的自定義表,您可以使用方法“ Row.createImageCell()”為圖像創建單元格,同時為您的自定義表構建行和單元格(那里只顯示了“ createCell”方法,但也有方法“圖片的createImageCell”)。 我希望這有幫助。
樣例代碼:
Image image = new Image(ImageIO.read(new File("/../logo.png")));
// imagine we have pretty big logo and we want scale that a little bit
float imageWidth = 75;
image = image.scaleByWidth(imageWidth);
Row<PDPage> row = table.createRow(12);
cell = row.createCell(30, "Data 1");
cell = row.createImageCell(imageWidth , image);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.