Skip to content

Commit f67abe5

Browse files
committed
修复印章预览不显示,数字签名位置异常
1 parent 14b374d commit f67abe5

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

PDFQFZ/Form1.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PDFQFZ/Form1.cs

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

PDFQFZ/Form1.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
<data name="pictureBox2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
125125
<value>
126126
iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAIAAAC1nk4lAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
127-
vgAADr4B6kKxwAAAArhJREFUaEPllkty5SAQBH2QWc79bzZneK4RZYwSEA1CL+aTkQuHqrupcHjhj9c+
127+
vQAADr0BR/uQrQAAArhJREFUaEPllkty5SAQBH2QWc79bzZneK4RZYwSEA1CL+aTkQuHqrupcHjhj9c+
128128
fv34eaGHdnC3NJoF9fIqi6VRYlmfm2S6NF7dok+HmSiNl7brZwJES+OBph7tgOGmHh0RKo3T0ENhsA49
129129
dMmgNC6WeuIGOFjqiQ5XpXGo1BO3wdlST7TolsaJrOOt4Ims44p2aSxnHT8AHso6PhMt7eBh8Kh0cKZR
130130
GmvSwVvA09JBAUtjQTp4IyggHXxxKo3RpLNJ7u9CZweD0g4m2Xsh6eDguzSGpINJcEQ6mARHpIM/ubTo

0 commit comments

Comments
 (0)