有没有什么办法可以让虚线的单元格边框(例如_ _ _ _ _ _ _ _ _ _ _ _)而不是实线(例如________________)在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. pdfptable的无形边框
- 2. UICollectionViewCell虚线边框
- 3. 用虚线边框Flex BorderContainer
- 4. 的RichTextBox与虚线边框
- 5. CSS边框动画 - 将实线转换为虚线
- 6. 自定义虚线边框。
- 7. 绘制虚线边框
- 8. 如何虚线边框
- 9. 使用css渐变的虚线边框
- 10. 嵌套iText PdfPTable的边框宽度
- 11. 如何启用双虚线边框?
- 12. 边框线条动画
- 13. CSS画斜线边框
- 14. 实心边框或虚线边框?何时使用哪个?
- 15. 动画虚线边框无需添加笔触
- 16. 按钮周围的虚线边框
- 17. Apache FOP上的虚线边框背景
- 18. 边界PdfPTable - iText,java
- 19. 在IE6/7中靠近并重叠的虚线边框边框
- 20. 如何在WPF中实现虚线或虚线边框?
- 21. CSS虚线边框渲染问题
- 22. 如果使用jQuery动画对象,虚线边框变为固定
- 23. HTML5动画虚线
- 24. three.js线框只有隐形边缘的形状为虚线
- 25. 下拉菜单:虚线边框和固体边界在一行
- 26. 1px在IE11 /边缘虚线边框渲染
- 27. cytoscape.js中的动画虚线
- 28. 虚线边界UIImageView swift
- 29. 如何使用CSS移动虚线边框?
- 30. 如何删除轮廓虚线边框使用CSS
我想我们无法为电池组的高度? – 2010-03-24 11:58:00