Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to create pdf file or pdf report in ASP

    Hi all am trying to open a page or report in pdf

    i got the following from the net and i tried it

    the script is as the following


    <%
    Response.buffer = true
    with response
    .Clear
    .ContentType = "application/pdf"
    .Charset = "UTF-8"
    .AddHeader "Content-Disposition","attachment;filename=test.pdf"
    end with

    Response.Write "Hi to my pdf file "

    Response.Flush
    Response.end
    %>



    when i run the above program it asks me whether to download or save the pdf files and in the both cases am getting the following error when am trying to open it


    "Adobe Reader could not opent 'test[1].pdf' because it is either not a supported file type or because the file has been corrupted ( fro example , it was sent as an email attachment and wasn't correctly decoded)"


    plz help me am newbie to ASP

  • #2
    Regular Coder
    Join Date
    May 2007
    Location
    UK
    Posts
    180
    Thanks
    0
    Thanked 18 Times in 18 Posts
    A pdf file contains many binary codes. It is not a simple text file.

    Setting the content type and the header warn the client browser to expect a Response stream that must be rendered by a pdf reader. What you also have to do is send the the binary codes that appear in a pdf file to the Response stream.

    It is possible to write suitable crafted XML for client browsers to view as Microsoft Excel and Word files. I suspect it is much harder for pdf files. You will probably need proprietary software, which you may have to pay for, to achieve this.

  • #3
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    Yes, it is possible to create PDF files using ASP...but you might have to get a third party library or plugin in order to do this...if you web host doesn't already support this functionality that is.

    So, get in touch with your hosting company and ask if they support PDF generation.

    If they don't support PDF at all, then you may wish to check out ASPPDF which is an ActiveX plugin that allows you to create PDF files on the fly.

    http://www.asppdf.com/

    Cheers,
    ~E

  • #4
    New Coder
    Join Date
    Feb 2007
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    thanks alot for all the replays,

    but is it possible to make make that without the need for a third party component ....???

  • #5
    New Coder
    Join Date
    Feb 2007
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks alot for all the replays,

    but is it possible to make make that without the need for a third party component ....???


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •