#1 2015-01-06 11:20:56

lagunero
Member
Registered: 2015-01-06
Posts: 6

SetTextJustification not working?

Hello, thanks for this library. In this piece of code:

lPDf:=TPDFDocumentGDI.Create;
  try
    lPage := lPDF.AddPage;
    lPage.PageWidth:=413;
    lPage.PageHeight:=556;
    with lPDF.VCLCanvas do
    begin
      mmode:=SetMapMode(Handle,MM_ANISOTROPIC);
      SetWindowExtEx(Handle,413,556,@oldwi);
      SetViewportExtEx(Handle,Round(((413/2.835)*96)/25.4),
        Round(((556/2.835)*96)/25.4),@oldvi);
      p:=Point(0,16);
      DPtoLP(Handle,p,1);
      Font.Height:=-p.Y;
      Font.Name:='Arial';
      s:='any string with four spaces';
      GetTextExtentPoint32(Handle,PChar(s),Length(s),sz);
      SetTextJustification(Handle,393-sz.cx,4);
      TextOut(10,10,s);
      SetTextJustification(Handle,0,0);
      SetViewPOrtExtEx(Handle,oldvi.cx,oldvi.cy,nil);
      SEtWindowExtEx(Handle,oldwi.cx,oldwi.cy,nil);
      SetMapMode(Handle,mmode);
    end;

As you see, in setviewport I transform the window extensions to the values in pixels, taking in account the values in the procedure: SetDefaultPaperSize in synpdf.pas.
sz.cx seems to report the correct amount and the font seems to be of the good size, so why SetTextJustification does nothing and the result is correct but without justification? Very appreciated, cheers.

Offline

#2 2015-01-06 12:11:08

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

Re: SetTextJustification not working?

Try to define the TPdfDocumentGDI.UseMetaFileTextPositioning property as expected.

Offline

#3 2015-01-06 16:26:28

lagunero
Member
Registered: 2015-01-06
Posts: 6

Re: SetTextJustification not working?

Thank you.

Offline

Board footer

Powered by FluxBB