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
    Regular Coder
    Join Date
    Nov 2002
    Location
    Southern California
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening the Printer Dialog box to print a PDF

    This can't be difficult, but i can't seem to find any info on how to do this.

    I would like to have a link that opens the Printer Dialog box so a PDF can be printed. This is without opening the PDF at all, but printing out the PDF on a printer. Can this be done?


    TIA!

    P.S. I bet it's so simple I'm going to slap myself...
    Everyone has the right to be stupid, some just abuse the privilege.

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Edit:
    I stand corrected. Nice one Glennv


    Code:
    <input type="button" value="Print" name="btnPrint" id="btnPrint" onclick="window.print();">
    this would print the html page the button resides on.

    It's untested, but if you had something like:
    Code:
    <iframe src="myDocument.pdf" id="myIframe"></iframe>
    <input type="button" value="Print" name="btnPrint" id="btnPrint" onclick="document.getElementById("myIframe").print();">
    It should print the content of that window/frame.

    hope this helps

    m_n
    Last edited by martin_narg; 05-26-2005 at 10:27 AM.
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Location
    Southern California
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts
    IE only.
    Everyone has the right to be stupid, some just abuse the privilege.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    At the moment, you have to make do with a workaround.

    Load the PDF in a hidden iframe. That will confuse users though as the Acrobat splash screen will show up even if they won't see a PDF file.

    Code:
    function printPDF(){
      var pdf = document.getElementById("pdfDoc").contentWindow;
      pdf.focus();
      pdf.print();
    }
    ...
    <iframe src="myDocument.pdf" id="pdfDoc" style="display:none"></iframe>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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