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
1cd55e86
Commit
1cd55e86
authored
Jun 07, 2021
by
施晓雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加输出图片的测试
parent
e684dd72
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
119 additions
and
22 deletions
+119
-22
Kivii.Pdf.Test.csproj
Kivii.Pdf.Test.csproj
+2
-2
frmMain.Designer.cs
frmMain.Designer.cs
+82
-19
frmMain.cs
frmMain.cs
+33
-0
packages.config
packages.config
+2
-1
No files found.
Kivii.Pdf.Test.csproj
View file @
1cd55e86
...
...
@@ -32,8 +32,8 @@
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Kivii.Common.V4.0, Version=5.
5.2020.92
80, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
packages\Kivii.Common.5.
5.2020.92
80\lib\net40\Kivii.Common.V4.0.dll
</HintPath>
<Reference
Include=
"Kivii.Common.V4.0, Version=5.
6.2021.50
80, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
packages\Kivii.Common.5.
6.2021.50
80\lib\net40\Kivii.Common.V4.0.dll
</HintPath>
</Reference>
<Reference
Include=
"Kivii.Pdf.V4.0, Version=5.5.2020.11000, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
packages\Kivii.Pdf.5.5.2020.11000\lib\net40\Kivii.Pdf.V4.0.dll
</HintPath>
...
...
frmMain.Designer.cs
View file @
1cd55e86
...
...
@@ -89,10 +89,16 @@
this
.
label26
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label24
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label25
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
groupBox4
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
btnExportImages
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
tbxExportImagesPath
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label30
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnSelectImagePath
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
panel1
.
SuspendLayout
();
this
.
groupBox2
.
SuspendLayout
();
this
.
groupBox1
.
SuspendLayout
();
this
.
groupBox3
.
SuspendLayout
();
this
.
groupBox4
.
SuspendLayout
();
this
.
SuspendLayout
();
//
// button1
...
...
@@ -593,15 +599,7 @@
//
// groupBox3
//
this
.
groupBox3
.
Controls
.
Add
(
this
.
label27
);
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
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
groupBox4
);
this
.
groupBox3
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Left
;
this
.
groupBox3
.
Location
=
new
System
.
Drawing
.
Point
(
441
,
0
);
this
.
groupBox3
.
Name
=
"groupBox3"
;
...
...
@@ -612,7 +610,7 @@
//
// label27
//
this
.
label27
.
Location
=
new
System
.
Drawing
.
Point
(
18
,
90
);
this
.
label27
.
Location
=
new
System
.
Drawing
.
Point
(
838
,
109
);
this
.
label27
.
Name
=
"label27"
;
this
.
label27
.
Size
=
new
System
.
Drawing
.
Size
(
331
,
43
);
this
.
label27
.
TabIndex
=
7
;
...
...
@@ -620,7 +618,7 @@
//
// btnStamp2
//
this
.
btnStamp2
.
Location
=
new
System
.
Drawing
.
Point
(
20
,
227
);
this
.
btnStamp2
.
Location
=
new
System
.
Drawing
.
Point
(
840
,
246
);
this
.
btnStamp2
.
Name
=
"btnStamp2"
;
this
.
btnStamp2
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
23
);
this
.
btnStamp2
.
TabIndex
=
6
;
...
...
@@ -630,21 +628,21 @@
//
// tbxPdfFilePath2
//
this
.
tbxPdfFilePath2
.
Location
=
new
System
.
Drawing
.
Point
(
83
,
30
);
this
.
tbxPdfFilePath2
.
Location
=
new
System
.
Drawing
.
Point
(
903
,
49
);
this
.
tbxPdfFilePath2
.
Name
=
"tbxPdfFilePath2"
;
this
.
tbxPdfFilePath2
.
Size
=
new
System
.
Drawing
.
Size
(
218
,
21
);
this
.
tbxPdfFilePath2
.
TabIndex
=
4
;
//
// tbxSaveFolder2
//
this
.
tbxSaveFolder2
.
Location
=
new
System
.
Drawing
.
Point
(
83
,
182
);
this
.
tbxSaveFolder2
.
Location
=
new
System
.
Drawing
.
Point
(
903
,
201
);
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
.
Location
=
new
System
.
Drawing
.
Point
(
1137
,
201
);
this
.
btnSelectSaveFolder2
.
Name
=
"btnSelectSaveFolder2"
;
this
.
btnSelectSaveFolder2
.
Size
=
new
System
.
Drawing
.
Size
(
32
,
23
);
this
.
btnSelectSaveFolder2
.
TabIndex
=
5
;
...
...
@@ -654,7 +652,7 @@
//
// btnSelectFile2
//
this
.
btnSelectFile2
.
Location
=
new
System
.
Drawing
.
Point
(
317
,
30
);
this
.
btnSelectFile2
.
Location
=
new
System
.
Drawing
.
Point
(
1137
,
49
);
this
.
btnSelectFile2
.
Name
=
"btnSelectFile2"
;
this
.
btnSelectFile2
.
Size
=
new
System
.
Drawing
.
Size
(
32
,
23
);
this
.
btnSelectFile2
.
TabIndex
=
5
;
...
...
@@ -665,7 +663,7 @@
// label26
//
this
.
label26
.
AutoSize
=
true
;
this
.
label26
.
Location
=
new
System
.
Drawing
.
Point
(
18
,
185
);
this
.
label26
.
Location
=
new
System
.
Drawing
.
Point
(
838
,
204
);
this
.
label26
.
Name
=
"label26"
;
this
.
label26
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label26
.
TabIndex
=
1
;
...
...
@@ -674,7 +672,7 @@
// label24
//
this
.
label24
.
AutoSize
=
true
;
this
.
label24
.
Location
=
new
System
.
Drawing
.
Point
(
81
,
54
);
this
.
label24
.
Location
=
new
System
.
Drawing
.
Point
(
901
,
73
);
this
.
label24
.
Name
=
"label24"
;
this
.
label24
.
Size
=
new
System
.
Drawing
.
Size
(
161
,
12
);
this
.
label24
.
TabIndex
=
6
;
...
...
@@ -683,22 +681,81 @@
// label25
//
this
.
label25
.
AutoSize
=
true
;
this
.
label25
.
Location
=
new
System
.
Drawing
.
Point
(
18
,
33
);
this
.
label25
.
Location
=
new
System
.
Drawing
.
Point
(
838
,
52
);
this
.
label25
.
Name
=
"label25"
;
this
.
label25
.
Size
=
new
System
.
Drawing
.
Size
(
47
,
12
);
this
.
label25
.
TabIndex
=
1
;
this
.
label25
.
Text
=
"PDF路径"
;
//
// groupBox4
//
this
.
groupBox4
.
Controls
.
Add
(
this
.
btnSelectImagePath
);
this
.
groupBox4
.
Controls
.
Add
(
this
.
btnExportImages
);
this
.
groupBox4
.
Controls
.
Add
(
this
.
tbxExportImagesPath
);
this
.
groupBox4
.
Controls
.
Add
(
this
.
label30
);
this
.
groupBox4
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
groupBox4
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
17
);
this
.
groupBox4
.
Name
=
"groupBox4"
;
this
.
groupBox4
.
Size
=
new
System
.
Drawing
.
Size
(
360
,
107
);
this
.
groupBox4
.
TabIndex
=
8
;
this
.
groupBox4
.
TabStop
=
false
;
this
.
groupBox4
.
Text
=
"获取图片"
;
//
// btnExportImages
//
this
.
btnExportImages
.
Location
=
new
System
.
Drawing
.
Point
(
16
,
63
);
this
.
btnExportImages
.
Name
=
"btnExportImages"
;
this
.
btnExportImages
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
23
);
this
.
btnExportImages
.
TabIndex
=
9
;
this
.
btnExportImages
.
Text
=
"导出图片"
;
this
.
btnExportImages
.
UseVisualStyleBackColor
=
true
;
this
.
btnExportImages
.
Click
+=
new
System
.
EventHandler
(
this
.
btnExportImages_Click
);
//
// tbxExportImagesPath
//
this
.
tbxExportImagesPath
.
Location
=
new
System
.
Drawing
.
Point
(
79
,
26
);
this
.
tbxExportImagesPath
.
Name
=
"tbxExportImagesPath"
;
this
.
tbxExportImagesPath
.
Size
=
new
System
.
Drawing
.
Size
(
208
,
21
);
this
.
tbxExportImagesPath
.
TabIndex
=
8
;
//
// label30
//
this
.
label30
.
AutoSize
=
true
;
this
.
label30
.
Location
=
new
System
.
Drawing
.
Point
(
14
,
29
);
this
.
label30
.
Name
=
"label30"
;
this
.
label30
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label30
.
TabIndex
=
7
;
this
.
label30
.
Text
=
"保存路径"
;
//
// btnSelectImagePath
//
this
.
btnSelectImagePath
.
Location
=
new
System
.
Drawing
.
Point
(
293
,
24
);
this
.
btnSelectImagePath
.
Name
=
"btnSelectImagePath"
;
this
.
btnSelectImagePath
.
Size
=
new
System
.
Drawing
.
Size
(
32
,
23
);
this
.
btnSelectImagePath
.
TabIndex
=
10
;
this
.
btnSelectImagePath
.
Text
=
"..."
;
this
.
btnSelectImagePath
.
UseVisualStyleBackColor
=
true
;
this
.
btnSelectImagePath
.
Click
+=
new
System
.
EventHandler
(
this
.
btnSelectImagePath_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
.
groupBox3
);
this
.
Controls
.
Add
(
this
.
label27
);
this
.
Controls
.
Add
(
this
.
panel1
);
this
.
Controls
.
Add
(
this
.
btnStamp2
);
this
.
Controls
.
Add
(
this
.
label2
);
this
.
Controls
.
Add
(
this
.
tbxPdfFilePath2
);
this
.
Controls
.
Add
(
this
.
textBox1
);
this
.
Controls
.
Add
(
this
.
tbxSaveFolder2
);
this
.
Controls
.
Add
(
this
.
button1
);
this
.
Controls
.
Add
(
this
.
btnSelectSaveFolder2
);
this
.
Controls
.
Add
(
this
.
label25
);
this
.
Controls
.
Add
(
this
.
btnSelectFile2
);
this
.
Controls
.
Add
(
this
.
label24
);
this
.
Controls
.
Add
(
this
.
label26
);
this
.
Name
=
"frmMain"
;
this
.
Text
=
"PDF "
;
this
.
panel1
.
ResumeLayout
(
false
);
...
...
@@ -707,7 +764,8 @@
this
.
groupBox1
.
ResumeLayout
(
false
);
this
.
groupBox1
.
PerformLayout
();
this
.
groupBox3
.
ResumeLayout
(
false
);
this
.
groupBox3
.
PerformLayout
();
this
.
groupBox4
.
ResumeLayout
(
false
);
this
.
groupBox4
.
PerformLayout
();
this
.
ResumeLayout
(
false
);
this
.
PerformLayout
();
...
...
@@ -776,6 +834,11 @@
private
System
.
Windows
.
Forms
.
Button
btnStampByService
;
private
System
.
Windows
.
Forms
.
TextBox
tbxServiceUrl
;
private
System
.
Windows
.
Forms
.
Label
label29
;
private
System
.
Windows
.
Forms
.
GroupBox
groupBox4
;
private
System
.
Windows
.
Forms
.
Button
btnExportImages
;
private
System
.
Windows
.
Forms
.
TextBox
tbxExportImagesPath
;
private
System
.
Windows
.
Forms
.
Label
label30
;
private
System
.
Windows
.
Forms
.
Button
btnSelectImagePath
;
}
}
frmMain.cs
View file @
1cd55e86
...
...
@@ -214,5 +214,38 @@ namespace Kivii.Pdf.Test
}
catch
{
}
}
private
void
btnSelectImagePath_Click
(
object
sender
,
EventArgs
e
)
{
FolderBrowserDialog
sfd
=
new
FolderBrowserDialog
();
if
(
sfd
.
ShowDialog
()
!=
DialogResult
.
OK
)
return
;
tbxExportImagesPath
.
Text
=
sfd
.
SelectedPath
;
}
private
void
btnExportImages_Click
(
object
sender
,
EventArgs
e
)
{
var
reader
=
new
PdfReader
(
tbxPdfFilePath
.
Text
);
for
(
var
i
=
0
;
i
<
reader
.
XrefSize
;
i
++)
{
var
pdfObj
=
reader
.
GetPdfObject
(
i
);
if
(
pdfObj
==
null
||
!
pdfObj
.
IsStream
())
continue
;
var
pdfStream
=
(
PdfStream
)
pdfObj
;
var
subType
=
pdfStream
.
Get
(
PdfName
.
SUBTYPE
);
if
(
subType
==
null
||
subType
.
ToString
()
!=
PdfName
.
IMAGE
.
ToString
())
continue
;
var
bytes
=
PdfReader
.
GetStreamBytesRaw
((
PRStream
)
pdfStream
);
if
(
bytes
==
null
)
continue
;
try
{
var
ms
=
new
MemoryStream
(
bytes
);
ms
.
Position
=
0
;
var
img
=
System
.
Drawing
.
Image
.
FromStream
(
ms
);
img
.
Save
(
Path
.
Combine
(
tbxExportImagesPath
.
Text
,
$"
{
i
}
.jpg"
),
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
}
catch
{
}
}
}
}
}
packages.config
View file @
1cd55e86
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"Kivii.Common"
version
=
"5.
5.2020.92
80"
targetFramework
=
"net40"
/>
<
package
id
=
"Kivii.Common"
version
=
"5.
6.2021.50
80"
targetFramework
=
"net40"
/>
<
package
id
=
"Kivii.Pdf"
version
=
"5.5.2020.11000"
targetFramework
=
"net40"
/>
</
packages
>
\ No newline at end of file
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