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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Location
    India Mumbai
    Posts
    248
    Thanks
    13
    Thanked 1 Time in 1 Post

    diaplying print preview directly to the user

    hi,

    Best Wishes 4 the new year!!!

    i have a print button on the page.Onclick i open the same page in a new window where in the user can print the page content. But now i want that the user should be directly show the print preview so that the user knows how and what will be printed on the page[ specially the remarks column which are toooo large].i dont how to do it ???
    whether i have to use javascript or php
    thanks in advance

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    You can use either...but JavaScript can be disabled and hence...I would suggest that you use PHP.

    Though, I think a combination of PHP and JavaScript is best. That is, if the user has not disabled JavaScript...then JavaScript will be used to provide the print preview and that would save the user a trip to the server in order to get a print preview.

    If you are to use JavaScript...than you can control which elements of the website are to be printed by using CSS and JavaScript. Just do a google search on that...and I am sure you find loads of examples.

    As for using PHP...you will need a page on the server to take care of that. for example, to print the home page...
    Code:
    http://domain.com/print.php?page=home
    to print about page...
    Code:
    http://domain.com/print.php?page=about
    in your print.php page...you should get the page to be printed like so
    Code:
    <?php
    $page = $_GET['page'];
    // code to read page here
    ?>
    Good luck.
    Ess


  •  

    Posting Permissions

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