Results 1 to 5 of 5

Thread: Printing a file from a VB Program

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    3

    Question Printing a file from a VB Program

    How can I print a pdf file saved on my hard disk from within a VB program. Please help

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    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...

  3. #3
    Hyperactive Member ZeroCool's Avatar
    Join Date
    Feb 2002
    Location
    In front of my computer
    Posts
    423
    Use Shell to Run This

    Code:
    C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe /p /h C:\Test.pdf"
    Visual Baisc 6 (SP5)
    Windows Xp

  4. #4
    Si_the_geek
    Guest
    That way only works for version 5.0 of acrobat reader, this will work for any version:

    VB Code:
    1. 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
    2.  
    3. Private Sub Form_Load()
    4.     'KPD-Team 1998
    5.     'URL: [url]http://www.allapi.net/[/url]
    6.     'E-Mail: [email][email protected][/email]
    7.     ShellExecute Me.hwnd, “print”, "c:\test.pdf", vbNullString, "C:\", 0
    8. End Sub

  5. #5
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    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:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     Pdf1.src = "C:\TEST.PDF"
    5.     Pdf1.printAll
    6. End Sub
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width