计算iTextSharp的PDF文档的高度? [英] Calculate height of iTextSharp PDF document?

查看:392
本文介绍了计算iTextSharp的PDF文档的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用iTextSharp的计算时,PDF文档的高度?


我使用iTextSharp的对使用绝对位置的PDF文档放置各种图像。不过我注意到 SetAbsolutePosition()位置从底部参数,所以我需要计算的高度能够做到这样的:

  Y = PdfHeight  - 我


解决方案

您应该能够通过使用每页,这样做...

  INT yPos = pdfDocument.PageSize.Height  - 我 -  elementHeight;

我=您将设置Ÿ如果是从页

顶部的位置

elementHeight =你定位元素(例如图像)的高度

How can I calculate the height of the PDF document when using iTextSharp?


I'm using iTextSharp to position various images on a PDF document using Absolute Position. However I've noticed SetAbsolutePosition() positions the Y parameter from the bottom, so I need to calculate the height to be able to do something like:

Y = PdfHeight - i

解决方案

You should be able to do that by using the PageSize, like this...

int yPos = pdfDocument.PageSize.Height - i - elementHeight;

i = the position you would set Y if it was from the top of the page

elementHeight = the height of the element you are positioning (e.g. an image)

这篇关于计算iTextSharp的PDF文档的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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