Attempting to use iText 7 in java. Want to have part of a paragraph be bold. Apparently in earlier releases this was done by formatting "chunks" separately then adding them to the paragraph. Apparently "chunks" don't exist in iText 7. What is the procedure for iText 7?
Chunk class in IText represents the smallest possible "chunk" of text. A Chunk can contain as little as a single character, up to several sentences. Notice how sentence 1 and sentence 6 are printed ontop of each other. The IText Chunk object does not add line breaks, paragraph spacing or any other kind of spacing.
iText vs iTextSharp As you can tell from the historical overview, iTextSharp has always been kept in sync with iText, but before version 5, there was a difference in version numbers. Starting with version 7, the name iTextSharp is no longer used in favor of using the name iText.
A chunk is represented as a single 64-bit value where the high-order 48 bits point to the location of the start of a compressed BGZF block within a BGZF file and the low-order 16 bits point to a position within the decompressed data in the BGZF block.
This license is a commercial license. You have to pay for it. To answer your question: iText can be used for free in situations where you also distribute your software for free. As soon as you want to use iText in a closed source, proprietary environment, you have to pay for your use of iText.
Text
in com.itextpdf.layout.element
is meant to be an alternative for Chunk
.
To make a part of a paragraph bold, you would need a bold font to be specified for a piece of a text.
Paragraph p = new Paragraph();
p.add(new Text("this will be in bold").setFont(boldFont));
Alternatively, you can rely on iText to simulate bold for regular font, but this is not a preferred way.
p.add(new Text("bold will be simulated for regular font").setBold());
Please check out the jumpstart tutorial written by Bruno Lowagie.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With