I am using iTextSharp in my current project. I have created a table with some underlined data but my requirement is shown in this image:
http://postimg.org/image/402ap3acf/
How can I build this type of table.
I need the below structure.
A/C Some text TAT Some text
----------------- -----------------
The doted lines are underline.
The underline is controlled via the Font object and if you only want to set part of a Paragraph to be underlined you'll want to use a Chunk.
Here's a quick helper method for generating a font with different styles. You can change the actual font to whatever font you want to use.
Private Shared Function CreateFont(size As Integer, Optional style As Integer = iTextSharp.text.Font.NORMAL) As iTextSharp.text.Font
Return New iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, size, style)
End Function
The style parameter takes integers from this list that you OR together:
iTextSharp.text.Font.NORMAL
iTextSharp.text.Font.BOLD
iTextSharp.text.Font.ITALIC
iTextSharp.text.Font.UNDERLINE
iTextSharp.text.Font.STRIKETHRU
So normal underlined text would be:
iTextSharp.text.Font.NORMAL Or iTextSharp.text.Font.UNDERLINE
You can use the above like this:
Dim P As New Paragraph()
P.Add(New Chunk("A/C ", CreateFont(12, iTextSharp.text.Font.NORMAL)))
P.Add(New Chunk("Some text", CreateFont(12, iTextSharp.text.Font.NORMAL Or iTextSharp.text.Font.UNDERLINE)))
EDIT
From iTextSharp's perspective, "underline" means "a line drawn underneath text". If there's no text there won't be an underline. A space, however, counts as text so you can just add extra spaces if you want like to continue the underline:
Dim P As New Paragraph()
P.Add(New Chunk("A/C ", CreateFont(12, iTextSharp.text.Font.NORMAL)))
P.Add(New Chunk("Some text ", CreateFont(12, iTextSharp.text.Font.NORMAL Or iTextSharp.text.Font.UNDERLINE)))
Related
I have object TextLayer with white text color string. Then I animate text color selection (second character changes color white -> blue).
How can I get this selection and color programmatically?
Seems like you can't reach the selection start and end values by scripting. But you can add expression controller effect and get the values from that one.
The code below asumes you have one comp in your project with an text layer called "my text layer".
Add an expression controller for color to that layer. Add the expression text.animator("Animator 1").property.fillColor to that effect.
You can do the same thing with the values from your selection.
var preExpression = true;
var currentTime = 5; // in seconds
// get the sourceText? works!
var val = app.project.item(1).layer("my text layer").property("ADBE Text Properties").property("ADBE Text Document").valueAtTime(currentTime, preExpression);
// get the Text Percent Start? Wont work!
var sel = app.project.item(1).layer("my text layer").property("ADBE Text Properties").property("ADBE Text Animators").property("ADBE Text Animator").property("ADBE Text Selectors").property("ADBE Text Selector").property("ADBE Text Percent Start").valueAtTime(currentTime, preExpression);
// add an expression controller for color and get the color from that one? works!
var col = app.project.item(1).layer("my text layer").property("ADBE Effect Parade").property("ADBE Color Control").property("ADBE Color Control-0001").valueAtTime(currentTime, false);
$.writeln(val);
$.writeln(sel);
$.writeln(col);
Take a look into the After Effects Scripting Guide. Use redefinery's rd_GimmePropPath script to get the match names of properties.
I need just one word in a label to be red. When I have a static text, everything works fine, as you can see here:
But I want to use in the label the value of another control. I am trying to do this with:
<xf:label value="concat('Is your name is ', xxf:bind('control-1-bind'), ' ?')"/>
But how can I make the imported value (control-1) red?
Try the following:
<xf:label mediatype="text/html">
Is your name
<xh:span class="labas"><xf:output value="xxf:bind('control-1-bind')"/></xh:span>?
</xf:label>
I am having an issue with styling individual cells in a DataGrid. I want to go through the text in a DataGrid cell and only color a specific portion of the text.
When a User uses a search filter, we want to color and bold the text in the cell that matches the search phrase. For example, the User filters a column of job titles with the search phrase "Adjust" and one of the cell values is "Claim Adjusters", we want "Claim " and "ers" at the end to be black font color and the "Adjust" to be another color (let's say red).
I noticed that if the String passed to the DataGrid was of the form:
value.substring(0,start) + "(b)" + value.substring(start,finish) + "(/b)" + value.substring(finish);
With "<>" rather than "()", the text between the bold tags gets displayed with a bold font, but it does not work with (font color=\"red\") ... (/font).
Any suggestions on how I can get the search text to color here as well as bold?
Only hexadecimal color (#FFFFFF) values are supported.
A simple alternative with lots of flexibility is to make your itemRendrer support html formatting:
public class HtmlItemRenderer extends DataGridItemRenderer {
override public function validateProperties():void {
super.validateProperties();
if (text.indexOf('<') > -1) {
htmlText = text;
}
}
}
The conditional doesn't need to be very strict, it will still save some cycles for most cells that contain no markup.
Can I set the font size for string? I want to do text formatting for string, Is it possible in flex?
You can use TextField/UITextField to display formatted text. In both classes you have two options:
You can use setTextFormat() method to format text
You can use htmlText property to display HTML text. These classes don't support all HTML tags. Supported HTML tags are listed here.
If all you need to do is change the font, you can use the StyleableTextField class or the Label and set the . She can set the fontSize style of either class to globally change the font size.
No,
you need to set the font size of label or any text other Text control that you use to show string value.
var str:String = 'This is sample text';
//set in any method
lbl.text = str;
lbl.setStyle('fontSize', 20);
enjoy.
I am treating a spark TextArea as text input(by setting heightInLines="1"). The TextArea is part of an mxml component and I want to resize the component when the text is changed.
I haven't been able to use textArea.measureaText(textArea.text) to get line metrics and use it. I get this error "Parameter antiAliasType must be non-null."
Is there any way to get the width of a TextArea which it is going to consume at runtime for a particular string or a particular TextFlow?
A little ugly but works for me:
var uiText:UItextField = new UITextField();
// if you have custom text style on the TextArea then set it the same of this uitextfield
uiText.setTextFormat("bla bla bla");
uiText.text = "This is the text that I want the size for";
var textW:Number = uiText.textWidth;
var textH:Number = uiText.textHeight;
// then we need to consider also the border of the text area and the paddings
// try read the padding values and border sizes using getStyle(...)
myTextArea.width = textW+2*borderW+paddingL+paddingR;
myTextArea.height = textH+2*borderH+paddingT+paddingB;
That should be all