Skip to content

Commit a93ee10

Browse files
DevExpressExampleBotDevExpressExampleBot
authored andcommitted
Source auto update [skip ci]
1 parent 3c88fd4 commit a93ee10

File tree

4 files changed

+77
-108
lines changed

4 files changed

+77
-108
lines changed

VB/PdfDocumentProcessor.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
23
# Visual Studio Version 16
34
VisualStudioVersion = 16.0.29418.71
45
MinimumVisualStudioVersion = 10.0.40219.1

VB/PdfDocumentProcessor/PdfDocumentProcessor.vbproj

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,38 @@
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
5+
<OptionInfer>On</OptionInfer>
56
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
67
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
78
<ProjectGuid>{F6DB10E3-D8E0-415C-A621-F62435CCA80A}</ProjectGuid>
89
<OutputType>Exe</OutputType>
9-
<RootNamespace></RootNamespace>
10+
<RootNamespace>
11+
</RootNamespace>
1012
<AssemblyName>PdfDocumentProcessor</AssemblyName>
1113
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1214
<FileAlignment>512</FileAlignment>
1315
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1416
<Deterministic>true</Deterministic>
15-
<OptionExplicit>On</OptionExplicit>
16-
<OptionCompare>Binary</OptionCompare>
17-
<OptionStrict>Off</OptionStrict>
18-
<OptionInfer>On</OptionInfer>
1917
</PropertyGroup>
2018
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2119
<PlatformTarget>AnyCPU</PlatformTarget>
2220
<DebugSymbols>true</DebugSymbols>
2321
<DebugType>full</DebugType>
2422
<Optimize>false</Optimize>
2523
<OutputPath>bin\Debug\</OutputPath>
26-
<DefineDebug>true</DefineDebug>
27-
<DefineTrace>true</DefineTrace>
24+
<DefineConstants>DEBUG,TRACE</DefineConstants>
2825
<ErrorReport>prompt</ErrorReport>
29-
<RemoveIntegerChecks>true</RemoveIntegerChecks>
26+
<WarningLevel>4</WarningLevel>
3027
</PropertyGroup>
3128
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3229
<PlatformTarget>AnyCPU</PlatformTarget>
3330
<DebugType>pdbonly</DebugType>
3431
<Optimize>true</Optimize>
3532
<OutputPath>bin\Release\</OutputPath>
36-
<DefineDebug>false</DefineDebug>
37-
<DefineTrace>true</DefineTrace>
33+
<DefineConstants>TRACE</DefineConstants>
3834
<ErrorReport>prompt</ErrorReport>
39-
<RemoveIntegerChecks>true</RemoveIntegerChecks>
35+
<WarningLevel>4</WarningLevel>
4036
</PropertyGroup>
41-
<ItemGroup>
42-
<Import Include="Microsoft.VisualBasic" />
43-
<Import Include="System" />
44-
<Import Include="System.Collections" />
45-
<Import Include="System.Collections.Generic" />
46-
<Import Include="System.Diagnostics" />
47-
<Import Include="System.Linq" />
48-
<Import Include="System.Xml.Linq" />
49-
<Import Include="System.Threading.Tasks" />
50-
<Import Include="System.Data" />
51-
<Import Include="System.Drawing" />
52-
</ItemGroup>
5337
<ItemGroup>
5438
<Reference Include="DevExpress.Data.v21.1, Version=21.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
5539
<Reference Include="DevExpress.Docs.v21.1, Version=21.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
@@ -67,7 +51,7 @@
6751
</ItemGroup>
6852
<ItemGroup>
6953
<Compile Include="Program.vb" />
70-
<Compile Include="My Project\AssemblyInfo.vb" />
54+
<Compile Include="Properties\AssemblyInfo.vb" />
7155
</ItemGroup>
7256
<ItemGroup>
7357
<None Include="App.config" />

VB/PdfDocumentProcessor/Program.vb

Lines changed: 54 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,64 @@
1-
Imports System
1+
Imports System
22
Imports DevExpress.Pdf
33
Imports System.Diagnostics
44
Imports DevExpress.Office.DigitalSignatures
5-
Imports System.Linq
65
Imports DevExpress.Office.Tsp
76

87
Namespace PdfDocumentProcessor
9-
Friend Class Program
10-
Shared Sub Main(ByVal args() As String)
11-
ApplySignatures()
12-
Process.Start("SignedDocument.pdf")
13-
End Sub
148

