Solved

Print pdf

Posted on 2006-06-09
10
329 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 70

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 51

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
LVL 70

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

680 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