Solved

PRINT FILE IN ASP.NET

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Can't create users table in existing DB 16 61
Whats wrong with this query 21 41
Calling stored proc in EDMX 11 19
Asp.net mvc 5 5 23
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

12 Experts available now in Live!

Get 1:1 Help Now