Commit 70dc6fd7 by 施晓雨

导入代码

parent 50479606
namespace Kivii.Pdf.Test
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(895, 619);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Kivii.Pdf.Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
......@@ -32,6 +32,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Kivii.Pdf.V4.0, Version=5.5.2020.6200, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Kivii.Pdf.5.5.2020.6200\lib\net40\Kivii.Pdf.V4.0.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
......@@ -44,16 +47,16 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<Compile Include="frmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
<Compile Include="frmMain.Designer.cs">
<DependentUpon>frmMain.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
<EmbeddedResource Include="frmMain.resx">
<DependentUpon>frmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
......@@ -64,6 +67,7 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
......
......@@ -15,7 +15,7 @@ namespace Kivii.Pdf.Test
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Application.Run(new frmMain());
}
}
}
namespace Kivii.Pdf.Test
{
partial class frmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.btnStamp = new System.Windows.Forms.Button();
this.tbxSaveFilePath = new System.Windows.Forms.TextBox();
this.btnSelectSaveFilePath = new System.Windows.Forms.Button();
this.label23 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label20 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.label22 = new System.Windows.Forms.Label();
this.label21 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.tbxSignatureTimeStampAuthorityUrl = new System.Windows.Forms.TextBox();
this.tbxSignatureLocation = new System.Windows.Forms.TextBox();
this.tbxSignatureReason = new System.Windows.Forms.TextBox();
this.tbxSignatureFilePassword = new System.Windows.Forms.TextBox();
this.label15 = new System.Windows.Forms.Label();
this.tbxStampWidth = new System.Windows.Forms.TextBox();
this.label14 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.cbxStampType = new System.Windows.Forms.ComboBox();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.tbxPages = new System.Windows.Forms.TextBox();
this.tbxSignatureFilePath = new System.Windows.Forms.TextBox();
this.tbxPdfFilePath = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.tbxMatchText = new System.Windows.Forms.TextBox();
this.label12 = new System.Windows.Forms.Label();
this.tbxStampFilePath = new System.Windows.Forms.TextBox();
this.label16 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.tbxOffsetX = new System.Windows.Forms.TextBox();
this.btnSelectStamp = new System.Windows.Forms.Button();
this.btnSelectPfx = new System.Windows.Forms.Button();
this.tbxOffsetY = new System.Windows.Forms.TextBox();
this.btnSelectFile = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(1059, 109);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(888, 41);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 21);
this.textBox1.TabIndex = 2;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(805, 45);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(59, 12);
this.label2.TabIndex = 3;
this.label2.Text = "源PDF文件";
//
// panel1
//
this.panel1.Controls.Add(this.groupBox2);
this.panel1.Controls.Add(this.groupBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(441, 657);
this.panel1.TabIndex = 12;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.btnStamp);
this.groupBox2.Controls.Add(this.tbxSaveFilePath);
this.groupBox2.Controls.Add(this.btnSelectSaveFilePath);
this.groupBox2.Controls.Add(this.label23);
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox2.Location = new System.Drawing.Point(0, 475);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(441, 182);
this.groupBox2.TabIndex = 13;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "操作";
//
// btnStamp
//
this.btnStamp.Location = new System.Drawing.Point(14, 65);
this.btnStamp.Name = "btnStamp";
this.btnStamp.Size = new System.Drawing.Size(75, 23);
this.btnStamp.TabIndex = 6;
this.btnStamp.Text = "执行";
this.btnStamp.UseVisualStyleBackColor = true;
this.btnStamp.Click += new System.EventHandler(this.btnStamp_Click);
//
// tbxSaveFilePath
//
this.tbxSaveFilePath.Location = new System.Drawing.Point(77, 20);
this.tbxSaveFilePath.Name = "tbxSaveFilePath";
this.tbxSaveFilePath.Size = new System.Drawing.Size(308, 21);
this.tbxSaveFilePath.TabIndex = 4;
//
// btnSelectSaveFilePath
//
this.btnSelectSaveFilePath.Location = new System.Drawing.Point(393, 20);
this.btnSelectSaveFilePath.Name = "btnSelectSaveFilePath";
this.btnSelectSaveFilePath.Size = new System.Drawing.Size(32, 23);
this.btnSelectSaveFilePath.TabIndex = 5;
this.btnSelectSaveFilePath.Text = "...";
this.btnSelectSaveFilePath.UseVisualStyleBackColor = true;
this.btnSelectSaveFilePath.Click += new System.EventHandler(this.btnSelectSaveFilePath_Click);
//
// label23
//
this.label23.AutoSize = true;
this.label23.Location = new System.Drawing.Point(12, 23);
this.label23.Name = "label23";
this.label23.Size = new System.Drawing.Size(53, 12);
this.label23.TabIndex = 1;
this.label23.Text = "保存路径";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label20);
this.groupBox1.Controls.Add(this.label19);
this.groupBox1.Controls.Add(this.label22);
this.groupBox1.Controls.Add(this.label21);
this.groupBox1.Controls.Add(this.label18);
this.groupBox1.Controls.Add(this.tbxSignatureTimeStampAuthorityUrl);
this.groupBox1.Controls.Add(this.tbxSignatureLocation);
this.groupBox1.Controls.Add(this.tbxSignatureReason);
this.groupBox1.Controls.Add(this.tbxSignatureFilePassword);
this.groupBox1.Controls.Add(this.label15);
this.groupBox1.Controls.Add(this.tbxStampWidth);
this.groupBox1.Controls.Add(this.label14);
this.groupBox1.Controls.Add(this.label17);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.label11);
this.groupBox1.Controls.Add(this.cbxStampType);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.label9);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label10);
this.groupBox1.Controls.Add(this.tbxPages);
this.groupBox1.Controls.Add(this.tbxSignatureFilePath);
this.groupBox1.Controls.Add(this.tbxPdfFilePath);
this.groupBox1.Controls.Add(this.label8);
this.groupBox1.Controls.Add(this.tbxMatchText);
this.groupBox1.Controls.Add(this.label12);
this.groupBox1.Controls.Add(this.tbxStampFilePath);
this.groupBox1.Controls.Add(this.label16);
this.groupBox1.Controls.Add(this.label13);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.tbxOffsetX);
this.groupBox1.Controls.Add(this.btnSelectStamp);
this.groupBox1.Controls.Add(this.btnSelectPfx);
this.groupBox1.Controls.Add(this.tbxOffsetY);
this.groupBox1.Controls.Add(this.btnSelectFile);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(441, 475);
this.groupBox1.TabIndex = 12;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "操作参数";
//
// label20
//
this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(75, 396);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(107, 12);
this.label20.TabIndex = 14;
this.label20.Text = "PDF授时服务器地址";
//
// label19
//
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(11, 375);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(47, 12);
this.label19.TabIndex = 12;
this.label19.Text = "TSA地址";
//
// label22
//
this.label22.AutoSize = true;
this.label22.Location = new System.Drawing.Point(12, 441);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(53, 12);
this.label22.TabIndex = 12;
this.label22.Text = "签名地址";
//
// label21
//
this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(12, 414);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(53, 12);
this.label21.TabIndex = 12;
this.label21.Text = "签名原因";
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(12, 348);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(53, 12);
this.label18.TabIndex = 12;
this.label18.Text = "证书密码";
//
// tbxSignatureTimeStampAuthorityUrl
//
this.tbxSignatureTimeStampAuthorityUrl.Location = new System.Drawing.Point(74, 372);
this.tbxSignatureTimeStampAuthorityUrl.Name = "tbxSignatureTimeStampAuthorityUrl";
this.tbxSignatureTimeStampAuthorityUrl.Size = new System.Drawing.Size(348, 21);
this.tbxSignatureTimeStampAuthorityUrl.TabIndex = 13;
this.tbxSignatureTimeStampAuthorityUrl.Text = "http://ts.cartaodecidadao.pt/tsa/server";
//
// tbxSignatureLocation
//
this.tbxSignatureLocation.Location = new System.Drawing.Point(77, 438);
this.tbxSignatureLocation.Name = "tbxSignatureLocation";
this.tbxSignatureLocation.Size = new System.Drawing.Size(348, 21);
this.tbxSignatureLocation.TabIndex = 13;
//
// tbxSignatureReason
//
this.tbxSignatureReason.Location = new System.Drawing.Point(77, 411);
this.tbxSignatureReason.Name = "tbxSignatureReason";
this.tbxSignatureReason.Size = new System.Drawing.Size(348, 21);
this.tbxSignatureReason.TabIndex = 13;
//
// tbxSignatureFilePassword
//
this.tbxSignatureFilePassword.Location = new System.Drawing.Point(77, 345);
this.tbxSignatureFilePassword.Name = "tbxSignatureFilePassword";
this.tbxSignatureFilePassword.Size = new System.Drawing.Size(348, 21);
this.tbxSignatureFilePassword.TabIndex = 13;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(233, 116);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(53, 12);
this.label15.TabIndex = 10;
this.label15.Text = "图片宽度";
//
// tbxStampWidth
//
this.tbxStampWidth.Location = new System.Drawing.Point(292, 112);
this.tbxStampWidth.Name = "tbxStampWidth";
this.tbxStampWidth.Size = new System.Drawing.Size(133, 21);
this.tbxStampWidth.TabIndex = 11;
this.tbxStampWidth.Text = "40mm";
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(12, 139);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(53, 12);
this.label14.TabIndex = 1;
this.label14.Text = "页面范围";
//
// label17
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(12, 309);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(53, 12);
this.label17.TabIndex = 1;
this.label17.Text = "证书路径";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 31);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(47, 12);
this.label1.TabIndex = 1;
this.label1.Text = "PDF路径";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(12, 231);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(53, 12);
this.label11.TabIndex = 1;
this.label11.Text = "匹配规则";
//
// cbxStampType
//
this.cbxStampType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbxStampType.FormattingEnabled = true;
this.cbxStampType.Items.AddRange(new object[] {
"Position-定位盖章",
"Paging-骑缝章",
"Signature-数据签章",
"Replace-替换图片",
"WaterMark-水印"});
this.cbxStampType.Location = new System.Drawing.Point(77, 112);
this.cbxStampType.Name = "cbxStampType";
this.cbxStampType.Size = new System.Drawing.Size(141, 20);
this.cbxStampType.TabIndex = 9;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(12, 186);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(47, 12);
this.label7.TabIndex = 1;
this.label7.Text = "X轴偏移";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(12, 112);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(53, 12);
this.label6.TabIndex = 8;
this.label6.Text = "操作类型";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(233, 181);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(47, 12);
this.label9.TabIndex = 1;
this.label9.Text = "Y轴偏移";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(75, 91);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(263, 12);
this.label5.TabIndex = 7;
this.label5.Text = "当使用Replace模式时,不填写路径即为移除图片";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 70);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(53, 12);
this.label4.TabIndex = 1;
this.label4.Text = "图片路径";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(282, 201);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(143, 12);
this.label10.TabIndex = 6;
this.label10.Text = "单位为mm,cm,px,默认为px";
//
// tbxPages
//
this.tbxPages.Location = new System.Drawing.Point(77, 136);
this.tbxPages.Name = "tbxPages";
this.tbxPages.Size = new System.Drawing.Size(348, 21);
this.tbxPages.TabIndex = 4;
this.tbxPages.Text = "1-E";
//
// tbxSignatureFilePath
//
this.tbxSignatureFilePath.Location = new System.Drawing.Point(77, 306);
this.tbxSignatureFilePath.Name = "tbxSignatureFilePath";
this.tbxSignatureFilePath.Size = new System.Drawing.Size(308, 21);
this.tbxSignatureFilePath.TabIndex = 4;
//
// tbxPdfFilePath
//
this.tbxPdfFilePath.Location = new System.Drawing.Point(77, 28);
this.tbxPdfFilePath.Name = "tbxPdfFilePath";
this.tbxPdfFilePath.Size = new System.Drawing.Size(308, 21);
this.tbxPdfFilePath.TabIndex = 4;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(75, 203);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(143, 12);
this.label8.TabIndex = 6;
this.label8.Text = "单位为mm,cm,px,默认为px";
//
// tbxMatchText
//
this.tbxMatchText.Location = new System.Drawing.Point(77, 228);
this.tbxMatchText.Name = "tbxMatchText";
this.tbxMatchText.Size = new System.Drawing.Size(348, 21);
this.tbxMatchText.TabIndex = 4;
//
// label12
//
this.label12.Location = new System.Drawing.Point(75, 252);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(350, 51);
this.label12.TabIndex = 6;
this.label12.Text = "当为Position类型时,可以定位PDF中的文本,*号为模糊匹配前缀或后缀。当为Replace类型时,可以匹配图片大小,W75-80,H75-80,T1。W为宽" +
"度匹配,H为高度匹配,T为次数匹配,默认为1次匹配";
//
// tbxStampFilePath
//
this.tbxStampFilePath.Location = new System.Drawing.Point(77, 67);
this.tbxStampFilePath.Name = "tbxStampFilePath";
this.tbxStampFilePath.Size = new System.Drawing.Size(308, 21);
this.tbxStampFilePath.TabIndex = 4;
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(75, 330);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(143, 12);
this.label16.TabIndex = 6;
this.label16.Text = "PDF数据证书路径,pfx格式";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(75, 160);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(347, 12);
this.label13.TabIndex = 6;
this.label13.Text = "默认为1-E,E代表最后一页,E1为最后一页的前1页,多页用,分隔";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(75, 52);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(161, 12);
this.label3.TabIndex = 6;
this.label3.Text = "可以选择文件或填写Http地址";
//
// tbxOffsetX
//
this.tbxOffsetX.Location = new System.Drawing.Point(77, 178);
this.tbxOffsetX.Name = "tbxOffsetX";
this.tbxOffsetX.Size = new System.Drawing.Size(141, 21);
this.tbxOffsetX.TabIndex = 4;
this.tbxOffsetX.Text = "0mm";
//
// btnSelectStamp
//
this.btnSelectStamp.Location = new System.Drawing.Point(393, 67);
this.btnSelectStamp.Name = "btnSelectStamp";
this.btnSelectStamp.Size = new System.Drawing.Size(32, 23);
this.btnSelectStamp.TabIndex = 5;
this.btnSelectStamp.Text = "...";
this.btnSelectStamp.UseVisualStyleBackColor = true;
this.btnSelectStamp.Click += new System.EventHandler(this.btnSelectStamp_Click);
//
// btnSelectPfx
//
this.btnSelectPfx.Location = new System.Drawing.Point(393, 306);
this.btnSelectPfx.Name = "btnSelectPfx";
this.btnSelectPfx.Size = new System.Drawing.Size(32, 23);
this.btnSelectPfx.TabIndex = 5;
this.btnSelectPfx.Text = "...";
this.btnSelectPfx.UseVisualStyleBackColor = true;
this.btnSelectPfx.Click += new System.EventHandler(this.btnSelectPfx_Click);
//
// tbxOffsetY
//
this.tbxOffsetY.Location = new System.Drawing.Point(284, 177);
this.tbxOffsetY.Name = "tbxOffsetY";
this.tbxOffsetY.Size = new System.Drawing.Size(141, 21);
this.tbxOffsetY.TabIndex = 4;
this.tbxOffsetY.Text = "0mm";
//
// btnSelectFile
//
this.btnSelectFile.Location = new System.Drawing.Point(393, 28);
this.btnSelectFile.Name = "btnSelectFile";
this.btnSelectFile.Size = new System.Drawing.Size(32, 23);
this.btnSelectFile.TabIndex = 5;
this.btnSelectFile.Text = "...";
this.btnSelectFile.UseVisualStyleBackColor = true;
this.btnSelectFile.Click += new System.EventHandler(this.btnSelectFile_Click);
//
// frmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1185, 657);
this.Controls.Add(this.panel1);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Name = "frmMain";
this.Text = "PDF ";
this.panel1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label20;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.Label label22;
private System.Windows.Forms.Label label21;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.TextBox tbxSignatureTimeStampAuthorityUrl;
private System.Windows.Forms.TextBox tbxSignatureLocation;
private System.Windows.Forms.TextBox tbxSignatureReason;
private System.Windows.Forms.TextBox tbxSignatureFilePassword;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.TextBox tbxStampWidth;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.ComboBox cbxStampType;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox tbxPages;
private System.Windows.Forms.TextBox tbxSignatureFilePath;
private System.Windows.Forms.TextBox tbxPdfFilePath;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox tbxMatchText;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.TextBox tbxStampFilePath;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox tbxOffsetX;
private System.Windows.Forms.Button btnSelectStamp;
private System.Windows.Forms.Button btnSelectPfx;
private System.Windows.Forms.TextBox tbxOffsetY;
private System.Windows.Forms.Button btnSelectFile;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button btnStamp;
private System.Windows.Forms.TextBox tbxSaveFilePath;
private System.Windows.Forms.Button btnSelectSaveFilePath;
private System.Windows.Forms.Label label23;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Kivii.Pdf.Test
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void btnSelectFile_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Pdf文件|*.pdf";
if (ofd.ShowDialog() != DialogResult.OK) return;
tbxPdfFilePath.Text = ofd.FileName;
}
private void btnSelectStamp_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "图片|*.png;*.jpg;*.gif";
if (ofd.ShowDialog() != DialogResult.OK) return;
tbxStampFilePath.Text = ofd.FileName;
}
private void btnSelectPfx_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "数字证书|*.pfx";
if (ofd.ShowDialog() != DialogResult.OK) return;
tbxSignatureFilePath.Text = ofd.FileName;
}
private void btnSelectSaveFilePath_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Pdf文件|*.pdf";
if (sfd.ShowDialog() != DialogResult.OK) return;
tbxSaveFilePath.Text = sfd.FileName;
}
private StampSetting getSetting()
{
try
{
var rtns = new StampSetting();
rtns.StampFilePath = tbxStampFilePath.Text;
rtns.StampWidth = tbxStampWidth.Text;
rtns.Pages = tbxPages.Text;
rtns.OffsetX = tbxOffsetX.Text;
rtns.OffsetY = tbxOffsetY.Text;
rtns.MatchText = tbxMatchText.Text;
rtns.SignatureFilePath = tbxSignatureFilePath.Text;
rtns.SignatureFilePassword = tbxSignatureFilePassword.Text;
rtns.SignatureReason = tbxSignatureReason.Text;
rtns.SignatureLocation = tbxSignatureLocation.Text;
rtns.SignatureTimeStampAuthorityUrl = tbxSignatureTimeStampAuthorityUrl.Text;
rtns.StampType = (StampType)Enum.Parse(typeof(StampType), cbxStampType.Text.Split('-')[0]);
return rtns;
}
catch
{
return null;
}
}
private void btnStamp_Click(object sender, EventArgs e)
{
var setting = getSetting();
if (setting == null)
{
MessageBox.Show("参数设置有误");
return;
}
PdfReader reader = null;
if (tbxPdfFilePath.Text.StartsWith("http", StringComparison.CurrentCultureIgnoreCase))
{
reader = new PdfReader(new Uri(tbxPdfFilePath.Text));
}
else
{
reader = new PdfReader(tbxPdfFilePath.Text);
}
var result=reader.Stamp(setting, tbxSaveFilePath.Text);
reader.Close();
MessageBox.Show($"操作结果:{result}");
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Kivii.Pdf" version="5.5.2020.6200" targetFramework="net40" />
</packages>
\ No newline at end of file
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