how to create pdf file from c#

Recommended Answers

All 4 Replies

By using library like iTextSharp

how to create pdf file from c#

Creating PDFs from scratch can involve a lot of effort. You'll almost certainly find the easiest solution is to use a third-party PDF component, of which there are many available on the market today.

For the .NET Framework, ABCpdf, iTextsharp and PDFSharp should do the trick. All available for free*. Each component has strengths and weaknesses, so finding the best one for a particular task requires a little research.

You'll find each component offers a unique set of basic drawing commands. These enable you to construct valid PDF documents. They may also provide additional drawing methods for laying out documents, such as System.Drawing, PostScript, HTML & CSS, etc.

The following C# code shows how simple creating a PDF document can be...

Doc theDoc = new Doc();
theDoc.FontSize = 96;
theDoc.AddText("Hello World");
theDoc.Save("simple.pdf");
theDoc.Clear();

* ABCpdf is a commercial component. A single license for the standard edition is obtainable for free.

* iTextsharp version 4 is free. Newer versions are free for non-commercial use.

how to create pdf file from c#

You should provide the question in more detail. If your requirement is only to save some record in pdf format there is built in methods to save a document as pdf files.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.