How to print individual lines and how to show/configure page

General TRichView support forum. Please post your questions here
Post Reply
Kym
Posts: 18
Joined: Fri Mar 24, 2006 1:57 pm

How to print individual lines and how to show/configure page

Post by Kym »

Hello, what I need is:

I have a text saved on database as RTF type, this text is showed in a component DBRichViewEdit using data aware components.

In my forms (paper), I have an area wich can store 50 lines of text in each page.

The user must check the paper, and tell me in wich line should I start printing, for example, on line 35.

Then I'll start print my text on line 35 and when I reach line 50, It's a new page. I have headers for all pages wich are not stored in the database because they are standard for all forms.

I need to see on the screen the page break, wich must be showed every 50 lines of text, is there a way to do that?

And is there a way to print lines the way I need? Or I have another option?

I know you help every one, but this is a hard question and I'll won some money if I'm able to do that, so if you fell this need some time to explain how to do, I can pay for the help.

Also, I'll register the component as soon as I finish my project, because I have no money untill it's working, I loved that comp untill now, it's helping a lot.

Well, thanks for everything you doing for us.
Kym
Posts: 18
Joined: Fri Mar 24, 2006 1:57 pm

Post by Kym »

I took some screenshoots to explain better

Image

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

Post by Sergey Tkachenko »

You can set page breaks in the proper places manually.
Set RichView.PageBreaksBeforeItems=True in all places where a new page must start.

As for adjusting the top position where document will be printed, you can do it by changing RVPrint.TopMarginMM (in mm) and RVPrint.StartAt (in pixels). I hope the examples in this topic will be useful for you: http://www.trichview.com/forums/viewtopic.php?t=87
Kym
Posts: 18
Joined: Fri Mar 24, 2006 1:57 pm

Post by Kym »

Sergey Tkachenko wrote:You can set page breaks in the proper places manually.
Set RichView.PageBreaksBeforeItems=True in all places where a new page must start.


Where should I set this? I mean, in a event? If so, wich one? I can't find.

To tell the true, I'm having a lot of difficult to understand how all the RichView components works :(
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

How are your documents created? Are they generated, or created by users?
Do I undestand you correctly: the places where these breaks must be added depend not on the number of lines, but on the document structure (i.e. your documents have sections (finished with the line with signature), and pagebreaks must be added between these sections)?
Kym
Posts: 18
Joined: Fri Mar 24, 2006 1:57 pm

Post by Kym »

Sergey Tkachenko wrote:How are your documents created? Are they generated, or created by users?
Do I undestand you correctly: the places where these breaks must be added depend not on the number of lines, but on the document structure (i.e. your documents have sections (finished with the line with signature), and pagebreaks must be added between these sections)?
I'll try to explain.

The documents are created filling params on a model.

1. The user select a model from the model's database (the models are made by the users itself) :

Image

Why this is a model? Because the text beteween '< >' and '{ }' are params, wich will be filled dynamically by the next form, I have a function that read the model's text, and generate this form for the user, then he can fill the content of the params.
The first step is fill the params between '{ }' wich are simple text params:

Image

Althought I have more params to replace getting data from the database, the final result will be just text, not a big text, in 90% of the cases, I have 100 lines max.

Now, I go back to the model, replace the params with the typed values and I have the text I need to Print on the Paper.

Image
Kym
Posts: 18
Joined: Fri Mar 24, 2006 1:57 pm

Post by Kym »

Well, now I have the text I need to Print.

But the paper I'll print this text, is not a blank paper, its a paper with a retangular moldure and this paper may have text printed already.

But considering that I use font Arial, size 11, for all models, I can always print 50 lines of text in each face of the paper (I print in front and in back).

What I need to do is: Check the paper I'll print and see in wich line I will start printing the new job.

For example, if someone have print 35 of lines already, I'll start printing on line 36, and when I reach line 50, I need to go to back of the page or to a new page, starting on line 1.

If the "new page" will be print on the back of current paper, it starts on line 1, but if it's a really new page, on the paper, I have to print a header.

Thas's why I need to show the pagebreak, for example, on Microsoft Word, when I reach the end of the page (50 lines in my case here), the next line will be shown in a new page, so the user knows where the new page starts.

