Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET PDF convert
How can i convert an .aspx page to a PDF file in button click using ASP.NET? Can anybody who knows please help me?
Posted 19-Jan-11 23:19pm
Rupa11.4K
Edited 21-Jan-11 17:07pm
Indivara32.9K
v2
Comments
Indivara at 21-Jan-11 23:07pm
   
Added tags, minor fixes
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Comments
Madhulika Satalkar at 4-Feb-13 4:46am
   
my page is web form including master page and having ..............multiple CSS so itestsharp is not useful for external CSS.................plz suggets
thnx
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Just use THIS[^] article as a reference.
 
.aspx page is ultimately get converted in HTML so think about HTMLtoPDF.
 
I think that article will take you towards your goal.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
There are many third party tools are available to do that.
Like itextsharp,PdfSharp etc. Search on them. You will get a more help.
 

umesh
  Permalink  
Comments
1nagaswarupa at 20-Jan-11 5:30am
   
without third party we can't do......?
soni uma at 20-Jan-11 5:35am
   
No, In .net there is not any inbuilt feature that provide to generate pdf. You must have to use third party for proper solution.
1nagaswarupa at 20-Jan-11 5:52am
   
thx a lot sir...............
soni uma at 20-Jan-11 5:54am
   
u welcome. But don't forgot to rate answer. it help to you and me in point increase.
1nagaswarupa at 20-Jan-11 6:06am
   
what is the use of rate to answer
soni uma at 20-Jan-11 6:13am
   
Read content on this page
http://www.codeproject.com/script/Membership/Reputation.aspx
1nagaswarupa at 20-Jan-11 6:21am
   
ok now i understood thx..........
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

I have gone thorugh this recently, I suggest you to go with iTextSharp.
I have tried many ways and finally concluded it as a best available solution.
They provide very good support for Conversion.
And with help of 'htmltopdf'(search this term), You will be able to convert part of HTML to PDF.
Go for the newer version of iTextSharp(version 5).
If you need more assistance then please be specific on it, I will help you for sure.
  Permalink  
Comments
1nagaswarupa at 21-Jan-11 8:53am
   
thx a lot sir.....for u reply
Gandalf - The White at 22-Jan-11 9:51am
   
You're welcome...
So have you started?
1nagaswarupa at 23-Jan-11 22:53pm
   
ok ...sir
Gandalf - The White at 27-Jan-11 3:30am
   
So, If you stuck anywhere, let me know I will help you.
Recently just two day before, I have generated PDF from HTML(Table based). And its generating awesome output with styles.
Member 7922075 at 26-Oct-12 1:41am
   
hi, i have same issue
can u help me?
Madhulika Satalkar at 4-Feb-13 4:45am
   
my page is having multiple external CSS ............using itextxharp......is not useful for me bcoz its not working with CSS............plz suggest something which will work with CSS
thnx
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

plz suggest thnx
i am using itextsharp for converting my asp page to pdf...............i am facing css issue as my page is in div structure..............also getting error also but getting error:
Protected Sub btnExport_Click(sender As Object, e As EventArgs)
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
Me.Page.RenderControl(hw)
 
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 100.0F, 0.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.[End]()
End Sub
 
http://www.mikesdotnetting.com/Article/87/iTextSharp-Working-with-images
 
using itextsharp dll for converting
htmlparser.Parse(sr)
 
is not defining proper path for the images:
 
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Images\Layout\an-Logo.png'.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

I have gone thorugh this recently, I suggest you to go with iTextSharp.
I have tried many ways and finally concluded it as a best available solution.
They provide very good support for Conversion.
And with help of 'htmltopdf'(search this term), You will be able to convert part of HTML to PDF.
Go for the newer version of iTextSharp(version 5).
If you need more assistance then please be specific on it, I will help you for sure.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 210
1 Richard MacCutchan 100
2 kbrandwijk 90
3 ProgramFOX 80
4 Mukesh Bhagat 65
0 Sergey Alexandrovich Kryukov 9,050
1 OriginalGriff 8,151
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 3 Mar 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100