How to split iText Paragraph into multiple columns? - itext

Is there any way I can split Paragraph data into multiple columns?
Current Paragraph
Something in the paragraph which need to read by the end user.
Required Paragraph
Something in --------- to read by
the paragraph --------- the end user.
which need ---------
Basically user wants to read shorter lines rather than a long line.
I am using itextpdf-5.4.4.jar Paragraph to display data.
Thanks for you help

Please read my answer to the question How to draw a rectangle around multiline text for which I've written DrawRectangleAroundText.
In this example, we have a Paragraph with plenty of text:
Paragraph p = new Paragraph("This is a long paragraph that doesn't"
+ "fit the width we defined for the simple column of the"
+ "ColumnText object, so it will be distributed over several"
+ "lines (and we don't know in advance how many).");
And we distribute this paragraph over different lines like this:
For this purpose, we use the ColumnText class:
ct = new ColumnText(cb);
ct.setSimpleColumn(300f, 500f, 430f, 780f);
ct.addElement(p);
ct.go();
This is only a simple proof of concept. For more info about ColumnText, read the section Absolute positioning of text in the free ebook The Best iText Questions on StackOverflow. This way, you'll be able to avoid posting a question that can be answered by recycling an answer that was posted less than a day ago.

Related

Need help in Numbering paragraph in Msword

I receive a word document daily which has many paragraph, Which is seperated by special character " ---------" at the end of each paragraph, I need help in numbering each of the paragraph like 1,2,3, till 300 max, I do this process manually, Is there any way to automate this process, Any help would really help me.
I do this process manually

Protractor paste list of numbers into text field

I am currently trying to use protractor to upload multiple numbers eg, 23245, 23343, 34324 into a text field these numbers can be copied out of a excel spread sheet id column and pasted into the text field on the application. The application will then add the ids onto a table. Each id will have a new row. Does anyone know if this can be done. Currently I am only sending one number into the text field. But the text field can also receive multiple numbers...
I don't fully understand the question, could you provide more context? What are multicity numbers?
If I were to send multiple numbers to a text field, I would probably:
<element>.sendKeys("1 \n 2 \n 3 \n 4 \n");
Or something similar. Please provide more information about the question so I/we can help better.
N
NOTE: I ORIGINALLY HAD THE SLASHES THE WRONG WAY, IVE EDITED THE ABOVE SNIPPET TO NOW BE CORRECT, MY BAD!

number representing text string

A web form collects data on students in a band organization at school. The form data is fed into a google sheet that then populates a merge template and the merged forms are emailed to the recipient. A parent needs to print, sign and turn in the forms. There are hundreds of kids in this band and at registration time when the forms are turned in it is easier to sort all the papers in the stack if you have a short sort number in the corner... Volunteer kids don't apply alphabetization well. I'm trying to create a formula that will give me that sorting number to merge onto the header of each page of the PDF they receive after submitting the form. I want it based on last name and then first name and be able to create that number (in the google sheet) on the fly because the merging happens almost instantly when the user submits the form. Hence, an excel type formula is desired that will result in a number representing the kids name. I'd like for each number to be unique but some names are the same for the first few letters, also some names are only 2 characters long. I tried making A=10, B=11, z=35 etc. (so all are 2 digits) So, using only the first 3 characters, Bob Jones would = 192423112411 - hardly easy to sort the paper at a glance and it doesn't really differentiate between Bob Janes either. 4 digits is preferable. I also looked at =code() formula and it came out with long numbers too. Any advice is appreciated. Thanks!
Side note: What method do spreadsheets use to sort text? Do they weight the characters or what? Before I got the automerge thing to work I assigned each kid in the list a number higher than the one below and lower than above (on the sheet), then did the merge.
One option is to:
sort the name list alphabetically
add a sort number column, and put a =TEXT(row(),"0000") formula to generate a unique ID
on the merge spreadsheet, use a VLOOKUP function to retrieve the unique ID for that specific name.
First off, that wall of text was kind of hard to read through. Please try and do a little formatting so the people trying to help you can easily follow what you're trying to convey.
Personally I would suggest a hyphenated system. First initial of last name converted to a number, followed by a hyphen, followed by the first two letters of their first name converted to numbers.
Bob Jones becomes 11-1956 assuming you differentiate between upper and lower case, or 11-1924 if you convert everything to upper case, which I guess makes more sense.
You could use this VBA function to convert names to a system like that:
Function ConvertToIndex(strInput As String) As String
Dim strLast As String
Dim arrName() As String
Dim strFirst1 As String
Dim strFirst2 As String
arrName = Split(strInput, " ")
strLast = Mid(arrName(1), 1, 1)
strFirst1 = Mid(arrName(0), 1, 1)
strFirst2 = Mid(arrName(0), 2, 1)
ConvertToIndex = Asc(UCase(strLast)) - 55 & "-" & Asc(UCase(strFirst1)) - 55 & Asc(UCase(strFirst2)) - 55
'MsgBox ConvertToIndex
End Function
Thank you Tim, Nutsch and Mad Tech for your responses. I appreciate your input. Sorry the paragraph was so long, I get wordy. Because the members get their merged PDF sheet immediately after submitting I need the number to be based on the name as soon as it's entered, not after the fact; so I was looking for a formula that would reside in the sheet. Interesting VBA function too though. I'll settle for numbering them afterwards, maybe when the sheets are turned in. By then I'll know all who are in the band and can assign numbers like before. Thanks again!

Regex to match lines between two expressions

I am sorting some data and want to 'cut' out some rubbish between two bits of useful information.
Eg:
Useful one
rubbish
rubbish //rubbish here is covered by [.*], but the number of lines can be any number 1 or above
rubbish
useful two
I have successfully matched the useful parts of my information, I just need to know how to match the rubbish stuff. The pattern is as follows: useful, new line (no content), new line (no content), rubbish, new line (no content), new line (no content), useful.
The important part of this is that the rubbish section can vary in number of lines, but always has at least one line. Im not sure if i described this very well, any help is appreciated.
The best way I know of doing this is to do this
(exp1)(.+?)(exp2)
and replace or use in code the two groups
$1 $3
where $x is the group place holder
comment me for more specific syntax
your regexp (rubbish\s+)(rubbish\s+)(rubbish)
Try a pattern like (useful\n\n\n(.*)\n\n\nuseful\n)+, capturing rubbish into parenthesis. Improving and applying this pattern depends on your needs and your code.

How to display a lot of read only text in GWT?

I have a requirement to display a somewhat large amount of text, read only to the user. It can be up to a maximum of 500 characters, which isn't excessive, but it's still a lot. Since it's read only I was thinking of a label a versus text area box, if it can handle that much. Is there a better way to do this than I'm not aware of?
Thanks,
James
Label works fine. Just remember that the default css for white-space collapses whitespace rather aggressively. If your text includes line breaks you may want to switch to pre or pre-wrap.
The most straightforward (if not necessarily most correct) way to do that is:
Label myLabel = new Label();
myLabel.getElement().getStyle().setProperty("whiteSpace", "pre");
Note the Camel Case on the CSS attribute.
Either a Label or a TextBox will definitely be able to handle 500 characters.
Think of all the blog posts, Wikipedia articles, Stack Overflow questions, longer than that that have been written. They were all composed in a text box and displayed in a div. You'll be fine.
500 chars is no big deal so it will be ok. Label is ultimately calling element.innerHTML = text which is a browser-native Javacript function that can handle any amount of text.