Click to See Complete Forum and Search --> : How to Create PDF document in ASP.NET


shivkumar
August 9th, 2009, 05:11 AM
Hi experts,
I m new to ASP.NET. and using vb.net as a source code. I m working on a very small project. I need to fetch the data from database and based on the data in reader, I need to generate PDF documents. e.g. I have a database where students marks are stored as below.

Std name sub1 sub2 sub3 sub4
-------------------------------------------------------------
Some name1 40 41 35 45
Some name2 30 45 15 49


I want when user clicks on a button go generate mark sheets, one PDF file of two pages (since only two records in database) will be generated as below:

Name : Some Name1
-------------------------------
Subjects Marks
sub1 40
sub2 41
sub3 35
sub4 45
----------------------------------
Total 161

and one more and same page for some name2, so that when print command is given user can print all or selected pages from the pdf document.


Please any one help me. Thanks in advance.

Shuja Ali
August 9th, 2009, 05:44 AM
ShivKumar, you should not post multiple threads for the same question.

If you do a simple google search, you will get 100s of samples showing you how to build PDF documents using ASP.NET. Here is a set of free libraries that you can use to generate PDF documents:
http://csharp-source.net/open-source/pdf-libraries

Although this is a C# site, you should still be able to convert the code to VB.NET using Developerfusion's C# to VB.NET Converter (http://www.developerfusion.com/tools/convert/csharp-to-vb/)

shivkumar
October 4th, 2009, 01:59 AM
Shuja ji,

thanks a lot for your guidance.
some how I m now able to generate pdf files. but I have a new issue.
when I m running the web pages, generated pdf files are stored automatically in the location

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\.

when I copied the web pages to the server, i dont know on which location these pages are created.

I want to create these pages to a location which I specity. Or it can go directly to the printer.

shivkumar
October 4th, 2009, 03:33 AM
I got it done my self.
I just added : Server.MapPath("Temp\") + : in below line and it started working fine

Dim Writer As PdfWriter = PdfWriter.GetInstance(Document, New FileStream(Server.MapPath("Temp\") + SlNo + ".pdf", FileMode.Create))