Table alignment not applying when saving document
Posted: Wed Feb 21, 2024 7:30 am
I am facing an issue when saving our docx template that contains a table.
The table is aligned to the center of the document, however when I load and save the tamplate it gets aligned to the right.
I have made a very simple test project to test this.
Here's a few things I have tried, but none of them seem to do the trick.
Ideas and any insight is greatly appreciated!
The table is aligned to the center of the document, however when I load and save the tamplate it gets aligned to the right.
I have made a very simple test project to test this.
Code: Select all
docx := TDOCXReadWriteVcl.Create(nil);
docx.LoadFromFile(template.docx'); //template.docx contains table aligned to center
docx.SaveToFile('test.docx'); //saving the template aligns the table to the left
Code: Select all
//Loop through the entire document, check if paras = table, set PAPX.Alignment := axptaCenter
for i := 0 to WordDoc.Editor.Paras.Count - 1 do
begin
if WordDoc.Editor.Paras.Items[i].Type_ = alptTable then
begin
// WordDoc.Editor.Paras.Items[i].TempPAPX.Alignment := axptaCenter;
// WordDoc.Editor.Paras.ParaAtIndex(i).PAPX.Alignment := axptaCenter;
WordDoc.Editor.Paras.Items[i].Paras.Last.PAPX.Alignment := axptaCenter;
end;
end;
// WordDoc.Editor.Footers.AddDefault;
// WordDoc.Editor.Footers.Default_.Paras[1].PAPX.Alignment := axptaCenter;