Source Code : Creates 2 documents with links to each other

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Creates 2 documents with links to each other

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 RemoteGotoPDF {
   public static void main(String[] args) {
        Document document = new Document();
        try {
            PdfWriter writerA = PdfWriter.getInstance(document, new FileOutputStream("DocumentA.pdf"));
            PdfWriter writerB = PdfWriter.getInstance(document, new FileOutputStream("DocumentB.pdf"));
            document.open();
            
            Paragraph pa = new Paragraph(new Chunk("Click this paragraph to go to a certain destination on document B").setRemoteGoto("DocumentB.pdf", "test"));
            Paragraph pb = new Paragraph(new Chunk("Click this paragraph to go to a certain destination on document A").setRemoteGoto("DocumentA.pdf", "test"));
            
            // a special remote goto
            Paragraph pc = new Paragraph("you can also jump to a ");
            pc.add(new Chunk("specific page on another document", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.ITALIC)).setRemoteGoto("DocumentB.pdf", 1));
            
            document.add(pa);
            document.add(pb);
            document.add(pc);

            document.add(pa);
            document.add(pb);
            document.add(pc);

            document.add(pa);
            document.add(pb);
            document.add(pc);
        }
        catch(Exception e) {
            System.err.println(e.getMessage());
        }
        document.close();
    }
}
           
       

Thank with us