Solved

Print pdf

Posted on 2006-06-09
10
323 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

705 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

17 Experts available now in Live!

Get 1:1 Help Now