print files in VB.net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am working on a VB.net project that needs to provide a feature that user
can print a file to a printer from a directory. The file can be any type,
like PDF, TIF, etc., not just text file. Could anybody help me with this?
Thanks in advance.

Li
 
Hi Li,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to write an app that can print
all kind of datat types. If there is any misunderstanding, please feel free
to let me know.

As far as I can see, this is a very big project. First, you have to make
sure that your application can open all these types of files. For text
files, you need to know the format, and for image files, you have to have
all the decoders for them. Then you can show them in you app and convert
the document to the printer. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
The users don't want to open the files. They get these files as attachments.
They just want to send these files to the printer. What I want to know is if
VB.net has some functionalities to do these. Or at least for PDF and TIF.
Then I can check if a file is a PDF or a TIF and call related class to send
it out to printer.

Thanks.

Li
 
Hi Li,

Printing the files involve opening them. If we need to print a file, the
printer itself doesn't know how to print that. We need the computer to open
it first and convert the file format to printer's interface.

However, VB.NET don't have functionalities to open PDF or TIF files. I
think you have to check for the third party components. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Li,

If you need to open PDF files and print them on the printer, you can try to
use Acrobat Reader automation. However the machine that runs the app has to
have Acrobat Reader installed. The following code might help.

Dim acrApp As Object
Dim avDoc As Object
Dim pdDoc As Object
Dim nbrPages As Int16

acrApp = CreateObject("AcroExch.App")
avDoc = CreateObject("AcroExch.AVDoc")
avDoc.Open("c:\t.pdf", "")
pdDoc = avDoc.GetPDDoc()
nbrPages = pdDoc.GetNumPages()

'avDoc.PrintPages 0, 1, 2, False, True
avDoc.PrintPages(0, nbrPages - 1, 2, False, True)
pdDoc = Nothing
avDoc = Nothing

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top