Solved

Print pdf

Posted on 2006-06-09
10
325 Views
Last Modified: 2010-04-07
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

0
Comment
Question by:dgb
  • 5
  • 2
10 Comments
 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 250 total points
ID: 16871422
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
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 250 total points
ID: 16871989
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
 

Author Comment

by:dgb
ID: 16877056
Is it possible to control the printer on wich the pdf is printed.
0
 

Author Comment

by:dgb
ID: 16877127
emoreau :
I've tryed the code you've mentiond and it works but the reader doesn't close by itself.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 69

Expert Comment

by:Éric Moreau
ID: 16877665
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
 

Author Comment

by:dgb
ID: 16883408
Can i force the application to close, it also looks for updates, very annoying.
0
 

Author Comment

by:dgb
ID: 17120156
anyone ??
0
 

Author Comment

by:dgb
ID: 17308421
Thanks everybody,

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Paint/Redraw window while dragging 16 68
Prevent checkbox click event occur while editing it in vb6 8 33
VB6 - Convert HH:MM into Decimal 8 51
Child Form in front 4 38
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now