Solved

PRINT FILE IN ASP.NET

Posted on 2011-03-03
2
298 Views
Last Modified: 2012-06-27

Guys,

I need send a image where is server to print of client browser.

How I can do this?
0
Comment
Question by:berechit
2 Comments
 
LVL 10

Accepted Solution

by:
John Claes earned 500 total points
ID: 35025757
Client Side Printing
Directly
ASP.NET does not provide direct access to printer on client-side.
     If you really want to do so, you should seek for a client-side solution like Java or Flash objects instead.

Using a PopUpScreen
If you might use a PrintPopUp that does it for you you always can see through the folowing example
http://www.dotnetcurry.com/ShowArticle.aspx?ID=92&AspxAutoDetectCookieSupport=1
this example generates a page in a popUp screen that will be send directly to the printer and will be closed afterwards.


Through Excel
I propose the folowing action :
First you have to retrieve the DataSet
Then you have to send it towards the Client
                I propose Excel : http://support.microsoft.com/default.aspx?scid=kb;en-us;319180
Then the User Can print it by himself after checking the data.

ServerSide printing
this is not possible because you can't reach the Client-Side printers from the Server-Side.
You can send your print instructions to a networkPrinter if we're talking about a IntraNet (inside company website)

regards

poor beggar
0
 
LVL 14

Expert Comment

by:Dhanasekaran Sengodan
ID: 35025771
You know 'window.print()' function will print the HTML content of the current page in the browser window.

Put the image in a DIV tag and then use the following code. The content of the DIV is written to a new window and then printed in this code.,


<script type="text/javascript"> 
   function ClientSidePrint(idDiv) 
    { 
          var w = 600;
          var h = 400;
          var l = (window.screen.availWidth - w)/2;
          var t = (window.screen.availHeight - h)/2;
            
          var sOption="toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=" + w + ",height=" + h + ",left=" + l + ",top=" + t;
 
       // Get the HTML content of the div
       var sDivText = window.document.getElementById(idDiv).innerHTML;

      // Open a new window
      var objWindow = window.open("", "Print", sOption);

    // Write the div element to the window
    objWindow.document.write(sDivText);
    objWindow.document.close(); 
 
    // Print the window                  
    objWindow.print();
   
    // Close the window
    objWindow.close();                  
   } 
</script>

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 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