Mega Code Archive

 
Categories / Java / PDF RTF
 

Pdf action

import java.awt.Color; import java.io.FileOutputStream; import com.lowagie.text.Anchor; import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.FontFactory; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfWriter; public class JumpLocalDestinationPDF {   public static void main(String[] args) {     Document document = new Document();     try {       PdfWriter.getInstance(document, new FileOutputStream("JumpLocalDestinationPDF.pdf"));              document.open();       Paragraph paragraph = new Paragraph();       Anchor anchor1 = new Anchor("some text", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color(0, 0, 255)));       anchor1.setName("top");       paragraph.add(anchor1);       document.add(paragraph);              Anchor anchor2 = new Anchor("please jump to a local destination", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255)));       anchor2.setReference("#top");       document.add(anchor2);            } catch (Exception e) {       System.err.println(e.getMessage());     }     document.close();   } }                     itext.zip( 1,748 k)