Add anchor to pdf using itext java

前端 未结 1 1884
甜味超标
甜味超标 2021-01-26 16:19

I am trying to add anchor(named destinations) to pdf using itext java api. But it\'s not working.When I click the text , nothing happens.This is what I am doing .



        
1条回答
  •  旧时难觅i
    2021-01-26 16:32

    Try this. It worked for me. setLocalGoto() and setLocalDestination() will do the magic.

    Chunk chunk = new Chunk("Contact information");
        chunk.setLocalGoto("contact");  
        document.add(new Paragraph(chunk));
        document.newPage();
    
        chunk chunk1 = new Chunk("Contact information");
        chunk1.setLocalDestination("contact");
        Chapter chapter = new Chapter(new Paragraph(chunk1),1);    
        chapter.setNumberDepth(0);
        document.add(chapter);
    

    0 讨论(0)
提交回复
热议问题