?
Solved

PRINT FILE IN ASP.NET

Posted on 2011-03-03
2
Medium Priority
?
304 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 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