#1 2012-10-30 08:38:25

noctrex
Member
From: Greece
Registered: 2012-10-30
Posts: 2

Question about font styles

Hello!
I'm trying to use your excellent SynPdf library, but it seems that I must be going something wrong.
I want to use different font styles on a text, that is going to exported to pdf, and I'm trying this:

procedure TForm1.Button1Click(Sender: TObject);
var
  pdf: TPdfDocument;
begin
  pdf := TPdfDocument.Create;
  pdf.AddPage;

  pdf.Canvas.BeginText;
  pdf.Canvas.SetFont('Courier New', 20, []);
  pdf.Canvas.TextOut(200, 500, 'Normal String');

  pdf.Canvas.SetFont('Courier New', 20, [fsBold]);
  pdf.Canvas.TextOut(200, 450, 'Bold String');

  pdf.Canvas.SetFont('Courier New', 20, [fsItalic]);
  pdf.Canvas.TextOut(200, 400, 'Italic String');

  pdf.Canvas.SetFont('Courier New', 20, [fsUnderline]);
  pdf.Canvas.TextOut(200, 350, 'Underlined String');

  pdf.Canvas.SetFont('Courier New', 20, [fsStrikeOut]);
  pdf.Canvas.TextOut(200, 300, 'StrikeOut String');
  pdf.Canvas.EndText;

  pdf.SaveToFile('test.pdf');
  pdf.Free;
end;

It seems that the underline and the strikeout styles are not working, I'm getting only normal text.
Is there something extra that I must do?
Thank you.

Last edited by noctrex (2012-10-30 08:39:02)

Offline

#2 2012-10-30 15:06:57

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

Re: Question about font styles

Yes, I suspect that underlined and striken font style have to be implemented by hand, since they are not existing in the PDF definition, AFAIR.

Another possibility is to use the TCanvas version of the library, and here you will have all usual font drawing at hand.

Offline

#3 2012-10-31 08:57:51

noctrex
Member
From: Greece
Registered: 2012-10-30
Posts: 2

Re: Question about font styles

ab wrote:

Yes, I suspect that underlined and striken font style have to be implemented by hand, since they are not existing in the PDF definition, AFAIR.

Another possibility is to use the TCanvas version of the library, and here you will have all usual font drawing at hand.

Thanks for the clarification!
I'm now using TGDIPages instead of TPdfDocument, and it works perfectly with every style!

Offline

Board footer

Powered by FluxBB