有沒有什麼辦法可以讓虛線的單元格邊框(例如_ _ _ _ _ _ _ _ _ _ _ _)而不是實線(例如________________)在iText-5.0.1中?iText-5.0.1 +用虛線畫出PdfPTable的邊框
1
A
回答
1
你能鑽機像小高和文本=「---------」增加了新的段落
PdfPCell Cell = new PdfPCell(new Paragraph("------"));
Cell.Height = 0.2f;
您也可以自己使用PdfPCellEvent繪製邊界。有不同的圖層可以添加到。在此處查看API:http://api.itextpdf.com/com/itextpdf/text/pdf/PdfPCellEvent.html
1
如上所述,使用PdfPCellEvent。下面的代碼應該可以幫你實現這個目標。 Cell event example.通過重寫單元格事件,您基本上可以告訴iText您應該如何繪製單元格。無論何時將任何單元格添加到表格中,他們都將遵循您的規則。
class CustomCell implements PdfPCellEvent {
public void cellLayout(PdfPCell cell, Rectangle rect,
PdfContentByte[] canvas) {
PdfContentByte cb = canvas[PdfPTable.LINECANVAS];
cb.setLineDash(new float[] {3.0f, 3.0f}, 0);
cb.stroke();
}
}
public class Main {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("output.pdf"));
document.open();
CustomCell border = new CustomCell();
PdfPTable table = new PdfPTable(6);
PdfPCell cell;
for (int i = 1; i <= 6; i++) {
cell = new PdfPCell(new Phrase("test"));
cell.setCellEvent(border);
table.addCell(cell);
}
document.add(table);
document.close();
}
}
+0
當我嘗試你的代碼時,E-Clipse發現了錯誤信息......「沒有可用的pdf型封閉實例.....」任何想法發生了什麼? – 2010-03-24 15:49:02
0
PdfPCell Border1 = new PdfPCell(new Paragraph("-----------------------------------------------------------------------------------------------------------------------"));
Border1.Border = 0;
Border1.VerticalAlignment = 3;
Border1.FixedHeight = 5F;
Border1.PaddingLeft = -5;
Border1.PaddingRight = -5;
Border1.PaddingBottom = -5;
Border1.PaddingTop = -5;
1
細胞強調了與破折號:
public class UnderlinedCell implements PdfPCellEvent {
public void cellLayout(PdfPCell cell, Rectangle position,
PdfContentByte[] canvases) {
PdfContentByte canvas = canvases[PdfPTable.LINECANVAS];
canvas.setLineWidth(0.5f);
canvas.setLineDash(3f, 3f);
canvas.moveTo(position.getLeft(), position.getBottom());
canvas.lineTo(position.getRight(), position.getBottom());
canvas.stroke();
}
}
相關問題
- 1. iOS動畫虛線矩形邊框
- 2. pdfptable的無形邊框
- 3. UICollectionViewCell虛線邊框
- 4. 用虛線邊框Flex BorderContainer
- 5. 與邊框圖像的虛線邊框
- 6. 的RichTextBox與虛線邊框
- 7. 虛線邊框邊框圓角
- 8. CSS邊框動畫 - 將實線轉換爲虛線
- 9. CSS:2格虛線邊框
- 10. 如何虛線邊框
- 11. 自定義虛線邊框。
- 12. 繪製虛線邊框
- 13. WPF虛線邊框控件
- 14. 使用css漸變的虛線邊框
- 15. 嵌套iText PdfPTable的邊框寬度
- 16. 用於虛線邊框的CSS邊框半徑
- 17. 如何啓用雙虛線邊框?
- 18. CSS虛線和斜線邊框
- 19. pyplot - 不能畫出虛線
- 20. 如何用虛線邊框或雙線邊框創建文本框
- 21. 實心邊框或虛線邊框?何時使用哪個?
- 22. CSS畫斜線邊框
- 23. 邊框線條動畫
- 24. WPF中的ListBoxItem上的虛線邊框
- 25. 動畫虛線邊框無需添加筆觸
- 26. 如何畫有虛線邊框透明形狀
- 27. 邊界PdfPTable - iText,java
- 28. Apache FOP上的虛線邊框背景
- 29. 企圖拉攏虛線邊框的UITableViewCell
- 30. 帶邊框的垂直虛線圓
我想我們無法爲電池組的高度? – 2010-03-24 11:58:00