Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to generate a pdf file on the fly in asp.net using vb.net code

Status
Not open for further replies.

Mentos123

Programmer
Feb 8, 2007
9
MY
Hi, can anybody help me here.. i have been looking into this problem for quite long but still dont manage to get it done.

I am trying to generate a pdf file on the fly depends on which registration number the user choose then the system will pull all the data from the database and generate a pdf file to display on the browser. Anyway, the pdf file wont be saved. It will just display and let the user print out.

I am using vb.net in asp.net. Thanks in advance
 
Crystal Reports for .Net has pdf export features. It requires that the report be defined at design time, but you can pass a dataset/datatable/enumberable to the report as a datasource at runtime.

CR.Net has the ability to export in different formats. PDF being one of them. (other formats: XLS, RTF, RPT, ...).

One thing to watch our for is IE6, Adobe Reader and inline files. These will not display properly. your options are
1. IE7, Adobe Reader and inline files
2. IE6, Adobe Acrobat and inline files
3. IE6, Adobe Reader and attached files
4. 3rd party borwser (FF, Opera), Adobe Reader and inline files

'inline files' refer to how the file is transmitted to the browser. Your options are inline or attachment. Inline automatically display the report without any user prompts (open, save, cancel). Attachments prompt the user for action (open, save, cancel).

My preference is to use an ASHX handler go generate the report. ASHX is similar to ASPX but doesn't contain the overhead of forms, which means it's much faster.

ASHX receives an HTTPContext object so you can access Request/Response objects to extract GET/POST values and set response headers (for the pdf).

for more information on ASHX google ASHX and check out the MS help. let me know if you have any questions.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top