Currently I have a file that is generated on the Web Server ; a pdf file; when the user clicks on a print button on the app.
So if there are printers on the web server then the file will be printed on the default printer .
But how can i get the file to be generated on teh web server and then when the user clicks on print it will bring up the printer dialog and allow them to select the printer ?
it's important to realize that for security reasons, web programmers are restricted from controlling hardware (printers, scanners, web cameras, hard disks, et cetera) on the client side ... otherwise, to many malicious possibilities exist ... already we
see viruses downloaded to end users' computers by evil black hat hackers ... imagine if someone could cause an end user's printer to print without the end user's intervention ... creepy people would cause printing of page after page of 100% black until the
end user's printer ran out of either ink/toner or paper.
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
is this an internet application? or an intranet application?
for an intranet application, you might choose a printer for your end users but you would not be able to let your intranet users
manipulate a server's printer dialog ... you would have to do everything for your intranet users "behind the curtain" AFAIK.
the concept that i mentioned earlier works both ways:
you do not get to directly control the hardware of internet end users; and
internet end users do not get to directly control the hardware of
your servier.
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
robby32
Member
120 Points
498 Posts
How can i do printing Client Side using c# ?
Jul 03, 2012 05:10 AM|LINK
Hi ,
Currently I have a file that is generated on the Web Server ; a pdf file; when the user clicks on a print button on the app.
So if there are printers on the web server then the file will be printed on the default printer .
But how can i get the file to be generated on teh web server and then when the user clicks on print it will bring up the printer dialog and allow them to select the printer ?
cheers
Robby
Paul Linton
Star
13421 Points
2535 Posts
Re: How can i do printing Client Side using c# ?
Jul 03, 2012 08:51 AM|LINK
http://stackoverflow.com/questions/687675/can-a-pdf-files-print-dialog-be-opened-with-javascript
gerrylowry
All-Star
20513 Points
5712 Posts
Re: How can i do printing Client Side using c# ?
Jul 03, 2012 10:19 AM|LINK
@ robby32
it's important to realize that for security reasons, web programmers are restricted from controlling hardware (printers, scanners, web cameras, hard disks, et cetera) on the client side ... otherwise, to many malicious possibilities exist ... already we see viruses downloaded to end users' computers by evil black hat hackers ... imagine if someone could cause an end user's printer to print without the end user's intervention ... creepy people would cause printing of page after page of 100% black until the end user's printer ran out of either ink/toner or paper.
g.
robby32
Member
120 Points
498 Posts
Re: How can i do printing Client Side using c# ?
Jul 03, 2012 11:49 PM|LINK
Hi ,
I have tried the example given there . It seems to work if the file is in the same directory as the aspx file which defines the iframe.,
In my case i am passing through a generated file.
I have defined a web form . lets say
PrintPDF.aspx defined as follows:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewFilePDF.aspx.cs" Inherits="ProfAdv.Purchasing.Web.ViewFilePDF" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <iframe src="<%=this.FrameURL %>" id="PDFtoPrint"></iframe> <input type="button" value="Print" onclick="document.getElementById('PDFtoPrint').focus(); document.getElementById('PDFtoPrint').contentWindow.print();" /> </div> </form> </body> </html>public partial class ViewFilePDF : System.Web.UI.Page { public string FrameURL = ""; protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["filename"] != null) { if (PAUtils.SafeStringTrim(Request.QueryString["filename"]) != "") FrameURL = PAUtils.SafeStringTrim(Request.QueryString["filename"]); } } }Response.Redirect("../ViewFilePDF.aspx?filename=" + "c:\test\printpdf\document.pdf");gerrylowry
All-Star
20513 Points
5712 Posts
Re: How can i do printing Client Side using c# ?
Jul 04, 2012 02:20 AM|LINK
@ robby32
what is your goal? it's somewhat unclear to me.
is this an internet application? or an intranet application?
for an intranet application, you might choose a printer for your end users but you would not be able to let your intranet users manipulate a server's printer dialog ... you would have to do everything for your intranet users "behind the curtain" AFAIK.
the concept that i mentioned earlier works both ways:
you do not get to directly control the hardware of internet end users; and
internet end users do not get to directly control the hardware of your servier.
g.