java - PDF 页面大小与提供的页面大小不准确

标签 java pdf pdf-generation itext

我需要使用固定尺寸的 iText 创建 PDF:

Height: 95 mm = 3.74 in

Width: 50 mm = 1.96 in

所以我在代码中做了:

float width = mmToPt(95); 
float height = mmToPt(50);
Rectangle rectanglePage = new Rectangle(width, height);
Document document = new Document(rectanglePage, 0, 0, 0, 0);

mmToPt() 函数所在的位置(根据文档 70pt=1in=2.54cm):

public static float mmToPt(float mm){
    //70pt = 25.4mm
    return ((70f * mm) / 25.4f);
}

问题是,当我打开生成的 PDF 文件/属性时,我可以看到它显示页面大小 3.64 x 1.91 英寸。这不是我设置的确切大小(大约短 2 或 3 毫米 -尽管只是一点点,但它很重要,因为文件必须具有此尺寸)。

会发生什么?我该如何解决这个问题?

谢谢。

最佳答案

它是 72 点 == 1 英寸,而不是 70。

关于java - PDF 页面大小与提供的页面大小不准确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4948698/

相关文章:

java - 在jsp中写出表格时计算总数

java - 它不要求输入,直接通过

ios - 如何生成不分页的PDF

python - Matplotlib 输出为 PDF 用于 Corel Draw

c# - 将表格保存在一张 MigraDoc/PDFsharp 中

java - 将字符串附加到抽象类中声明的静态最终字符串

java - 如何使用 BouncycaSTLe Java 将 PGP 公钥存储和读取为字符串?

java - 警告 : PDF write support was not found on the class path

android - 使用 openwith 选项 android 打开 pdf

ios - 如何使用 Monotouch 或 Xcode 4.2 对 PDF 文件进行数字签名?