tags:

views:

140

answers:

9

Hi All,

I am using asp.net 2.0 with c#.

I have to convert my label text into pdf. For this I have used this tutorial http://www.codeproject.com/KB/aspnet/Creating_PDF_documents_in.aspx

now I am facing two problems:

  1. Every time it is creating 1.pdf, what if there are so many user wants to see the the pdf format of any page
  2. As my label text contains HTML content, it is showing a HTMl output. I don't want HTML to be display in the pdf.

please let me know if you have any other way to create a pdf.

Thanks in advance.

A: 

I use CrystalReports. It can create a PDF on the fly and output it to disk or http directly.

Jeroen
maybe the downvoter could state it's reason?
Jeroen
A: 

Creating a PDF with HTML-formatted content is not entirely trivial, and the CodeProject sample code isn't quite suitable for that. You'll most likely want to look into a (commercial) third-party solution for this: I myself use Siberix Report Writer: it's flexible, quite affordable, works in partial-trust scenarios (nice for shared web hosting environments) and most importantly doesn't require a per-server license, so you can embed it in your product without redistribution issues.

mdb
+1  A: 

Item 1) You cache your pdf files to disk. When a request is made for a pdf check if the pdf has been created (i.e. there is a file on disk) and if not generate it. Then send the pdf using the response.writefile command

Item 2) If you are trying to print formatted html into pdf then you will need something that is capable of rendering html. There are a number of html to pdf converters however I have not found them to be all that good. If you are comfortable with php then there are some pretty good converters you can use. Joomla supports html to pdf, so whilst it may not be the exact solution it maybe a good starting point.

Alex
A: 

I would also suggest you take a look at Aspose PDF.

bleevo
A: 

I would suggest using RDLC Report or Crystal Reports as suggested by @Jeroen

A: 

Cete Pdf Generator has HtmlTextArea element and supports some limited HTML

http://www.cete.com/support/net_help_library/html/ceTeDynamicPDFPageElementsHtmlTextArea.htm

Sonic Soul
A: 

ABCpdf is another commercial component which converts html to pdf. http://www.websupergoo.com/abcpdf-5.htm

Tajan
A: 

You could try the itextsharp library. I've not used it but it has been highly commended by other developers I know. http://sourceforge.net/projects/itextsharp/

In regards to the caching issue. I would check the file system for a pdf named via a convention. If the file is found then serve it. Otherwise, call another method which generates the pdf and saves it to the drive. This way only the first ever request will cause the generation of the pdf. Naming conventions will be key here. The basic implementation wont be thread safe. But it's a good start.

WDuffy