print files in VB.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Li Weng

    print files in VB.net

    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
  • Kevin Yu [MSFT]

    #2
    RE: print files in VB.net

    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 misunderstandin g, 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."

    Comment

    • Li Weng

      #3
      RE: print files in VB.net

      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

      "Kevin Yu [MSFT]" wrote:
      [color=blue]
      > 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 misunderstandin g, 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."
      >
      >[/color]

      Comment

      • Kevin Yu [MSFT]

        #4
        RE: print files in VB.net

        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."

        Comment

        • Kevin Yu [MSFT]

          #5
          RE: print files in VB.net

          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("A croExch.App")
          avDoc = CreateObject("A croExch.AVDoc")
          avDoc.Open("c:\ t.pdf", "")
          pdDoc = avDoc.GetPDDoc( )
          nbrPages = pdDoc.GetNumPag es()

          'avDoc.PrintPag es 0, 1, 2, False, True
          avDoc.PrintPage s(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."

          Comment

          Working...