|
Rank: Newbie Groups: Member
Joined: 4/26/2024 Posts: 3
|
Hello,
I have come into an issue while working with EO.Pdf, I would like to have an AcmBlock horizontally aligned to the right, but the AcmText inside the AcmBlock I would like to have it horizontally aligned left, reading the documentation suggests that it is not even possible, since if you change alignment on the AcmBlock all of it's children will inherit the same setting, so my question would be, is it possible to achieve the AcmBlock alignment on the right and the child AcmText alignment on the left?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, Have you tried to use a nested AcmBlock to align the text, so the ACM tree would be like this:
Code:
AcmBlock -> Aligned to the right Other contents that aligned to the right AcmBlock -> Aligned to the left AcmText
Please let us know if this works for you. Additionally, you can always use HTML for alignment. HTML alignment is a lot more powerful and versatile. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 4/26/2024 Posts: 3
|
Hi,
Nesting the AcmBlock's does not work, since you set the alignment to the right for the first parent and according to the documentation all of the children of that block will inherit the alignment, so that will makes the first AcmBlock align to the right, the second AcmBlock within the first one aligned to the right, and the text align to the right even if you define it that it should be aligned left. HTML alignment works, but the current implementation of the system is done with these blocks and it would be nicer to keep it consistent, but if it is not possible then it is what it is.
Thanks for the support and your time!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
Our original post did not indent the blocks correct. We have modified the post so that it shows the indentation thus clarifies the parent/child relationship of the blocks.
The second AcmBlock will inherits the first AcmBlock's alignment unless overriden. So the key here is you would explicitly set the second AcmBlock's alignment to left so that it overrides the inherited value (to the right).
Please let us know if you still have any questions.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 4/26/2024 Posts: 3
|
Hey,
I did it exactly like you described and it does not work, even retried it again, the difference in my case that I do not have the "other contents that are aligned to the right", also tried adding some random stuff just to test it out if that is the problem and no it is not. The result from this approach is that the text which needs to be aligned on the right side of the page but with left text alignment, is now on the left side of the page and with left text alignment. The following code in C#:
var headerBlock = new AcmBlock(); headerBlock.Style.HorizontalAlign = AcmHorizontalAlign.Right;
var nestedBlock = new AcmBlock(); nestedBlock.Style.HorizontalAlign = AcmHorizontalAlign.Left;
var text = new AcmText("test text"): text.AutoTrim = false;
headerBlock.Children.Add(nestedBlock); nestedBlock.Children.Add(text);
I have also tried adding the children in different orders the outcome is the same.
Thanks for the support!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, We tested your code here and it seems to work correctly. Our full test code is as follow:
Code: C#
var headerBlock = new AcmBlock();
headerBlock.Style.HorizontalAlign = AcmHorizontalAlign.Right;
var nestedBlock = new AcmBlock();
nestedBlock.Style.HorizontalAlign = AcmHorizontalAlign.Left;
var text = new AcmText("test text");
text.AutoTrim = false;
headerBlock.Children.Add(nestedBlock);
nestedBlock.Children.Add(text);
PdfDocument doc = new PdfDocument();
AcmRender render = new AcmRender(doc);
render.Render(headerBlock);
doc.Save(result_pdf_file);
This will generate result_pdf_file and the text "test text" is aligned to the left. We are using the latest build. Thanks!
|
|