Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8643191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:58:17+00:00 2026-06-12T11:58:17+00:00

I have this code: Private printDocument1 As New PrintDocument() Private stringToPrint As String Private

  • 0

I have this code:

Private printDocument1 As New PrintDocument()
Private stringToPrint As String

Private Sub ReadFile()
    Dim docName As String = "print_doc.rtf"
    Dim docPath As String = fsPathPrintDoc
    printDocument1.DocumentName = docName
    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

and I do the printing using:

ReadFile()
printDocument1.Print()

I want to print a rtf file using a VB.NET printdialog.show(), because in want to choose specific printers for printing, but my above code i dont have any idea, how i can embed printdialog here.

This is required because i want to print that file using printers available on different systems using network. Now all these available printers are available for me in print dialog, what i want is to simply print a particular file in my drive using printdialog()

Also, I tried to find a possibility to print a file using printdialog and printdocument but unfortunately failed.

Edit:

I found http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx but it does not includes printdialog

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:58:19+00:00Added an answer on June 12, 2026 at 11:58 am

    You assign your PrintDocument to the PrintDialogs Document Property, it will then add the selected printer to your Document. You then print the Document as normal.

    PrintDialog1.AllowSomePages = True 
    PrintDialog1.ShowHelp = True 
    PrintDialog1.Document = printDocument1 'Assign your Document here
    
    Dim result As DialogResult = PrintDialog1.ShowDialog()
    
    If (result = DialogResult.OK) Then
        printDocument1.Print()
    End If 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have this code : Private Sub Worksheet_Change(ByVal Target As Range) Dim lastrow
I have this code private static Set<String> myField; static { myField = new HashSet<String>();
I have this code: private static readonly Dictionary<string, ChatUser> _users = new Dictionary<string, ChatUser>(StringComparer.OrdinalIgnoreCase);
I have this code private void writeReport(IReport report, string reportName) { string reportString =
I currently have this code Private Sub Worksheet_Change(ByVal Target As Range) WorksheetChanged(Target, Range(AB3).CurrentRegion, Range(B18:B19))
I have this snippet of code private Templates retrieveFromCache(String name) { TemplatesWrapper t =
I have the following code: private void _DoValidate(object sender, DoWorkEventArgs e) { this.BeginInvoke(new MethodInvoker(()
I have this code private void saveImage() { Bitmap bmp1 = new Bitmap(pictureBox.Image); bmp1.Save(c:\\t.jpg,
I have this code: private static void saveMetricsToCSV(String fileName, double[] metrics) { try {
I have this code : private void insertValus() { ContentValues initialValues = new ContentValues();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.