I have only text on my models, no tables, no pictures, nothing except text and formated text (bold, italic, underline, justified, etc..)

Sorry about the long post, my english is not very good, so I tried to give you as more details as I could.

Do you undertstand me now?
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

As I said, you can set the position of the top line by changing RVPrint.TopMarginMM (in mm), and, in addition, RVPrint.StartAt (in pixels).

If 35 lines were already printed, you can set TopMarginMM and/or StartAt so what the printing will start below the 35th line.
If all these 35 lines use the same font without pictures, I can explain how to calculate their height.
The printing will continue on the next page automatically.
Kym
Posts: 18
Joined: Fri Mar 24, 2006 1:57 pm

Post by Kym »

Sergey Tkachenko wrote:As I said, you can set the position of the top line by changing RVPrint.TopMarginMM (in mm), and, in addition, RVPrint.StartAt (in pixels).

If 35 lines were already printed, you can set TopMarginMM and/or StartAt so what the printing will start below the 35th line.
If all these 35 lines use the same font without pictures, I can explain how to calculate their height.
The printing will continue on the next page automatically.
Yes, I usee the same font without pictures in all documents.

And how about the "pagebreak"? What I mean by pagebreak is this:

Image
Image

I want the user to know where the page ends, because this can happen for example in the last line of the text, and the user dont want to print only 1 line in other page, than he can edit the text, make it a little small and print all in one page.

How to configure this "pagebreak" to show every 50 lines of text?
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Soft page breaks are displayed when the document is ready for printing (RVPrint.FormatPages is called), after you call RichViewEdit.AssignSoftPageBreaks(RVPrint).

Sorry, TRichView cannot add pagebreaks after the specified number of lines. You can add pagebreaks yourself, but a number of lines on printing may be different, not the same as in editor.
If the problem is in hanging lines, you can include rvpaoKeepLinesTogether in the Options of paragraph style.

As for determining height of one line of text on printer (in pixels), the code is below:

Code: Select all

function GetPrnTextHeight: Integer;
var DC: HDC;
    Canvas: TCanvas;
begin
  DC := RV_GetPrinterDC;
  try
    Canvas := TCanvas.Create;
    try
      Canvas.Handle := DC;
      Canvas.Font.PixelsPerInch := GetDeviceCaps(DC, LOGPIXELSY);
      // assign your font to canvas here
      Result := Canvas.TextHeight('A');
    finally
      Canvas.Handle := 0;
      Canvas.Free;
    end;
  finally
    DeleteDC(DC)
  end;
end;
Kym
Posts: 18
Joined: Fri Mar 24, 2006 1:57 pm

Post by Kym »

Hmm, is there a way to reproduce on screen, exactly what will be print?

I mean, I'll use Office Paper (A5) as form to print, and I'll adjust it using the top/bottom left/right margin.

If I can find the right size (Width) of richview wich reproduce my util area on the paper, I think it's enough.

Or better, if I can lock the ruler to this Width, I'll give a nice effect and this will work because I can format page when I need to know where the page breaks are in.
Kym
Posts: 18
Joined: Fri Mar 24, 2006 1:57 pm

Post by Kym »

Ok, I got it, thank you.

But let me ask you, is there any possibility that RichView support WYSIWYG later on? Or just NO WAY, forget it? I mean, do you plan to work on that?
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Planned, but not for near future
Kym
Posts: 18
Joined: Fri Mar 24, 2006 1:57 pm

Post by Kym »

Sergey Tkachenko wrote:Planned, but not for near future
Ok, let me guess about something then:

I need to reproduce on the screen, what I'll print, as I already said, the only way to do this is using the preview, wich is not editable, as you already said.

The only feature that I'll use then with richview, wich I dont have in the regular richtext component, is the power to justify the text and to add pagebreaks (I can get this on the screen after preview), besides the facilities of richviewactions.

Is there a way to make a funcion that format the richview to show the text like in the preview? I can type the text, then press a button to format the component.

Is there a way to print individual lines, keeping the format (bold/italic/alignment/etc)? I can make a loop wich print the lines one by one, since I use Arial11 all the way.

Or do you have another ideia?

I only need a component because I dont know how to justify text and print what I see on the screen, if I cant have that, seens like the component (even this is a greate component), doesnt work for me :(

What do you have to say for me?
Post Reply