1. How to print document without user action?
  2. Is it necessary to have Word installed when creating report? 
  3. Some chars are not displayed correctly? 
  4. Why WordPad does not display graphic picture? 
  5. Static picture in a report template makes a big RTF file? 
  6. How to skip detail block in report, if there is no details for master record? 
  7. Master-detail link doesn't work? 
  8. How to insert rich formatted memo in a report?

 

1. How to print document without user action?

If you use Word, you may use OLE for printing: in uses section add unit ComObj; Generate report using Execute method. In print procedure or in event OnFinished write this code:

procedure TForm1.EkRTF1Finished(Sender: TObject); 
var V:Variant; 
begin 
try 
 V:= CreateOLEObject('Word.Application'); 
(* uncomment next line if you want to make Word window visible *)
 //V.Visible:=true; 
 V.Documents.Open(EkRTF1.outfile); 
 V.ActiveDocument.PrintOut(False); 
(* Quit, do not save changes; *)
V.Quit(0);
 V:=UnAssigned; 
except 
 ShowMessage('Could not print document using MS Word'); 
end; 
end; 

If you use WordPad, add this code to your project:

uses ShellApi;

function StartFile(const FileName, FileParam:string; ShowCmd: Integer): THandle; 
begin 
 Result := ShellExecute(Application.MainForm.Handle, nil, PChar(FileName), PChar(FileParam), nil, ShowCmd); 
if Result<=32 then showmessage('Can''t open file!'); 
end;

Use method Execute instead of ExecuteOpen. In event OnFinished write next code (for example):

procedure TForm1.EkRTF1Finished(Sender: TObject); 
begin 
 StartFile('wordpad.exe','c:\Docs\outfile.doc /p',SW_MINIMIZE); 
end; 

Option /p forces to print document and close WordPad. Take a look that WordPad does not support most features of formatting. Your reports must be very simple if you are using WordPad.

2. Is it necessary to have Word installed when creating report?


It is not necessary to have Word installed on computer to create report, but you will need some application (free or shareware RTF editor, viewer) to see report results and print it.

3. Some chars are not displayed correctly?

Check properties Charset and Lang in your report component. If you need unicode output, set property UnicodeByDefault := True.

4. Why WordPad does not display graphic picture?


When inserting pictures with function \fimg(somepict)\ set Options properties eoGraphicsWMFCompatible and eoGraphicsBinary as shown:

  eoGraphicsWMFCompatible eoGraphicsBinary
Word false true
WordPad true true
Other true false

Note: When eoGraphicsBinary is set to false your output file will be quite a big size, because graphics will be inserted as text hexadecimal data. But this mode will allow to display pictures with most shareware and free RTF editors.

5. Static picture in a report template makes a big RTF file?

Don't insert large static pictures into report template manually. Use function fimg() instead. In report template insert field \fimg(pict1)\. Fimg is function that inserts file, specified in variable pict1, as picture. Add variable for example pict1=c:\Pics\graphic.bmp to VarList. The component supports BMP, JPG, WMF, EMF files. See also previous question.

6. How to skip detail block in report if there is no details for master record?

Use Scan block in with "noeof" option. Keywords scanentry and scanfooter might be useful too in this case.

7. Master-details link doesn't work?

Set property DiasbleControls := False. Check this property for both: EK RTF component and your datasets.

8. How to insert rich formatted memo in a report?

Use frtf() data format. See example "Rich text - frtf()" in the demo center. Note: frtf() format works only in registered versions of EK RTF. 

See also Quick start example