- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
Calls method from listing 3.13 in Java
Calls method from listing 3.13 QR Code 2d Barcode Drawer In Java Using Barcode encoder for Java Control to generate, create QR image in Java applications. www.OnBarcode.comQR Code ISO/IEC18004 Reader In Java Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comCreates ColumnText object and adds content
PDF417 Maker In Java Using Barcode generation for Java Control to generate, create PDF 417 image in Java applications. www.OnBarcode.comEncode EAN-13 Supplement 5 In Java Using Barcode creation for Java Control to generate, create UPC - 13 image in Java applications. www.OnBarcode.comThe result is shown in figure 3.10. Now you re ready to go to the film festival! We aren t finished discussing the ColumnText object yet. This example worked out fine because you were able to fit the content inside the rectangles reserved for the screenings. But what would have happened if the text didn t fit Also, you ve been adding a Phrase object to the column to display its contents at an absolute position. Can you add other objects such as Paragraphs, Lists, and Images with the ColumnText object The answer to the first question will be explained in section 3.3.1; the answer to the second question is yes, but not in text mode, only in composite mode. ANSI/AIM Code 128 Generation In Java Using Barcode maker for Java Control to generate, create Code 128 Code Set B image in Java applications. www.OnBarcode.comCode-128 Creator In Java Using Barcode encoder for Java Control to generate, create Code 128C image in Java applications. www.OnBarcode.comWorking with the ColumnText object
Generate Barcode In Java Using Barcode generator for Java Control to generate, create Barcode image in Java applications. www.OnBarcode.comCode 11 Drawer In Java Using Barcode generator for Java Control to generate, create Code 11 image in Java applications. www.OnBarcode.comThe finished timetable, now with the movie titles
QR-Code Decoder In Java Using Barcode reader for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comDenso QR Bar Code Printer In None Using Barcode generator for Office Word Control to generate, create QR Code image in Microsoft Word applications. www.OnBarcode.comUsing ColumnText in text mode
Matrix 2D Barcode Creation In .NET Using Barcode encoder for Visual Studio .NET Control to generate, create 2D Barcode image in .NET applications. www.OnBarcode.comMake UCC - 12 In Objective-C Using Barcode generator for iPhone Control to generate, create GS1 128 image in iPhone applications. www.OnBarcode.comIn section 2.3.3, you created PDF documents with movie information that was organized in Paragraphs. Suppose you want to repeat this exercise, but now you want to organize the same information in columns, as is shown in figure 3.11. GTIN - 13 Generation In Visual Basic .NET Using Barcode maker for Visual Studio .NET Control to generate, create EAN 13 image in .NET applications. www.OnBarcode.comRecognizing ANSI/AIM Code 128 In Java Using Barcode decoder for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comFigure 3.11 Movie information, organized in columns
Creating UCC.EAN - 128 In None Using Barcode creator for Word Control to generate, create EAN / UCC - 14 image in Office Word applications. www.OnBarcode.comPrint Barcode In None Using Barcode drawer for Word Control to generate, create Barcode image in Office Word applications. www.OnBarcode.comAdding content at absolute positions
Paint USS Code 39 In Java Using Barcode creator for Android Control to generate, create USS Code 39 image in Android applications. www.OnBarcode.comReading USS-128 In Visual Basic .NET Using Barcode decoder for VS .NET Control to read, scan read, scan image in VS .NET applications. www.OnBarcode.comInstead of the setSimpleColumn() method from listing 3.15, which can be used for a single Phrase, you ll use addText() to add a series of Phrases and Chunks. QR Code JIS X 0510 Generation In C# Using Barcode creation for .NET Control to generate, create Denso QR Bar Code image in Visual Studio .NET applications. www.OnBarcode.comPaint Code 3 Of 9 In .NET Using Barcode maker for ASP.NET Control to generate, create Code39 image in ASP.NET applications. www.OnBarcode.comADDING CONTENT WITH ADDTEXT() Take a look at the code used to produce the columns shown in figure 3.11.
Listing 3.16 MovieColumns1.java
List movies = PojoFactory.getMovies(connection); ColumnText ct = new ColumnText(writer.getDirectContent()); Creates column for (Movie movie : movies) { ct.addText(createMovieInformation(movie)); Adds content ct.addText(Chunk.NEWLINE); } ct.setAlignment(Element.ALIGN_JUSTIFIED); ct.setExtraParagraphSpace(6); Defines column ct.setLeading(0, 1.2f); properties ct.setFollowingIndent(27); int linesWritten = 0; int column = 0; Initializes status int status = ColumnText.START_COLUMN; while (ColumnText.hasMoreText(status)) { Loops until column is empty ct.setSimpleColumn( COLUMNS[column][0], COLUMNS[column][1], Defines position COLUMNS[column][2], COLUMNS[column][3]); on page ct.setYLine(COLUMNS[column][3]); status = ct.go(); Writes content linesWritten += ct.getLinesWritten(); column = Math.abs(column - 1); if (column == 0) Switches columns document.newPage(); } ct.addText(new Phrase("Lines written: " + linesWritten)); ct.go(); B C D E F G
Just as in listing 3.15, you create a ColumnText object, passing a PdfContentByte object as a parameter. You add content (Phrase and/or Chunk objects) to this column with the addText() method. You set the properties for the text that will be rendered, such as the alignment, the leading, extra space between paragraphs, and special indentations. You perform some initializations. The linesWritten parameter informs you about the number of lines that have been written. The column variable (keeping track of the column number) and the status of the ColumnText object are more important. You want all the content added to the ColumnText object to be rendered, so you invoke the go() method in a loop as long as the ColumnText.NO_MORE_TEXT bit isn t set in the status value. You define the dimensions of the column where the next block of text will be added. In this case, COLUMNS is a two-dimensional array, containing two sets of four values (one rectangle for each column). You also define the Y position; that s the vertical start position of the text in the column. Working with the ColumnText object
Lines of text are written as soon as you invoke the go() method. Text that didn t fit the current column remains in the ColumnText object. The content that was rendered is consumed; it s no longer present in the ColumnText object. Each time a column is written, you have to switch to the next column. If there are no more columns on the current page, you have to go to a newPage(). In this example, you re changing the properties of the text. The setAlignment() method is similar to the Paragraph method with the same name. It takes the same parameters: Element.ALIGN_LEFT, Element.ALIGN_RIGHT, Element.ALIGN_JUSTIFIED, and Element.ALIGN_JUSTIFIED_ALL. The setLeading() method comes in two flavors: in listing 3.16, you define an absolute leading of 0 pt and a relative leading of 1.2. The resulting leading will be 0 + 1.2 x 12 pt (the font size) = 14.4 pt. In listing 3.17, you ll use the other setLeading() method to define a leading of 14 pt. Let s examine the properties that can be set for the text that has to be rendered.
|
|