July 25, 2020   |   by admin

Usually, we are going to use a combination of `PdfReader` to read the document and `PdfStamper`, `PdfCopy` or How to update a PDF without creating a new PDF? The Best iText Questions on Stack Overflow; Manipulating existing PDFs . Hello Sir I have a problem. I have a pdf file which has some textfields which i created using form tool in acrobat. And i wanted to add PdfPTable. Last few days I was trying to modify some PDF file using iText library. So my first try was to replace the existing text with dynamic data. I.

Author: Kar Dijora
Country: Puerto Rico
Language: English (Spanish)
Genre: Relationship
Published (Last): 7 May 2007
Pages: 32
PDF File Size: 8.55 Mb
ePub File Size: 15.29 Mb
ISBN: 959-1-34088-533-3
Downloads: 81732
Price: Free* [*Free Regsitration Required]
Uploader: Nadal

By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

Inserting Text To an Existing Pdf using Itext

I’ ve been searching the Internet for 2 Weeks and found some interesting solutions for my Problem, but nothing seems to give me the answer.

I would like to keep the design of the content. Is it really that hard? This keeps the formatation of the rest of text and does only change my searched text. I need a solution for text which is NOT in a Textfield.

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. The general issue is that text existin may use embedded fonts with specific glyphs assigned to specific letters.

So if you replace “abcdef” with “xyz” then the PDF will not display these “xyz” as no glyphs are available for these letters to be displayed. This question already has an answer here: Kevin Plaul 36 1 1 5.


C# tutorial: add content to an existing PDF document

Dec 14 ’16 at Are you aware of font subsetting? What if you insert a character that is not in the existing subset? You would need to find out what font was used originally not always trivial and then have that font on your system. There are other problems than this — I see this is a duplicate question. Hi Jongware, I know there is this already a post like mine, but without any “Maybe”-Code and the answer “NO” with is not really a good answer.

No matter how long you search the internet, you cannot find a method to walk from Britain to America. So I would consider the following workflow: Iterate through all the text objects; Add new text objects created from scratch on top of PDF file and set the same properties font, position, etc but with a different text; This step could require you to have the same fonts installed on your as were used in the original PDF but you may check for installed fonts and use another font for a new text object.

Remove original text object once you have created a duplicated text object; Process every text object with the workflow described above; Save the modified PDF document into a new file. Eugene 2, 11 I also like the comments by Jongware because they clearly explain why the OP is trying to use PDF for something it should be used for.

I want to replace one String by another in PDF and keep all styles and have the text reflow, is a question that sounds like “I want to watch TV on my radio” and remarks such as “I hate eating soup with a fork”. Very good, thorough explanation indeed!


I think we’ll redirect duplicates to this answer from now on! If the OP still doesn’t like it I’d encourage them to click to each user’s profile that’s replied so far and look at their tags.

c# – ITextSharp insert text to an existing pdf – Stack Overflow

They’ll find a combined score of over 1, in the [pdf] categories so I think they received a very knowledgeable response. I have worked on the same requirement and I am able to achieve this by the following steps. Read Source Pdf file and Itectsharp for the location of string that we want to replace Step3: Replacing the string with new one.

PdfStamper pReader, new System. SetFontAndSize bf, 9 ; cb2.

ShowTextAligned 0, replacingText, rect. Bottom, 0 ; cb2.

Pradeep Kumar 23 2. Where do you “replace”?

In particular, where do you remove the original text and where do you add new text using the same style as the original? GetOverContent page ; here cb will take the text content over pdf page and cb2 will take the white back ground of the pdf page As long as the pdf shall only be printed, that is OK, but if it shall still be electronically distributed, that can be a show-stopper.

Stack Overflow works best with JavaScript enabled.