使用itextsharp的文本的x和y坐标 [英] x and y coordinate of text using itextsharp

查看:154
本文介绍了使用itextsharp的文本的x和y坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用itextsharp提取文本时,我将获得文本的x和y坐标。通过使用这两个坐标,如果我将文本从pdf转换为html基于x y位置文本位置chnages。得到我使用的x,y坐标

When i extract text using itextsharp, i will get x and y coordinate of text. By using these 2 coordinates if i convert text from pdf to html based on x y position the text position chnages . to get x ,y coordinates i used


  • Vector curBaseline = renderInfo.GetBaseline()。GetStartPoint();

  • Vector curBaseline = renderInfo.GetBaseline().GetStartPoint();

float x = curBaseline [Vector.I1];

float x=curBaseline[Vector.I1];

float y = curBaseline [Vector.I2];

float y= curBaseline[Vector.I2];

例如:当我使用上述方法提取文本时,说x = 42且y = 659;

for example : when i extract text using above method say x=42 and y=659;

推荐答案

发布为答案...

如果我没记错的话,PDF使用的坐标系从BOTTOM的左下角开始当你在html中直接使用它时,每个coordiante都是错误的。你必须转换这些值。

If i recall correctly, PDF uses a coordinate system which starts in the left corner at the BOTTOM of the page, not at the Top. So every coordiante is wrong, when you use it directly in html. You will have to convert the values.

你的pdf文件应该是有类似document.actualheight的东西,只需从中减去你的价值....

Your pdf document should have something like document.actualheight, simply subtract your value from that....

这篇关于使用itextsharp的文本的x和y坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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