Print PDF File From Web

Hi everyone,

I need code vb6 where I can print PDF file(Located on web server) in Local Printer without opening a file
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
You would have to write a PDF reader to do that.  Or have a printer that can print PDFs directly.  PDFs have to be interpreted to convert to a printable format.
iamdxbAuthor Commented:
Please provide  me code If you have thanx in advance
Dave BaldwinFixer of ProblemsCommented:
I don't have such a code.  It would be the size of Adobe reader.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

iamdxbAuthor Commented:
I need code in vb6 where I can print PDF file(Located on web server) in Local Printer without opening a file

Please help anyone its urgent...
Dave BaldwinFixer of ProblemsCommented:
You can click on "Request Attention" above to get others to look at your question but I don't think you're going to get what you want.
Michel PlungjanIT ExpertCommented:
I find multiple articles and discussions here

perhaps you find something useful?

In any case if you have the pdf on the server and you need to click on a link to print it from a web server, then you will need to open it

It can contain a pdf javascript to call the printer
How about this idea:

1. Download the file to a known location, maybe like this:

2. Set your default printer, maybe like this:

3. Print your file, maybe using the ShellExecute API (, with lpszOp set to "print".
iamdxbAuthor Commented:
hi kbirecki,
I am busy with other work , I will try yr solution  after that I will put comment.

I have used to do what you are requesting(silent, client side print of a pdf located on a network share - all controlled by javascript).  I use it as an activeX control in the browser - it is licensed by user and we have it installed it on specific user machines, so this is not an internet solution.  
iamdxbAuthor Commented:
Hi all

I will try above solution let know....
iamdxbAuthor Commented:
Hi kbirecki,

I have made ocx control, that I am using in webpage its working fine, only after printing Adobe Reader app window is not closing. I have used shell command ( Print your file, maybe using the ShellExecute API (, with lpszOp set to "print")  If you know please let me know.

Thanks a lot
Can you post the command you executed via the shell command that opens and prints the PDF but does not close.
iamdxbAuthor Commented:
Hi kbirecki,

below code is writen in OCX control

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 Declare Function apiFindWindow Lib "user32" Alias "FindWindowA" _
   (ByVal lpclassname As Any, ByVal lpCaption As Any) As Long


Private Function ShellExecuteExample()

   Dim hwnd
   Dim StartDoc
   On Error GoTo ErrHandler
   hwnd = apiFindWindow("OPUSAPP", "0")

   StartDoc = ShellExecute(hwnd, "print", "C:\POS\SI.pdf", "", "C:\", 0)
   Exit Function

  MsgBox ("Closing Application Error:" & Err.Number & Err.Description)
End Function
It looks like you are finding an already open window ("OPUSAPP") and sending a command to print the open file.  Is that what you want?  If so, you may need to manually close the window with something like:

Private Declare Function PostMessage Lib "user32" _
         Alias "PostMessageA" _
         (ByVal hwnd As Long, _
         ByVal wMsg As Long, _
         ByVal wParam As Long, _
         ByVal lParam As Long) As Long

Const WM_CLOSE = &H10

lngReturnValue = PostMessage(hWindow, WM_CLOSE, 0&, 0&)

Open in new window

See this article for more info on using PostMessage to close a window.

If that is the case, I don't see where the file is being opened.  However, if all you want to do is open, print a close a file, try this variation of your code:

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
                   (ByVal hwnd As Long, ByVal lpszOp As String, _
                    ByVal lpszFile As String, ByVal lpszParams As String, _
                    ByVal LpszDir As String, ByVal FsShowCmd As Long) _
                    As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long

Sub Test()
     Dim hwnd As Long
     Const SW_HIDE = 0
     hwnd = GetDesktopWindow()
     ShellExecute(hwnd, "Print", "C:\POS\SI.pdf", "", "C:\", SW_HIDE)
End sub

Open in new window

More info on this here.
Edit:, print and close a file,...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
iamdxbAuthor Commented:
Thanks  to All
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.