CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Print to file

  1. #1
    Join Date
    Aug 2001
    Posts
    8

    Print to file

    How can i print to a specified file in VB?
    Although i can see "print to file" checkbox in CommonDialog (showPrint) Controls, when i check it, it is not available.
    How Can i do ?



  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Print to file

    What do you need to send to the file. If it is a text then

    Open "c:\temp\temp.txt" For Output As #1 'to write to
    Print #1, StringToPrint
    Close #1

    otherwise you can open a file in a binary mode and print to it

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Aug 2001
    Posts
    8

    Re: Print to file

    Thanks for your help.
    your answer is really available and simple, but i have to write a procedure to read this file and send it to printer ,and where the shoe pinches is i dont know the format and content i am going to print at all.
    Actually, i am anxious to know how can i make a general *.prn file in VB, so I can directly print a *.prn file with Win32 API as follows:

    OpenPrinter
    StartDocPrinter
    StartPagePrinter
    ' Open file and pump it to the printer.
    WritePrinter
    EndPagePrinter
    EndDocPrinter
    ClosePrinter

    The problem may be described as how to use these above functions to access the print spooler to construct a general *.prn file?

    i know a API function ReadPrinter which can retrieve data from the specified printer, but i don't know when to use this function, how to avoid transfer data in print spooler to a actual print, and so on.

    i am in Beijing,China. my english is very poor, please forgive me for the mistakes in my message.

    Kind regards,

    G. Chen




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured