Hi, I am using C# .NET 2.0.I want to generate a PDF file . I should write a text in the file.
What are the prerequsites we need to generate the PDF.
Any simplae coding samples will help me.
PLease suggest opensource libraries.
Thanks in advance.
Hi, I am using C# .NET 2.0.I want to generate a PDF file . I should write a text in the file.
What are the prerequsites we need to generate the PDF.
Any simplae coding samples will help me.
PLease suggest opensource libraries.
Thanks in advance.
UPDATE: SharpPDF looks dead. Go with PDFSharp instead...
This question has been asked a few times on SO:
Use PDFSharp
PDFsharp is the Open Source library that easily creates PDF documents from any .NET language. The same drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer.
// Create a new PDF document
PdfDocument document = new PdfDocument();
// Create an empty page
PdfPage page = document.AddPage();
// Get an XGraphics object for drawing
XGraphics gfx = XGraphics.FromPdfPage(page);
// Create a font
XFont font = new XFont("Verdana", 20, XFontStyle.Bold);
// Draw the text
gfx.DrawString("Hello, World!", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormat.Center);
// Save the document...
string filename = "HelloWorld.pdf";
document.Save(filename);
// ...and start a viewer.
Process.Start(filename);
I would recommend iTextSharp: http://sourceforge.net/projects/itextsharp/
It's a port of iText: http://www.lowagie.com/iText/