Click here to Skip to main content
13,194,662 members (68,855 online)
Rate this:
Please Sign up or sign in to vote.
Hi all i am a beginner programmer, and have a small problem. I have a webpage with a table that gets its information dynamically from the database. I have a export button that exports the data of the table to pdf format (using ITEXTSHARP). The export button works and the PDF file is saved into the solution folder of the project. But how can i get the PDF file to show after the export button is clicked so the user/viewer can see the pdf and then select where to save it. Any help will be much appreciated, thanking you in advance...
Posted 20-Sep-12 1:10am
Updated 20-Sep-12 1:11am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

1) There is a library called PDF.js, PDF JS[^] you could give this a shot as well.

2) PDF Object is a library to render your PDF using js as well.[^]
-Sample code from their site:
    <title>PDFObject example</title>
    <script type="text/javascript" src="pdfobject.js"></script>
    <script type="text/javascript">
      window.onload = function (){
        var success = new PDFObject({ url: "sample.pdf" }).embed();
    <p>It appears you don't have Adobe Reader or PDF support in this web
    browser. <a href="sample.pdf">Click here to download the PDF</a></p>

Hope this helps.

Rate this: bad
Please Sign up or sign in to vote.

Solution 4

Thanks for all the responses. But i ended up just using a hyperlink that points to the pdf file that was created when the user clicked the export button.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

When the user clicks the button at the end of the eventhandler you can use

For this to work you will need the PDF to be in a folder where the user can browse to.

If you leave the content-type default the browser will probably open the document like normal, but it might download it if the user has his settings on that.
If you want to force a download, and leave the user on your page, you will have to change the http content-type header to application/octet-stream.

To change the http header you can use the following code.
Response.ContentType = "application/octet-stream";
Ruwaldo 21-Sep-12 4:00am
I tried the Rsponse.Redirect but nothing is happening. Im not getting any errors, but its not doing anything

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171018.2 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2017
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