I am creating a PDF using iText. I want to insert blank lines between paragraphs and tables.
How can I achieve this?
Choose View > Show/Hide > Rulers & Grids > Rulers. Do one of the following: Drag down from the horizontal ruler to create a horizontal guide, or drag right from the vertical ruler to create a vertical guide.
Draw on any PDF document. Select the marker icon in the Comment toolbar to activate the Draw Free Form tool. Draw on the PDF. You can change line color, thickness, and opacity in the Comment toolbar. Once you're finished, save your PDF.
You can trigger a newline by inserting Chunk.NEWLINE into your document. Here's an example.
public static void main(String args[]) { try { // create a new document Document document = new Document( PageSize.A4, 20, 20, 20, 20 ); PdfWriter.getInstance( document, new FileOutputStream( "HelloWorld.pdf" ) ); document.open(); document.add( new Paragraph( "Hello, World!" ) ); document.add( new Paragraph( "Hello, World!" ) ); // add a couple of blank lines document.add( Chunk.NEWLINE ); document.add( Chunk.NEWLINE ); // add one more line with text document.add( new Paragraph( "Hello, World!" ) ); document.close(); } catch (Exception e) { e.printStackTrace(); } } Below is a screen shot showing part of the PDF that the code above produces.

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