How to tell if ultragrid text has been truncated - text

We are using infragistics ultragrid to present data to the user. if the user modifies the width of a column, I need to be able to tell if the data is truncated so that I can adjust the output properly when exporting the data into pdf. We want to truncate the data when exporting to other formats to match what the user sees after the column width adjustment.
Thanks,
Currie

Whether the text is cut off or not is done automatically when drawing the string so you would need to get the available space and the string and then determine how much of it fits into the space when drawn.
Within the CellExporting event of the UltraDocumentExporter, you can get the text and the size with the following:
Size size = e.GridRow.GetCellSizeResolved(e.GridColumn);
string text = e.GridRow.GetCellText(e.GridColumn);
You can also change the value that is being exported by setting e.ExportValue to the string that you want to put in the PDF document.
What remains to be done is to determine the amount of characters that fit into the rectangle and the following should help you with that:
How to determine maximum number of characters given a fixed width font and a maximum width in pixels

Related

Wrap Text in openPD

Is there a way to wrap text around an image in openPDF? or around other text? I'm trying to mesh two texts onto one page (texts which may contain pictures), but one text may be larger or smaller then the other. They could look like one of these two pictures:
I was going to make a column text, and test the length of text 2 against the length of the text of text 1 that remains after the first few lines (see the picture), but I couldn't return the remaining text with columnText.go(true).
Is there an easy way to wrap text around a picture or other variable object (aka text)?

restrict table dimensions to the table placeholder dimensions in python-pptx

i am trying to add a table to a presentation using python-pptx with a specific dimensions
i created a slide layout from power-point which contains the table placeholder in the area i want and loaded it using python-pptx.
slide_layout
but regardless of the placeholder dimensions, the table itself after creation is exceeding the placeholder are.
mainly it is dependent on the number of rows as per the documentation "The table's height is determined by the number of rows."
shape_id, name, height = self.shape_id, self.name, Emu(rows * 370840)
i tried to update the placeholder.py file manually and change the row height but the same output appears.
shape_id, name, height = self.shape_id, self.name, Emu(rows * 18429)
the table is insisting on exceeding the placeholder area as per the below image
output
below is my code, any clues ?
from pptx import Presentation
# the presentation including the table placeholder
prs = Presentation('Presentation2.pptx')
slide1 = prs.slides.add_slide(prs.slide_layouts[11])
table_placeholder = slide1.shapes[0]
shape = table_placeholder.insert_table(rows=22,cols=2)
prs.save('test.pptx')
Tables in PowerPoint expand vertically to accommodate new rows; that's just the way they work. You will need to do any resizing yourself, which you may find is a challenging problem. This isn't the same kind of problem when a user is creating a table in the application because they will just make adjustments for fit until it looks best for their purposes.
You'll need to adjust font-size and row-height and perhaps other attributes like column-width etc. based on your application and whatever heuristics you can resolve, perhaps related to the row count and length of text in certain cells and so on.
A table placeholder really just gives a starting position and width.

Format to text file with predefined size for each field

I have an Excel file which I need to convert to text file. Now the thing is that for each value there is a specified field size which should be there in text file. For example:
if my Excel contains a character of size 10 with value ABCDEF, then in text file it should be as ABCDEF____ (4 spaces).
After this next value is appended in similar manner with its rest of the size is left blank.
Any kind of hint or pointer will be really helpful on how to procede with this.
Assuming your string is in A1, and its length isn't more than the 10 characters:
=A1&REPT(" ",10-LEN(A1))

Text alignment in Crystal Reports

I am developing a crystal report and data is also coming fine but I am unable to format the fields in the same, just like a comment field must be multiline but when I select the "can Grow" in Format object section, the display is vague.
Can Grow with a value zero stands for the display will grow to multiple lines till it is displayed fully.
As the grow can happen multiple lines, you can adjust the width of the item so that it will not overlap with other item.
What should You do:
Set can grow property to zero
Resize the item (for which you set cangrow 0) so that it will not overlap the item of the next column.

force breaking a string in a fixed width Gridview cell

I have a Gridview control on an ASP.Net page with fixed width cells. The data coming from the database occasionally comes over as a contiguous string of characters. When there are dashes in the string, it will break so as not to upset the width of the layout. If there are no dashes (specifically, I'm dealing with underscores), the string will not break and forces the cell to widen out, thus upsetting the layout of the page. Is there a way to tell the cell to keep its width and break the string? As it stands, I don't have access to the field's data directly, as the GridView bind its datasource to a dataset object coming from the database. Thanks for any feedback.
If you handle the RowDataBound event you'll be able to break the string "manually". Otherwise it'll only break based on "HTML rules".
First thing to note is that this doesn't have a lot to do with ASP.NET but is rather a pure HTML (and CSS) problem.
A possible solution is to use the css attribute table-layout: fixed and set some fixed width values to all columns. The disadvantage of this approach is that the total table width is fixed so it doesn't scale with the window size.
Another possible approach is to display in columns shorter strings using a utility function that cuts the long strings to a maximum length.

Resources