Text Height

Hello,

We are seriously considering buying your Aspose.Pdf package; the Site OEM Subscription.

Our application is going to be creating Aspose Xml to create PDF reports, and so far it works pretty good.

But we have run into a one snag. See attached PDF, bottom half after color label, were text is warpped.

Is there a way to stop word wrapping in a Text paragraph?

Also I do not see any Height attribute for Text paragraphs, This would be really nice to have, are you calculating the height based on the font and data being passed in?

Would you have any Libiary calls, that are not public, that we could use to decide when to crop the text data based on the TextWidth, text data and font? I did not see any API calls for this kind of info.

Do you have any suggestions on how to prevent this from happening? I know if I increase the TextWidth, I could prevent this type of problem. But there will be times when I will be restricted by space and I really do not want the text to wrap or have it show up below the next text paragraph.

This could be a show stopper for us, and we really do not want to start looking for another PDF generator, but we may have to.

Thanks

Neil

Dear Neil,

Thank you for considering Aspose.

The text height is calculated during the rendering process and we don't provide public interface to calculate the text height. I don't know how you generated the document but I think you can adjust your code to avoid this problem. If you can't please attach a runable example and let me check it.

I would not be able to provide you with runable code at this time.

It relies on three outside xml files and a local image server. One xml is our basic design, layout template. The other two work with data and data binding from our SQL database. I do not use any API calls to generate the PDF, I just create the XML in Aspose format.

I can attach the finished Aspose xml.

Neil

Dear Neil,

Thank you for considering Aspose.

I checked your XML and find almost all the content in it is positioned using absolute position. If you use absolute positioning, Aspose.Pdf can't ensure the content don't be overlaped. I suggest that you don't use custom positioing. You can use paragraph margin to control the position or design table without borders and put the image and text into the table. Please refer to our online demos and examples.

Tommy,

Thanks for you response. A table could work but I still have the problem of too much text.

If I set FixedRowHeight and there is more text that would cause a second line, the cell seems to expand to accommodate all the text, ignoring the FixedRowHeight. What I need is a way to trim and or crop the text to fit in the designed space.

I found this example for C# which will trim text when drawing to a shape.

Do you have anything like this that would return the trimmed text?

Private void ShowStringTrimming(PaintEventArgs e)
{

StringFormat format1 = new StringFormat();
string quote = "Not everything that can be counted counts," +
" and not everything that counts can be counted.";
format1.Trimming = StringTrimming.EllipsisWord;
e.Graphics.DrawString(quote, this.Font, Brushes.Black,
new RectangleF(10.0F, 10.0F, 90.0F, 50.0F), format1);
}

Thanks

Neil

Dear Neil,

Thank you for considering Aspose.

We can't support the your requirement now. But I'd like to provide a method for getting text height. But I don't think this can be done in short time. Maybe I need several weeks.

Thanks for considering text height.

Neil

Hello Tommy,

Are you still considering a method to get Text Height?

Please let me know.

Thanks

Neil

Dear Neil,

Yes I have added this task into our schedule. But there are too many urgent tasks. I hope this feature can be avalable next month.

Tommy,

I know you have added this task to your schedule; I was wondering if you had any ideas on how to prevent the text in a Text paragraph from expanding. Basically cropping the text to fit in a bounding box.

One idea that I have tried is to first create the Text paragraph then create a Graph paragraph using a rectangle that is filled with the same color as the page. The Top of the Graph paragraph is placed were I think the bottom of the Text Paragraph should be.

See example below

<Text IsHtmlTagSupported="True" LineSpacing="0.65" TextWidth="225" Top="120.75" Left="349.5" BackgroundColor="White" Color="Black" Alignment="left" FontName="Arial" FontSize="12" PositioningType="PageRelative">

<Segment>1 quart personal cooler. Carry strap is not attached. 4 7/8" diameter x 8 11/16".</Segment>

</Text>

<Graph Left="349.5" Top="176.75" Width="225" Height="548.25" PositioningType="PageRelative">

<Rectangle Position="0 0 225 548.25" FillColor="White" Color="White" IsFilled="true" />

</Graph>

This effectively crops the text so it fits in the area we want it to display, with out it running under another Text paragraph. The only problem that we are going to run into is if the user decides to have a background image on the page.

So is this the best way to solve this problem at this time?

Thanks

Neil

Dear Neil,

I have no other solutions that is better than yours. Sorry for the delay of the text height function. I hope that feature can be available next month.

Based on the present release version, I think you are on a good way to work around some functional deficiency. Thanks for sharing your experience for us and it's very important for developers to consider as great references.

Best Regards

We have supported this feature in the new hotfix 3.0.3.