iTextSharp - Copying elements from one PDF to another

霸气de小男生 提交于 2019-12-11 02:21:52

问题


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 first PDF.

Please help me how this can be achieved.


回答1:


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.



来源:https://stackoverflow.com/questions/6521573/itextsharp-copying-elements-from-one-pdf-to-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!