You are not logged in.
How can I add a paragraph that only occupies, for example, 50% of a page width? It would be the second of three paragraphs, the other two being full-width. I want to add an image to the right side of this smaller paragraph.
Offline
Yes, I have tried using columns but then there is no option to justify the text. Only caLeft, caCenter, caRight, or caCurrency.
I'm working on an adaptation of the code in caLeft like caJustify but with another function similar to WrapText that expands the whitespace but as text for each line. But it is not always exactly on the right margin all aligned because it is on the text and not on the canvas
I've covered all the margin options. Most respond to the TControl and not to the document as such, and the modifiable right is only as MarginRightPos and is only read
Offline
What I answered is that you can read the PageMargins property into a temporary TRect variable, then change the right margin (in millimeters), and write back the new property value.
Offline
Yes, I set PageMargins rect to TempRect variable. But how can I change right margin temporally?
Only I can see RightMarginPos and it's only readable, not write as LeftMargin
TempRect:= Reporte.PageMargins;
// Reporte.RightMargin:= 127; <-- doesn't exists
Reporte.RightMarginPos:= 127; <-- exists but it's only read
I try to change RightMargin as LeftMargin in mormot.ui.report and when I try DrawText after set RightMargin it fall into blocking loop
Editing...
With this code I can change Right, ok, but never justified (in code you treat taJustified as taLeft)
// 2do Bloque
RectOriginal:= Reporte.PageMargins;
RectModif:= RectOriginal;
RectModif.Right:= 50;
Reporte.PageMargins:= RectModif;
Reporte.TextAlign:= taJustified;
Reporte.DrawText(TextoLargo);
Reporte.NewLine;
Reporte.PageMargins:= RectOriginal;
Last edited by Sapiem (2026-01-26 05:25:47)
Offline
It doesn't justify
This is the code
procedure TForm1.Button1Click(Sender: TObject);
var
Reporte: TGDIPages;
txt: string;
TextoLargo: string;
RectOriginal, RectModif: TRect;
begin
Reporte := TGDIPages.Create(Self);
Reporte.Parent := Panel1;
Reporte.Align := alClient;
txt:= 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod '+
'tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis '+
'nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.';
TextoLargo := 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod '+
'tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis '+
'nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis '+
'aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat '+
'nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui '+
'officia deserunt mollit anim id est laborum.';
try
Reporte.Caption := 'Report 123456';
Reporte.TextAlign:= taJustified;
Reporte.BeginDoc;
Reporte.Font.Name := 'Segoe UI';
Reporte.AddTextToHeader('Header');
Reporte.AddTextToFooter('Footer');
Reporte.Font.Size := 12;
Reporte.DrawTitle('Title', True);
// 1er Bloque
Reporte.Font.Color:= clblue;
Reporte.DrawText(txt);
Reporte.DrawText(TextoLargo);
Reporte.NewLine;
// 2do Bloque
Reporte.Font.Color:= clRed;
RectOriginal:= Reporte.PageMargins;
RectModif:= RectOriginal;
RectModif.Right:= 100;
Reporte.PageMargins:= RectModif;
Reporte.TextAlign:= taJustified;
Reporte.DrawText(TextoLargo);
Reporte.NewLine;
Reporte.PageMargins:= RectOriginal;
Reporte.EndDoc;
Reporte.Show;
finally
// No liberar aquí para que persista en el Panel
end;
end;Last edited by Sapiem (2026-01-27 01:21:59)
Offline
It doesn't justify
Your code does justify on break characters.
BUT... did you check what the break character for the font Segoe UI is ???
It's not "space" ![]()
Change your code to use 'Arial' as font and you see the justify is done correctly on the break character (which is space for Arial).
Otherwise use the GetTextMetrics function to find out what the break character is for Segoe UI.
When using Justify, there is extra space added to certain "break characters" (usually this is the space character for normal fonts).
If the break character is different, then you won't get justify on space and the justification doesn't work.
See the documentation for more information about justify and break characters.
https://learn.microsoft.com/en-us/windo … tification
Edit: BTW, just check the break character for Segoe UI. It's #13, not #32. So that's the reason for it not justifying.
procedure GetFontBreakChar(Canvas: TCanvas; out BreakChar: WideChar);
var
Metrics: TTextMetric;
begin
GetTextMetrics(Canvas.Handle, Metrics);
BreakChar := Metrics.tmBreakChar;
end;Last edited by rvk (2026-01-27 10:23:12)
Offline
Perfect, change to tahoma fix the justify. Thanks
Sorry another doubt: is it possible to display the pages one after another instead of a single one, and switch between them one by one using the buttons in the upper corners?
Offline
Sorry another doubt: is it possible to display the pages one after another instead of a single one, and switch between them one by one using the buttons in the upper corners?
As far as I can see, the page navigation is build in the TGDIPages component, so my guess is that you can't show a continues page layout.
Offline