- I would like to add a page to an existing PDF document containing simple text. I have tried the following code that I found on the internet, but so far I haven't got it to work: PdfReader reader.
- Apr 08, 2012 iTextSharp is open source PDF solution. In most of the examples below, I tried to alter,copy a template PDF and then save it into a brand new output PDF file. It's easy to work with PDFs, when we have a basic template (created externally using Adobe/OpenOffice) in place,.
The title sums it all.
Apr 29, 2013 Reading PDF content with itextsharp dll in c# - Reading PDF File Using iTextSharp c# - How to read a PDF Portfolio using iTextSharp c# - Read/Modify PDF Metadata using iTextSharp itextsharp read.
I want to add a text to an existing PDF file using iTextSharp, however i can't find how to do it anywhere in the web..
C Itextsharp Pdf Free
PS: I cannot use PDF forms.
4 Answers
I found a way to do it (dont know if it is the best but it works)
I hope this can be usefull for someone =) (and post here any errors)
jrcs3In addition to the excellent answers above, the following shows how to add text to each page of a multi-page document:
Matthew LockC Itextsharp Pdf File
This worked for me and includes using OutputStream:
Here is a method that uses stamper and absolute coordinates showed in the different PDF clients (Adobe, FoxIt and etc. )
protected by Community♦Mar 12 '12 at 13:38
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
C Itextsharp Pdf Template
Not the answer you're looking for? Browse other questions tagged c#asp.netpdfitextpdf-generation or ask your own question.
How can I read PDF content with the itextsharp with the Pdfreader class. My PDF may include Plain text or Images of the text.
Dustin Laine6 Answers
ShravankumarKumar ShravankumarKumarYou can't read and parse the contents of a PDF using iTextSharp like you'd like to.
From iTextSharp's SourceForge tutorial:
You can't 'parse' an existing PDF file using iText, you can only 'read' it page per page.
What does this mean?
The pdf format is just a canvas where text and graphics are placed without any structure information. As such there aren't any 'iText-objects' in a PDF file. In each page there will probably be a number of 'Strings', but you can't reconstruct a phrase or a paragraph using these strings. There are probably a number of lines drawn, but you can't retrieve a Table-object based on these lines. In short: parsing the content of a PDF-file is NOT POSSIBLE with iText. Post your question on the newsgroup news://comp.text.pdf and maybe you will get some answers from people that have built tools that can parse PDF and extract some of its contents, but don't expect tools that will perform a bullet-proof conversion to structured text. Serial season 2 episode 2.
Jay RiggsJay RiggsNone of the other answers were useful to me, they all seem to target the AGPL v5 of iTextSharp. I could never find any reference to SimpleTextExtractionStrategy
or LocationTextExtractionStrategy
in the FOSS version.
Sommerville software engineering 9th edition. Something else that might be very useful in conjunction with this:
This will extract the text only data from the PDF, if the text displayed is Foo(bar)
it will be encoded in the PDF as (Foo(bar))Tj
, this method would return Foo(bar)
as expected. This method will strip out lots of additional information such as location coordinates from the raw pdf content.
C Itextsharp Pdf Converter
Here is a VB.NET solution based on ShravankumarKumar's solution.
This will ONLY give you the text. The images are a different story.
Carter MedlinCarter MedlinIn my case I just wanted the text from a specific area of the PDF document so I used a rectangle around the area and extracted the text from it. In the sample below the coordinates are for the entire page. I don't have PDF authoring tools so when it came time to narrow down the rectangle to the specific location I took a few guesses at the coordinates until the area was found.
As noted by the above comments the resulting text doesn't maintain any of the formatting found in the PDF document, however I was happy that it did preserve the carriage returns. In my case there were enough constants in the text that I was able to extract the values that I required.