Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

.rtf File Printing

$
0
0
Hi all

I am attempting to write a routine with VB 2010 that can be called via a dos program that prints an .rtf page.
But when i run the program all i get is a blank page from the printer.

This is what I have so far

Code:


Imports System.Drawing.Printing
Imports System.IO

Public Class Form1

    Private printDocument1 As New PrintDocument()
    Private stringToPrint As String

    Private Sub ReadFile()
        Dim docName As String = "PRINTER TEST ROUTINE.rtf"
        Dim docPath As String
        printDocument1.DocumentName = docName

        docPath = "C:\Documents and Settings\User\My Documents\"
        Dim stream As New FileStream(docPath + docName, FileMode.Open)
        Try
            Dim reader As New StreamReader(stream)
            Try
                stringToPrint = reader.ReadToEnd()
            Finally
                reader.Dispose()
            End Try
        Finally
            stream.Dispose()
        End Try
    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ReadFile()
        printDocument1.Print()

    End Sub

Any ideas what im doing wrong

Many Thanks

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>