iTextSharp-将元素从一个PDF复制到另一个 [英] iTextSharp - Copying elements from one PDF to another

查看:116
本文介绍了iTextSharp-将元素从一个PDF复制到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用iTextSharp将某些元素从一个PDF复制到另一个.

I want to copy certain elements from one PDF to another using iTextSharp.

我想读取一个PDF,从中读取文本元素并进行更正,并使用更新后的文本元素和第一个PDF中的所有图像等创建新的PDF.

I want to read one PDF, read text elements from that and correct them and create a new PDF using the updated text elements and all the images etc. from the first PDF.

请帮助我如何实现这一目标.

Please help me how this can be achieved.

推荐答案

此任务非常复杂.我为大型贺卡制造商编写了一个程序来执行此操作.

This task is very complex. I wrote a program to do this for a large greeting card maker.

首先,您必须找到文本并计算字形边界框.接下来,您必须修改内容流以删除文本.根据PDF创建者的不同,文本可能会分成许多部分.您必须从内容流中删除这些运算符,并调整CTM,因为某些运算符使用相对定位.最后,您必须插入与原始文本的样式(字体,大小,颜色,方向等)匹配的替换文本

First you have to locate the text and calculate the glyph bounding boxes. Next you have to modify the contents stream to remove the text. The text may be broken into many pieces depending on the PDF creator. You have to remove those operators from the contents stream and adjust the CTM because some operators use relative positioning. Finally, you have to insert the replacement text, matching the original text's style (font, size, color, orientation, etc.)

对于将元素从一个PDF复制到另一个PDF,需要上述大多数步骤,而且还必须复制资源.字体,色彩空间,图案等,转换为新的PDF.

As for copying elements from one PDF to another, most of the steps above are required plus you have to copy resources, eg. fonts, colorspaces, patterns, etc, to the new PDF.

这篇关于iTextSharp-将元素从一个PDF复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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