在itext中为pdf

时间:2015-06-09 12:07:43

标签: java pdf itext

我想使用itext从现有文件(DXL - > Domino XML)创建pdf文件,这些文件可以包含附件,当发生这种情况时,需要将附件导入到新pdf中,并在同一个地方添加注释链接它在前一个文件中。

使用注释链接我指的是双击然后打开附件的符号(例如Adobe标准是图钉)

到目前为止,我设法创建了一个pdf文件并附加了这样的注释链接,但是我通过使用试错法放置它(更改x,y然后再次使用硬编码文本进行测试来测试它)。

当有大约3个行间距时,它意味着至少有一个附件,它们需要再次放在那里。 不幸的是我无法发布任何关于我的pdf外观的图片,因为我没有代表 - >新用户:/

现在我的问题是如何找到这些“空行”以在那里添加注释链接,如果有多个,我如何将它们相互插入而不是全部插入一个点?

________________编辑_____________________

public void createPdf(String filename) throws DocumentException, IOException {
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        List list = new List(List.UNORDERED);

        Paragraph pa1 = new Paragraph();
        pa1.add(
            "This is some textThis is some textThis is some textThis is some textThis is some textThis is some textThis is some              textThis is some textThis is some textThis is some textThis is some textThis is some textThis is some textThis is                some textThis is some textThis is some text\n");

        Paragraph pa2 = new Paragraph();
        pa2.add("This is some textThis is some textThis is some Text\n");

        list.add("This is a list elementThis is a list element\n");

        list.add("This is a list elementThis is a list element\n");

        Paragraph pa3 = new Paragraph();
        pa5.add("This is some textThis is some textThis is some textThis is some textThis is some text.\n");

        Paragraph pa4 = new Paragraph();
        pa6.add(
            "This is some textThis is some textThis is some textThis is some textThis is some textThis is some textThis is some              textThis is some textThis is some textThis is some textThis is some textThis is some textThis is some text\n");

        Paragraph pa5 = new Paragraph();
        pa7.add(
            "This is some textThis is some textThis is some textThis is some textThis is some textThis is some textThis is some              textThis is some textThis is some textThis is some textThis is some textThis is some text \n");

        document.open();
        document.add(pa1);
        document.add(Chunk.NEWLINE);
        document.add(pa2);
        document.add(Chunk.NEWLINE);
        document.add(list);
        document.add(Chunk.NEWLINE);
        document.add(pa3);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(pa4);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(pa5);
        document.close();
}

最诚挚的问候 克里斯托弗

0 个答案:

没有答案