改变PDF - 文本重新定位 [英] Alter PDF - Text repositioning

查看:93
本文介绍了改变PDF - 文本重新定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法为移/动里现有的PDF页面的其他一些位置

Is there any way to shift / move the text inside existing pdf page to some other position?

好像有一些文字在区域X = 100,Y = 100,W = 100,H = 100,我想将其移动到X = 50,Y = 200,W = 100,H = 100。

Like there is some text at area x=100, y=100, w=100, h=100 and i want to move it to x=50, y=200, w=100, h=100.

我做了很多的研究,似乎 iTextSharp的不能做到这一点。 PDFSharp 声称,这是可以做到,但我找不到任何的例子。

I did a lot of research and it seems iTextSharp cannot do that. PDFSharp claims that it can be done but i could not find any examples.

一种方法是做一个位图我想移动的文字特定区域,画出白色矩形在该地区,并在新的位置插入的位图。我不希望因为我有较大的PDF文件工作,1K多页,其中每一页都必须改变,以使用该解决方案。

One way is to make a bitmap of specific area of the text i want to shift, draw white rectangle over that area and insert bitmap at new location. I don't want to use this solution as i work with large pdf files with more than 1K pages where each page has to be altered.

我发现了什么是我需要找到一种方法来改变文本的定位符(文本矩阵和文本状态参数),这是没有那么简单。

What i found out is that i need to find a way to change text-positioning operators (text matrix and the text state parameters) which is not that simple.

任何人有什么想法?

推荐答案

我认为它可以如果所有的PDF文件是简单的(未复)从同一个应用程序来完成的。结果
。如果你需要这个如。一个网站,用户可以上传文件的话,最好忘掉它:你永远不会得到一个解决方案,将与任何PDF文件很好地工作。

I think it can be done if all the PDF files are simple (not complex) coming from the same application.
If you need this for e.g. a website where users can upload files, then better forget it: you'll never get a solution that will work perfectly with any PDF file.

PDFsharp可以帮助 - 但AFAIK PDFsharp只做你所需要的一半。 PDFsharp会给你弥补的PDF文件块。你必须解析块找到绘图指令,检查岗位,以及重新安置他们。结果
有些应用甚至不画的话,那么一个简单的词,如你好可能在3绘制块(也许他,LL和O)。您可能必须要注意这一点; 。也许不是,如果所有的文件都来自同一个应用程序

PDFsharp can help - but AFAIK PDFsharp only does half of what you need. PDFsharp will give you the blocks that make up the PDF file. You have to parse the blocks to find the drawing instructions, check the positions, and relocate them.
Some applications don't even draw words, so a simple word such as "Hello" could be drawn in 3 chunks (maybe "He", "ll" and "o"). You may have to pay attention to this; maybe not if all files come from the same application.

我觉得这里证明提取文本可帮助的代码:结果
http://forum.pdfsharp.net/viewtopic.php?p=4010#p4010 结果
要搬迁,你必须找到它摆在首位的文字 - 很多额外的工作仍然需要...

I think the code shown here to extract text could be helpful:
http://forum.pdfsharp.net/viewtopic.php?p=4010#p4010
To relocate text you have to find it in the first place - a lot of additional work still needed ...

这篇关于改变PDF - 文本重新定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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