title: How to print a server side text file on a client printer programically
body: <p>I have a server side application which creates a series of text files on the server.  I need to allow a user to print one or more of the files directly on the client printer by clicking a button on a web page.  That should bring up a printer selection window and then commence printing the selected web pages.  I can handle the file selection and the printer selection windows but have not been able to get the files to print.  I located code on Code Project (<a href="http://www.codeproject.com/Tips/689325/Send-PDF-files-directly-to-client-printer-without" rel="nofollow">http://www.codeproject.com/Tips/689325/Send-PDF-files-directly-to-client-printer-without</a>) which was described as doing exactly what I need but for for PDF files.  I have attempted to adapt it to text files and the code runs without visible error, but nothing arrives at the printer and I do not know how to locate what happens after the code executes the value attribute of the Object tag of the web pages source code (see below).  I program in VB.Net.</p>
  
  <p>Here is the object tag in the source code:</p>
  
  <pre><code> &lt;object id = "Object1" name="Txt1" 
  type="file/txt" width="1" height="1" &gt;
              &lt;param  name='SRC' value='&lt;%= SReportFileName %&gt;'/&gt;
  &lt;/object&gt; 
  </code></pre>
  
  <p>Here is the code from the code behind file:</p>
  
  <pre><code>Partial Class ViewResults_PrintingReports
      Inherits System.Web.UI.Page
      Public SReportFileName As String = ""
  Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
          Dim PathName As String = ""
          Dim Uname As String = ""
          Dim Iyr As String = ""
          Dim Iwld As String = ""
          Dim Iqtr As String = ""
          Dim FName As String = ""
          Dim CNumber As String = ""
          Uname = "UserName"
          Iyr = "3"
          Iqtr = "1"
          FName = "ReportA"
          CNumber = "1"
          Iwld = "1"
          '       Dim cs As ClientScriptManager = Page.ClientScript
          PathName = "~/Competitions/" &amp; Uname &amp; "/BP/" &amp; "World" &amp; Iwld &amp; "/Reports/QtrRpts" &amp; Iwld &amp; "." &amp; Iyr &amp; Iqtr &amp; "/" &amp; FName &amp; "." &amp; Iwld &amp; CNumber &amp; ".txt"
          SReportFileName = PathName '// temp/mypdf.pdf 
          Try
              ClientScript.RegisterStartupScript(GetType(Page), "MessagePopUp", "&lt;script language=text/javascript&gt;document.Txt1.printAll()&lt;/script&gt;")
          Catch ex As Exception
              MsgBox("Problem printing file", , ex.Message)
          End Try
      End Sub
  End Class
  </code></pre>
  
  <p>Any help would be appreciated.</p>