Document.add() will break at chunks. Use ColumnText and the chunks
will keep together.

Paulo

On Wed, Jul 4, 2012 at 9:54 PM, Viktor Zeltser <[email protected]> wrote:
> Paolo,
>
> Thank you for your response.
>
> Unfortunately, non-breaking space does not help me. Please consider my
> example again:
>
>     <p>I have a line of text with a <b>formatting</b>…</p>
>
> You see, there is no any space between word "formatting" and ellipsis
> character, and there should not be any. That's the point, the word
> "formatting" and ellipsis should not be separated. Even worse, I tried
> inserting non-breaking space and it does not keep them together on same line
> — because word "formatting" is bold and ellipsis is not, we have to create
> two separate Chunks for them, and that allows ellipsis, being a separate
> Chunk, to break away to the next line, regardless of the non-breaking space,
> am I wrong?
>
> Just in case, here is a simple code to reproduce the problem:
>
>   Document document = new Document();
>   document.setPageSize(PageSize.A6);
>   PdfWriter writer = PdfWriter.getInstance(document, new
> FileOutputStream("c:/tmp/test.pdf"));
>   document.open();
>   XMLWorkerHelper.getInstance().parseXHtml(writer, document, new
> FileReader("c:/tmp/test.html"));
>   document.close();
>
> And the test.html is:
>
>   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
>   <html xmlns="http://www.w3.org/1999/xhtml"; lang="en" xml:lang="en">
>   <body>
>     <p>__ I have a line of text with a <b>formatting</b>…</p>
>   </body>
>   </html>
>
> And the desired behavior is demonstrated by browser when opening that same
> html file: if the window is too narrow to fit that phrase, then the word
> "formatting" and ellipsis go to the next line together, never separated.
>
> Thank you very much,
>
> --
> Viktor
>
>
> On Wed, Jul 4, 2012 at 2:00 AM, Paulo wrote:
>>
>> Use a non-breaking space (\u00a0).
>>
>> Paulo
>>
>> On Tue, Jul 3, 2012 at 8:15 PM, Viktor wrote:
>>
>> > Hello,
>> >
>> > Is there a way to make certain chunks keep together on same line?
>> >
>> > For example, I have an html like this:
>> >
>> >     <p>I have a line of text with a <b>formatting</b>…</p>
>> >
>> > When I parse it, it ends up being three chunks, the last being ellipsis
>> > character. And if it doesn't fit, the  ellipsis could break away to the
>> > next
>> > line like this:
>> >
>> >     I have a line of text with a formatting
>> >     …
>> >
>> > Is there a way to prevent ellipsis breaking away from "formatting"?
>> >
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples:
> http://itextpdf.com/themes/keywords.php

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to