Solved

Print PDF File From Web

Posted on 2011-09-23
18
381 Views
Last Modified: 2012-06-21
Hi everyone,

I need code vb6 where I can print PDF file(Located on web server) in Local Printer without opening a file
0
Comment
Question by:iamdxb
  • 7
  • 4
  • 3
  • +2
18 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36591366
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.
0
 

Author Comment

by:iamdxb
ID: 36591373
Please provide  me code If you have thanx in advance
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36591420
I don't have such a code.  It would be the size of Adobe reader.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:iamdxb
ID: 36592181
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...
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36593180
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.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 36594430
I find multiple articles and discussions here

http://www.google.com/search?q=print+pdf+without+opening+it

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
0
 
LVL 11

Expert Comment

by:kbirecki
ID: 36595192
How about this idea:

1. Download the file to a known location, maybe like this: http://visualstudiomagazine.com/Articles/2008/03/27/Simple-Asynchronous-Downloads.aspx?Page=1

2. Set your default printer, maybe like this: http://weblogs.asp.net/jamauss/archive/2004/07/12/181138.aspx

3. Print your file, maybe using the ShellExecute API (http://support.microsoft.com/kb/238245), with lpszOp set to "print".
0
 

Author Comment

by:iamdxb
ID: 36719706
hi kbirecki,
I am busy with other work , I will try yr solution  after that I will put comment.

thanx
0
 
LVL 5

Expert Comment

by:LlamaJoe
ID: 36922497
I have used http://www.pdf-tools.com/pdf/pdf-printer-print-pdfa.aspx 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.  
0
 

Author Comment

by:iamdxb
ID: 36940410
Hi all

I will try above solution let know....
0
 

Author Comment

by:iamdxb
ID: 36960554
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 (http://support.microsoft.com/kb/238245), with lpszOp set to "print")  If you know please let me know.

Thanks a lot
0
 
LVL 11

Expert Comment

by:kbirecki
ID: 36961249
Can you post the command you executed via the shell command that opens and prints the PDF but does not close.
0
 

Author Comment

by:iamdxb
ID: 36967621
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

ErrHandler:
   
  MsgBox ("Closing Application Error:" & Err.Number & Err.Description)
 
 
End Function
0
 
LVL 11

Expert Comment

by:kbirecki
ID: 37074215
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.
0
 
LVL 11

Accepted Solution

by:
kbirecki earned 125 total points
ID: 37074218
Edit: ....open, print and close a file,...
0
 

Author Closing Comment

by:iamdxb
ID: 37163065
Thanks  to All
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create animated movies for web page 18 86
If condition on Html with Asp 11 28
Html CheckBox obtain Its Value 5 28
Executing a script on a timer online 5 22
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

831 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