Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What replaces chunk in iText 7?

Tags:

java

itext7

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?

like image 466
OldAndTired Avatar asked May 28 '16 16:05

OldAndTired


People also ask

What is chunk in iText?

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.

Is iText same as iTextSharp?

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.

What are chunks in Java?

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.

Is iText free for commercial use?

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.


1 Answers

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.

like image 91
Alexey Subach Avatar answered Oct 20 '22 02:10

Alexey Subach