@@ -72,7 +72,7 @@ private void Form1_Load(object sender, EventArgs e)
7272 string QfzType = iniFileHelper . ContentValue ( section , "qfzType" ) ; //骑缝章类型
7373 string YzType = iniFileHelper . ContentValue ( section , "yzType" ) ; //印章类型
7474 string DjType = iniFileHelper . ContentValue ( section , "djType" ) ; //叠加类型
75- string QmType = iniFileHelper . ContentValue ( section , "qmType" ) ; //签名类型
75+ // string QmType = iniFileHelper.ContentValue(section, "qmType");//签名类型
7676 string WzType = iniFileHelper . ContentValue ( section , "wzType" ) ; //骑缝章位置类型
7777 string Qbflag = iniFileHelper . ContentValue ( section , "qbflag" ) ; //是否切边标记
7878 string Size = iniFileHelper . ContentValue ( section , "size" ) ; //印章尺寸
@@ -87,7 +87,7 @@ private void Form1_Load(object sender, EventArgs e)
8787 qfzType = ToIntOrDefault ( QfzType , 0 ) ;
8888 yzType = ToIntOrDefault ( YzType , 0 ) ;
8989 djType = ToIntOrDefault ( DjType , 0 ) ;
90- qmType = ToIntOrDefault ( QmType , 0 ) ;
90+ // qmType = ToIntOrDefault(QmType, 0);
9191 wzType = ToIntOrDefault ( WzType , 3 ) ;
9292 qbflag = ToIntOrDefault ( Qbflag , 0 ) ;
9393 size = ToIntOrDefault ( Size , 40 ) ;
@@ -311,7 +311,7 @@ private void button1_Click(object sender, EventArgs e)
311311 iniFileHelper . WriteIniString ( section , "qfzType" , qfzType . ToString ( ) ) ;
312312 iniFileHelper . WriteIniString ( section , "yzType" , yzType . ToString ( ) ) ;
313313 iniFileHelper . WriteIniString ( section , "djType" , djType . ToString ( ) ) ;
314- iniFileHelper . WriteIniString ( section , "qmType" , qmType . ToString ( ) ) ;
314+ // iniFileHelper.WriteIniString(section, "qmType", qmType.ToString());
315315 iniFileHelper . WriteIniString ( section , "wzType" , wzType . ToString ( ) ) ;
316316 iniFileHelper . WriteIniString ( section , "qbflag" , qbflag . ToString ( ) ) ;
317317 iniFileHelper . WriteIniString ( section , "size" , size . ToString ( ) ) ;
@@ -843,20 +843,33 @@ private bool PDFWatermark(string inputfilepath, string outputfilepath)
843843
844844 if ( yzType == 1 )
845845 {
846- signpage = numberOfPages ;
846+ signpage = numberOfPages ; //尾页加印章
847847 }
848848 else if ( yzType == 2 )
849849 {
850- signpage = 1 ;
850+ signpage = 1 ; //首页加印章
851851 }
852852 else if ( yzType == 3 )
853853 {
854- signpage = numberOfPages ;
854+ signpage = numberOfPages ; //所有页加印章
855855 all = true ;
856856 }
857857 else if ( yzType == 4 )
858858 {
859- signpage = numberOfPages ;
859+ signpage = 1 ; //自定义页加印章
860+ // 遍历 DataTable 的所有行
861+ foreach ( DataRow row in dtPos . Rows )
862+ {
863+ if ( row [ "Path" ] . ToString ( ) == inputfilepath )
864+ {
865+ // 获取当前行的某一列的值,假设这一列的列名为 "ColumnName"
866+ int columnValue = Convert . ToInt32 ( row [ "Page" ] ) ;
867+ if ( columnValue > signpage )
868+ {
869+ signpage = columnValue ;
870+ }
871+ }
872+ }
860873 all = true ;
861874 }
862875
@@ -890,8 +903,17 @@ private bool PDFWatermark(string inputfilepath, string outputfilepath)
890903 hbl = 1 - Convert . ToSingle ( dr [ "Y" ] . ToString ( ) ) ;
891904 }
892905 img = iTextSharp . text . Image . GetInstance ( imgYz , System . Drawing . Imaging . ImageFormat . Png ) ; //创建一个图片对象
893- Random random = new Random ( ) ;
894- img . RotationDegrees = random . Next ( - 10 , 11 ) ; //每页的印章设置个随机的角度
906+ int RotationDegrees = 0 ;
907+ if ( i != signpage )
908+ {
909+ Random random = new Random ( ) ;
910+ RotationDegrees = random . Next ( - 10 , 11 ) ; //每页的印章设置个随机的角度
911+ }
912+ else
913+ {
914+ RotationDegrees = 0 ;
915+ }
916+ img . RotationDegrees = RotationDegrees ;
895917 //img.Transparency = new int[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };//这里透明背景的图片会变黑色,所以设置黑色为透明
896918 img . ScalePercent ( sfbl ) ; //设置图片比例
897919 imgW = img . Width * sfbl / 100f ;
@@ -1498,6 +1520,7 @@ public void viewPDFPage()
14981520 pictureBox1 . Location = new Point ( point . X - pictureBox1 . Width / 2 , point . Y - pictureBox1 . Height / 2 ) ;
14991521 pictureBox1 . Image = pageImage ;
15001522 labelPage . Text = imgStartPage + "/" + imgPageCount ;
1523+ pictureBox2 . Visible = true ;
15011524
15021525 float px , py ;
15031526 DataRow [ ] arrRow = dtPos . Select ( "Path = '" + previewPath + "' and Page = " + imgStartPage ) ;
@@ -1730,6 +1753,7 @@ private void comboQmtype_SelectionChangeCommitted(object sender, EventArgs e)
17301753 //选择PDF预览文件
17311754 private void comboPDFlist_SelectionChangeCommitted ( object sender , EventArgs e )
17321755 {
1756+ dtPages . Rows . Clear ( ) ; //清空PDF页下拉项
17331757 previewPath = comboPDFlist . SelectedValue . ToString ( ) ;
17341758 if ( previewPath != "" )
17351759 {
@@ -1764,8 +1788,6 @@ private void comboPDFlist_SelectionChangeCommitted(object sender, EventArgs e)
17641788 pictureBox1 . Image = bmp ;
17651789 buttonUp . Enabled = false ;
17661790 buttonNext . Enabled = false ;
1767-
1768- dtPages . Rows . Clear ( ) ; //情况PDF页下拉项
17691791 }
17701792
17711793 }
0 commit comments