Print

General TRichView support forum. Please post your questions here
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Print

Post by Ceprotec »

Hello Sergey!

I'm having problems with the printing of documents.
I need to have the possibility to choose between printing odd or even pages and also the possibility to choose which pages to print. Currently there are: "to" 1 "through" 10 "I need to choose" 1, 2, 5, 6, 8, 9.

This is very important for our company.
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

I needed it to be implemented in the print dialog. For I am not good with codes and functions. Would have to be coupled with the window that exists when run TsrvActionPrint .. Is it possible?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you use ScaleRichView (TSRichViewEdit) instead of TRichViewEdit+TRVPrint?
In this case, you should use different method: create TSRVPrint, assign a TSRichViewEdit control to its SRichViewEdit property, srvpAuto to its PrintMode property, and call SRVPrint.PrintFrame(PageNo, 1) to print one page. The rest of code is the same as in the example above.

As for the user interface. RichViewActions, both for TRichViewEdit and TSRichViewEdit, uses the standard printing dialog (TPrintDialog). This dialog does not support a sophisticated definition of the pages to print. And, since this is a standard windows dialog, it cannot be modified.
I am afraid you need to create a new dialog yourself.
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

TPrintDialog The component can be inserted in the project but can not associate it with the SRICHVIEWEDIT. In TPrintDialog there are some options within and have the option of selection. Do you know if this can help?
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

Ceprotec wrote:TPrintDialog The component can be inserted in the project but can not associate it with the SRICHVIEWEDIT. In TPrintDialog there are some options within and have the option of selection. Do you know if this can help?
you understood what I need?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

TPrintDialog allows choosing the printer, define a range of pages to print (all / from-to / selection), define a number of copies.
Depending on the values chosen in this dialog, TsrvActionPrint calls either SRichView.PrintAll or SRichView.PrintRange as many times as the number of copies specified.

Do you ask about printing a selection?
In TsrvActionPrint, selection printing is not implemented, so it is disabled.
In TrvActionPrint (for TRichViewEdit), it is implemented in the following way: a temporal hidden TRichView is created, the selection is copied to this TRichView, it is printed, then destroyed.
If you need, I can implement it in TsrvActionPrint for TSRichViewEdit in the same way.

But if you want to modify this dialog to allow more complex defining of pages to print, like in your first post, it is not possible. You need to create your dialog instead.
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

Sergey'm with questions regarding how to print. I currently use the action srvActionPrint1.Execute; to print the pages of SRichViewEdit.
I would like to print the pages without using the srichviewedit this action and use the component TPrintDialogs therefore not how to connect to each other?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If you want to see how to display TPrintDialog and then print SRichViewEdit according to settings made in this dialog, open SRVActions.pas and see the code in TsrvActionPrint.ExecuteTarget.
You can copy the code from this method to your unit.
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

Sergey procedure is giving this error in the "Printer": Undeclared identifier 'Printer'. You know why?

PrintSomePages procedure (const Title: String;
RVPrint: TRVPrint; const Pages: array of Integer);
var i: Integer;
begin
Printer.Title: = Title;
Printer.BeginDoc;
for i: = Low (Pages) to High (Pages) do begin
if i <> Low (Pages) then
Printer.NewPage;
RVPrint.rv.DrawPage (Pages , Printer.Canvas, False, False)
end;
Printer.EndDoc;
end;
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Add Printers in uses.
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

Is giving this error when you run the procedure under "RVPrint.rv.DrawPage (Pages , Printer.Canvas, False, False);"this error:
"style of printable TRichView component is not assigned"

I also needed to pick the leaves as well as for printing, choose which printer and size of leaves .. how?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Before printing, you need to specify what to print and prepare RVPrint for printing. Did you call RVPrint.AssignSource and RVPrint.FormatPages before calling this code?

To specify the printer and its properties, you can create TPrintDialog and call its Execute method.
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

Hey sergey

I used this command to print a check but when he returns to printing, the screen is only a selection that was printed

begin
/ / copying the selection
Stream: = TMemoryStream.Create;
try
Edit.RichViewEdit.SaveRVFToStream (Stream, True);
Stream.Position: = 0;
Edit.LoadRVFFromStream (Stream);
finally
Stream.Free;
end;
/ / printing
Edit.PrintAll;
end;

know why this happens?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

SaveRVFToStream(... True) copies the selection.
Use SaveRVFToStream(... False) to copy the complete document.
Post Reply