?
Solved

Print a pdf document - Urgent.

Posted on 2003-03-28
6
Medium Priority
?
272 Views
Last Modified: 2007-12-19
Hi

I want to print a pdf document through my VB program. I am new to VB, so a complete function would be of great help.

Thanks in advance
0
Comment
Question by:cool_dudeps
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 9

Expert Comment

by:tkalchev
ID: 8223789
First, it is possible ONLY of you have Adobe Acrobat or Adobe Acrobat Reader installed on your computer.

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 Const SW_HIDE = 0


Private Sub Command1_Click()


  ShellExecute Me.hwnd, "print", "c:\p.pdf", Null, Null, SH_HIDE
 

End Sub


Assuming your pdf file is c:\p.pdf
0
 
LVL 9

Expert Comment

by:tkalchev
ID: 8223795
Ops, the correct is :

Private Sub Command1_Click()


  ShellExecute Me.hwnd, "print", "c:\p.pdf", "", "", SH_HIDE
 

End Sub

Replace Null with ""
0
 
LVL 3

Expert Comment

by:DocM
ID: 8223809

Private Sub Command1_Click()

    filename = "C:\Program Files\Adobe\Acrobat 5.0\Help\ENU\ACROBAT.PDF"
    result = PrintPdfDocument(filename)

End Sub

Function PrintPdfDocument(filename) As String

    On Error GoTo ErrorHandler

    strcommand = "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe /p /h " & filename

    PrintPdfDocument = Shell(strcommand)

    Exit Function
   
ErrorHandler:
    PrintPdfDocument = "Error :" & Err.Number & Err.Description
End Function
0
Technology Partners: 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:cool_dudeps
ID: 8229860
Hello tkalchev and docm,

Thanks for the help, but the printout is not correct with the code you have given. It works fine with normal system fonts, but in case the document to be printed has some other fonts, it gives the following error:
"Unable to find or create the font 'ZTR6C.tmp,Bold'. Some characters may not display or print correctlty."

Please provide me with an appropriate solution to the above problem. Thanks again for the help in advance.

Regards.
0
 
LVL 9

Accepted Solution

by:
tkalchev earned 200 total points
ID: 8229937
then use the acrobat pdf activex control to handle printing
0
 

Expert Comment

by:CleanupPing
ID: 8531433
Hi cool_dudeps,
This old question (QID 20566181) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0

Featured Post

Independent Software Vendors: 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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

801 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