开发者

iTextSharp - Copying elements from one PDF to another

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

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 f开发者_StackOverflow中文版irst 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.

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.)

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