Solved

TWebBrower - Printing Problem

Posted on 2001-07-02
6
926 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Working with hours 3 74
tidtcpserver connection lost handle 2 111
Firemonkey BASS_Init into a thread 17 57
Firemonkey Queue list 1 32
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 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