{oapdf_gg}
Chapter III anchor , lists and notesanchorwe all know that in the HTML hypertext links, when we click on certain words, you can jump to other pages online. Also in the PDF of this function can be achieved. In fact, the entire section of Chapter XI on the PDF link in the introduction, but this is iText more advanced applications, this chapter we deal with simple iText. If you want to add a document to external links (such as the use of URL links to other documents on the WEB), you can simply use the Anchor object, it is derived from Phrase object, use the same method. There are only two additional methods of the definition of two additional variables:setName and setReference. External linksexample: Anchor anchor = new Anchor ( "website", FontFactory.getFont (FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color (0, 0, 255 ))); anchor.Reference = "http://itextsharp.sourceforge.net"; anchor.Name = "website"; If you want to add the internal link, select the link you need a different name, as you phase in the HTML to use the same name as the anchor. To that end, you need to add a "#." internal linkexample: Anchor anchor1 = new Anchor ( "This is an internal link "); anchor1.Name = "link1"; Anchor anchor2 = new Anchor ( "Click here to jump to the internal link "); anchor.Reference = "# link1"; link these two examples, see sample code 0301. listthrough Class List and ListItem, you can add a list of the PDF document, for the list you can choose whether or not to sort. to sort a list of examples: List list = new List (true, 20); list.Add (new ListItem ( "First line ")); list.Add (new ListItem ( "The second line is longer to see what happens once the end of the line is reached. Will it start on a new line ?")); list.Add (new ListItem ( "Third line ")); results are as follows:
not sort the following example: List overview = new List (false, 10); overview.Add (new ListItem ( "This is an item ")); overview.Add ( "This is another item "); results are as follows:
you can change the list of symbols setListSymbol methods: //use the string as a list of symbols list1.ListSymbol = "*"; //use Chunk as a list of symbols (including "•" character) list2.ListSymbol = new Chunk ( "\ u2022", FontFactory.getFont (FontFactory.HELVETICA, 20 )); //use image as a list of symbols list3.ListSymbol = new Chunk (Image.getInstance ( "myBullet.gif"), 0, 0); can also use the method set setIndentationLeft and setIndentationRight indent, indented list of symbols set in the constructor. More examples please see the sample code 0302. |