Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
498 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (7)


to print url/html file using IE browserGo to Mike Shkolnik's websiteFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi all versions
Category:
Internet / Web
Skill Level:
Scoring:
Last Update:
10/22/2001
Search Keys:
delphi delphi3000 article borland vcl code-snippet IE browser print html OLE
Times Scored:
7
Visits:
12057
Uploader: Mike Shkolnik
Company: Scalabium Software
Reference: http://www.scalabium.com/faq/dct0127.htm
 
Question/Problem/Abstract:
How can I print url/html file using IE browser?
Answer:



I want to show how you can activate printing of any url and/or html file using installed IE.

I solved this task yesterday and solution is very useful and have a small
size:-)

uses ComObj;

procedure PrintHTMLByIE(const url: string);
const
  OLECMDID_PRINT = $00000006;
  OLECMDEXECOPT_DONTPROMPTUSER = $00000002;
var
  ie, vaIn, vaOut: Variant;
begin
  ie := CreateOleObject('InternetExplorer.Application');
  ie.Navigate(url);
  ie.Visible := True;
  ie.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, vaIn, vaOut);
end;

Sample:
PrintHTMLByIE('file:\\c:\misha\webpage\index.htm');
or
PrintHTMLByIE('http:\\www.scalabium.com\sme\index.htm');





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
slight mod to variant type
    Stephen Smith (Mar 22 2002 12:56AM)

I had to use OleVariant for the type (instead of Variant) but I'm using the TWebBrowser control like this:

procedure TForm1.btnPrintClick(Sender: TObject);
const
  OLECMDID_PRINT = 6;
  OLECMDEXECOPT_DONTPROMPTUSER = 2;
var
  vaIn, vaOut: OleVariant;
begin
  WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, vaIn, vaOut);
end;
Respond

RE: slight mod to variant type
Mike Shkolnik (Mar 23 2002 11:02AM)

Your code is a same as mine in article. One difference only is that you used early binding (WebBrowser must be installed as component from imported type library) but I shown a sample for late binding without any tlb-importing.

But anyway both samples are correct.

With best regards, Mike Shkolnik
E-mail: mshkolnik@scalabium.com
WEB: http://www.scalabium.com

Respond

Could not print with your method
    Dmitri Papichev (Oct 22 2001 4:06PM)

I get "Trying to revoke drop target that has not been registered" error all the time. The only way the function works is if you step over the code with F8. Any ideas why?
Respond

RE: Could not print with your method
PEPS ^^ (Feb 27 2002 9:36PM)

there is a bugfix for that on the community site !

just do this...

const
  OLECMDF_SUPPORTED = 1;
  OLECMDF_ENABLED = 2;

var
  ie, vaIn, vaOut: Variant;
begin
  ie := CreateOleObject('InternetExplorer.Application');
  ie.Navigate(url);
  ie.Visible := True;

  while ie.QueryStatusWB( OLECMDID_PRINT) <> OLECMDF_SUPPORTED + OLECMDF_ENABLED do
    Forms.Application.ProcessMessages;

  sleep(2000);

  ie.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, vaIn, vaOut);

end;


Respond

RE: RE: Could not print with your method
Abhi (Jul 19 2004 9:24PM)

Using WBExec 6, -1 could not suppress "Print to file " Dialog while printing to postscript file using "Acrobat Distiller 3.0". It prompts for a file name
Is there a way to programatically set the output file name and set the printer too..
Please help.

Thanks
Regards
Abhi
Respond

RE: RE: RE: Could not print with your method
Akshat Sharma (Jun 19 2007 9:19AM)

Dmitri Papichev Just copyed code from http://dn.codegear.com/article/27043. not working at all, plz just tell me this code belongs to c# or vb.net.
Respond

RE: RE: RE: RE: Could not print with your method
Akshat Sharma (Jun 19 2007 9:30AM)

object ep = null;
axWebBrowser1.Navigate2(ref source, ref ep, ref ep, ref ep, ref ep);

while (axWebBrowser1.QueryStatusWB(SHDocVw.OLECMDID.OLEC MDID_PRINT) != (SHDocVw.OLECMDF.OLECMDF_SUPPORTED & SHDocVw.OLECMDF.OLECMDF_ENABLED))
Application.DoEvents();

axWebBrowser1.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRI NT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER , ref ep, ref ep);

Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
A. B. Talal
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)