CellProperties, VAlignment , vs OnGetAlignment

I can set FontName, FontSize, FontStyle, FontColor, BrushColor, and Alignment (horizontal) using CellProperties, and as far as I can tell, that works correctly.
But VAlignment doesn't work. What am I doing wrong?

I read somewhere that it should work via OnGetAlignment, but that was in a different place, so I don't have that information anymore.

It would be really cool if VAlignment worked too.

        if GetBitUI8(Projekt.CalcPDFFm[tmceFmIdx].Layout,cly_Right) then
          pdf_StrGr.CellProperties[ACol,ARow].Alignment  := taRightJustify;
        if GetBitUI8(Projekt.CalcPDFFm[tmceFmIdx].Layout,cly_CentH) then
          pdf_StrGr.CellProperties[ACol,ARow].Alignment  := taCenter;

if GetBitUI8(Projekt.CalcPDFFm[tmceFmIdx].Layout,cly_Bott) then
pdf_StrGr.CellProperties[ACol,ARow].VAlignment := vtaBottom;
if GetBitUI8(Projekt.CalcPDFFm[tmceFmIdx].Layout,cly_CentV) then
pdf_StrGr.CellProperties[ACol,ARow].VAlignment := vtaCenter;

pdf_StrGr.CellProperties[ACol,ARow].FontName := Projekt.CalcPDFFm[tmceFmIdx].Font.Name;
pdf_StrGr.CellProperties[ACol,ARow].FontSize := Projekt.CalcPDFFm[tmceFmIdx].Font.Size;
pdf_StrGr.CellProperties[ACol,ARow].FontStyle := Projekt.CalcPDFFm[tmceFmIdx].Font.Style;

pdf_StrGr.CellProperties[ACol,ARow].FontColor := Projekt.CalcPDFFm[tmceFmIdx].FontColor;
pdf_StrGr.CellProperties[ACol,ARow].BrushColor := Projekt.CalcPDFFm[tmceFmIdx].HintColor;

I need this for a PDF output is OnGetAlignment not called at all in that case?

For vertical alignment, this needs to be set through the event handler OnGetAlignment() and also make sure to set grid.WordWrap := false, as wordwrapped text is always drawn top aligned.

OnGetAlignment() does not respond

I need that with TAdvStringGrid / TAdvGridPDFIO

image

At this moment, it isn't supported at PDF level. We put it on our todolist to investigate to add support for a future version.

Okay,

is there perhaps a temporary solution?
I'm already doing this with the grid lines in AfterDrawContent.
Could you suggest a solution for the text?

grid lines:
That would also be a useful feature: Transferring the line color/style/width from the grid to the PDF.

Using custom drawing would be the only alternative I can think of.
We'll also put line colors on the todolist.

I have another problem.

If the text is longer than the cell size, it always appears aligned to the left (top ?), even though I've set pdf_StrGr.CellProperties[tCol,tRow].Alignment := taRightJustify; As soon as there's enough space for the text, it works.

Set grid.WordWrap = false

I create multiple TAdvStringGrid objects at runtime.
To avoid having to define them from scratch,
I have a template called “pdf_vlgStrGr,”
which assign to the runtime-created object using
"pdf_StrGr.Assign(pdf_vlgStrGr);".

Shouldn't word wrap be applied there as well?

pdf_vlgStrGr.WordWrap is false

pdf_StrGr := TAdvStringGrid.Create(Self);
pdf_StrGr.Assign(pdf_vlgStrGr);
pdf_StrGrIO.Grid := pdf_StrGr;

pdf_StrGr.WordWrap := false;
pdf_StrGrIO.Grid.WordWrap := false;

doesn't make a difference

So, the alignment problem is in the generated PDF rather than on screen in the TAdvStringGrid instance?
I assume and guess that pdf_StrGrIO represents a TAdvGridPDFIO instance then?

The structure is as follows:

  TF_PDF = class(TForm)
    pdf_vlgStrGr: TAdvStringGrid;
    pdf_StrGrIO: TAdvGridPDFIO;
  ....

var
  ...
  pdf_StrGr     : TAdvStringGrid;

begin
  pdf_StrGr                 := TAdvStringGrid.Create(Self);
  pdf_StrGr.Assign(pdf_vlgStrGr);
  pdf_StrGrIO.Grid          := pdf_StrGr;

  pdf_StrGr.WordWrap        := false;
  pdf_StrGrIO.Grid.WordWrap := false;

  for tCol,tRow ...
    pdf_StrGr.Cells[tCol,tRow]   := 'xxxxx';
    pdf_StrGr.CellProperties[tCol,tRow].Alignment  := taRightJustify;
  end;

  pdf_StrGrIO.Save(aFilename);
end;

We could see an inconsistency in the PDF export and we are investigating this.

We applied a fix, which will be available in the next release.

Thanks for reporting!