itextsharp将点数转换为cm [英] itextsharp convert points to cm

查看:123
本文介绍了itextsharp将点数转换为cm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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:


UserUnit
number
(可选; PDF 1.6)正数这将给出默认用户空间单位的大小,为1/72英寸的倍数。支持值的范围应取决于实现。

UserUnit number (Optional; PDF 1.6) A positive number that shall give the size of default user space units, in multiples of 1⁄72 inch. The range of supported values shall be implementation-dependent.

默认值:1.0(用户空间单位为1/72英寸)。

Default value: 1.0 (user space unit is 1⁄72 inch).

(表30,第7.7.3.3节,ISO 32000-1)

由于该默认值,您的假设成立如果没有其他选择。

Due to that default your assumption holds if nothing else is selected.

这篇关于itextsharp将点数转换为cm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