【问题标题】:Create HyperLink in dynamic pdf using iText in android在android中使用iText在动态pdf中创建超链接
【发布时间】:2013-06-18 10:25:12
【问题描述】:

我动态创建了一个pdf,现在我想在pdf中添加链接。可能吗?

如果是这样,如果您有任何想法,请告诉我。谢谢。

【问题讨论】:

  • 你试过我的解决方案了吗?

标签: java android pdf pdf-generation itext


【解决方案1】:

试试,下面的文章链接解释了在 itext pdf 中添加锚点

http://tutorials.jenkov.com/java-itext/anchor.html

和上面文章中的示例代码链接

import com.itextpdf.text.*;
import com.itextpdf.text.pdf.PdfWriter;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

    public class AnchorExample {

      public static void main(String[] args) {

        Document document = new Document();

        try {
          PdfWriter.getInstance(document,
                new FileOutputStream("Anchor.pdf"));

          document.open();

          Paragraph paragraph = new Paragraph();
          paragraph.add(new Phrase("You can find the IText tutorial at "));


          Anchor anchor = new Anchor(
              "http://tutorials.jenkov.com/java-itext/index.html");
          anchor.setReference(
              "http://tutorials.jenkov.com/java-itext/index.html");

          paragraph.add(anchor);

          document.add(paragraph);

          document.close();

        } catch (DocumentException e) {
          e.printStackTrace();
        } catch (FileNotFoundException e) {
          e.printStackTrace();
        }

      }
    }

【讨论】:

  • 谢谢你,但是当我尝试这个代码时 Anchor anchor_mobileapp = new Anchor("App link"); anchor_mobileapp.setReference("mycoolapp://");此代码不适用于 android 手机(adobe reader 移动应用程序)。您的代码运行良好。
  • 大家好,你们有什么解决办法吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-31
相关资源
最近更新 更多