Recent

Author Topic: Height of multiline text in PowerPDF ?  (Read 471 times)

Aidex

  • New Member
  • *
  • Posts: 17
Height of multiline text in PowerPDF ?
« on: March 24, 2019, 08:23:23 am »
Hello!
I want to print multiline text of variable length into a PDF (PowerPDF). I don't know how many lines will result from the line breaks (.WordWrap=true).
How can I determine the required number of lines or the pixel height? Because I want to adjust the panel to the actual size in order to add more content below it.
I tried .AutoSize=true, but can't see any effect.

I'm using PowerPDF 0.9.15 and Lazarus 2.0 on Windows 64.
Thank you in advance!  :)

uses PReport, LCLIntf;

procedure TForm1.Button1Click(Sender: TObject);
var
    Rep:  PReport.TPReport;
    Page: PReport.TPRPage;
    PPanel: PReport.TPRLayoutPanel;
    PText:  PReport.TPRText;
    i: Integer;
    s: String;
begin
  Page:=TPRPage.Create(NIL);
  PPanel:=TPRLayoutPanel.Create(Page);
  PPanel.Parent:=Page;
  PPanel.Height:=Page.Height; // otherwise default height 100

  PText:=TPRText.Create(PPanel);
  PText.Parent:=PPanel;
  PText.AutoSize:=true;  // no effect?! also when Width/Height = 0
  PText.Width:=Page.Width div 2;
  PText.Height:=PPanel.Height;  // otherwise default height 30
  PText.WordWrap:=true;

  s:='';
  for i:=1 to 100 do  s:=s+' Hello '+IntToStr(i);
  PText.Lines.add(s);

  Rep:=TPReport.Create(NIL);
  Rep.FileName:='Test.pdf';
  Rep.BeginDoc;
  Rep.Print(Page);
  Rep.EndDoc;
  Rep.Destroy;

  PPanel.Destroy;
  Page.Destroy;

  LCLIntf.OpenDocument('Test.pdf');
end;