Skip to content

Commit 7a0bb72

Browse files
committed
Add Contents for link annotations
DEVSIX-8679 Autoported commit. Original commit hash: [0e74db99e]
1 parent d4f3658 commit 7a0bb72

File tree

17 files changed

+41
-25
lines changed

17 files changed

+41
-25
lines changed

itext.tests/itext.html2pdf.tests/itext/html2pdf/HtmlConverterPdfUA1UA2Test.cs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,46 +51,45 @@ public static void BeforeClass() {
5151

5252
[NUnit.Framework.Test]
5353
public virtual void SimpleLinkTest() {
54-
// TODO DEVSIX-8679 Apply links alternate description according to UA standard
5554
String sourceHtml = SOURCE_FOLDER + "simpleLink.html";
5655
String cmpPdfUa1 = SOURCE_FOLDER + "cmp_simpleLinkUa1.pdf";
5756
String cmpPdfUa2 = SOURCE_FOLDER + "cmp_simpleLinkUa2.pdf";
58-
String destinationPdfUa1 = DESTINATION_FOLDER + "simpleLink.pdf";
59-
String destinationPdfUa2 = DESTINATION_FOLDER + "simpleLink.pdf";
60-
String expectedUa1Message = MessageFormatUtil.Format(PdfUAExceptionMessageConstants.ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_OR_ALT_KEY
61-
, PdfName.Link.GetValue());
62-
ConvertToUa1AndCheckCompliance(sourceHtml, destinationPdfUa1, cmpPdfUa1, false, expectedUa1Message);
63-
// Expected valid UA-2 document because PDF/UA-2 does not require Contents in Link annotations
57+
String destinationPdfUa1 = DESTINATION_FOLDER + "simpleLinkUa1.pdf";
58+
String destinationPdfUa2 = DESTINATION_FOLDER + "simpleLinkUa2.pdf";
59+
ConvertToUa1AndCheckCompliance(sourceHtml, destinationPdfUa1, cmpPdfUa1, true, null);
6460
ConvertToUa2AndCheckCompliance(sourceHtml, destinationPdfUa2, cmpPdfUa2, true);
6561
}
6662

6763
[NUnit.Framework.Test]
6864
public virtual void BackwardLinkTest() {
69-
// TODO DEVSIX-8679 Apply links alternate description according to UA standard
7065
String sourceHtml = SOURCE_FOLDER + "backwardLink.html";
7166
String cmpPdfUa1 = SOURCE_FOLDER + "cmp_backwardLinkUa1.pdf";
7267
String cmpPdfUa2 = SOURCE_FOLDER + "cmp_backwardLinkUa2.pdf";
7368
String destinationPdfUa1 = DESTINATION_FOLDER + "backwardLinkUa1.pdf";
7469
String destinationPdfUa2 = DESTINATION_FOLDER + "backwardLinkUa2.pdf";
75-
String expectedUa1Message = MessageFormatUtil.Format(PdfUAExceptionMessageConstants.ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_OR_ALT_KEY
76-
, PdfName.Link.GetValue());
77-
ConvertToUa1AndCheckCompliance(sourceHtml, destinationPdfUa1, cmpPdfUa1, false, expectedUa1Message);
78-
// Expected valid UA-2 document because PDF/UA-2 does not require Contents in Link annotations
70+
ConvertToUa1AndCheckCompliance(sourceHtml, destinationPdfUa1, cmpPdfUa1, true, null);
7971
ConvertToUa2AndCheckCompliance(sourceHtml, destinationPdfUa2, cmpPdfUa2, true);
8072
}
8173

8274
[NUnit.Framework.Test]
8375
public virtual void ImageLinkTest() {
84-
// TODO DEVSIX-8679 Apply links alternate description according to UA standard
8576
String sourceHtml = SOURCE_FOLDER + "imageLink.html";
8677
String cmpPdfUa1 = SOURCE_FOLDER + "cmp_imageLinkUa1.pdf";
8778
String cmpPdfUa2 = SOURCE_FOLDER + "cmp_imageLinkUa2.pdf";
8879
String destinationPdfUa1 = DESTINATION_FOLDER + "imageLinkUa1.pdf";
8980
String destinationPdfUa2 = DESTINATION_FOLDER + "imageLinkUa2.pdf";
90-
String expectedUa1Message = MessageFormatUtil.Format(PdfUAExceptionMessageConstants.ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_OR_ALT_KEY
91-
, PdfName.Link.GetValue());
92-
ConvertToUa1AndCheckCompliance(sourceHtml, destinationPdfUa1, cmpPdfUa1, false, expectedUa1Message);
93-
// Expected valid UA-2 document because PDF/UA-2 does not require Contents in Link annotations
81+
ConvertToUa1AndCheckCompliance(sourceHtml, destinationPdfUa1, cmpPdfUa1, true, null);
82+
ConvertToUa2AndCheckCompliance(sourceHtml, destinationPdfUa2, cmpPdfUa2, true);
83+
}
84+
85+
[NUnit.Framework.Test]
86+
public virtual void ExternalLinkTest() {
87+
String sourceHtml = SOURCE_FOLDER + "externalLink.html";
88+
String cmpPdfUa1 = SOURCE_FOLDER + "cmp_externalLinkUa1.pdf";
89+
String cmpPdfUa2 = SOURCE_FOLDER + "cmp_externalLinkUa2.pdf";
90+
String destinationPdfUa1 = DESTINATION_FOLDER + "externalLinkUa1.pdf";
91+
String destinationPdfUa2 = DESTINATION_FOLDER + "externalLinkUa2.pdf";
92+
ConvertToUa1AndCheckCompliance(sourceHtml, destinationPdfUa1, cmpPdfUa1, true, null);
9493
ConvertToUa2AndCheckCompliance(sourceHtml, destinationPdfUa2, cmpPdfUa2, true);
9594
}
9695

@@ -187,15 +186,12 @@ public virtual void PageBreakAfterAvoidTest() {
187186
public virtual void LinkWithPageBreakBeforeTest() {
188187
// TODO DEVSIX-8864 PDF 2.0: Destination in GoTo action is not a structure destination
189188
// TODO DEVSIX-8476 PDF 2.0 doesn't allow P tag be a child of H tag
190-
// TODO DEVSIX-8679 Apply links alternate description according to UA standard
191189
String sourceHtml = SOURCE_FOLDER + "linkWithPageBreakBefore.html";
192190
String cmpPdfUa1 = SOURCE_FOLDER + "cmp_linkWithPageBreakBeforeUa1.pdf";
193191
String cmpPdfUa2 = SOURCE_FOLDER + "cmp_linkWithPageBreakBeforeUa2.pdf";
194192
String destinationPdfUa1 = DESTINATION_FOLDER + "linkWithPageBreakBeforeUa1.pdf";
195193
String destinationPdfUa2 = DESTINATION_FOLDER + "linkWithPageBreakBeforeUa2.pdf";
196-
String expectedUa1Message = MessageFormatUtil.Format(PdfUAExceptionMessageConstants.ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_OR_ALT_KEY
197-
, PdfName.Link.GetValue());
198-
ConvertToUa1AndCheckCompliance(sourceHtml, destinationPdfUa1, cmpPdfUa1, false, expectedUa1Message);
194+
ConvertToUa1AndCheckCompliance(sourceHtml, destinationPdfUa1, cmpPdfUa1, true, null);
199195
ConvertToUa2AndCheckCompliance(sourceHtml, destinationPdfUa2, cmpPdfUa2, false);
200196
}
201197

0 commit comments

Comments
 (0)