I would guess, that an external link is not allowed in a PDF/A conformant 
document.

Regards,

/Gerold

-----Ursprüngliche Nachricht-----
Von: avchavan [mailto:avinash.cha...@capgemini.com] 
Gesendet: Freitag, 04. September 2015 15:20
An: itext-questions@lists.sourceforge.net
Betreff: [iText-questions] PdfAConformanceException while adding link(anchor) 
to a document iText5.5.6

I have the following example and i am coming across Exception in thread "main" 
com.itextpdf.text.pdf.PdfAConformanceException: Annotation of type /Link should 
have Contents key. Exception. I am trying to add some text as
link(anchor) in the PDF document with external link. Is there any issue with my 
approach of adding the link(anchor)? Am i missing anything?


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import com.itextpdf.text.Anchor;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.List;
import com.itextpdf.text.ListItem;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.ICC_Profile;
import com.itextpdf.text.pdf.PdfAConformanceLevel;
import com.itextpdf.text.pdf.PdfAWriter; import 
com.itextpdf.text.xml.xmp.DublinCoreProperties;
import com.itextpdf.text.xml.xmp.PdfProperties;
import com.itextpdf.text.xml.xmp.XmpWriter;
import com.itextpdf.xmp.XMPException;


public class SquareBullet {

    public static void main(String[] args) throws IOException, 
DocumentException, XMPException {
        Document document = new Document();
        PdfAWriter writer = PdfAWriter.getInstance(document, new 
FileOutputStream("list.pdf"), PdfAConformanceLevel.PDF_A_1A);
        writer.setViewerPreferences(PdfAWriter.PageModeUseOutlines);
        writer.setRunDirection(PdfAWriter.RUN_DIRECTION_LTR);
        writer.setTagged(PdfAWriter.markAll);
        writer.createXmpMetadata();
        XmpWriter xmp = writer.getXmpWriter();

        DublinCoreProperties.addSubject(xmp.getXmpMeta(), "Subject");
        DublinCoreProperties.setTitle(xmp.getXmpMeta(), "Title", "en_US", 
"en_US");
        DublinCoreProperties.setDescription(xmp.getXmpMeta(), "Description", 
"en_US", "en_US");
        PdfProperties.setKeywords(xmp.getXmpMeta(), "Keywords");
        PdfProperties.setVersion(xmp.getXmpMeta(), "1.4");
        document.addLanguage("en_US");
        document.open();
        Font font = FontFactory.getFont("ZapfDingbats.ttf",
BaseFont.WINANSI, BaseFont.EMBEDDED, 8);
        Font font1 = FontFactory.getFont("ROsanswebtextregular.ttf",
BaseFont.WINANSI, BaseFont.EMBEDDED, 12);
        ICC_Profile icc = ICC_Profile.getInstance(new FileInputStream("sRGB 
Color Space Profile.icm"));
        writer.setOutputIntents("Custom", "", "http://www.color.org";, "sRGB 
IEC61966-2.1", icc);
        List list = new List(10);
        Chunk c = new Chunk(String.valueOf((char)110), font);
        list.setListSymbol(c);
        list.add(new ListItem(new Chunk("Test 1", font1)));
        list.add(new ListItem(new Chunk("Test 2", font1)));
        list.add(new ListItem(new Chunk("Test 3", font1)));

        document.add(list);

        Paragraph anchorP = new Paragraph();
        Anchor anchor = new Anchor("Google", font);
        anchor.setReference("https://google.com";);
        anchor.setName("Google");
        anchorP.add(anchor);
        document.add(anchorP);

        document.close();
    }
}




--
View this message in context: 
http://itext.2136553.n4.nabble.com/PdfAConformanceException-while-adding-link-anchor-to-a-document-iText5-5-6-tp4660892.html
Sent from the iText mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/ Please check the keywords list 
before you ask for examples: http://itextpdf.com/themes/keywords.php

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to