15-
Public Shared Sub ApplySignatures()
16-
'Load a document to sign
17-
Using signer = New PdfDocumentSigner("Document.pdf")
18-
'Specify the name and location of the signature field
19-
Dim signatureFieldInfo = New PdfSignatureFieldInfo(1)
20-
signatureFieldInfo.Name = "SignatureField"
21-
signatureFieldInfo.SignatureBounds = New PdfRectangle(20, 20, 150, 150)
22-
signatureFieldInfo.RotationAngle = PdfAcroFormFieldRotation.Rotate90
9+
Friend Class Program
2310

24-
'Create a timestamp
25-
Dim tsaClient As ITsaClient = New TsaClient(New Uri("https://freetsa.org/tsr"), HashAlgorithmType.SHA256)
11+
Shared Sub Main(ByVal args As String())
12+
Call ApplySignatures()
13+
Call Process.Start("SignedDocument.pdf")
14+
End Sub
2615

27-
'Create a PAdES PKCS#7 signature
28-
Dim pkcs7Signature As New Pkcs7Signer("Signing Documents/certificate.pfx", "123", HashAlgorithmType.SHA256, tsaClient, Nothing, Nothing, PdfSignatureProfile.PAdES_BES)
29-
30-
'Apply a signature to a new form field created before
31-
Dim cooperSignature = New PdfSignatureBuilder(pkcs7Signature, signatureFieldInfo)
32-
33-
'Specify an image and signer information
34-
cooperSignature.SetImageData(System.IO.File.ReadAllBytes("Signing Documents/JaneCooper.jpg"))
35-
cooperSignature.Location = "USA"
36-
cooperSignature.Name = "Jane Cooper"
37-
cooperSignature.Reason = "Acknowledgement"
38-
39-
'Apply a signature to an existing form field
40-
Dim santuzzaSignature = New PdfSignatureBuilder(pkcs7Signature, "Sign")
41-
42-
'Specify an image and signer information
43-
santuzzaSignature.Location = "Australia"
44-
santuzzaSignature.Name = "Santuzza Valentina"
45-
santuzzaSignature.Reason = "I Agree"
46-
47-
' Specify signature appearance parameters:
48-
Dim signatureAppearance As New PdfSignatureAppearance()
49-
signatureAppearance.SetImageData("Signing Documents/SantuzzaValentina.png")
50-
signatureAppearance.SignatureDetailsFont.Size = 12
51-
signatureAppearance.SignatureDetailsFont.Italic = True
52-
signatureAppearance.ShowDate = True
53-
signatureAppearance.ShowReason = True
54-
santuzzaSignature.SetSignatureAppearance(signatureAppearance)
55-
56-
'Create a new signature form field:
57-
Dim signatureFieldInfo1 = New PdfSignatureFieldInfo(1)
58-
signatureFieldInfo1.Name = "SignatureField1"
59-
signatureFieldInfo1.SignatureBounds = New PdfRectangle(200, 200, 250, 250)
60-
61-
'Create a document level time stamp:
62-
Dim pdfTimeStamp As New PdfTimeStamp(tsaClient)
63-
64-
'Apply this time stamp to the form field:
65-
Dim timeStampSignature = New PdfSignatureBuilder(pdfTimeStamp, signatureFieldInfo1)
66-
67-
'Add signatures to an array
68-
Dim signatures() As PdfSignatureBuilder = { cooperSignature, santuzzaSignature, timeStampSignature }
69-
70-
'Sign and save the document
71-
signer.SaveDocument("SignedDocument.pdf", signatures)
72-
End Using
73-
End Sub
74-
End Class
16+
Public Shared Sub ApplySignatures()
17+
'Load a document to sign
18+
Using signer = New PdfDocumentSigner("Document.pdf")
19+
'Specify the name and location of the signature field
20+
Dim signatureFieldInfo = New PdfSignatureFieldInfo(1)
21+
signatureFieldInfo.Name = "SignatureField"
22+
signatureFieldInfo.SignatureBounds = New PdfRectangle(20, 20, 150, 150)
23+
signatureFieldInfo.RotationAngle = PdfAcroFormFieldRotation.Rotate90
24+
'Create a timestamp
25+
Dim tsaClient As ITsaClient = New TsaClient(New Uri("https://freetsa.org/tsr"), HashAlgorithmType.SHA256)
26+
'Create a PAdES PKCS#7 signature
27+
Dim pkcs7Signature As Pkcs7Signer = New Pkcs7Signer("Signing Documents/certificate.pfx", "123", HashAlgorithmType.SHA256, tsaClient, Nothing, Nothing, PdfSignatureProfile.PAdES_BES)
28+
'Apply a signature to a new form field created before
29+
Dim cooperSignature = New PdfSignatureBuilder(pkcs7Signature, signatureFieldInfo)
30+
'Specify an image and signer information
31+
cooperSignature.SetImageData(IO.File.ReadAllBytes("Signing Documents/JaneCooper.jpg"))
32+
cooperSignature.Location = "USA"
33+
cooperSignature.Name = "Jane Cooper"
34+
cooperSignature.Reason = "Acknowledgement"
35+
'Apply a signature to an existing form field
36+
Dim santuzzaSignature = New PdfSignatureBuilder(pkcs7Signature, "Sign")
37+
'Specify an image and signer information
38+
santuzzaSignature.Location = "Australia"
39+
santuzzaSignature.Name = "Santuzza Valentina"
40+
santuzzaSignature.Reason = "I Agree"
41+
' Specify signature appearance parameters:
42+
Dim signatureAppearance As PdfSignatureAppearance = New PdfSignatureAppearance()
43+
signatureAppearance.SetImageData("Signing Documents/SantuzzaValentina.png")
44+
signatureAppearance.SignatureDetailsFont.Size = 12
45+
signatureAppearance.SignatureDetailsFont.Italic = True
46+
signatureAppearance.ShowDate = True
47+
signatureAppearance.ShowReason = True
48+
santuzzaSignature.SetSignatureAppearance(signatureAppearance)
49+
'Create a new signature form field:
50+
Dim signatureFieldInfo1 = New PdfSignatureFieldInfo(1)
51+
signatureFieldInfo1.Name = "SignatureField1"
52+
signatureFieldInfo1.SignatureBounds = New PdfRectangle(200, 200, 250, 250)
53+
'Create a document level time stamp:
54+
Dim pdfTimeStamp As PdfTimeStamp = New PdfTimeStamp(tsaClient)
55+
'Apply this time stamp to the form field:
56+
Dim timeStampSignature = New PdfSignatureBuilder(pdfTimeStamp, signatureFieldInfo1)
57+
'Add signatures to an array
58+
Dim signatures As PdfSignatureBuilder() = {cooperSignature, santuzzaSignature, timeStampSignature}
59+
'Sign and save the document
60+
signer.SaveDocument("SignedDocument.pdf", signatures)
61+
End Using
62+
End Sub
63+
End Class
7564
End Namespace
76-
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1-
Imports System.Reflection
2-
Imports System.Runtime.CompilerServices
1+
Imports System.Reflection
32
Imports System.Runtime.InteropServices
43

