How to adjust spacing between paragraphs in iText7 - itext

In iText7 I need to create 5 lines of text at the top of a document that are centered to the page. The easiest way I found to do this is:
doc.add(new Paragraph("text of line 1").SetTextAlignment(TextAlignment.CENTER));
doc.add(new Paragraph("text of line 2").SetTextAlignment(TextAlignment.CENTER));
etc.
However there is a larger amount of space between each of the lines than I want. Within a paragraph you can set line leading, but how do I set leading between paragraphs in a document? Or am I doing this the complete wrong way to begin with?

Paragraph has 2 methods for handling what is known as the leading.
Paragraph o1 = new Paragraph("");
o1.setMultipliedLeading(1.0f);
Multiplied leading is when you specify a factor of how big the leading will be compared to the height of the font.
You can also set it document wise:
document.setProperty(Property.LEADING, new Leading(Leading.MULTIPLIED, 1.2f));

In my case with iText7, I used SetMarginTop(0f) and SetMarginBottom(0f) to make it.

Related

Fillable Pdf multi-line, Allow rich text formatting in Acrobat Pro DC: but it ignores line spacing/leading set in More

I'm on Win10, using Acrobat Pro DC 2021.011... to edit and Reader DC (same version) to test.
From experience and from reading forums etc, forms in these apps are maddening... but I have not been able to find any discussion (or solutions) to the following behavior...
The form I'm building for other employees' use has a large edit text box set to Multi-line and Allow Rich Text Formatting. It is set to a default font, Calibri and size 50pt. For most situations this will work for them; provides 2-3 lines for a short product description. But occasionally they want a smaller font and more lines... They know how to get the ctrl+e properties bar. But in my testing of this alternative situation they'll need sometimes, I'm finding it's impossible to get the smaller font size and more lines to work. Here's my process.
tab into text box. Ctrl+E for properties bar.
before typing I set the font size to 24
then I type in my 4 lines of text
then I tab to my next form field...
and kaboom... the field I just filled...it's line height is so large it's pushed some of the content invisible. I assume this is coming from the field's default font size, 50
And if I try to adjust the line height, by selecting all the text and then choosing in More...>Form Field Text Properties>Paragraph>Line Spacing
If I set it to Single and click Close/click into another field I get the very large leading (presumably for 50pt font (same as pic above after point 5)
If I choose Exactly and set to point size slightly larger, click Close/out of field, I get another ridiculous result where the 2/3 line have the height I set, but the space between the 1 & 2 second line is way too much and the space between the last line and 3rd line is way too small...
before tabbing or clicking out of field to another field
Good lord.. what is that! 3 different leading values in the same field; just after applying 1 value to all lines, all text in the field...
It makes no sense... it doesn't look like it regards your input at all, and just comes up with it's own random leading... I've fiddled with Space before/after and combinations of Line Height and nothing comes close to what we need... At this point I'm convinced the Acrobat tools for a stylizing text in a multi-line, allow formatting text field are useless. I'd be better off with my employees they can't format anything, ever. Just type one line and hit Tab or Enter...
What is going on! I'm trying to make a simple fillable form for other employees to use, but this kind of behavior makes that impossible (It's enough of a stretch to teach them to use the ctrl+E and do some styling of their text but this is bonkers and completely unteachable... there's not rhyme or pattern to teach!)
Hope someone can help or has seen this behavior too.

How to set width of text marks in vega-lite / altair (text wrapping and line break) for long text

I am trying to display text over time using altair (vega-lite), which works fine using a layered chart, where one is created using the alt.Chart().mark_text() function to display the text.
The text though is multiple phrases and should be wrapped (with line breaks). How can this be done?
(I do not want to use fixed line breaks, e.g. \n, at distinct positions since the text wrapping should work with zooming too)
Not exactly what you want, but you can specify a character on which to break to a new line. When zooming, the text stays the same size, so it should always fit the view.
For example making a new line for every word:
.mark_text(lineBreak=' ')

Jasperreports: line under each row

I have a rather long String as an input in my report. It is desirable to represent it in a such way that every next line of this String is underlined.
Usage of style "underlined" doesn't help since it underlines words only and I want thewhole line to be underlined.
Using border doesn't do the trick as well since it shows one line only at the very bottom of the textfield.
Will be greatful for any help here.
P.S. Sorry for the excessive usage of word "line" here :)

Multi-line button labels

Is there an easy way to have two lines of button.text where you specify each line individually? Also, there seem to be large margins on the buttons so the text font needs to be quite small to fit. Is there a way to allow the text to use more of the button area?
The way I would do a two-line text implementation is:
Dim t1,t2 As String
t1="This is line one"
t2="This is line two"
...
MyButton.Text = t1 & CRLF & t2
The CRLF performs a Carriage Return and Line feed thus splitting the text up
I can't help with the padding issue though. Have you tried changing the font size?
MyButton.TextSize=9

UILabel text on each line

If I have a UILabel of a certain size, with line break mode set to WordWrap and numberOfLines = 0 (so it grows depending on the amount of text), is there a way to determine what characters are on each line of the label?
So if i have the text "All People Seem To Need Data Processing" as text on the label, and assuming it displays like this on screen
All People
Seem To
Need Data
Processin
g
is there a way to know the text on each line? or the width of each line?
Line 1 : All People
Line 2 : Seem To
Line 3 : Need Data
Line 4 : Processin
Line 5 : g
How about using NSString's sizeWithFont? Do up to each word until you get a number bigger than the label's width. Then chop those words and do again for the next line.
I have given an answer regarding same query How to get text from nth line of UILabel?.
There is a method, Just call it. It will return an array of each line. Happy Coding :)