Skip to content

Commit 9a5f597

Browse files
committed
改为导入下拉选择的方式选择印章文件
1 parent c9e79fa commit 9a5f597

File tree

2 files changed

+60
-48
lines changed

2 files changed

+60
-48
lines changed

PDFQFZ/Form1.Designer.cs

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

PDFQFZ/Form1.cs

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ public partial class Form1 : Form
1515
{
1616
int fw, fh,imgStartPage=0, imgPageCount=0;
1717
string certDefaultPath = $@"{Application.StartupPath}\pdfqfz.pfx";//证书默认存放地址
18+
string yzLog = $@"{Application.StartupPath}\yz.log";//获取印章记录
1819
DataTable dt = new DataTable();//PDF列表
1920
DataTable dtPos = new DataTable();//PDF各文件印章位置表
21+
DataTable dtYz = new DataTable();//PDF列表
2022
string sourcePath = "",outputPath = "",imgPath = "",previewPath = null,signText = "", password="";
2123
int wjType = 1, qfzType = 0, yzType = 0, djType = 0, qmType = 0, sizeType = 1, size = 40, rotation = 0, opacity = 100, wz = 50, yzr = 10, maximg = 250;
2224
Bitmap imgYz = null;
@@ -53,6 +55,29 @@ private void Form1_Load(object sender, EventArgs e)
5355
comboBoxBL.SelectedIndex = sizeType;
5456
fw = this.Width;
5557
fh = this.Height;
58+
dtYz.Columns.Add("Name", typeof(string));
59+
dtYz.Columns.Add("Value", typeof(string));
60+
comboBoxYz.DisplayMember = "Name";
61+
comboBoxYz.ValueMember = "Value";
62+
comboBoxYz.DataSource = dtYz;
63+
if (!File.Exists(yzLog))
64+
{
65+
File.Create(yzLog).Close();
66+
}
67+
else
68+
{
69+
string line;
70+
string filename;
71+
StreamReader sr = new StreamReader(yzLog, false);
72+
while ((line = sr.ReadLine()) != null)
73+
{
74+
Console.WriteLine(line);
75+
filename = System.IO.Path.GetFileName(line);//文件名
76+
dtYz.Rows.Add(new object[] { filename, line });
77+
}
78+
sr.Close();
79+
sr.Dispose();
80+
}
5681
dt.Columns.Add("Name", typeof(string));
5782
dt.Columns.Add("Value", typeof(string));
5883
comboPDFlist.DisplayMember = "Name";
@@ -86,7 +111,7 @@ private void button1_Click(object sender, EventArgs e)
86111
{
87112
sourcePath = pathText.Text;
88113
outputPath = textBCpath.Text;
89-
imgPath = textGZpath.Text;
114+
imgPath = comboBoxYz.SelectedValue.ToString();
90115
signText = textname.Text;
91116
password = textpass.Text;
92117

@@ -194,7 +219,7 @@ private void pdfGz()
194219
string output = outputPath + "\\" + fileInfo.Name;
195220
if (isSaveSources.Checked == true)
196221
{
197-
output = fileInfo.DirectoryName + "\\" + Path.GetFileNameWithoutExtension(fileInfo.Name) + "_已盖章" + fileInfo.Extension;
222+
output = fileInfo.DirectoryName + "\\" + System.IO.Path.GetFileNameWithoutExtension(fileInfo.Name) + "_已盖章" + fileInfo.Extension;
198223

199224
}
200225

@@ -221,7 +246,7 @@ private void pdfGz()
221246
{
222247
string filename = System.IO.Path.GetFileName(file);//文件名
223248
string output = outputPath + "\\" + filename;//输出文件的绝对路径
224-
if (outputPath == Path.GetDirectoryName(file))
249+
if (outputPath == System.IO.Path.GetDirectoryName(file))
225250
{
226251
output = outputPath + "\\" + System.IO.Path.GetFileNameWithoutExtension(file) + "_QFZ.pdf";//如果跟源文件在同一个目录需要重命名
227252
}
@@ -707,7 +732,7 @@ private void SaveSources(object sender, EventArgs e)
707732
}
708733
else if (comboType.SelectedIndex == 1 && pathText.Text != "")
709734
{
710-
textBCpath.Text = Path.GetDirectoryName(pathText.Text);
735+
textBCpath.Text = System.IO.Path.GetDirectoryName(pathText.Text);
711736
}
712737
}
713738
else
@@ -720,7 +745,7 @@ private void SaveSources(object sender, EventArgs e)
720745
}
721746
else if (comboType.SelectedIndex == 1 && pathText.Text != "")
722747
{
723-
textBCpath.Text = Path.GetDirectoryName(pathText.Text) + "\\QFZ";
748+
textBCpath.Text = System.IO.Path.GetDirectoryName(pathText.Text) + "\\QFZ";
724749
}
725750
}
726751

@@ -793,7 +818,7 @@ private void SelectPath_Click(object sender, EventArgs e)
793818
pathText.Text = string.Join(",", file.FileNames);
794819
if (textBCpath.Text == "")
795820
{
796-
textBCpath.Text = Path.GetDirectoryName(file.FileName);
821+
textBCpath.Text = System.IO.Path.GetDirectoryName(file.FileName);
797822
}
798823
dt.Rows.Clear();
799824
dt.Rows.Add(new object[] { "", "" });
@@ -820,9 +845,19 @@ private void GzPath_Click(object sender, EventArgs e)
820845
{
821846
OpenFileDialog file = new OpenFileDialog();
822847
file.Filter = "图片文件|*.jpg;*.png";
848+
file.Multiselect = true;
823849
if (file.ShowDialog() == DialogResult.OK)
824850
{
825-
textGZpath.Text = file.FileName;
851+
string filename;
852+
StreamWriter sw = File.AppendText(yzLog);
853+
foreach (string filePath in file.FileNames)
854+
{
855+
filename = System.IO.Path.GetFileName(filePath);//文件名
856+
dtYz.Rows.Add(new object[] { filename, filePath });
857+
sw.WriteLine(filePath);
858+
}
859+
sw.Close();
860+
sw.Dispose();
826861
}
827862
}
828863
//预览图定位
@@ -1059,30 +1094,6 @@ private void pathText_DragDrop(object sender, DragEventArgs e)
10591094

10601095
}
10611096

1062-
private void textGZpath_DragEnter(object sender, DragEventArgs e)
1063-
{
1064-
if (e.Data.GetDataPresent(DataFormats.FileDrop))
1065-
{
1066-
e.Effect = DragDropEffects.All;//调用DragDrop事件
1067-
}
1068-
else
1069-
{
1070-
e.Effect = DragDropEffects.None;
1071-
}
1072-
}
1073-
1074-
private void textGZpath_DragDrop(object sender, DragEventArgs e)
1075-
{
1076-
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);//拖放的多个文件的路径列表
1077-
1078-
string extension = System.IO.Path.GetExtension(filePaths[0]);//文件后缀名
1079-
if ((extension == ".gif") || (extension == ".bmp") || (extension == ".png") || (extension == ".jpg") || (extension == ".jpeg"))
1080-
{
1081-
//todo you code
1082-
this.textGZpath.Text = filePaths[0];
1083-
}
1084-
}
1085-
10861097

10871098
//数字签名类型
10881099
private void comboQmtype_SelectionChangeCommitted(object sender, EventArgs e)

0 commit comments

Comments
 (0)