Skip to content

Commit 4acca5c

Browse files
committed
预览图添加印章位置显示
1 parent 49fedde commit 4acca5c

File tree

4 files changed

+87
-15
lines changed

4 files changed

+87
-15
lines changed

PDFQFZ/Form1.Designer.cs

Lines changed: 29 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PDFQFZ/Form1.cs

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,10 @@ private void pictureBox1_Click(object sender, EventArgs e)
634634
dr.EndEdit();
635635
dtPos.AcceptChanges();
636636
}
637-
638-
637+
Point pt1 = pictureBox1.Location;
638+
639+
pictureBox2.Location = new Point(pt1.X+pt.X-10, pt1.Y + pt.Y - 10);
640+
639641
}
640642
//印章比例类型
641643
private void comboBoxBL_SelectionChangeCommitted(object sender, EventArgs e)
@@ -703,9 +705,29 @@ private void buttonUp_Click(object sender, EventArgs e)
703705
imgStartPage--;
704706
PDFFile pdfFile = PDFFile.Open(pdfInputPath);
705707
Bitmap pageImage = pdfFile.GetPageImage(imgStartPage-1, 56 * 1);
708+
pdfFile.Dispose();
706709
pictureBox1.Image = pageImage;
707710
labelPage.Text = imgStartPage + "/" + imgPageCount;
708711

712+
float px, py;
713+
DataRow[] arrRow = dtPos.Select("Path = '" + pdfInputPath + "' and Page = " + imgStartPage);
714+
if (arrRow == null || arrRow.Length == 0)
715+
{
716+
px = Convert.ToSingle(textPx.Text);//这里根据比例来定位
717+
py = Convert.ToSingle(textPy.Text);//这里根据比例来定位
718+
}
719+
else
720+
{
721+
DataRow dr = arrRow[0];
722+
px = Convert.ToSingle(dr["X"].ToString());
723+
py = Convert.ToSingle(dr["Y"].ToString());
724+
}
725+
int X = Convert.ToInt32(pictureBox1.Width*px);
726+
int Y = Convert.ToInt32(pictureBox1.Height*py);
727+
Point pt1 = pictureBox1.Location;
728+
729+
pictureBox2.Location = new Point(pt1.X + X - 10, pt1.Y + Y - 10);
730+
709731
}
710732
}
711733
//下一页
@@ -716,9 +738,29 @@ private void buttonNext_Click(object sender, EventArgs e)
716738
imgStartPage++;
717739
PDFFile pdfFile = PDFFile.Open(pdfInputPath);
718740
Bitmap pageImage = pdfFile.GetPageImage(imgStartPage-1, 56 * 1);
741+
pdfFile.Dispose();
719742
pictureBox1.Image = pageImage;
720743
labelPage.Text = imgStartPage + "/" + imgPageCount;
721744

745+
float px,py;
746+
DataRow[] arrRow = dtPos.Select("Path = '" + pdfInputPath + "' and Page = " + imgStartPage);
747+
if (arrRow == null || arrRow.Length == 0)
748+
{
749+
px = Convert.ToSingle(textPx.Text);//这里根据比例来定位
750+
py = Convert.ToSingle(textPy.Text);//这里根据比例来定位
751+
}
752+
else
753+
{
754+
DataRow dr = arrRow[0];
755+
px = Convert.ToSingle(dr["X"].ToString());
756+
py = Convert.ToSingle(dr["Y"].ToString());
757+
}
758+
int X = Convert.ToInt32(pictureBox1.Width * px);
759+
int Y = Convert.ToInt32(pictureBox1.Height * py);
760+
Point pt1 = pictureBox1.Location;
761+
762+
pictureBox2.Location = new Point(pt1.X + X - 10, pt1.Y + Y - 10);
763+
722764
}
723765
}
724766

@@ -785,6 +827,7 @@ private void comboPDFlist_SelectionChangeCommitted(object sender, EventArgs e)
785827
pictureBox1.Image = pageImage;
786828
imgStartPage = 1;
787829
imgPageCount = pdfFile.PageCount;
830+
pdfFile.Dispose();
788831
labelPage.Text = imgStartPage + "/" + imgPageCount;
789832
}
790833
//根据印章类型切换窗口大小

PDFQFZ/Form1.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@
121121
<value>17, 17</value>
122122
</metadata>
123123
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
124+
<data name="pictureBox2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
125+
<value>
126+
iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
127+
wgAADsIBFShKgAAAAVpJREFUOE+VVCF2wzAMNRwc3BHGWmLZLWmPMDg4ODg4uFsU7hiDg4WDhYOFhW0S
128+
4EmKnCqKs6R67z8rkv6PUql2U3ZZrR6bELYZ1Xq9lNRtVsf41gAcmhgTCqXuJAD84vmRNps7KR836Wjf
129+
kS0ANA41QBTq0KoQXuoQztzNXOBLkPMuElejzmrvbxMjXLvfilRrGNjzZ5QI+rQ5AXZ5TIvFPYvxAChB
130+
gpaoSJM5gE8WxCRNrRW0xdYvCQlwQGdXeb/sinSH9nlCLIMm+8yFRM4CBC1SiudnA4eTfe1IBEvIvs7b
131+
nALvXpGkkXOZmGMFONr0HikTtaCNCbkER/9HXJtTJzZGniFGaNcmhF1PLMPGyNfCwxf8sGDy/gE//ThK
132+
/l+EQTtIK8iCZBeAp15Hc306EcULAgt2vQ7m+AgU+xKJofEVRkMi0gToqit2Zk1+0+9BN9oPoXC5OvcH
133+
bQ8BJqxxbfEAAAAASUVORK5CYII=
134+
</value>
135+
</data>
124136
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
125137
<value>
126138
AAABAAEAQEAAAAEAIAAoQgAAFgAAACgAAABAAAAAgAAAAAEAIAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAA

PDFQFZ/PDFQFZ.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
<Compile Include="Properties\AssemblyInfo.cs" />
110110
<EmbeddedResource Include="Form1.resx">
111111
<DependentUpon>Form1.cs</DependentUpon>
112+
<SubType>Designer</SubType>
112113
</EmbeddedResource>
113114
<EmbeddedResource Include="Properties\Resources.resx">
114115
<Generator>ResXFileCodeGenerator</Generator>

0 commit comments

Comments
 (0)