Frequently asked questions
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.
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.
Check properties Charset and Lang in your report component. If you need unicode output, set property UnicodeByDefault := True.
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.
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.
Use Scan block in with "noeof" option. Keywords scanentry and scanfooter might be useful too in this case.
Set property DiasbleControls := False. Check this property for both: EK RTF component and your datasets.
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