Welcome Guest Search | Active Topics | Sign In | Register

AcmBlock right alignment aligns text to the right as well Options
ErikasMont
Posted: Friday, April 26, 2024 4:21:53 AM
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?
eo_support
Posted: Friday, April 26, 2024 12:04:33 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
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!
ErikasMont
Posted: Monday, April 29, 2024 1:22:51 AM
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!
eo_support
Posted: Monday, April 29, 2024 11:49:31 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
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!
ErikasMont
Posted: Tuesday, April 30, 2024 12:43:34 AM
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!
eo_support
Posted: Tuesday, April 30, 2024 10:19:47 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
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!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.