问题描述
我正在使用 iTextsharp
- 一个java pdf lib - 动态生成pdfs。
现在据我所知,测量以点数表示。我知道在哪里放置厘米的地方。
所以我需要转换:
points< - > cm
I am using iTextsharp
- a java pdf lib - to generate pdfs dynamically.Now as I understood it, measurements are specified in points. I know where to place what on the place in cm.so I need the conversion:points <-> cm
推荐答案
iText(夏普)有a 实用程序
类(包 com.itextpdf.text
/ namespace iTextSharp.text
)包含几种静态转换方法,特别是:
iText(Sharp) has a Utilities
class (package com.itextpdf.text
/ namespace iTextSharp.text
) which contains several static conversion methods, in particular:
// iText
public static final float millimetersToPoints(final float value);
public static final float millimetersToInches(final float value);
public static final float pointsToMillimeters(final float value);
public static final float pointsToInches(final float value);
public static final float inchesToMillimeters(final float value);
public static final float inchesToPoints(final float value);
// iTextSharp
public static float MillimetersToPoints(float value);
public static float MillimetersToInches(float value);
public static float PointsToMillimeters(float value);
public static float PointsToInches(float value);
public static float InchesToMillimeters(float value);
public static float InchesToPoints(float value);
您假设测量以点数指定只是部分正确但在你的用例动态生成pdfs 这已经足够了。
Your assumption that measurements are specified in points is only partially correct but in your use case to generate pdfs dynamically that's good enough.
一般情况下,测量是以用户空间单位指定的,默认用户空间单位(即在任何转换到位之前)可以在每页的基础上配置为1/72英寸的任何浮动倍数(受特定于实现的限制):
In general, though, measurements are specified in user space units, and the default user space unit (i.e. before any transformations are in place) can be configured on a per-page basis to be any float multiple (subject to implementation specific limitations) of 1/72 inch:
默认值:1.0(用户空间单位为1/72英寸)。
Default value: 1.0 (user space unit is 1⁄72 inch).
由于该默认值,您的假设成立如果没有其他选择。
Due to that default your assumption holds if nothing else is selected.
这篇关于itextsharp将点数转换为cm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!