Solved

PRINT FILE IN ASP.NET

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

896 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

11 Experts available now in Live!

Get 1:1 Help Now