{oapdf_gg}
paragraphparagraph is a series of blocks and (or) phrases. With the same phrase, paragraph spacing are identified. Users can also specify the indent; in the side and (or) the right to retain a certain blank paragraph can be left-justified, right-aligned and center aligned. Document is added to each of the paragraphs are automatically starts a new line. There are several ways to build a paragraph, such as: Paragraph p1 = new Paragraph (new Chunk ( "This is my first paragraph.", FontFactory.getFont (FontFactory.HELVETICA, 12 ))); Paragraph p2 = new Paragraph (new Phrase ( "This is my second paragraph.", FontFactory.getFont (FontFactory.HELVETICA, 12 ))); Paragraph p3 = new Paragraph ( "This is my third paragraph.", FontFactory.getFont (FontFactory.HELVETICA, 12)); Someall objects will be added to the paragraph: p1.add ( "you can add strings,"); p1.add (new Chunk ( "you can add chunks")); p1.add (new Phrase ( "or you can add phrases .")); Description:A one paragraph and only one pitch, if you add a phrase in different fonts or block, the original pitch is still valid, you can SetLeading to change the pitch, but all the contents of paragraphs will be using the new The spacing of. See sample code 0205. u to maintain the integrity of the paragraph sample code in 0206, we used setKeepTogether (true) method to try to be a paragraph on the same page, the method is not always effective, for example, not just the first paragraph of the page, they were divided into two parts. Was placed in the second paragraph of the second page, but along the cis to the third paragraph of the third page. a continuation of the fontfontextension you should have some rules of the application of these rules, see sample code 0207, when some of the elements we will use the specified font (non-default fonts) to create a phrase or a paragraph and then add more content, early object before the font style will be the continuation, see the "Hello 1!" and "Hello 2": Phrase myPhrase = new Phrase ( "Hello 2!", new Font (Font.TIMES_NEW_ROMAN, 8, Font.BOLD )); myPhrase.Add (new Phrase ( "some other font", new Font (Font.HELVETICA, 8, Font.ITALIC ))); myPhrase.Add (new Phrase ( "This is the end of the sentence. \ n", new Font (Font.TIMES_NEW_ROMAN, 8, Font.ITALIC ))); document.Add (myPhrase); we bold Times New Roman to start, add some text instead of using the Helvetica font specified style, we find that change has become a bold text, when we add some text using the Times New Roman font and italic style, the results of become bold italic. If we use FontFactory to create a font, font style will not be a continuation of another because FontFactory use technology to build a font: myPhrase = new Phrase ( "Hello 1bis!", FontFactory.getFont (FontFactory.TIMES_NEW_ROMAN, 8, Font.BOLD )); myPhrase.Add (new Phrase ( "some other font", FontFactory.getFont (FontFactory.HELVETICA, 8, Font.ITALIC ))); myPhrase.Add (new Phrase ( "This is the end of the sentence. \ n", FontFactory.getFont (FontFactory.TIMES_NEW_ROMAN, 8, Font.ITALIC ))); document.Add (myPhrase); In the above code, the use of Helvetica text fonts do not specify the font style (neither bold nor italic). Using Times New Roman only display additional text in italics. you can see we added a paragraph, add the paragraph as a phrase. Paragraph myParagraph = new Paragraph ( "Hello 1!", new Font (Font.TIMES_NEW_ROMAN, 8, Font.BOLD )); myParagraph.Add (new Paragraph ( "This is the end of the sentence.", FontFactory.getFont (new Font.TIMES_NEW_ROMAN, 8 ))); document.Add (myParagraph); you can not do so, but will lose the extension of the font style, the first paragraph do not create any fonts (eg fonts, we just give a spacing of 1.5 times), and then add the contents of the different parts.
myParagraph = new Paragraph (12); myParagraph.Add (new Paragraph ( "Hello 3!", new Font (Font.TIMES_NEW_ROMAN, 8, Font.BOLD ))); myParagraph.Add (new Paragraph ( "This is the end of the sentence.", new Font (Font.TIMES_NEW_ROMAN, 8, Font.ITALIC ))); document.Add (myParagraph); If you use a Phrase object, you will lose the same font style of the continuation of: myPhrase = new Phrase (12); myPhrase.Add (new Phrase ( "Hello 4!", new Font (Font.TIMES_NEW_ROMAN, 8, Font.BOLD ))); myPhrase.Add (new Phrase ( "This is the end of the sentence.", newFont (Font.TIMES_NEW_ROMAN, 8, Font.ITALIC ))); document.Add (myPhrase); Fuu change the partition Typically, when the text can not be on the line, the text will be cut into different parts, iText segmentation looks at first, if not found, the text will be truncated at the end. Some of the partition is scheduled to address such as "" space and "-" hyphens, but you can use the method to cover these setSplitCharacter default. 0208 in the sample code, you can see when the reach the end-of-line when a block is to be separated. Separator and then be replaced by point ".", The Bank of the characters is to be divided. |