54
' General Information about an assembly is controlled through the following
65
' set of attributes. Change these attribute values to modify the information
76
' associated with an assembly.
8-
<Assembly: AssemblyTitle("PdfDocumentProcessor")>
9-
<Assembly: AssemblyDescription("")>
10-
<Assembly: AssemblyConfiguration("")>
11-
<Assembly: AssemblyCompany("")>
12-
<Assembly: AssemblyProduct("PdfDocumentProcessor")>
13-
<Assembly: AssemblyCopyright("Copyright © 2019")>
14-
<Assembly: AssemblyTrademark("")>
15-
<Assembly: AssemblyCulture("")>
16-
7+
<Assembly:AssemblyTitle("PdfDocumentProcessor")>
8+
<Assembly:AssemblyDescription("")>
9+
<Assembly:AssemblyConfiguration("")>
10+
<Assembly:AssemblyCompany("")>
11+
<Assembly:AssemblyProduct("PdfDocumentProcessor")>
12+
<Assembly:AssemblyCopyright("Copyright © 2019")>
13+
<Assembly:AssemblyTrademark("")>
14+
<Assembly:AssemblyCulture("")>
1715
' Setting ComVisible to false makes the types in this assembly not visible
1816
' to COM components. If you need to access a type in this assembly from
1917
' COM, set the ComVisible attribute to true on that type.
20-
<Assembly: ComVisible(False)>
21-
18+
<Assembly:ComVisible(False)>
2219
' The following GUID is for the ID of the typelib if this project is exposed to COM
23-
<Assembly: Guid("f6db10e3-d8e0-415c-a621-f62435cca80a")>
24-
20+
<Assembly:Guid("f6db10e3-d8e0-415c-a621-f62435cca80a")>
2521
' Version information for an assembly consists of the following four values:
2622
'
2723
' Major Version
@@ -32,5 +28,5 @@ Imports System.Runtime.InteropServices
3228
' You can specify all the values or you can default the Build and Revision Numbers
3329
' by using the '*' as shown below:
3430
' [assembly: AssemblyVersion("1.0.*")]
35-
<Assembly: AssemblyVersion("1.0.0.0")>
36-
<Assembly: AssemblyFileVersion("1.0.0.0")>
31+
<Assembly:AssemblyVersion("1.0.0.0")>
32+
<Assembly:AssemblyFileVersion("1.0.0.0")>

0 commit comments

Comments
 (0)