Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 04, 2012 02:20 AM by gerrylowry
Jul 03, 2012 05:10 AM|LINK
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 ?
Jul 03, 2012 08:51 AM|LINK
Client Side using c#
Jul 03, 2012 10:19 AM|LINK
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.
Jul 03, 2012 11:49 PM|LINK
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">
<form id="form1" runat="server">
<iframe src="<%=this.FrameURL %>" id="PDFtoPrint"></iframe>
<input type="button" value="Print" onclick="document.getElementById('PDFtoPrint').focus(); document.getElementById('PDFtoPrint').contentWindow.print();" />
The PrintPDF..aspx.cs is as follows:
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"]);
Now i call this page via the following
Response.Redirect("../ViewFilePDF.aspx?filename=" + "c:\test\printpdf\document.pdf");
Now if when the PrintPDF page is loaded the src is set to c:\test\printpdf\document.pdf , but it is not displayed in the frame ...
what could be causing the issue there ?
Jul 04, 2012 02:20 AM|LINK
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