Print file from browser

Posted on 2008-11-18
Last Modified: 2012-05-05

I'm trying to print a file from a  browser.
I have the path to the file. Ex

What i what to achive is that the user can push a button/link and the browser will send the file to the users printer.
I would prefer if it just pics the default printer but the print window is also acceptable.

The files can be of all type(doc,txt,ptt,pdf).
I'm using the .net 1.1

I've don't really have any ideers how to make this work so I'm open for any sugestions



Question by:Birger1000
    LVL 3

    Expert Comment

    You can open up the print control through javascript, using window.print(); Not sure if this is what you're looking for.

    Author Comment

    I'm not trying to print the browser window, but a file that is on another server.


    The user is on this page and pushed a link on the page and then I want this file to print -

    Hope this explais the problem.

    LVL 3

    Expert Comment

    You can't print external files like that, not even on the same server.

    Author Comment

    I've just discoved that the files that need to be printet is only pdf files.
    Will this improve my chances of printer in the way I descibed above
    LVL 2

    Expert Comment

    Try these solution It's not work for me, but maybe it will works for you. If you have an opportunity to setup printer on you application server I can send to you c# server code to print from server side scripts.

    Accepted Solution

    I'm just found a solution..
    It's not all that good but it gets the job done

    I'm adding the requied pdf as object on the page and then fires a javascript that prints all the object

    Thanks for all the support
    function printDocument() {
          var i = 0;
          while (document.getElementById('pdf' + i))
                alert("count " + i);
                document.getElementById('pdf' + i++).printWithDialog();
          //setTimeout("window.close()", 5000);
    Response.Write("<OBJECT id = ""pdf"+ count.ToString  +""" name=""pdf"+ count.ToString  +""" CLASSID=""clsid:CA8A9780-280D-11CF-A24D-444553540000"" WIDTH=""364"" HEIGHT=""290""><PARAM NAME='SRC' VALUE="+ item.Value  +"></OBJECT>")  
              Dim y as string = "<script language='JavaScript'>printDocument();</script>"
              Me.RegisterClientScriptBlock("clientscript", y)

    Open in new window


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
    Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now