Generate PDF from HTML with C# in ASP.NET

Softarea51.com is your source for all the latest computer technology and software related press releases.
Browse our archive for more press releases!

Released on: 1, October 2009
, Author: DuoDimension Software
, Audience: Software related

Recommended: Click here to improve PC speed »


PDF Duo .Net is a converting component for use in ASP.NET (VB, C# etc.) and enables toconvert HTML to PDF. The main class HtmlToPdf provides several methods and properties to enable multi-purpose customization of the resulting PDF. Main functions allow to convert HTML represented as a File, Page from Url address, Stream or as a String.

Developers can easily invoke the converting component in their own application or website projects on base of ASP.NET. To deploy the PDF Duo .Net component you will need only three lines of code. Installing package is provided with fully featured demos written in both C# and Visual Basic. Simple examples with source code help you using the PDF Duo .Net component to successfully convert HTML to PDF.

I have used PDFDuo-NET.dll (version 2.3) in my project which is very useful. First, you need to convert content of your ASPX to HTML and then converted that HTML content into a PDF file or another way which I use is to create a simple HTML string and then convert it.

See below C# code:

using System;
using System.Web;
using System.Web.UI;
using System.IO;
using DuoDimension;


public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string html = "" +
"ProductQuantityCost" +
"Product Name 15$100" +
"Product Name 215$300" +
"Product Name 355$500" +
"";
string pdf = "pdf_file.pdf";
DuoDimension.HtmlToPdf conv = new DuoDimension.HtmlToPdf();
conv.PageInfo.PageFormat = ePageFormat.A4;
conv.PdfDocumentInfo.Title = "Generate PDF from HTML source";
conv.Header = "
HTML table Example";
try
{
conv.OpenHTML(html);
conv.SavePDF(MapPath("~/Reports/") + pdf);
}
catch (Exception ex)
{
throw ex;
}
}
}


Adobe's PDF format is one of the most widely accepted document formats in use today. Most users and clients expect that the software you write will be able to generate and work with PDFs. Unfortunately, however, Adobe does not offer a free SDK that you can download and use; you have to pay to license the API.

Statically creating PDF files is quite simple. Applications, such as OpenOffice.org Writer, give the user options to export a word processor document as a PDF file. Users can even find utilities that allow them to "print" directly to a PDF file. Features like these are well-known to end users and are useful for creating a PDF based off a document originally created in another format.

But what about dynamic PDF generation? Some programs need to be able to write out PDF files. PDF Duo .NET alleviates this problem. It will give you the ability to add PDF functionality to your applications. Using PDF Duo .NET, you can create PDF by converting HTML string or file, so you can deliver the functionality your users expect.

It is up to you how you generate your HTML from your data source and then convert it to PDF or another option is to convert your ASPX to HTML first and then to PDF. This need to be done because PDF Duo .NET component can only works with clear html format. It did not support for asp:control and runat=server tag for now. You can apply styleshhet to tables, h1, h2, paragraph, and all others necessary stylesheet tag to complete your PDF.

PDF Duo .NET is absolutely independent, doesn't require any additional components and really appropriate for ASP.NET websites. The component is written entirely in C# for the .NET platform. PDF Duo .NET is a library that allows you to generate (convert) PDF documents from HTML web page.

For more information about the component please visit the product page:
http://www.duodimension.com/html_pdf_asp.net/component_html_pdf.aspx

If you have any questions or concerns about component, let us know:
support@duodimension.com

Related downloads


CatStudio provides a features-rich environment to create Product Catalog in HTML, Movie or PDF format. Besides the product information, It allows to add different types of content, includes: Flash animation, images, text, and others.

Bodie's Favorites is a program with which will be able to generate a HTML file, with all the links that you possess as favorites Internet Explorer. Useful if you need to access to the same ones from another PC, from a cyber, etc...

Create HTML forms for your website. Generate them with an online wizard. Contact forms are very useful to receive message from your visitors. Build polls, questionnaires, and other types of web forms. No programming skills are required.

Make web forms quickly using this HTML form generator software. Design the form,
have form validations, get form submissions by email, send an auto response and more.
No programming required. Just choose the options and generate the code.

Powerful database design tool which allows you to visually create Entity Relationship Diagrams (ERD) for various database systems - MS SQL, Oracle, DB2, MySQL, InterBase, Sybase etc. Features: ERD, SQL script generation, Reverse engineering...

EdgeTracer is a tool to create non-rectangular windows and image maps. It features a lightning fast proprietary tracing algorithm. It generates source code (complete with Project & Form files) for Visual Basic, C++ Builder, Delphi as well as HTML.

EdgeTracer is a tool to create non-rectangular windows and image maps. It features a lightning fast proprietary tracing algorithm. It generates source code (complete with Project & Form files) for Visual Basic, C++ Builder, Delphi as well as HTML.

Fast video indexer creates indexes by automatically capturing video screenshots. Generate jpeg contact sheets och html collection indexes or simply extract jpegs from the video. Batch all your videos and wait for fast video indexer to do its work.

Choose a template or build one, fill the keywords value if any, select your images, rotate them if necessary, and let FHPhotoGallery create the thumbnails, resize your images, and generate all html pages with the corresponding links.

Keep track of your colors while you build your website. Crayon Box can help you organize your color lists and generate the html color codes. Use a standard color picker. Automatically generates html color code. Label your colors! Try it today.
Softarea51.com RSS Feed

Get RSS updates on latest computer technology and software related press releases Subscribe to Latest Press Releases RSS feed    Subscribe



You are welcome to include these headlines in your own pages. If you want to find out how to parse this RSS file please read our tutorial How to parse RSS feeds with PHP.