Solved

TWebBrower - Printing Problem

Posted on 2001-07-02
6
919 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
Comment Utility
Try this:


Uses priners;

Printer.Orientation := poLandscape;
0
 
LVL 1

Author Comment

by:SJohnson
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:SJohnson
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
System restore point 4 77
Delphi OLE Error 8 82
Multiple image collision 13 42
Tembedded WB animatid gifs not animated on some pcs 2 23
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

7 Experts available now in Live!

Get 1:1 Help Now