html2pdf页面大小,带有页面大小检测的itext 7 html到pdf(itext 7 html to pdf with page size detection)...

本文探讨了在使用iText 7将HTML转换为PDF时遇到的页面尺寸问题。作者期望得到512px的宽度,但实际布局结果为385px。经过讨论,确定这是由于像素和点之间的单位转换问题,512像素等于384点,这并非错误。解决方案涉及到理解不同的测量系统并进行适当转换。
摘要由CSDN通过智能技术生成

带有页面大小检测的itext 7 html到pdf(itext 7 html to pdf with page size detection)

我使用itext 7将HTML模板(Velocity)呈现为PDF,然后呈现为PNG(Apache PdfBox),用于热敏打印机打印。

我的模板呈现为:

...

我的容器的固定宽度为512px。 我想测量HTML的渲染高度,然后将其渲染为页面高度为测量高度的单页PDF。

但渲染的大小不是预期的大小。 我期望有一个512px的渲染宽度,但layoutResult返回宽度385(而不是预期的512)。

我错过了哪个参数? 谢谢。

I am using itext 7 to render HTML templates (Velocity) to PDF, then to PNG (Apache PdfBox), for thermal printer printing.

My template is rendered as :

...

My container has a fixed width to 512px. I would like to measure the rendered height of the html, and then render it as a single page PDF with page height = measured height.

But the rendered size is not the expected size. I expect to have a rendered width of 512px, but the layoutResult returns a width of 385 (instead o

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值