Commit 6642000a by 施晓雨

1

parent a7623a3c
......@@ -77,6 +77,23 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="st_leo.pfx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="test.pdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="qrcode.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="stamp.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="watermark.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -76,15 +76,15 @@
this.tbxOffsetY = new System.Windows.Forms.TextBox();
this.btnSelectFile = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.button2 = new System.Windows.Forms.Button();
this.label27 = new System.Windows.Forms.Label();
this.btnStamp2 = new System.Windows.Forms.Button();
this.tbxPdfFilePath2 = new System.Windows.Forms.TextBox();
this.tbxSaveFolder2 = new System.Windows.Forms.TextBox();
this.btnSelectSaveFolder2 = new System.Windows.Forms.Button();
this.btnSelectFile2 = new System.Windows.Forms.Button();
this.label26 = new System.Windows.Forms.Label();
this.label24 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label25 = new System.Windows.Forms.Label();
this.label26 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button4 = new System.Windows.Forms.Button();
this.label27 = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
......@@ -550,11 +550,11 @@
// groupBox3
//
this.groupBox3.Controls.Add(this.label27);
this.groupBox3.Controls.Add(this.button4);
this.groupBox3.Controls.Add(this.textBox2);
this.groupBox3.Controls.Add(this.textBox3);
this.groupBox3.Controls.Add(this.button3);
this.groupBox3.Controls.Add(this.button2);
this.groupBox3.Controls.Add(this.btnStamp2);
this.groupBox3.Controls.Add(this.tbxPdfFilePath2);
this.groupBox3.Controls.Add(this.tbxSaveFolder2);
this.groupBox3.Controls.Add(this.btnSelectSaveFolder2);
this.groupBox3.Controls.Add(this.btnSelectFile2);
this.groupBox3.Controls.Add(this.label26);
this.groupBox3.Controls.Add(this.label24);
this.groupBox3.Controls.Add(this.label25);
......@@ -566,40 +566,57 @@
this.groupBox3.TabStop = false;
this.groupBox3.Text = "组合功能操作";
//
// button2
// label27
//
this.button2.Location = new System.Drawing.Point(317, 30);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(32, 23);
this.button2.TabIndex = 5;
this.button2.Text = "...";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.btnSelectFile_Click);
this.label27.Location = new System.Drawing.Point(18, 90);
this.label27.Name = "label27";
this.label27.Size = new System.Drawing.Size(331, 43);
this.label27.TabIndex = 7;
this.label27.Text = "执行过程参数以数组形式写在代码中,请参考代码,对文件进行组合操作";
//
// label24
// btnStamp2
//
this.label24.AutoSize = true;
this.label24.Location = new System.Drawing.Point(81, 54);
this.label24.Name = "label24";
this.label24.Size = new System.Drawing.Size(161, 12);
this.label24.TabIndex = 6;
this.label24.Text = "可以选择文件或填写Http地址";
this.btnStamp2.Location = new System.Drawing.Point(20, 227);
this.btnStamp2.Name = "btnStamp2";
this.btnStamp2.Size = new System.Drawing.Size(75, 23);
this.btnStamp2.TabIndex = 6;
this.btnStamp2.Text = "执行";
this.btnStamp2.UseVisualStyleBackColor = true;
this.btnStamp2.Click += new System.EventHandler(this.btnStamp2_Click);
//
// textBox2
// tbxPdfFilePath2
//
this.textBox2.Location = new System.Drawing.Point(83, 30);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(218, 21);
this.textBox2.TabIndex = 4;
this.tbxPdfFilePath2.Location = new System.Drawing.Point(83, 30);
this.tbxPdfFilePath2.Name = "tbxPdfFilePath2";
this.tbxPdfFilePath2.Size = new System.Drawing.Size(218, 21);
this.tbxPdfFilePath2.TabIndex = 4;
//
// label25
// tbxSaveFolder2
//
this.label25.AutoSize = true;
this.label25.Location = new System.Drawing.Point(18, 33);
this.label25.Name = "label25";
this.label25.Size = new System.Drawing.Size(47, 12);
this.label25.TabIndex = 1;
this.label25.Text = "PDF路径";
this.tbxSaveFolder2.Location = new System.Drawing.Point(83, 182);
this.tbxSaveFolder2.Name = "tbxSaveFolder2";
this.tbxSaveFolder2.Size = new System.Drawing.Size(218, 21);
this.tbxSaveFolder2.TabIndex = 4;
//
// btnSelectSaveFolder2
//
this.btnSelectSaveFolder2.Location = new System.Drawing.Point(317, 182);
this.btnSelectSaveFolder2.Name = "btnSelectSaveFolder2";
this.btnSelectSaveFolder2.Size = new System.Drawing.Size(32, 23);
this.btnSelectSaveFolder2.TabIndex = 5;
this.btnSelectSaveFolder2.Text = "...";
this.btnSelectSaveFolder2.UseVisualStyleBackColor = true;
this.btnSelectSaveFolder2.Click += new System.EventHandler(this.btnSelectSaveFolder2_Click);
//
// btnSelectFile2
//
this.btnSelectFile2.Location = new System.Drawing.Point(317, 30);
this.btnSelectFile2.Name = "btnSelectFile2";
this.btnSelectFile2.Size = new System.Drawing.Size(32, 23);
this.btnSelectFile2.TabIndex = 5;
this.btnSelectFile2.Text = "...";
this.btnSelectFile2.UseVisualStyleBackColor = true;
this.btnSelectFile2.Click += new System.EventHandler(this.btnSelectFile2_Click);
//
// label26
//
......@@ -610,40 +627,23 @@
this.label26.TabIndex = 1;
this.label26.Text = "保存路径";
//
// button3
//
this.button3.Location = new System.Drawing.Point(317, 182);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(32, 23);
this.button3.TabIndex = 5;
this.button3.Text = "...";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.btnSelectSaveFolder_Click);
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(83, 182);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(218, 21);
this.textBox3.TabIndex = 4;
//
// button4
// label24
//
this.button4.Location = new System.Drawing.Point(20, 227);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 6;
this.button4.Text = "执行";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.btnStamp_Click);
this.label24.AutoSize = true;
this.label24.Location = new System.Drawing.Point(81, 54);
this.label24.Name = "label24";
this.label24.Size = new System.Drawing.Size(161, 12);
this.label24.TabIndex = 6;
this.label24.Text = "可以选择文件或填写Http地址";
//
// label27
// label25
//
this.label27.Location = new System.Drawing.Point(18, 90);
this.label27.Name = "label27";
this.label27.Size = new System.Drawing.Size(331, 60);
this.label27.TabIndex = 7;
this.label27.Text = "执行过程参数以数组形式写在代码中,请参考代码,对文件进行组合操作";
this.label25.AutoSize = true;
this.label25.Location = new System.Drawing.Point(18, 33);
this.label25.Name = "label25";
this.label25.Size = new System.Drawing.Size(47, 12);
this.label25.TabIndex = 1;
this.label25.Text = "PDF路径";
//
// frmMain
//
......@@ -720,11 +720,11 @@
private System.Windows.Forms.Label label23;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Label label27;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button btnStamp2;
private System.Windows.Forms.TextBox tbxPdfFilePath2;
private System.Windows.Forms.TextBox tbxSaveFolder2;
private System.Windows.Forms.Button btnSelectSaveFolder2;
private System.Windows.Forms.Button btnSelectFile2;
private System.Windows.Forms.Label label26;
private System.Windows.Forms.Label label24;
private System.Windows.Forms.Label label25;
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
......@@ -110,5 +111,80 @@ namespace Kivii.Pdf.Test
reader?.Close();
}
}
private void btnSelectFile2_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Pdf文件|*.pdf";
if (ofd.ShowDialog() != DialogResult.OK) return;
tbxPdfFilePath2.Text = ofd.FileName;
tbxSaveFolder2.Text = System.IO.Path.GetDirectoryName(ofd.FileName);
}
private void btnSelectSaveFolder2_Click(object sender, EventArgs e)
{
FolderBrowserDialog sfd = new FolderBrowserDialog();
if (sfd.ShowDialog() != DialogResult.OK) return;
tbxSaveFolder2.Text = sfd.SelectedPath;
}
private void btnStamp2_Click(object sender, EventArgs e)
{
var folder = AppDomain.CurrentDomain.BaseDirectory;
List<StampSetting> settings = new List<StampSetting>();
var setting = new StampSetting();
#region 替换QRCODE
setting.Pages = "1";
setting.MatchText = "W139,H141";
setting.StampType = StampType.Replace;
setting.StampFilePath = Path.Combine(folder, "qrcode.png");
settings.Add(setting);
#endregion
#region 移除签章
setting = new StampSetting();
setting.Pages = "1";
setting.MatchText = "W240,H240";
setting.StampType = StampType.Replace;
setting.StampFilePath = string.Empty;
settings.Add(setting);
#endregion
#region 加骑缝章
setting = new StampSetting();
setting.Pages = "1-E";
setting.StampType = StampType.Paging;
setting.StampFilePath = Path.Combine(folder, "stamp.png");
settings.Add(setting);
#endregion
#region 加水印
setting = new StampSetting();
setting.Pages = "1-E";
setting.StampType = StampType.WaterMark;
setting.StampFilePath = Path.Combine(folder, "watermark.png");
settings.Add(setting);
#endregion
#region 数字签名
setting = new StampSetting();
setting.Pages = "1";
setting.MatchText = "*签发日期*";
setting.StampType = StampType.Signature;
setting.StampFilePath = Path.Combine(folder, "stamp.png");
setting.SignatureFilePath= Path.Combine(folder, "st_leo.pfx");
setting.SignatureFilePassword = "www.kivii.com";
setting.SignatureReason = "Test";
setting.SignatureLocation = "Nanjing";
settings.Add(setting);
#endregion
var normalSettings = settings.Where(o => o.StampType != StampType.Signature);
var reader = new PdfReader(tbxPdfFilePath2.Text);
var stamper=new PdfStamper(reader,)
}
}
}
qrcode.png

22.3 KB

stamp.png

161 KB

File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment