Board index » delphi » TWebBrowser with Adobe Reader

TWebBrowser with Adobe Reader


2006-06-04 02:04:31 AM
delphi221
I display various reports in an embedded TWebBrowser component.
Some reports are HTML and others are PDF. The PDF reports automatically
call Adobe Reader which embeds itself in IE and displays the file.
I have a print button that can automatically print to either the default
printer, or bring up the print dialog. For the print to default I call this:
Browser1.ControlInterface.ExecWB( OLECMDID_PRINT,
OLECMDEXECOPT_DONTPROMPTUSER, vaIn, vaOut )
This does NOT bring up the print dialog form for html reports, but it DOES
for PDF reports.
Is there some way to get the Adobe Reader control that is embedded in the
TWebBrowser do I can perhaps call it is Print method directly? (TAcroReader
control has a Print and PrintWithDialog method).
Rick
 
 

Re:TWebBrowser with Adobe Reader

Hi Rick, here's how I call the 'PrintReport' method on a CRViewer (Crystal Reports ActiveX Viewer) once it is loaded into TWebBrowser.
function TfPreview.PrintReport(): boolean;
var
methodName: WideString;
disps : TDispIDList;
panswer : ^olevariant;
answer : olevariant;
dispParams: TDispParams;
aexception : TExcepInfo;
begin
result := False;
if not Assigned(Self) then
exit;
if not Assigned(Self.WebBrowser1) then
exit;
methodName := 'PrintReport';
WebDoc := WebBrowser1.Document as HTMLDocument;
CRViewer := WebDoc.applets.item('CRViewer',0);
CRViewer.GetIDsOfNames(GUID_NULL, @methodName, 1, 0, @disps);
pAnswer := @answer;
dispparams.rgvarg := nil;
dispparams.rgdispidNamedArgs := nil;
dispparams.cArgs := 0;
dispparams.cNamedArgs := 0;
CRViewer.Invoke( disps[0],
GUID_NULL,
0,
DISPATCH_METHOD,
dispParams,
pAnswer,
@aexception,
nil);
if aexception.bstrDescription = '' then
result := True;
end;
Before all of this though you have to wait for the TWebBrowser document complete event or WebBrowser1.Document will not be assigned.
HTMLDocument is in MSHTML. Here is my entire uses clause on this unit:
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, MSHTML, ComObj, ActiveX, ComServ, StdCtrls, Menus;
Doug
"Rick" <XXXX@XXXXX.COM>writes:
Quote
I display various reports in an embedded TWebBrowser component.

Some reports are HTML and others are PDF. The PDF reports automatically
call Adobe Reader which embeds itself in IE and displays the file.

I have a print button that can automatically print to either the default
printer, or bring up the print dialog. For the print to default I call this:

Browser1.ControlInterface.ExecWB( OLECMDID_PRINT,
OLECMDEXECOPT_DONTPROMPTUSER, vaIn, vaOut )

This does NOT bring up the print dialog form for html reports, but it DOES
for PDF reports.

Is there some way to get the Adobe Reader control that is embedded in the
TWebBrowser do I can perhaps call it is Print method directly? (TAcroReader
control has a Print and PrintWithDialog method).

Rick