Welcome Guest Search | Active Topics | Sign In | Register

Keep image+text together when linewrapping? Options
Linus V.
Posted: Tuesday, April 19, 2016 4:49:53 AM
Rank: Newbie
Groups: Member

Joined: 4/19/2016
Posts: 7
Hello everyone,

I have an issue in trying to create a legend for a chart we are exporting as a PDF when it comes to linewraps.

We would like to keep a color marker along the text, and move the entire group to a new line if it overflows.

We currently get linewrapping such as:


but would like it to be


The code we render the items with are:
Code: C#
var legendRow = new AcmBlock();
foreach (var item in items)
{
    var itemContent = new AcmContent();
    legendRow.Children.Add(itemContent);
    using (var bmp = new Bitmap(9, 9))
    {
        using (var gfx = Graphics.FromImage(bmp))
        using (var brush = new SolidBrush(ColorTranslator.FromHtml(legendItem.Color)))
        {
            gfx.FillRectangle(brush, 0, 0, bmp.Width, bmp.Height);
        }
        itemContent .Children.Add(new AcmImage(bmp));
    }
    itemContent .Children.Add(new AcmText(legendItem.Key));
}



Is there some way our desired layout can be achieved?
We've tried creating inline blocks (can't, abstract), wrapping them in AcmText (can't add image) and we apparently can't set the IsInline property either.


Tables are not really an option either since we can have anywhere from 0 to 10 items in our legend, each with a potentially very long text.


Thankful for any input!

Best regards,
Linus


*edit* Updated images with more complete examples since the first ones could easily be misunderstood.
eo_support
Posted: Tuesday, April 19, 2016 8:37:35 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

You will need to use an AcmParagraph object for each row. Or you can also use an AcmTable object. When you just use image and text object, they are all considered "inline" so they just flow from one line to the next.

Thanks!
Linus V.
Posted: Tuesday, April 19, 2016 9:22:19 AM
Rank: Newbie
Groups: Member

Joined: 4/19/2016
Posts: 7
eo_support wrote:
Hi,

You will need to use an AcmParagraph object for each row. Or you can also use an AcmTable object. When you just use image and text object, they are all considered "inline" so they just flow from one line to the next.

Thanks!



Ah, sorry, I should have made a better example.

We want to have the items inline since we can't have 10 rows. We just need the line wrapping if we hit the max width. Will update my original post with a better preview.

The actual examples:
The way it currently works:


The desired result:
eo_support
Posted: Tuesday, April 19, 2016 4:20:11 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

Acm does not have this capacity since essentially you need to keep the image, text and number for each category together as a single non-breaking element. Currently the ACM objects does not have this feature. So you may want to consider using the HTML to PDF converter for this. The HTML to PDF converter is much more powerful in formatting since HTML and CSS is very flexible and versatile.

Thanks!
Linus V.
Posted: Wednesday, April 20, 2016 4:59:19 AM
Rank: Newbie
Groups: Member

Joined: 4/19/2016
Posts: 7
eo_support wrote:
Hi,

Acm does not have this capacity since essentially you need to keep the image, text and number for each category together as a single non-breaking element. Currently the ACM objects does not have this feature. So you may want to consider using the HTML to PDF converter for this. The HTML to PDF converter is much more powerful in formatting since HTML and CSS is very flexible and versatile.

Thanks!



Kind of expected that response but figured it was worth a try to ask.


Thanks for the answer, now I know!

eo_support
Posted: Wednesday, April 20, 2016 8:22:36 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
You are very welcome and sorry that it wasn't what you hoped. Please feel free to let us know if you have any more questions.


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.