Grunow, André (beeone extern) wrote:

Thanks, Bruno, for your very fast answer.

Unfortunately, it doesn't work. :-(
But it does!
Have a look at the attached source code: NonBreakingSpace.java
and the resulting nbsp.pdf

After replacing all characters with the unicode you proposed, the result did 
not change: the words are still seperated.

Changing 'all' characters?
I hope you didn't replace all space characters.
You should only change those between words that may not be separated.
Otherwise the sentence will break when the end of the line is reached anyway.

When I debug the code, then I can see, that after replacing the "blank"-character with 
the unicode-character, there are still "normal" blanks inside.
Hmm... are you sure you replaced the characters?
What if you try my small code sample?
Maybe you have replaced the characters in the wrong String...
best regards,
Bruno

Attachment: nbsp.pdf
Description: Adobe PDF document

package test;

import java.io.FileOutputStream;
import java.io.IOException;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;

public class NonBreakingSpace {
	public static void main(String[] args) {

		String string1 = "Look at this paragraph with a lot of different products and at least one product called Kautschuk Plant, where the plant itself can be planted, on the other hand, there are some more words with absolutely no sense.";
		String string2 = "Look at this paragraph with a lot of different products and at least one product called Kautschuk\u00a0Plant, where the plant itself can be planted, on the other hand, there are some more words with absolutely no sense.";
		// step 1: creation of a document-object
		Document document = new Document();
		try {
			// step 2:
			// we create a writer
			PdfWriter.getInstance(
					// that listens to the document
					document,
					// and directs a PDF-stream to a file
					new FileOutputStream("nbsp.pdf"));
			// step 3: we open the document
			document.open();
			// step 4: we add a paragraph to the document
			document.add(new Paragraph(string1));
			document.add(new Paragraph(string2));
		} catch (DocumentException de) {
			System.err.println(de.getMessage());
		} catch (IOException ioe) {
			System.err.println(ioe.getMessage());
		}

		// step 5: we close the document
		document.close();
	}
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to