Adding attachment links between lines in itext for pdf

226 views Asked by At

I want to use itext to create pdf files from existing files (DXL --> Domino XML) which can have attachments and when that happens the attachments need to be imported to the new pdf with an annotation link on the same place it was on the prior file.

With annotation link I mean a symbol to doubleclick and then open the attached file (e.g. Adobe standard is a pushpin)

So far I managed to create a pdf file and attach such a annotation link but I placed it by using the trial and error method (change x,y and then test again also with a hardcoded text to test it).

When there are about 3 linespaces it means, that there was at least one attachment and they need to be put there again. Unfortunately I can't post any pictures of how my pdfs look because I have no rep --> new user :/

Now my question is how can I find these "empty lines" to add annotation links there and if there are more than one how can I insert them one to another and not all on one point?

________________Edit_____________________

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();
}

Best Regards Christoph

0

There are 0 answers