tags:

views:

168

answers:

9

Hi everyone,

How do I create and read the pdf file using C# programmatically?

+2  A: 

Use PDFSharp: http://pdfsharp.com/PDFsharp/

mgroves
+1 This is the simplest library I have used for PDF so far. This works great! =)
Will Marcouiller
+4  A: 

You have to use a special library. ITextSharp is free for non commercial applications.

Catalin Florea
Ok.Will that provide's Security Features
programmer4programming
Define Security Features
Catalin Florea
If you mean "set passwords and security flags", then yes. In addition to the "Standard" security handler at various key strengths, iText also supports PDF signatures (which are cryptographically secure).
Mark Storer
+1  A: 

There is a list of open source PDF libraries here

Jeff Norman
+1  A: 

Creating PDFs is quite easy with open source libraries (such as ITextSharp). Reading PDFs with anything but very simple formatting can be quite difficult though. PDF is not the easiest format to parse.

trendl
A: 

At NiXPS we are working on a new completely native C# library to create, read and edit PDF files. If you're interested in testing it, send us an email at info at nixps.com.

Kristof
A: 

Unfortunately, like most people said PDF is not easy to read.

However there are options, but it requires having Adobe Acrobat installed on your system, and isn't quite 'server grade'.

The native acrobat type libraries have methods to grab text given coordinates in the PDF file. It's based on standard 72 points per inch , and originates from the bottom left corner of the document. It's a bit cumbersome but possible. Obviously this is missing all the calls to create the various objects but to give you an example, this is how to 'scrape' text from a PDF location

                    objPDFRect.Left = 36
                    objPDFRect.right = 400
                    objPDFRect.Top = 115
                    objPDFRect.bottom = 110
                    objPDFTextSelection = objPDFDoc.CreateTextSelect(xyz - 1, objPDFRect)

                    If objPDFTextSelection Is Nothing Then
                    Else
                        temptextcount = objPDFTextSelection.GetNumText
                        For lngTextRangeCount = 1 To objPDFTextSelection.GetNumText
                            line2 = line2 & objPDFTextSelection.GetText(lngTextRangeCount - 1)
                        Next
                        If temptextcount > 0 Then
                            'store line2 somewhere.
                        End If

                    End If
Ed Roper
+1  A: 

Open Source:

iTextSharp (for generating PDF)

GhostScript (for interpretting PDF, eg rasterising to Images etc)

Commercial:

The components from Tall Components are very good, have use to great successs (not affiliated)

Reporting:

If you want to generate reports a commercial reporting tool is advised.

HTH

Mark Redman
A: 

iTextSharp is a C# port of iText, a Java PDF library. The C# port is maintained by Paulo Soares (no I don't know how to pronounce it either), the second-largest contributor to iText after Bruno Lowagie (the original author). iTextSharp (as of 5.0) is covered under the AGPL. That means anyone with access to the program's output must have access to the source. In order to use it in a closed-source/commercial environment, you must license it from iTextSoftware.com.

Prior to 5.0, it was released under the LGPL and Mozilla licenses (as was iText proper), which is much more commerce-friendly (and much less likely to earn the people who have spent years on it any money, thus the change). These versions are still available, but don't expect to get any support from the [email protected] mailing list.

But there's always stack overflow...

Mark Storer
A: 

You can try losLab EzPDFlibrary, it can read and create PDF doucments.

Sarah