CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    7

    How to print pdf files to printer

    hi,
    I want to know how to print pdf files through VB.i know how to print word documents,declare as object and

    Option Explicit
    Dim o1 As Word.Application
    Dim o2 As Word.Document
    'Set o1 = CreateObject("word.application")
    '
    'Set o2 = o1.Documents.Open("c:\applcare.doc")
    ' Dim BeginPage, EndPage, NumCopies, i
    ' CommonDialog1.CancelError = True
    ' On Error GoTo ErrHandler
    ' CommonDialog1.ShowPrinter
    ' BeginPage = CommonDialog1.FromPage
    ' EndPage = CommonDialog1.ToPage
    ' NumCopies = CommonDialog1.Copies
    ' For i = 1 To NumCopies
    ' ' Put code here to send data to your printer.
    ' o1.Visible = True
    ' o1.Print


    can you please help me how to print it.
    Thanks in advance.
    syamala




  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: How to print pdf files to printer

    The following code should do it, if you have Adobe Acrobat in your system.

    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 Const SW_HIDE = 0
    private Sub Command1_Click()
    ShellExecute me.hwnd, "print", "yourfile.pdf", vbNullString, vbNullString, SW_HIDE
    End Sub





  3. #3
    Join Date
    Jun 2002
    Location
    Montevideo, Uruguay
    Posts
    3
    shree, your code works fine, but it leaves an open Acrobat Reader window. I'm using Acrobat Reader 5.
    Is this the normal behavior? and if it is, how can I close the window when the printing ends?
    Thanks.

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

Featured