How to align a paragraph (justify) whith Itext? - itext

I have 2 lines and I want to align (justify) them.
I have this code:
Paragraph p=new Paragraph(ANC,fontFootData);
p.setLeading(1, 1);
p.setAlignment(Element.ALIGN_JUSTIFIED);
document.add(p);
Paragraph p2=new Paragraph(RUTTEL,fontFootData);
p2.setLeading(1, 1);
p2.setAlignment(Element.ALIGN_JUSTIFIED);
document.add(p2);
where ANC and RUTTEL are string, but they not be align.
Could anybody help me?

For a one line use ALIGN_JUSTIFIED_ALL, more than one line use ALIGN_JUSTIFIED.

If you are using for C#, then:
p.Alignment = Element.ALIGN_JUSTIFIED;

Related

How can I convert text with spaces to single space in TextFormField?

How can I convert text with too many spaces to single space? For example name: "Brad Pit" there is only one space between first and last name but user can write "Brad (4 space) Pit" with too much space. How can I reduce this to single space in TextFormField?
Code:
void main() {
var name = 'Pratik Butani';
print(name);
print(name.replaceAll(new RegExp(r"\s+"), " "));
}
Output:
Pratik Butani
Pratik Butani
Explanation: Here I have used RegExp which will take continue spaces using \s+ and It will be replaced by one space.
You can this demo on DartPad
Do let me know if you have any confusion.
To reduce multiple space to a single space
Please refer to this answer
https://stackoverflow.com/a/1981366/9414608
Also you can prevent users from adding spaces in the TextFormField by using inputFormatters
Please refer to this answer
https://stackoverflow.com/a/59065304/9414608
flutterdartwhitespacestextformfieldstring
In Dart u can use:
print(yourString.trim())
to convert text with too many spaces
and u can try this
String name = 'Brad Pit ';
print(name.replaceAll(new RegExp(r"\s+"), ""));

Aligning Visio shape text to the top and to the left using Powershell

I'm having problems with the second line below. How can I use PowerShell to align the shape text?
$squareshape.text = "abc";
$squareshape.align.top;
try this code
$squareshape.cells('VerticalAlign') = 0
$squareshape.cells('Para.HorzAlign') = 0

jasperreports html split text without whitespaces

String example:
"fooTextExmaple" x 100
So, it looks like one large word without whitespaces.
I have no problems with same strings in pdf, however,
I have problems dealing with large text without whispaces while exporting to HTML.
It looks like long row which does not fit any fixed width. The row's width would change dynamically by adding new chars without whitespaces to this string:
Is there any way to deal with this problem?
EDIT:
The way like it does not work:
PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
req.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, print);
exporter = new HtmlExporter();
SimpleHtmlReportConfiguration configuration = new SimpleHtmlReportConfiguration();
configuration.setWrapBreakWord(true);
exporter.setConfiguration(configuration);
exporter.setExporterInput(new SimpleExporterInput(print));
SimpleHtmlExporterOutput output = new SimpleHtmlExporterOutput(out);
String[] uriParts = req.getRequestURI().split("/");
output.setImageHandler(new WebHtmlResourceHandler("/" + uriParts[1] + "/image?image={0}"));
exporter.setExporterOutput(output);
exporter.exportReport();
Set the net.sf.jasperreports.text.save.line.breaks property to true.
Read more about it at http://jasperreports.sourceforge.net/config.reference.html
The net.sf.jasperreports.export.html.wrap.break.word property is supposed to help as well, but it only works in some browsers.

Apache POI word, how to remove the white space (new line) from beginning of table cell?

I am only able to style the contents of a table cell using paragraph element to change the color of the text for example.
When i create a paragraph inside the table it creates a new line. For my project i need these cell to be as small as possible for that i am using
tr.setHeight(300);
tr.getCtRow().getTrPr().getTrHeightArray(0).setHRule(STHeightRule.EXACT);
that works when there is no blank lines.
the code below is the problem
XWPFTable tb = document.createTable(2,2);
XWPFParagraph p1 = tb.getRow(0).getCell(0).addParagraph();
XWPFRun p1run = p1.createRun();
p1run.setText("why is there a space");
XWPFParagraph p2 = tb.getRow(1).getCell(1).addParagraph();
XWPFRun p2run = p2.createRun();
p2run.setText("still there ");
This create this output
http://i.stack.imgur.com/bSONW.png
I found the solution here..
Duplicate Table Paragraphs in Docx created with Apache POI
It seems you add a paragraph then remove the original with this code:
XWPFParagraph paragraph = cell.addParagraph();
cell.removeParagraph(0);
Before adding a paragraph clearing text in cell worked for me
cell.clearText();
This works >>
Use cell.getParagraphs().get(0) instead of cell.addParagraph().

What is wrong with my 'selecting' code? (VB)

I have the following code in VB:
If TextBox1.Text = (Label2.Select(0, 1) Then
TextBox2.Focus()
End If
But it doesnt't work :(
This is what my code is supposed to do:
If the text in texbox1 is the same as the first letter of label 2
Then move cursor to textbox2
You're trying to write Label2.Text.Substring(0,1).