@@ -43,8 +43,10 @@ source product.
43
43
using System ;
44
44
using System . IO ;
45
45
using iText . Kernel . Colors ;
46
+ using iText . Kernel . Geom ;
46
47
using iText . Kernel . Pdf ;
47
48
using iText . Kernel . Pdf . Action ;
49
+ using iText . Kernel . Pdf . Annot ;
48
50
using iText . Kernel . Pdf . Navigation ;
49
51
using iText . Kernel . Utils ;
50
52
using iText . Layout . Borders ;
@@ -277,5 +279,28 @@ public virtual void TableHeaderLinkTest01() {
277
279
NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
278
280
, "diff" ) ) ;
279
281
}
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
+ }
280
305
}
281
306
}
0 commit comments