Hi,
at first: sorry for my bad english.
I'm a trichview nebie. It seems not too be too simple to work with trichview, espezially if one has not too much experience with object-orientated programming.
A very-beginner-question: How to print a given file.
I have the file /home/peter/test.rtf. I just want to print this file to the printer named "HP-Weiss". Therefore i have the Button "Print". I'm missing a beginner-code in the examples for this or did i overlook it?
I have a Form1 with a Button1:TButton and the RVPrint1:TRVPrint. Now i need the code to print the file.
// print the file /home/peter/test.rtf
procedure TForm1.Button1Click(Sender: TObject);
begin
????????
end;
Please fill in...
Maybe it would help others to get fast succes with trichview.
Peter Jensen
Print a defined rtf
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Place on form:
RichView1: TRichView,
RVStyle1: TRVStyle;
RVPrint1: TRVPrint.
Assign (at designtime) RichView1.Style := RVStyle1.
Loading RTF file:
Next, you need to choose printer.
RVPrint uses the application printer settings, so, by default, it prints on the system default printer.
You can use TPrintDialog or TPrinterSetupDialog to allow user to choose printer.
If you want to do it in code:
Printing:
RichView1: TRichView,
RVStyle1: TRVStyle;
RVPrint1: TRVPrint.
Assign (at designtime) RichView1.Style := RVStyle1.
Loading RTF file:
Code: Select all
RichView1.Clear;
RichView1.LoadRTF('/home/peter/test.rtf');
RichView1.Format;
RVPrint uses the application printer settings, so, by default, it prints on the system default printer.
You can use TPrintDialog or TPrinterSetupDialog to allow user to choose printer.
If you want to do it in code:
Code: Select all
uses Printers;
...
var PrinterIndex: Integer;
begin
PrinterIndex := Printer.Printers.IndexOf('HP-Weiss');
if PrinterIndex>=0 then
Printer.PrinterIndex := PrinterIndex;
end;
Code: Select all
RVPrint1.AssignSource(RichView1);
RVPrint1.FormatPages(rvdoAll);
RVPrint1.Print('Test', 1, False);
Hello Sergey,
thanks for the fast answer.
But something goes wrong:
1) RichView1.LoadRTF => no memeber LoadRTF
2) RVPrint1.FormatPages => no identifier rvdoAll
What i did:
In the objektinspektor on RichView1 i choosed RVStyle1 for Style.
Then i made the code as seen below.
But i get the both errors which you can see in the code.
This example leastwise prints a blank page. The second error i found when comented out the first error-line.
But where do the errors come from ?
I don't think that i failed to install RichView in my lazarus because it prints a blank page. I tookm lazrichview-0.5.2.2.tar.gz from sourgeforge.
---------
procedure TForm1.Button1Click(Sender: TObject);
var PrinterIndex: Integer;
begin
RichView1.Clear;
// RichView1.LoadRTF('/home/peter/test.rtf'); //Error: identifier idents no member "LoadRTF"
RichView1.Format;
PrinterIndex := Printer.Printers.IndexOf('HP-Weiss');
if PrinterIndex>=0 then Printer.PrinterIndex := PrinterIndex;
RVPrint1.AssignSource(RichView1);
// RVPrint1.FormatPages(rvdoAll); // Identifier not found "rvdoAll"
RVPrint1.Print('Test', 1, False);
end;
thanks for the fast answer.
But something goes wrong:
1) RichView1.LoadRTF => no memeber LoadRTF
2) RVPrint1.FormatPages => no identifier rvdoAll
What i did:
In the objektinspektor on RichView1 i choosed RVStyle1 for Style.
Then i made the code as seen below.
But i get the both errors which you can see in the code.
This example leastwise prints a blank page. The second error i found when comented out the first error-line.
But where do the errors come from ?
I don't think that i failed to install RichView in my lazarus because it prints a blank page. I tookm lazrichview-0.5.2.2.tar.gz from sourgeforge.
---------
procedure TForm1.Button1Click(Sender: TObject);
var PrinterIndex: Integer;
begin
RichView1.Clear;
// RichView1.LoadRTF('/home/peter/test.rtf'); //Error: identifier idents no member "LoadRTF"
RichView1.Format;
PrinterIndex := Printer.Printers.IndexOf('HP-Weiss');
if PrinterIndex>=0 then Printer.PrinterIndex := PrinterIndex;
RVPrint1.AssignSource(RichView1);
// RVPrint1.FormatPages(rvdoAll); // Identifier not found "rvdoAll"
RVPrint1.Print('Test', 1, False);
end;
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: