Discussion Locked

Open and Print .pdf's in vb6

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hope somebody can help me/point me in the right direction. I need to write an application which will open a specific .pdf file based on user input and allow the user to print the file. I own Acrobat 5.0 so I will be able to place the Acrobat control on my form but I need some examples of how to manipulate the controls properties to allow me to load the .pdf files and print them. I am using VB6.

Thanks for the help

4 replies

by gandolfw

Add the following declaration to the appropriate source file:

Private 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

After you determine the desired file, add the following statement to open the file in the default application (Acrobat or Reader):

ShellExecute 0&, "open", fileName, "", "", vbNormalFocus

Just set "fileName" to the appropriate file prior to invoking the statement.

by dragon emperor

You load a file with the following:
Pdf1.LoadFile FileNameNPath

The runtime toolbars of the control allow the user to easily print, however printing is also simple:
Pdf1.Print

by dragon emperor

NOTE: You do not need the full version of Acrobat to use the pdf.ocx control. It comes with Reader as well (though on your development system you will want to reference the newest full Acrobat one you have).

by dragon emperor

You can open a file with the following:
Pdf1.LoadFile FilePathNName

You can print a file with the following:
Pdf1.Print

However, the toolbars provided by the control allow the user easy access to print functions.

NOTE: You do not need the full version of Acrobat to use the pdf.ocx control. It comes with Reader as well (though on your development system you will want to reference the newest full Acrobat one you have).

This discussion is closed to new replies.