小编nit*_*ppa的帖子

如何在 iText 7 中创建/设置表格单元格和边框的自定义颜色?

我需要创建一个具有自定义彩色单元格和边框的表格。Color类中定义了一些常量,但我需要自定义颜色。我需要#a6cb0b 作为带有颜色代码#cccccc 的标题和边框线的背景颜色。我如何设置它们?

Table table = new Table(new float[]{1,1,1});
Cell cell = new Cell();
cell.add(new Paragraph("TITLE"));
cell.setBackgroundColor(Color.???);
table.addCell(cell);
...
...
Run Code Online (Sandbox Code Playgroud)

java pdf itext7

3
推荐指数
1
解决办法
2230
查看次数

如何获取特定pdf表单字段的页码和位置,并在iText7中插入表格?

我想在表单字段的位置插入一个表.如何获取表单字段的位置和页码?如何在该位置插入表格?

//Retrieves AcroForm from the document.
//If there is no AcroForm in the document Catalog and createIfNotExist
//flag is true then the AcroForm dictionary will be created and added to the document.
PdfAcroForm acroForm = PdfAcroForm.getAcroForm(pdfDoc, true);
//Gets the form fields as a Map.
Map<String, PdfFormField> fields = acroForm.getFormFields();
//Create Table
Table table = new Table(new float[]{1,1});
table.setHorizontalAlignment(HorizontalAlignment.CENTER);
table.setWidthPercent(95);  
Cell cell = new Cell();
cell.add(new Paragraph("Name"));
//cell.setBorder(Border.NO_BORDER);
table.addCell(cell);
Cell cell = new Cell();
cell.add(new Paragraph("Address"));
//cell.setBorder(Border.NO_BORDER);
table.addCell(cell);
...
...
doc.add(table); …
Run Code Online (Sandbox Code Playgroud)

java pdf itext7

0
推荐指数
1
解决办法
440
查看次数

标签 统计

itext7 ×2

java ×2

pdf ×2