Local Destination : Chunk « PDF « Java Tutorial






import java.awt.Color;
import java.io.FileOutputStream;

import com.lowagie.text.Chunk;
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 MainClass {
  public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter writerA = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    PdfWriter writerB = PdfWriter.getInstance(document, new FileOutputStream("3.pdf"));

    document.open();
    Font font = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color(0, 0, 255));
    Paragraph p1 = new Paragraph("1");
    Chunk chunk = new Chunk(" 2", font);
    chunk.setRemoteGoto("dog.pdf", "2");
    p1.add(chunk);

    Paragraph p3 = new Paragraph("test");
    p3.add(new Chunk("test.", font).setLocalDestination("2"));

    writerB.pause();
    document.add(p1);
    writerB.resume();
    writerA.pause();
    document.add(p3);
    writerB.pause();
    document.newPage();
    document.add(new Paragraph("page 2"));
    document.newPage();
    document.add(new Paragraph("page 3"));
    writerB.resume();
    document.close();
  }
}








29.16.Chunk
29.16.1.PDF file with hyphenated text
29.16.2.Chunk with anchor
29.16.3.Chunk with action
29.16.4.Width of a chunk
29.16.5.Chunk.NEWLINE
29.16.6.Scale Chunk
29.16.7.Use TextRise of a chunk to create supscript and subscript
29.16.8.Background of a chunk
29.16.9.Chunk Underline
29.16.10.Chunk Text Render Mode: PdfContentByte.TEXT_RENDER_MODE_FILL
29.16.11.Chunk Text Render Mode: PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE
29.16.12.Chunk Text Render Mode: PdfContentByte.TEXT_RENDER_MODE_INVISIBLE
29.16.13.Chunk Text Render Mode:PdfContentByte.TEXT_RENDER_MODE_STROKE
29.16.14.Chunk in bold
29.16.15.Create chunk from string
29.16.16.Skew a chunk
29.16.17.Create Phase from chunk
29.16.18.Local Destination