How can I print a pdf file saved on my hard disk from within a VB program. Please help
Printable View
How can I print a pdf file saved on my hard disk from within a VB program. Please help
The only way I could imagine you printing a PDF file from another application would be
1) IF Adobet released a control plug-in to work with VB or C++
2) I don't think they would, since that's their technology, and that's how they make money.
Other than using API to directly open the file and hope to god that the system opens Acrobat Reader (Writer) for you, there would still be no way I know to print the file.
You should contact Adobe on this and see what they say...
Use Shell to Run This
Code:C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe /p /h C:\Test.pdf"
That way only works for version 5.0 of acrobat reader, this will work for any version:
VB Code:
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 Private Sub Form_Load() 'KPD-Team 1998 'URL: [url]http://www.allapi.net/[/url] 'E-Mail: [email][email protected][/email] ShellExecute Me.hwnd, “print”, "c:\test.pdf", vbNullString, "C:\", 0 End Sub
you can also do it in your app using the pdf.ocx
add the control pdf.ocx to your project from
C:\Program Files\Adobe\Acrobat 4.0\Reader\ActiveX\pdf.ocx
VB Code:
Option Explicit Private Sub Command1_Click() Pdf1.src = "C:\TEST.PDF" Pdf1.printAll End Sub