#1 2012-04-05 19:51:27

Jeff
Member
Registered: 2012-04-05
Posts: 2

TGDIPages - can DrawText not append a NewLine?

I just discovered SynPDF this morning so please forgive my newbie-ness.  I have searched the forum but have not seen this topic addressed elsewhere.

I would like to be able to write the following code and have the text all on the same line:

   Rept := TGDIPages.Create(Application);
      try
        Screen.Cursor := crHourGlass;
        Rept.BeginDoc;
        Rept.DrawText('plain text ');
        Rept.Font.Style := [fsUnderline];
        Rept.DrawText('Underlined text');
        Rept.Font.Style := [fsBold];
        Rept.DrawText('bold text'); // <-- DrawText ALWAYS adds a NEWLINE to the end...
        Rept.Font.Style := [];
        Rept.DrawText(' plain text');
        Rept.EndDoc;
     finally
        Screen.Cursor := crDefault;
        Rept.Free;
     end;

Ideally the output would look like this:
plain text underlined textbold text plain text

but it looks like this:
plain text
underlined text
bold text
plain text

---
Is this possible?

Thanks!
PS this tool is great!

Offline

#2 2012-04-06 05:35:06

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,253
Website

Re: TGDIPages - can DrawText not append a NewLine?

This is not possible directly.

You have several workarounds:
- Use the supplied Canvas property to draw the text as usual with Delphi (you have to render it);
- Write your text into a TRichEdit content, then add it to the page via the TGDIPages.AppendRichEdit() method.

For the later, see http://synopse.info/forum/viewtopic.php?id=76

Offline

#3 2012-04-08 19:13:26

Jeff
Member
Registered: 2012-04-05
Posts: 2

Re: TGDIPages - can DrawText not append a NewLine?

Ok thank you.  I can do it with the Canvas, I was just hoping to take advantage of the Begin/EndGroup feature.

Thanks for the quick reply.
-Jeff

Offline

Board footer

Powered by FluxBB