Solved

PRINT FILE IN ASP.NET

Posted on 2011-03-03
2
299 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
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…

829 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