Page 1 of 1

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

Posted: Tue May 08, 2012 5:26 am
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

Posted: Tue May 08, 2012 10:38 am
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?

YES

Posted: Wed May 09, 2012 1:37 am
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

Posted: Wed May 09, 2012 7:08 am
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.

Posted: Wed May 09, 2012 1:38 pm
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

Posted: Thu May 10, 2012 12:31 am
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);

Posted: Thu May 10, 2012 10:44 am
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