Print file VB.Net
-
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()
-
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()
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
-
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
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 DriveD:
and my program file would beD:\Program Files
and the code is fix to driveC:
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
-
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 DriveD:
and my program file would beD:\Program Files
and the code is fix to driveC:
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
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
-
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
-
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
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