Solved

TWebBrower - Printing Problem

Posted on 2001-07-02
6
921 Views
Last Modified: 2012-05-04
Can anyone help me with this problem.  I need to be able to print the contents of a TWebBrowser, but I first need to set it's printer settings (namely, changing it to print in landscape instead of portrait).  I am able to print perfectly well, but I would like to prevent my users from having to change the layout type each time they print.

Is this possible to do?

Thanks in advance,

Stuart.
0
Comment
Question by:SJohnson
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6247457
Try this:


Uses priners;

Printer.Orientation := poLandscape;
0
 
LVL 1

Author Comment

by:SJohnson
ID: 6247473
Hi Epsylon,

Nope.  Didn't work :(  The dialog is still displayed too.  To print, I use: Browser.OleObject.Document.ExecCommand('Print');

I guess that the Document's printer is different to what we can set within Delphi.

I need to print out a stack of different HTML pages, and I only want to display the printer setup dialog box once, not for each page.

Thanks for the input.

Stu.
0
 
LVL 17

Accepted Solution

by:
inthe earned 300 total points
ID: 6247539
hi stu,
dunno how to tell webbrowser to print landscape but to hide the dialog after the first time you could set a boolean variable and check if its set then use:

var
I,O : OleVariant;
begin
 WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER,I,O);

assuming the dialog will hold the landscape setting for all print jobs.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:SJohnson
ID: 6247570
HOLY **** BARRY IT WORKED!!!!

You're a genius!!!

For an extra 100 points, where did you find that info out??


Stu.
0
 
LVL 17

Expert Comment

by:inthe
ID: 6247731
from newsgroups originally?(its pretty old)

i subscribe to egroups-delphi-webbrowser (recently taken over by yeahaa
http://groups.yahoo.com/group/delphi-webbrowser/
thats where the fellas who made embeddedwb:
http://www.euromind.com/iedelphi/
and author of this site:
http://members.home.com/hfournier/
hang out so probably the best place for finding stuff..
i should mention you should really use embeddedwb ,it has many bugs from ie fixed like the message handling is much better,alot of extra properties also ,it really saves much coding out of the bugs.

Regards Barry


some extras with similarities:

procedure TForm1.copy1Click(Sender: TObject);
var
 I,O : OleVariant;
begin
 WebBrowser1.ExecWB(OLECMDID_COPY,0,I,O);
end;


procedure TForm1.SelectAll1Click(Sender: TObject);
var
I,O : OleVariant;
begin
 WebBrowser1.ExecWB(OLECMDID_SELECTALL,0,I,O);
end;


was hoping there was one of the following for the print dialog cause we could have automated it but unfortunatly theres not :-(

procedure TForm1.Button2Click(Sender: TObject);
var
v : OleVariant;
Sh: ISHellUIHelper;
const
  CLSID_ShellUIHelper: TGUID = '{64AB4BB7-111E-11D1-8F79-00C04FC2FBE1}';
begin
Sh := CreateComObject(CLSID_SHELLUIHELPER) as ISHELLUIHELPER;
Sh.ShowBrowserUI('LanguageDialog', v);
//  or
//sh.ShowBrowserUI('OrganizeFavorites', v);
end;
0
 
LVL 1

Author Comment

by:SJohnson
ID: 6248026
Thanks very much, Barry!  You're a true gentleman and a scholar!

I have book marked the links and will try out your code in the morning.  It's dinner time now :)

Cheers mate!

Stu.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how do i create updater to My Activex application? 3 79
Delphi XE10, MySQL Query 4 126
Correct Component for Shopping Cart. 2 96
Magic Software info 18 125
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now