@@ -350,6 +350,11 @@ private bool PDFWatermark(string inputfilepath, string outputfilepath, X509Certi
350350 signpage = numberOfPages ;
351351 all = true ;
352352 }
353+ else if ( zyz == 4 )
354+ {
355+ signpage = numberOfPages ;
356+ all = true ;
357+ }
353358
354359 for ( int i = 1 ; i <= numberOfPages ; i ++ )
355360 {
@@ -367,6 +372,10 @@ private bool PDFWatermark(string inputfilepath, string outputfilepath, X509Certi
367372 DataRow [ ] arrRow = dtPos . Select ( "Path = '" + inputfilepath + "' and Page = " + i ) ;
368373 if ( arrRow == null || arrRow . Length == 0 )
369374 {
375+ if ( zyz == 4 ) //自定义页加印章,如果没有印章定位的页就不盖
376+ {
377+ continue ;
378+ }
370379 wbl = Convert . ToSingle ( textPx . Text ) ; //这里根据比例来定位
371380 hbl = 1 - Convert . ToSingle ( textPy . Text ) ; //这里根据比例来定位
372381 }
@@ -628,6 +637,7 @@ private void pictureBox1_Click(object sender, EventArgs e)
628637 }
629638 Point pt1 = pictureBox1 . Location ;
630639
640+ pictureBox2 . Visible = true ;
631641 pictureBox2 . Location = new Point ( pt1 . X + pt . X - 10 , pt1 . Y + pt . Y - 10 ) ;
632642
633643 }
@@ -705,11 +715,16 @@ private void buttonUp_Click(object sender, EventArgs e)
705715 DataRow [ ] arrRow = dtPos . Select ( "Path = '" + pdfInputPath + "' and Page = " + imgStartPage ) ;
706716 if ( arrRow == null || arrRow . Length == 0 )
707717 {
718+ if ( comboYz . SelectedIndex == 4 )
719+ {
720+ pictureBox2 . Visible = false ;
721+ }
708722 px = Convert . ToSingle ( textPx . Text ) ; //这里根据比例来定位
709723 py = Convert . ToSingle ( textPy . Text ) ; //这里根据比例来定位
710724 }
711725 else
712726 {
727+ pictureBox2 . Visible = true ;
713728 DataRow dr = arrRow [ 0 ] ;
714729 px = Convert . ToSingle ( dr [ "X" ] . ToString ( ) ) ;
715730 py = Convert . ToSingle ( dr [ "Y" ] . ToString ( ) ) ;
@@ -738,11 +753,16 @@ private void buttonNext_Click(object sender, EventArgs e)
738753 DataRow [ ] arrRow = dtPos . Select ( "Path = '" + pdfInputPath + "' and Page = " + imgStartPage ) ;
739754 if ( arrRow == null || arrRow . Length == 0 )
740755 {
756+ if ( comboYz . SelectedIndex == 4 )
757+ {
758+ pictureBox2 . Visible = false ;
759+ }
741760 px = Convert . ToSingle ( textPx . Text ) ; //这里根据比例来定位
742761 py = Convert . ToSingle ( textPy . Text ) ; //这里根据比例来定位
743762 }
744763 else
745764 {
765+ pictureBox2 . Visible = true ;
746766 DataRow dr = arrRow [ 0 ] ;
747767 px = Convert . ToSingle ( dr [ "X" ] . ToString ( ) ) ;
748768 py = Convert . ToSingle ( dr [ "Y" ] . ToString ( ) ) ;
@@ -814,32 +834,47 @@ private void comboQmtype_SelectionChangeCommitted(object sender, EventArgs e)
814834 private void comboPDFlist_SelectionChangeCommitted ( object sender , EventArgs e )
815835 {
816836 pdfInputPath = comboPDFlist . SelectedValue . ToString ( ) ;
817- PDFFile pdfFile = PDFFile . Open ( pdfInputPath ) ;
818- Bitmap pageImage = pdfFile . GetPageImage ( 0 , 56 * 1 ) ;
819- pictureBox1 . Image = pageImage ;
820- imgStartPage = 1 ;
821- imgPageCount = pdfFile . PageCount ;
822- pdfFile . Dispose ( ) ;
823- labelPage . Text = imgStartPage + "/" + imgPageCount ;
824-
825- float px , py ;
826- DataRow [ ] arrRow = dtPos . Select ( "Path = '" + pdfInputPath + "' and Page = " + imgStartPage ) ;
827- if ( arrRow == null || arrRow . Length == 0 )
837+ if ( pdfInputPath != "" )
828838 {
829- px = Convert . ToSingle ( textPx . Text ) ; //这里根据比例来定位
830- py = Convert . ToSingle ( textPy . Text ) ; //这里根据比例来定位
839+ PDFFile pdfFile = PDFFile . Open ( pdfInputPath ) ;
840+ Bitmap pageImage = pdfFile . GetPageImage ( 0 , 56 * 1 ) ;
841+ pictureBox1 . Image = pageImage ;
842+ imgStartPage = 1 ;
843+ imgPageCount = pdfFile . PageCount ;
844+ pdfFile . Dispose ( ) ;
845+ labelPage . Text = imgStartPage + "/" + imgPageCount ;
846+
847+ float px , py ;
848+ DataRow [ ] arrRow = dtPos . Select ( "Path = '" + pdfInputPath + "' and Page = " + imgStartPage ) ;
849+ if ( arrRow == null || arrRow . Length == 0 )
850+ {
851+ px = Convert . ToSingle ( textPx . Text ) ; //这里根据比例来定位
852+ py = Convert . ToSingle ( textPy . Text ) ; //这里根据比例来定位
853+ }
854+ else
855+ {
856+ DataRow dr = arrRow [ 0 ] ;
857+ px = Convert . ToSingle ( dr [ "X" ] . ToString ( ) ) ;
858+ py = Convert . ToSingle ( dr [ "Y" ] . ToString ( ) ) ;
859+ }
860+ int X = Convert . ToInt32 ( pictureBox1 . Width * px ) ;
861+ int Y = Convert . ToInt32 ( pictureBox1 . Height * py ) ;
862+ Point pt1 = pictureBox1 . Location ;
863+
864+ pictureBox2 . Location = new Point ( pt1 . X + X - 10 , pt1 . Y + Y - 10 ) ;
831865 }
832866 else
833867 {
834- DataRow dr = arrRow [ 0 ] ;
835- px = Convert . ToSingle ( dr [ "X" ] . ToString ( ) ) ;
836- py = Convert . ToSingle ( dr [ "Y" ] . ToString ( ) ) ;
868+ imgStartPage = 1 ;
869+ imgPageCount = 1 ;
870+ labelPage . Text = "1/1" ;
871+ Bitmap bmp = new Bitmap ( 177 , 250 ) ;
872+ Graphics g = Graphics . FromImage ( bmp ) ;
873+ g . FillRectangle ( Brushes . White , new Rectangle ( 0 , 0 , 177 , 250 ) ) ;
874+ g . Dispose ( ) ;
875+ pictureBox1 . Image = bmp ;
837876 }
838- int X = Convert . ToInt32 ( pictureBox1 . Width * px ) ;
839- int Y = Convert . ToInt32 ( pictureBox1 . Height * py ) ;
840- Point pt1 = pictureBox1 . Location ;
841-
842- pictureBox2 . Location = new Point ( pt1 . X + X - 10 , pt1 . Y + Y - 10 ) ;
877+
843878 }
844879 //根据印章类型切换窗口大小
845880 private void comboYz_SelectionChangeCommitted ( object sender , EventArgs e )
0 commit comments