How do you know how much space an NSString (using default font) will occupy on a UITableView section header? - iphone

Basically I want to copy the behavior in iPhone's Calendar where the day of week (Mon, Tue, Wed) is on the left side of the table's section header (left justified) while the formatted date (Apr 1, 2010, May 1, 2010) based on locale is on the right side of the table's section header (right justified).
I was thinking of inserting a variable amount of space in between the day of week and formatted date but I first need to know the actual space consumed by the text on both sides to figure out how much space to add.
Hope to hear your thoughts on this.
Thanks.

There're some additions made in UIKit to NSString class, among them functions allowing to determine string size when drawing with specific font. See this function in docs for a start:
- (CGSize)sizeWithFont:(UIFont *)font

Maybe you could create a temporary UILabel, set your date string as text of the label and then get the width of the label through the frame property (--> label.size.width).

Related

Google Sheets conditional formatting with differently styled dates

in Google Sheets I'd like to format an area of cells automatically by comparing its date value to another cell. In fact, I have some cells representing a month (the area of cells to be formatted) and a single cell with another date (05.05.2022 formatted as 05.05. see screenshot).
So date for homework is located in U6 and cell area for moth of may is K11:Q16. When I set conditional formatting to
apply to range: K11:Q16
and
Date is: exact date: =U6 or custom formula is: =U6
it does not work. But when I set range to N12 (05.05.2022 formatted as 5) it does work.
Any ideas?
Thanks in advance.
edit:
I created a separate sheet for sharing, so this does not fit to the screenshot:
https://docs.google.com/spreadsheets/d/1gBx3dbzxk3Qb999uo3YMdz0A9-ViSE4xPeihhasN7FQ/edit?usp=sharing
try like this:
=COUNTIF($I$2:$I$5; D11)
or:
=MATCH(D11; $I$2:$I$5; )

stretch a textField to a max height in jasper reports

I think this is more of a general issue. I would like to use a textfield that gets dynamic data and doesn't stretch more than a given max height. For instance, I have a textfield that, if it gets text that fits in one line, the textfield will be one line height, and i have other elements under it, that will move up with float positioning. Or, if I want a 3 line max height and if the text exceeds that space, then the rest will be trimmed.
I don't want to use java expressions to trim that text, as it is not always accurate. I am new to jasper and I am trying to know if there is any way to do this. I did a lot of searches, but maybe there is something that i missed, and i hope someone can help me. Thank you
I managed to solve this by extending net.sf.jasperreports.engine.fill.TextMeasurer and overriding initialize() method; also I had to extend net.sf.jasperreports.engine.util.AbstractTextMeasurerFactory and override the createMeasurer() method.
Now, whenever I want to have max # of lines, with no overflow, I add a property to that text field (e.g. maxLines) which is being passed to my custom TextMeasurerFactory. I hope this helped you.
We had a similar problem at work with JASPER Reports 4.5, where we had an invoice with a header and a table. We wanted the header to have dynamic height based on the lengths of certain fields (like address, partner name, etc,), but not more than a critical limit, otherwise the header will push the table and thus making a mess by splitting it across multiple pages. Also, the invoice shouldn't exceed 1 page.
We eventually had to move the header in the background section, where we also put a background for the table consisting of vertical lines (so it will extend to the end of an A4 page) and a white opaque square.
This way, if the header exceeds the max height it will go underneath the table's background, cropping the text. This was the desired effect we were looking for.
Sounds crazy, but it worked ...

Dynamically position vertical StripLine in SSRS 2008

I am building a Control Chart where the user selects an interrupt date and I would like to place the StripLine immediately before that. So, let's say a user selects July 2009 as their interrupt date, I'd like to place the StripLine at June 2009. Based on how I got the image below it looks like I need to use index-based placement. How can I determine where on the chart June 2009 is? The user can also select the start and end dates so it would vary chart to chart.
If it matters the horizontal axis labels are MYYYY but the values are YYYYMM for sorting. In the image below I set the IntervalOffset to 3, not 72009 or 200907.
I have the following chart with (what is right now) a statically positioned vertical strip line.
SSRS is not my strength so please let me know if you need additional information.
OK this is pretty specific to my scenario but I figured I'd post the answer in case it can help someone else. Setting the expression for IntervalOffset to the following value worked:
=IIf(
Parameters!StartYear.Value = Parameters!InterruptYear.Value,
CInt(Parameters!InterruptMonth.Value - Parameters!StartMonth.Value),
CInt(
(CInt(Parameters!InterruptYear.Value)*12+CInt(Parameters!InterruptMonth.Value)) -
(CInt(Parameters!StartYear.Value)*12+CInt(Parameters!StartMonth.Value))
)
)

how to find out if the string given will fit on a particular gwt label or not.

I am new to gwt and I am trying to check if the dynamic string document id that i am retrieving will will fit on the gwt label or not. Now I am checking for the number of characters and if the number exceeds 15 I am appending ... after 12 characters and displaying the actual id in the tooltip. I need to know how do i achieve this without calculating the number of characters. Please help
The width of a label does not only depend on the string size, but on the font used.
You could write you string in a temporary label attached to the dom and query the size using the method 'getClientWidth' of the element or gwtquery, and remove recursively the last character until you get the appropriate size.
In my opinion the easier way would be to use css and define a fixed width of your label and set the property overflow to hidden, so you see just the chars which fit in the label and you dont have to deal with a different string.

Text not fitting into form fields (iTextSharp)

I created a .PDF file using Adobe Acrobat Pro. The file has several text fields. Using iTextSharp, I'm able to populate all the fields and mail out the .PDF.
One thing is bugging me - some of the next will not "fit" in the textbox. In Adobe, if I type more that the allocated height, the scroll bar kicks in - this happens when font size is NOT set to auto and multi-line is allowed.
However, when I attempt to set the following properties:
//qSize is float and set to 15;
//auto size of font is not being set here.
pdfFormFields.SetFieldProperty("notification_desc", "textsize", qSize, null);
// set multiline
pdfFormFields.SetFieldProperty("notification_desc", "setfflags", PdfFormField.FF_MULTILINE, null);
//fill the field
pdfFormFields.SetField("notification_desc", complaintinfo.OWNER_DESC);
However upon compilation and after stamping, the scroll bar does not appear in the final .PDF.
I'm not sure if this is the right thing to do. I'm thinking that perhaps I should create a table and flood it with the the text but the documentation makes little or no reference to scroll bars....
When you flatten a document, you remove all interactivity. Expecting working scroll bars on a flattened form, is similar to expecting working scroll bars on printed paper. That's why you don't get a lot of response to your question: it's kind of absurd.
When you fill out a rectangle with text, all text that doesn't fit will be omitted. That's why some people set the font size to 0. In this case, the font size will be adapted to make the text fit. I don't know if that's an option for you as you clearly state that the font size must be 15 pt.
If you can't change the font size, you shouldn't expect the AcroForm form field to adapt itself to the content. ISO-32000-1 is clear about that: the coordinates of a text field are fixed.
Your only alternative is to take control over how iText should fill the field. I made an example showing how to do this in the context of my book: MovieAds.java/MovieAds.cs. In this example, I ask the field for its coordinates:
AcroFields.FieldPosition f = form.GetFieldPositions(TEXT)[0];
This object gives you the page number f.page and a Rectangle f.position. You can use these variables in combination with ColumnText to add the content exactly the way you want to (and to check if all content has been added).
I hope you understand that:
it's only normal that there are no scroll bars on a flattened form,
the standard way of filling out fields clips content that doesn't fit,
you need to do more programming if you want a custom result.
For more info: please consult "iText in Action - Second Edition".