Re: [iText-questions] PdfAConformanceException while adding link(anchor) to a document iText5.5.6

2015-09-07 Thread avchavan
I solved this using the below code, Hope this helps someone!!

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

Chunk c = new Chunk("Google", font1);
PdfAction action = new PdfAction("https://google.com;);

PdfAnnotation annotation = PdfAnnotation.createLink(
writer, new Rectangle(0 ,0), PdfName.HIGHLIGHT,
action);
annotation.put(PdfName.CONTENTS, PdfName.TEXT);
annotation.setBorderStyle(new PdfBorderDictionary(0,
PdfBorderDictionary.STYLE_BEVELED));
c.setAnnotation(annotation);
document.add(c);
document.close();
}
}



--
View this message in context: 
http://itext.2136553.n4.nabble.com/PdfAConformanceException-while-adding-link-anchor-to-a-document-iText5-5-6-tp4660892p4660897.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


Re: [iText-questions] PdfAConformanceException while adding link(anchor) to a document iText5.5.6

2015-09-07 Thread avchavan
The document contains a list of points and a hyperlink.

You can even consider the document containing only a hyperlink and nothing
else for simplicity purpose to debug the issue (I have tried this as well
and getting the same Exception).



--
View this message in context: 
http://itext.2136553.n4.nabble.com/PdfAConformanceException-while-adding-link-anchor-to-a-document-iText5-5-6-tp4660892p4660896.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


Re: [iText-questions] PdfAConformanceException while adding link(anchor) to a document iText5.5.6

2015-09-04 Thread Gerold Krommer
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


Re: [iText-questions] PdfAConformanceException while adding link(anchor) to a document iText5.5.6

2015-09-04 Thread Leonard Rosenthol
External links (eg. A hyperlink out to a specific URI) is perfectly acceptable 
in PDF/A.  

What is wrong with this particular one is unclear without seeing the document 
in question.

Leonard




On 9/4/15, 11:20 AM, "Gerold Krommer"  wrote:

>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