C Itextsharp Pdf

  

Active5 months ago
  1. 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.
  2. 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.

C Itextsharp Pdf
Tony
TonyTony
1,6282 gold badges19 silver badges31 bronze badges

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)

jrcs3
2,7001 gold badge17 silver badges35 bronze badges
TonyTony
1,6282 gold badges19 silver badges31 bronze badges

In addition to the excellent answers above, the following shows how to add text to each page of a multi-page document:

Matthew Lock

C Itextsharp Pdf File

8,6547 gold badges68 silver badges113 bronze badges
Chris SchiffhauerChris Schiffhauer
13.5k14 gold badges67 silver badges83 bronze badges

This worked for me and includes using OutputStream:

jpsnow72jpsnow72

Here is a method that uses stamper and absolute coordinates showed in the different PDF clients (Adobe, FoxIt and etc. )

Zhivko KabaivanovZhivko Kabaivanov

protected by CommunityMar 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.

Active2 years, 1 month ago

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 Laine
32.9k8 gold badges75 silver badges115 bronze badges
user221185user221185

6 Answers

ShravankumarKumar ShravankumarKumar
1,8271 gold badge11 silver badges2 bronze badges

You 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 Riggs
48k9 gold badges120 silver badges138 bronze badges
Converter

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

dovid
4,8351 gold badge22 silver badges54 bronze badges
Chris MarisicChris Marisic

C Itextsharp Pdf Converter

22.7k18 gold badges140 silver badges243 bronze badges

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 Medlin
9,1754 gold badges51 silver badges63 bronze badges

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

C Itextsharp Pdf Tutorial

voidmainvoidmain
kleopatra
46k16 gold badges76 silver badges168 bronze badges
RajaRaja

C Itextsharp Pdf Format

Not the answer you're looking for? Browse other questions tagged c#vb.netpdfitextsharp or ask your own question.