Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Converting a webpage to PDF

  • 02-10-2009 9:27am
    #1
    Closed Accounts Posts: 408 ✭✭


    Hi All,

    I've been busy creating a webpage that uses javascript to generate some graphs and such, and I was wondering whether there was a tried and tested method to convert the webpage to PDF for download upon the user clicking a button.

    I can't use an external windows application to convert the file as the process needs to be performed within the web app, of course when the user clicks the download/print link button. (if that makes sense :S)

    A javascript plugin or piece of ASP code would be ideal - but I haven't had alot of luck so far...

    Any ideas?

    Thanks,

    Dan


Comments

  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    you might get some ideas here:
    http://www.velocityreviews.com/forums/t619932-web-page-to-pdf-on-the-fly.html

    Don't rule out an external web application as you might be able to pass in some parameters to it from the ASP page, and it would be launched as a background process.


  • Registered Users, Registered Users 2 Posts: 3,141 ✭✭✭ocallagh


    If your server can handle some PHP code let me know, don't know about ASP.


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger




  • Closed Accounts Posts: 408 ✭✭Chada


    Hey thanks for all the replies.

    I was originally adverse to having a desktop app convert the html page for me but the top link you supplied ginger looks like it could be one of the best options.

    I guess i was going for a long shot hoping I could get some javascript plugin to do it for me :P

    I'll give this a whirl see how I get on :)

    Thanks again all :D


  • Registered Users, Registered Users 2 Posts: 35,524 ✭✭✭✭Gordon


    I know it's probably not going to help you, but fyi you can print to pdf from a webpage on Mac X.


  • Advertisement
  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    I've thought about this, and I reckon this is a non-runner ?

    Javascript runs AFTER the page loads, but most print options print the source code of the page.

    And most document editors won't even see the Javascript.


  • Registered Users, Registered Users 2 Posts: 3,141 ✭✭✭ocallagh


    Liam Byrne wrote: »
    I've thought about this, and I reckon this is a non-runner ?

    Javascript runs AFTER the page loads, but most print options print the source code of the page.

    And most document editors won't even see the Javascript.
    You could send the innerHTML of the graphs to a script (via HTTP POST/AJAX) and have the script output an application/pdf content-type with a .pdf extension giving the user a download/open prompt whcih they can open and print directly from (similar to google docs print option which just gives the user a PDF of the file)


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    Spot on, ocallagh - I completely overlooked that it was the OP's own web page!

    Being able to add/edit a script within that page changes things a fair bit.


  • Registered Users, Registered Users 2 Posts: 2,120 ✭✭✭p


    What's the goal you're after? It's definitely possible to create PDFs on the fly, though getting the layout etc... maybe require some tweaking.

    A quick google reveals plenty of resources, but this one looks promising:
    http://www.webresourcesdepot.com/open-source-pdf-library-for-aspnet-pdfsharp/

    One thing I'd consider (or may be part of your eventual solution) is to use a separate CS file for printing, that way when you print you can make something very suitable for a document. Modern browsers just grab that CSS file instead of the regular stylesheet when you hit print.


Advertisement