我正在测试iText以生成由平铺格式的8个图像组成的PDF。我使用JFreeChart创建一个图形,然后通过iText将其转换为图像。 PDF生成正常,但是当我打开输出文件时,左侧,右侧和底部仍有大约一英寸的空白区域。我想在打印时利用合法尺寸页面上的所有空间。
我知道PDF中没有“边距”的概念,而且它不是可编辑的格式。必须创建没有空白区域的图像。那么Document构造函数中的额外参数实际上做了什么?
我认为通过向Document对象(LEGAL和1f params)提供必要的参数将消除空白区域,我的表将占用打印页面上的所有8.5x14,但没有运气。
有什么建议吗?提前致谢
原始代码:
// Setup document
Document doc = new Document(PageSize.LEGAL, 1f, 1f, 1f, 1f);
PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("c:\\temp\\image_in_chunk.pdf"));
doc.open();
//create the chart, save to file system, and create an iText Image object
ChartUtilities.saveChartAsPNG(new File("C:\\temp\\img.png"), createChart(createDataset()), 240, 240);
Image img1 = Image.getInstance("C:\\temp\\img.png");
PdfPCell cell1 = null;