How Can I do ?The SRichViewEdit only to print the new conten

General TRichView support forum. Please post your questions here
Post Reply
kisshexuxia
Posts: 29
Joined: Mon May 07, 2012 2:36 am

How Can I do ?The SRichViewEdit only to print the new conten

Post by kisshexuxia »

How Can I do ?The SRichViewEdit only to print the new content

When the Next print ,I Can Free choice print starting point
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you want to print on the same paper as the old content was printed?
Is the new content added to the end of the document?
kisshexuxia
Posts: 29
Joined: Mon May 07, 2012 2:36 am

YES

Post by kisshexuxia »

Sergey Tkachenko wrote:Do you want to print on the same paper as the old content was printed?
Is the new content added to the end of the document?

YES
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

After the first print, store the count of items in some integer variable:
LastPrintedItemCount := SRichViewEdit1.RichViewEdit.ItemCount.

When printing next time, assign
SRichViewEdit1.MinPrintedItemNo := LastPrintedItemCount;

Then you can store the count of items in LastPrintedItemCount again, and so on.
kisshexuxia
Posts: 29
Joined: Mon May 07, 2012 2:36 am

Post by kisshexuxia »

Sergey Tkachenko wrote:After the first print, store the count of items in some integer variable:
LastPrintedItemCount := SRichViewEdit1.RichViewEdit.ItemCount.

When printing next time, assign
SRichViewEdit1.MinPrintedItemNo := LastPrintedItemCount;

Then you can store the count of items in LastPrintedItemCount again, and so on.
Thank you! You Are Right.
Then i want to Print where my selected text,some people tell me,use GetSelBounds. what can i do?
Thank you very much
kisshexuxia
Posts: 29
Joined: Mon May 07, 2012 2:36 am

Post by kisshexuxia »

kisshexuxia wrote:
Sergey Tkachenko wrote:After the first print, store the count of items in some integer variable:
LastPrintedItemCount := SRichViewEdit1.RichViewEdit.ItemCount.

When printing next time, assign
SRichViewEdit1.MinPrintedItemNo := LastPrintedItemCount;

Then you can store the count of items in LastPrintedItemCount again, and so on.
Thank you! You Are Right.
Then i want to Print where my selected text,some people tell me,use GetSelBounds. what can i do?
Thank you very much
The problem has been solved .
I use GetSelectionBounds to get startItemNo,endItemNo.

rve.RVData.GetSelectionBounds(startItemNo,startItemOfs,endItemNo,endItemOfs,false);
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, but it may be not what the user expects.
If you use MinPrintedItemNo and MaxPrintedItemNo to print only items belonging to the selection, there will be the following problems:

1) If the item is selected only partially, it will still be printed completely.
2) The selection will be printed at the same position on the page(s) as it is in the original document. But (I believe) the user expects that it will be printed from the beginning of the page.

Currently, the only solution is to create a hidden TSRichViewEdit, copy the selection to it, and then print this hidden TSRichViewEdit.

A code for copying:

Code: Select all

var Stream: TMemoryStream;
if not SRichViewEdit1.ActiveEditor.SelectionExists then
  exit; // no selection;
Stream := TMemoryStream.Create;
SRichViewEdit1.SaveRVFToStream(Stream, True);
Stream.Position := 0;
SRichViewEditHidden.RichViewEdit.LoadRVFFromStream(Stream);
Stream.Free;
// now print SRichViewEditHidden
Post Reply