Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Print file VB.Net

Print file VB.Net

Scheduled Pinned Locked Moved Visual Basic
questioncsharpdatabase
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    partt
    wrote on last edited by
    #1

    I know I'll get hell for this one....How do I print a PDF file from vbnet? My code is below which populates a crystal reports document and saves it as a pdf, how can I print it now? Dim sc As New PP.BusinessLogicLayer.Schedule() sc.ScheduleStamp = Session("Sch") sc.StudyNo = txtStudyNumber.Text.Trim sc.AQ = Session("AQ") sc.PrintTopSheet() Dim CRDoc As New ReportDocument() CRDoc.Load("C:\w\x\y\z.rpt") Dim logonInfo As New TableLogOnInfo() Dim i As Integer For i = 0 To CRDoc.Database.Tables.Count - 1 logonInfo.ConnectionInfo.ServerName = serverName logonInfo.ConnectionInfo.DatabaseName = databaseName logonInfo.ConnectionInfo.UserID = uid logonInfo.ConnectionInfo.Password = pwd CRDoc.Database.Tables.Item(i).ApplyLogOnInfo(logonInfo) Next Dim crExportOptions As ExportOptions Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions() Dim Fname As String Fname = "\\a\b\c.pdf" crDiskFileDestinationOptions.DiskFileName = Fname crExportOptions = CRDoc.ExportOptions With crExportOptions .DestinationOptions = crDiskFileDestinationOptions .ExportDestinationType = ExportDestinationType.DiskFile .ExportFormatType = ExportFormatType.PortableDocFormat End With CRDoc.Export()

    D 1 Reply Last reply
    0
    • P partt

      I know I'll get hell for this one....How do I print a PDF file from vbnet? My code is below which populates a crystal reports document and saves it as a pdf, how can I print it now? Dim sc As New PP.BusinessLogicLayer.Schedule() sc.ScheduleStamp = Session("Sch") sc.StudyNo = txtStudyNumber.Text.Trim sc.AQ = Session("AQ") sc.PrintTopSheet() Dim CRDoc As New ReportDocument() CRDoc.Load("C:\w\x\y\z.rpt") Dim logonInfo As New TableLogOnInfo() Dim i As Integer For i = 0 To CRDoc.Database.Tables.Count - 1 logonInfo.ConnectionInfo.ServerName = serverName logonInfo.ConnectionInfo.DatabaseName = databaseName logonInfo.ConnectionInfo.UserID = uid logonInfo.ConnectionInfo.Password = pwd CRDoc.Database.Tables.Item(i).ApplyLogOnInfo(logonInfo) Next Dim crExportOptions As ExportOptions Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions() Dim Fname As String Fname = "\\a\b\c.pdf" crDiskFileDestinationOptions.DiskFileName = Fname crExportOptions = CRDoc.ExportOptions With crExportOptions .DestinationOptions = crDiskFileDestinationOptions .ExportDestinationType = ExportDestinationType.DiskFile .ExportFormatType = ExportFormatType.PortableDocFormat End With CRDoc.Export()

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You have to shell out to Acrobat Reader to print it. The command line is:

      "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" /p /h "<fullPathToFileHere>"

      RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      L 1 Reply Last reply
      0
      • D Dave Kreskowiak

        You have to shell out to Acrobat Reader to print it. The command line is:

        "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" /p /h "<fullPathToFileHere>"

        RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Hi Dave, I have a 2 question from here. Dave Kreskowiak wrote: "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" /p /h "" What do you mean by /p and /h? Because in my application, i did not use these two argument. I just access the acrobat executable file and run the file base on its path. Dave Kreskowiak wrote: C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe If i install windows on Drive D: and my program file would be D:\Program Files and the code is fix to drive C: how could we write code that could check which is the system drive for our windows??? It contain an error if I use: "%programfiles%\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" "" Can you give me some solution?


        A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office

        D 1 Reply Last reply
        0
        • L Lost User

          Hi Dave, I have a 2 question from here. Dave Kreskowiak wrote: "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" /p /h "" What do you mean by /p and /h? Because in my application, i did not use these two argument. I just access the acrobat executable file and run the file base on its path. Dave Kreskowiak wrote: C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe If i install windows on Drive D: and my program file would be D:\Program Files and the code is fix to drive C: how could we write code that could check which is the system drive for our windows??? It contain an error if I use: "%programfiles%\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" "" Can you give me some solution?


          A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          The man from SCN-CO wrote: What do you mean by /p and /h? THese are command line parameters that Acrobot Reader uses to tell it to Hide itself (no visible form or interface) and Print the file specified on its command line. The man from SCN-CO wrote: If i install windows on Drive D: and my program file would be D:\Program Files and the code is fix to drive C: how could we write code that could check which is the system drive for our windows??? It contain an error if I use: "%programfiles%\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" "" It's just an example. How you adapt the code is up to you. An example of getting the path to Program Files would be:

          Dim path As String = Environment.GetFolderPath( Environment.SpecialFolder.ProgramFiles )
          

          You could also read the Registry at the following key to find the complete path to AcroRd32.exe:

          KHEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\5.0\InstallPath

          or

          KHEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\6.0\InstallPath

          RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          L 2 Replies Last reply
          0
          • D Dave Kreskowiak

            The man from SCN-CO wrote: What do you mean by /p and /h? THese are command line parameters that Acrobot Reader uses to tell it to Hide itself (no visible form or interface) and Print the file specified on its command line. The man from SCN-CO wrote: If i install windows on Drive D: and my program file would be D:\Program Files and the code is fix to drive C: how could we write code that could check which is the system drive for our windows??? It contain an error if I use: "%programfiles%\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" "" It's just an example. How you adapt the code is up to you. An example of getting the path to Program Files would be:

            Dim path As String = Environment.GetFolderPath( Environment.SpecialFolder.ProgramFiles )
            

            You could also read the Registry at the following key to find the complete path to AcroRd32.exe:

            KHEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\5.0\InstallPath

            or

            KHEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\6.0\InstallPath

            RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Ok, thank you Dave. I have to find another document about accessing the registry from vb.net before I work with this code.


            A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office

            1 Reply Last reply
            0
            • D Dave Kreskowiak

              The man from SCN-CO wrote: What do you mean by /p and /h? THese are command line parameters that Acrobot Reader uses to tell it to Hide itself (no visible form or interface) and Print the file specified on its command line. The man from SCN-CO wrote: If i install windows on Drive D: and my program file would be D:\Program Files and the code is fix to drive C: how could we write code that could check which is the system drive for our windows??? It contain an error if I use: "%programfiles%\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" "" It's just an example. How you adapt the code is up to you. An example of getting the path to Program Files would be:

              Dim path As String = Environment.GetFolderPath( Environment.SpecialFolder.ProgramFiles )
              

              You could also read the Registry at the following key to find the complete path to AcroRd32.exe:

              KHEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\5.0\InstallPath

              or

              KHEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\6.0\InstallPath

              RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Hi Dave, according to your comment and my research, now I found a document from http://www.codeproject.com/vb/net/registry_with_vb.asp[^] about accessing the registry. This will speed up my project, Thank you a lot ;)


              A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups