Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Pdf.Test
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
示例代码
Kivii.Pdf.Test
Commits
6642000a
Commit
6642000a
authored
Jun 22, 2020
by
施晓雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a7623a3c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
169 additions
and
75 deletions
+169
-75
Kivii.Pdf.Test.csproj
Kivii.Pdf.Test.csproj
+18
-0
frmMain.Designer.cs
frmMain.Designer.cs
+75
-75
frmMain.cs
frmMain.cs
+76
-0
qrcode.png
qrcode.png
+0
-0
stamp.png
stamp.png
+0
-0
test.pdf
test.pdf
+0
-0
watermark.png
watermark.png
+0
-0
No files found.
Kivii.Pdf.Test.csproj
View file @
6642000a
...
...
@@ -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
frmMain.Designer.cs
View file @
6642000a
...
...
@@ -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
.
b
utton4
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
t
extBox
2
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
t
extBox3
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
b
utton3
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
b
utton
2
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
b
tnStamp2
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
t
bxPdfFilePath
2
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
t
bxSaveFolder2
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
b
tnSelectSaveFolder2
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
b
tnSelectFile
2
);
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
);
//
// t
extBox
2
// t
bxPdfFilePath
2
//
this
.
t
extBox
2
.
Location
=
new
System
.
Drawing
.
Point
(
83
,
30
);
this
.
t
extBox2
.
Name
=
"textBox
2"
;
this
.
t
extBox
2
.
Size
=
new
System
.
Drawing
.
Size
(
218
,
21
);
this
.
t
extBox
2
.
TabIndex
=
4
;
this
.
t
bxPdfFilePath
2
.
Location
=
new
System
.
Drawing
.
Point
(
83
,
30
);
this
.
t
bxPdfFilePath2
.
Name
=
"tbxPdfFilePath
2"
;
this
.
t
bxPdfFilePath
2
.
Size
=
new
System
.
Drawing
.
Size
(
218
,
21
);
this
.
t
bxPdfFilePath
2
.
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地址"
;
//
// label2
7
// label2
5
//
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
b
utton4
;
private
System
.
Windows
.
Forms
.
TextBox
t
extBox
2
;
private
System
.
Windows
.
Forms
.
TextBox
t
extBox3
;
private
System
.
Windows
.
Forms
.
Button
b
utton3
;
private
System
.
Windows
.
Forms
.
Button
b
utton
2
;
private
System
.
Windows
.
Forms
.
Button
b
tnStamp2
;
private
System
.
Windows
.
Forms
.
TextBox
t
bxPdfFilePath
2
;
private
System
.
Windows
.
Forms
.
TextBox
t
bxSaveFolder2
;
private
System
.
Windows
.
Forms
.
Button
b
tnSelectSaveFolder2
;
private
System
.
Windows
.
Forms
.
Button
b
tnSelectFile
2
;
private
System
.
Windows
.
Forms
.
Label
label26
;
private
System
.
Windows
.
Forms
.
Label
label24
;
private
System
.
Windows
.
Forms
.
Label
label25
;
...
...
frmMain.cs
View file @
6642000a
...
...
@@ -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
0 → 100644
View file @
6642000a
22.3 KB
stamp.png
0 → 100644
View file @
6642000a
161 KB
test.pdf
0 → 100644
View file @
6642000a
File added
watermark.png
0 → 100644
View file @
6642000a
27.6 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment