@@ -34,6 +34,7 @@ You should have received a copy of the GNU Affero General Public License
34
34
using iText . Kernel . Pdf ;
35
35
using iText . Kernel . Pdf . Annot ;
36
36
using iText . Kernel . Pdf . Canvas ;
37
+ using iText . Kernel . Pdf . Xobject ;
37
38
using iText . Kernel . Utils ;
38
39
using iText . Layout ;
39
40
using iText . Layout . Element ;
@@ -517,7 +518,6 @@ public virtual void AcroFieldDictionaryNoFields() {
517
518
}
518
519
519
520
[ NUnit . Framework . Test ]
520
- [ NUnit . Framework . Ignore ( "DEVSIX-7264: Investigate 3 failed forms tests from 7.3/develop on .NET" ) ]
521
521
public virtual void RegenerateAppearance ( ) {
522
522
String input = "regenerateAppearance.pdf" ;
523
523
String output = "regenerateAppearance.pdf" ;
@@ -1525,6 +1525,48 @@ public virtual void DisableChildRegenerationTest() {
1525
1525
NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outPdf , cmpPdf , destinationFolder ) ) ;
1526
1526
}
1527
1527
1528
+ [ NUnit . Framework . Test ]
1529
+ public virtual void SignatureLayersTest ( ) {
1530
+ String fileName = destinationFolder + "signatureLayersTest.pdf" ;
1531
+ PdfDocument pdfDoc = new PdfDocument ( new PdfWriter ( fileName ) ) ;
1532
+ PdfAcroForm form = PdfFormCreator . GetAcroForm ( pdfDoc , true ) ;
1533
+ pdfDoc . AddNewPage ( ) ;
1534
+ PdfSignatureFormField signField = new SignatureFormFieldBuilder ( pdfDoc , "signature" ) . SetWidgetRectangle ( new
1535
+ Rectangle ( 36 , 436 , 100 , 100 ) ) . CreateSignature ( ) ;
1536
+ PdfFormXObject layer0 = new PdfFormXObject ( new Rectangle ( 0 , 0 , 100 , 100 ) ) ;
1537
+ // Draw pink rectangle with blue border
1538
+ new PdfCanvas ( layer0 , pdfDoc ) . SaveState ( ) . SetFillColor ( ColorConstants . PINK ) . SetStrokeColor ( ColorConstants .
1539
+ BLUE ) . Rectangle ( 0 , 0 , 100 , 100 ) . FillStroke ( ) . RestoreState ( ) ;
1540
+ PdfFormXObject layer2 = new PdfFormXObject ( new Rectangle ( 0 , 0 , 100 , 100 ) ) ;
1541
+ // Draw yellow circle with gray border
1542
+ new PdfCanvas ( layer2 , pdfDoc ) . SaveState ( ) . SetFillColor ( ColorConstants . YELLOW ) . SetStrokeColor ( ColorConstants
1543
+ . DARK_GRAY ) . Circle ( 50 , 50 , 50 ) . FillStroke ( ) . RestoreState ( ) ;
1544
+ signField . SetBackgroundLayer ( layer0 ) . SetSignatureAppearanceLayer ( layer2 ) ;
1545
+ form . AddField ( signField ) ;
1546
+ pdfDoc . Close ( ) ;
1547
+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( fileName , sourceFolder + "cmp_signatureLayersTest.pdf"
1548
+ , destinationFolder , "diff_" ) ) ;
1549
+ }
1550
+
1551
+ [ NUnit . Framework . Test ]
1552
+ public virtual void PdfWithSignatureFieldTest ( ) {
1553
+ String fileName = destinationFolder + "pdfWithSignatureFieldTest.pdf" ;
1554
+ PdfDocument pdfDoc = new PdfDocument ( new PdfWriter ( fileName ) ) ;
1555
+ PdfAcroForm form = PdfFormCreator . GetAcroForm ( pdfDoc , true ) ;
1556
+ pdfDoc . AddNewPage ( ) ;
1557
+ PdfFormField signField = new SignatureFormFieldBuilder ( pdfDoc , "signature" ) . SetWidgetRectangle ( new Rectangle
1558
+ ( 100 , 600 , 400 , 150 ) ) . CreateSignature ( ) ;
1559
+ signField . GetPdfObject ( ) . Put ( PdfName . Name , new PdfName ( "test name" ) ) ;
1560
+ signField . GetPdfObject ( ) . Put ( PdfName . Reason , new PdfString ( "test reason" ) ) ;
1561
+ signField . GetPdfObject ( ) . Put ( PdfName . Location , new PdfString ( "test location" ) ) ;
1562
+ signField . GetPdfObject ( ) . Put ( PdfName . ContactInfo , new PdfString ( "test contact" ) ) ;
1563
+ signField . GetFirstFormAnnotation ( ) . SetBackgroundColor ( ColorConstants . PINK ) . SetColor ( ColorConstants . WHITE ) ;
1564
+ form . AddField ( signField ) ;
1565
+ pdfDoc . Close ( ) ;
1566
+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( fileName , sourceFolder + "cmp_pdfWithSignatureFieldTest.pdf"
1567
+ , destinationFolder , "diff_" ) ) ;
1568
+ }
1569
+
1528
1570
internal class CustomButtonFormField : PdfButtonFormField {
1529
1571
private int counter = 0 ;
1530
1572
0 commit comments