Print Selected Text Only

General TRichView support forum. Please post your questions here
Post Reply
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Print Selected Text Only

Post by tiagosis »

how can i implement a routine of printing only the selected text?
ps: I can't implement copying to a temporary srichview because I need to maintain the position of the form on the page. example I already have a page with printed information and I want to continue printing on an existing page, that is, the text at the top cannot be overwritten.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Print Selected Text Only

Post by Sergey Tkachenko »

It's possible to define the range of items to print, MinPrintedItemNo and MaxPrintedItemNo properties.

Unfortunately, it's not possible for an arbitrary fragment, which may start in the middle of a text item or in a table.
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: Print Selected Text Only

Post by tiagosis »

what i need to know is: with this component can i start printing on line X and finish on line Y?
example:
line 1 - AAAAAAAAAAA
line 2 - BBBBBBBBBBB
line 3 - CCCCCCCCCC
line 4 - DDDDDDDDDD
line 5 - EEEEEEEEEEE
line 6 - FFFFFFFFFFFF

I need to print the content starting from line 2 to 4.

if this is not possible can i print the text at the end? from 4 to 6?

you could post an example code for this printout using TSRichViewEdit
or indicate a location we gave?

I believe it was clear, thanks.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Print Selected Text Only

Post by Sergey Tkachenko »

It depends on the definition of "line".

If you mean lines created because of word wrapping, then no, it cannot.
But if you mean paragraphs, i.e. lines that are made by pressing Enter, it is possible.

In this case, if all text is of the same font and does not contain tab character, each line/paragraph is one item.
To print lines from 2 to 4, assign
SRichViewEdit1.MinPrintedItemNo := 1;
SRichViewEdit1.MaxPrintedItemNo := 3;
(item indexes are zero-based)
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: Print Selected Text Only

Post by tiagosis »

I started SRichViewEdit1.MinPrintedItemNo := 8; but printing started with line 6, why is that?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Print Selected Text Only

Post by Sergey Tkachenko »

Probably, some lines contain several items.
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: Print Selected Text Only

Post by tiagosis »

ok, but I need printing to start on the line that I indicate in "MinPrintedItemNo" is what I expect from the component, how do I solve it ?. This is a crucial issue for my project. I would like you to point me to a solution for me to end my deadline here already.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Print Selected Text Only

Post by Sergey Tkachenko »

As I understand, the problem is the following:
- you have paragraphc that need to be printed
- you need to find which values of Min/MaxPrintedItemNo correspond to these paragraphs.

(As I said, the result is guaranteed only with paragraphs (separated by hard line breaks added using Enter key), not with lines (that may be created because text wraps).

But tell me how do you define these paragraphs to print. Is it ok to define them by index from the beginning of document?
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: Print Selected Text Only

Post by tiagosis »

this is exactly what happens, if I order printing to start on line 4, it prints only the excerpt "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"

because it believes that "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

is a single line because it was not generated by ENTER. I really need the component to behave according to the lines displayed to the user, it should be like this because it even induces the user to error when choosing the line number
Attachments
Screenshot_1.png
Screenshot_1.png (21.51 KiB) Viewed 36677 times
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: Print Selected Text Only

Post by tiagosis »

the user just types the text, the component automatically breaks as it has to be, this is correct as in word. However when printing it needs that regardless of having Enter or not that it starts on the line that it only needs this, if MinPrintedItemNo doesn't work, could you indicate another way to get around this situation?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Print Selected Text Only

Post by Sergey Tkachenko »

This feature is not supported yet.

It's not to difficult to implement a way to define a printing range with a higher precision than a range of items, to allow defining printed lines.
However, it was not implemented, mostly because this feature is rarely used.

I can implement it in future updates, but not right now, because currently I finish the next major update preparation, and it is feature-locked.
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: Print Selected Text Only

Post by tiagosis »

Could you point out a way to get around this component weakness? as i told you this is a feature that compromises the future of my project on a client already in production, i really couldn't wait until the day that you could fix this bug in the component as it will certainly cost my contracts with my clients, again, you points out any way to get around this component weakness?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Print Selected Text Only

Post by Sergey Tkachenko »

Sorry, I do not consider it as a bug, because everything works as it was designed and documented.

But ok, in the next update I'll add two new properties: MinPrintedOffsInItem and MaxPrintedOffsInItem.
The first position to print will be defined by MinPrintedItemNo and MinPrintedOffsInItem, the last position will be defined by MaxPrintedItemNo and MaxPrintedOffsInItem, in a way like selection is defined (Get/SetSelectionBounds methods of TRichView).

The printing range will be defined with up-to-line, not up-to-character precision, and there still will not be possible to select which table rows to print. As I understand, these limitations are not problems for your task.

This change will be included in the update that will be released in the next week.
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: Print Selected Text Only

Post by tiagosis »

that's exactly it, I will wait for next week's update to finish my work, PS: how do I know about the update's publication? thanks.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Print Selected Text Only

Post by Sergey Tkachenko »

It will be announced on the website and this forum.

If you want to release a notification by email, there are options:

1) You can subscribe to the blog: https://blog.trichview.com

2) There is a mailing list for registered TRichView users. If you are a registered customer, please send me email with information allowing to find your order (for example, which email address was used when ordering)
Post Reply