Print pdf

How can i print a pdf.
The only thing is that there are different users with different versions of acrobat reader.

I've read something about pdf.ocx but a im afraid that it won't work with multiple versions.

If needbe i can use vb5/vb6/ 2005.net

dgbAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Ryan ChongConnect With a Mentor Commented:
in vb5/6, you can try use the ShellExecute API to print a document, like:

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long

Public Function PrintDoc(ByVal FileName As String, Optional CommandLine As String = "") As Long
    Dim Scr_hDC As Long
    Scr_hDC = GetDesktopWindow()
    'change "Open" to "Explore" to bring up file explorer
    PrintDoc = ShellExecute(Scr_hDC, "Print", FileName, CommandLine, vbNullString, 1)
End Function

then:

Private Sub Command1_Click()
    tmp = "c:\test.pdf"
    PrintDoc tmp
End Sub
0
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
Hi dgb,

In .Net, you can use the Process component:
Dim MyProcess As New Process
MyProcess.StartInfo.FileName = "c:\temp\test.pdf"
MyProcess.StartInfo.Verb = "Print"
MyProcess.Start()


Cheers!
0
 
dgbAuthor Commented:
Is it possible to control the printer on wich the pdf is printed.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
dgbAuthor Commented:
emoreau :
I've tryed the code you've mentiond and it works but the reader doesn't close by itself.
0
 
Éric MoreauSenior .Net ConsultantCommented:
It depends on the version of Acrobat you have. On the server where my application runs, Acrobat (v 5.0 I think) closes by itself.  On my PC, it doesn't (recent version).
0
 
dgbAuthor Commented:
Can i force the application to close, it also looks for updates, very annoying.
0
 
dgbAuthor Commented:
anyone ??
0
 
dgbAuthor Commented:
Thanks everybody,

To bad no one responded to my last question though.
0
All Courses

From novice to tech pro — start learning today.