WPCubed Product Support

Insert Text and horiz. line

Hi !

I wrote some little procedures to get a simple way adding text und horizontal line by code.

procedure TForm1.AddText(
                  NewPage: Boolean;         // Insert new Page bevor text add
                  FontName: String;         // Font for text
                  FontSize: Integer;        // Size for text
                  FontBold: Boolean;        //
                  FontItalic: Boolean;      //
                  FontUnderline: Boolean;   //
                  Color: TColor;            // Color of the text
                  Text: String              // Text to Add ...
                  );
begin
    if NewPage = True then RTF.InputString(#12);  // New Page
    RTF.WritingAttr.Clear;
    RTF.WritingAttr.SetColor(Color);
    RTF.WritingAttr.SetFontName(FontName);
    RTF.WritingAttr.SetFontSize(FontSize);
    if FontBold then      RTF.WritingAttr.IncludeStyle(afsBold);
    if FontItalic then    RTF.WritingAttr.IncludeStyle(afsItalic);
    if FontUnderline then RTF.WritingAttr.IncludeStyle(afsUnderline);

    RTF.InputString(Text);
end;

procedure TForm1.AddHorizLine;
begin
  with rtf.TextObjects.InsertNewObject(
       wpobjHorizontalLine, false, false) do
  begin
    Height  := 10;
    iParam  := clPurple	;
  end;
end;

If I want to add text / line / text:

AddText(False,'Verdana',14,True,True,False,clBlue,'Some little Tests ...');
AddHorizLine;
AddText(False,'Verdana',10,False,False,False,clBlack,
'Dies ist dann einfach nur ein schnöder Text!');

The result is:
Some little Tests
... *)


Dies ist dann einfach nur ein schnöder Text!

*) What is the reason for this new line??
Is here something missing in general?

#1 ♥ 0
5.1k Views 2 users read 2 min

Hi,

this looks like a problem with the reformat routine which tried to combine the line object with the dot characters. You can avoid it by closing your text with a space.

Julian

#2 ♥ 0

Hi Julian!

I started to write a complete new unit for creating simple reports. I used your CreateTable Demo for starting.

For now it worked really great.

btw: How can I retieve the number / index of the actual paragraph?

#3 ♥ 0
This category is archived. No new posts are possible.