Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test-net-framework-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ jobs:
'Other/StreamIO/',
'Printing/PrintPDF/',
'Printing/PrintPDFGUI/',
'Security/AddDigitalSignature/',
'Security/AddDigitalSignatureCMS/',
'Security/AddDigitalSignatureRFC3161/',
'Security/AddRegexRedaction/',
'Security/Redactions/',
'Text/AddGlyphs/',
Expand Down
8 changes: 7 additions & 1 deletion Samples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RegexTextSearch", "Text\Reg
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextExtract", "Text\TextExtract\TextExtract.csproj", "{11C4A647-3DDA-41A5-855C-E14EDF1BFFDE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddDigitalSignature", "Security\AddDigitalSignature\AddDigitalSignature.csproj", "{AB753937-DF3D-4B06-B475-D3B597D32BC5}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddDigitalSignatureCMS", "Security\AddDigitalSignatureCMS\AddDigitalSignatureCMS.csproj", "{AB753937-DF3D-4B06-B475-D3B597D32BC5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddDigitalSignatureRFC3161", "Security\AddDigitalSignatureRFC3161\AddDigitalSignatureRFC3161.csproj", "{74FA984E-AB89-475A-9077-9D612DE12AEC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -548,6 +550,10 @@ Global
{AB753937-DF3D-4B06-B475-D3B597D32BC5}.Debug|x64.Build.0 = Debug|x64
{AB753937-DF3D-4B06-B475-D3B597D32BC5}.Release|x64.ActiveCfg = Release|x64
{AB753937-DF3D-4B06-B475-D3B597D32BC5}.Release|x64.Build.0 = Release|x64
{74FA984E-AB89-475A-9077-9D612DE12AEC}.Debug|x64.ActiveCfg = Debug|x64
{74FA984E-AB89-475A-9077-9D612DE12AEC}.Debug|x64.Build.0 = Debug|x64
{74FA984E-AB89-475A-9077-9D612DE12AEC}.Release|x64.ActiveCfg = Release|x64
{74FA984E-AB89-475A-9077-9D612DE12AEC}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@

/*
*
* This sample program demonstrates the use of AddDigitalSignature.
* This sample program demonstrates the use of AddDigitalSignature for CMS signature type.
*
* Copyright (c) 2025, Datalogics, Inc. All rights reserved.
*
*/
namespace AddDigitalSignature
namespace AddDigitalSignatureCMS
{
class AddDigitalSignature
class AddDigitalSignatureCMS
{
static void Main(string[] args)
{
Console.WriteLine("AddDigitalSignature Sample:");
Console.WriteLine("AddDigitalSignatureCMS Sample:");

using (new Library())
{
Console.WriteLine("Initialized the library.");

String sInput = Library.ResourceDirectory + "Sample_Input/SixPages.pdf";
String sLogo = Library.ResourceDirectory + "Sample_Input/ducky_alpha.tif";
String sOutput = "DigSig-out.pdf";
String sOutput = "DigSigCMS-out.pdf";

String sDERCert = Library.ResourceDirectory + "Sample_Input/Credentials/DER/RSA_certificate.der";
String sDERKey = Library.ResourceDirectory + "Sample_Input/Credentials/DER/RSA_privKey.der";
Expand Down Expand Up @@ -55,6 +55,10 @@ static void Main(string[] args)
sigDoc.SetNonPfxSignerCert(sDERCert, 0, CredentialStorageFmt.OnDisk);
sigDoc.SetNonPfxPrivateKey(sDERKey, 0, CredentialStorageFmt.OnDisk);

// Set the signature type to be used.
// The available types are defined in the SignatureType enum. Default CMS.
sigDoc.DocSignType = SignatureType.CMS;

// Setup the signer information
// (Logo image is optional)
sigDoc.SetSignerInfo(sLogo, 0.5F, "John Doe", "Chicago, IL", "Approval", "Datalogics, Inc.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{AB753937-DF3D-4B06-B475-D3B597D32BC5}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>AddDigitalSignature</RootNamespace>
<AssemblyName>AddDigitalSignature</AssemblyName>
<RootNamespace>AddDigitalSignatureCMS</RootNamespace>
<AssemblyName>AddDigitalSignatureCMS</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Expand Down Expand Up @@ -45,7 +45,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AddDigitalSignature.cs" />
<Compile Include="AddDigitalSignatureCMS.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35818.85
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddDigitalSignature", "AddDigitalSignature.csproj", "{3790CE63-DB43-4F16-8226-BDFEFA25BCDD}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddDigitalSignatureCMS", "AddDigitalSignatureCMS.csproj", "{3790CE63-DB43-4F16-8226-BDFEFA25BCDD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
64 changes: 64 additions & 0 deletions Security/AddDigitalSignatureRFC3161/AddDigitalSignatureRFC3161.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Text;
using Datalogics.PDFL;

/*
*
* This sample program demonstrates the use of AddDigitalSignature for RFC3161 timestamp signature type.
*
* Copyright (c) 2025, Datalogics, Inc. All rights reserved.
*
*/
namespace AddDigitalSignatureRFC3161
{
class AddDigitalSignatureRFC3161
{
static void Main(string[] args)
{
Console.WriteLine("AddDigitalSignatureRFC3161 Sample:");

using (new Library())
{
Console.WriteLine("Initialized the library.");

String sInput = Library.ResourceDirectory + "Sample_Input/CreateAcroForm2h.pdf";

String sOutput = "DigSigRFC3161-out.pdf";

if (args.Length > 0)
sInput = args[0];

if (args.Length > 1)
sOutput = args[1];

Console.WriteLine("Input file: " + sInput);
Console.WriteLine("Writing to output: " + sOutput);

using (Document doc = new Document(sInput))
{
using (Datalogics.PDFL.SignDoc sigDoc = new Datalogics.PDFL.SignDoc())
{
// Setup Sign params
sigDoc.FieldID = SignatureFieldID.SearchForFirstUnsignedField;

// Set signing attributes
sigDoc.DigestCategory = DigestCategory.Sha256;

// Set the signature type to be used, RFC3161/TimeStamp.
// The available types are defined in the SignatureType enum. Default CMS.
sigDoc.DocSignType = SignatureType.RFC3161;

// Setup Save params
sigDoc.OutputPath = sOutput;

// Finally, sign and save the document
sigDoc.AddDigitalSignature(doc);

Console.WriteLine();
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{74FA984E-AB89-475A-9077-9D612DE12AEC}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>AddDigitalSignatureRFC3161</RootNamespace>
<AssemblyName>AddDigitalSignatureRFC3161</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AddDigitalSignatureRFC3161.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Adobe.PDF.Library.LM.NETFramework">
<Version>18.*</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
24 changes: 24 additions & 0 deletions Security/AddDigitalSignatureRFC3161/AddDigitalSignatureRFC3161.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35818.85
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddDigitalSignatureRFC3161", "AddDigitalSignatureRFC3161.csproj", "{74FA984E-AB89-475A-9077-9D612DE12AEC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{74FA984E-AB89-475A-9077-9D612DE12AEC}.Debug|x64.ActiveCfg = Debug|x64
{74FA984E-AB89-475A-9077-9D612DE12AEC}.Debug|x64.Build.0 = Debug|x64
{74FA984E-AB89-475A-9077-9D612DE12AEC}.Release|x64.ActiveCfg = Release|x64
{74FA984E-AB89-475A-9077-9D612DE12AEC}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {08DC1B85-4756-4272-B76A-197A8E79394D}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions Security/AddDigitalSignatureRFC3161/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
5 changes: 4 additions & 1 deletion Security/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## ***AddDigitalSignature***
## ***AddDigitalSignatureCMS***
Demonstrates adding a digital signature with a logo to a PDF document.

## ***AddDigitalSignatureRFC3161***
Demonstrates adding an RFC3161 timestamp signature to a PDF document.

## ***AddRegexRedaction***
Uses a regular expression to find a specified phrase of text in a PDF document and then redacts that text.

Expand Down
Loading