我是iText的新手,面对一个关于在段落中添加外部图像的真实有趣案例.这是事情:
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("out2.pdf"));
document.open();
Paragraph p = new Paragraph();
Image img = Image.getInstance("blablabla.jpg");
img.setAlignment(Image.LEFT| Image.TEXTWRAP);
// Notice the image added to the Paragraph through a Chunk
p.add(new Chunk(img2, 0, 0, true));
document.add(p);
Paragraph p2 = new Paragraph("Hello Worlddd!");
document.add(p2);
Run Code Online (Sandbox Code Playgroud)
给我的照片和"Hello Worlddd!" 以下字符串.然而,
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("out2.pdf"));
document.open();
Paragraph p = new Paragraph();
Image img = Image.getInstance("blablabla.jpg");
img.setAlignment(Image.LEFT| Image.TEXTWRAP);
// Notice the image added directly to the Paragraph
p.add(img);
document.add(p);
Paragraph …Run Code Online (Sandbox Code Playgroud) 有没有办法在将表格添加到文档之前获取表格的高度?
乍一看,我认为表格中的行数足以计算高度,因为我知道字体大小。然而,有些行违反了这一规则。例如,一个单元格可能存储具有多行的段落。因此,我需要知道的是每行的高度之和。
我正在使用Java中的iText创建一些PDF报告.根据要求,我应该做的是以page_number/page_numbers_in_total的格式对页面进行编号.
但是,内存操作给我的项目增加了负 因此,我不想再次浏览所有页面以便对它们进行编号.有没有办法实现这个目标?