Skip to content

Commit 82bf9d2

Browse files
ars18wrwiText-CI
authored andcommitted
Add some link tests.
The test demonstrates that the annotation's rectangle isn't considered while rendering a Link layout element. DEVSIX-3150 Autoported commit. Original commit hash: [26bed2bf4]
1 parent 858b813 commit 82bf9d2

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

itext.tests/itext.layout.tests/itext/layout/LinkTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ source product.
4343
using System;
4444
using System.IO;
4545
using iText.Kernel.Colors;
46+
using iText.Kernel.Geom;
4647
using iText.Kernel.Pdf;
4748
using iText.Kernel.Pdf.Action;
49+
using iText.Kernel.Pdf.Annot;
4850
using iText.Kernel.Pdf.Navigation;
4951
using iText.Kernel.Utils;
5052
using iText.Layout.Borders;
@@ -277,5 +279,28 @@ public virtual void TableHeaderLinkTest01() {
277279
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
278280
, "diff"));
279281
}
282+
283+
/// <exception cref="System.IO.IOException"/>
284+
/// <exception cref="System.Exception"/>
285+
[NUnit.Framework.Test]
286+
public virtual void LinkWithCustomRectangleTest01() {
287+
String outFileName = destinationFolder + "linkWithCustomRectangleTest01.pdf";
288+
String cmpFileName = sourceFolder + "cmp_linkWithCustomRectangleTest01.pdf";
289+
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName));
290+
Document doc = new Document(pdfDocument);
291+
String text = "Hello World";
292+
PdfAction action = PdfAction.CreateURI("http://itextpdf.com");
293+
PdfLinkAnnotation annotation = new PdfLinkAnnotation(new Rectangle(1, 1)).SetAction(action);
294+
Link linkByAnnotation = new Link(text, annotation);
295+
doc.Add(new Paragraph(linkByAnnotation));
296+
annotation.SetRectangle(new PdfArray(new Rectangle(100, 100, 20, 20)));
297+
Link linkByChangedAnnotation = new Link(text, annotation);
298+
doc.Add(new Paragraph(linkByChangedAnnotation));
299+
Link linkByAction = new Link(text, action);
300+
doc.Add(new Paragraph(linkByAction));
301+
doc.Close();
302+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
303+
));
304+
}
280305
}
281306
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
67c775941510d4a0896b948e94f1df5de9704948
1+
26bed2bf498752e2ed5f837342b62c148b639007

0 commit comments

Comments
 (0)