diff --git a/EnvelopeGenerator.Test/EnvelopeGenerator.Test.vbproj b/EnvelopeGenerator.Test/EnvelopeGenerator.Test.vbproj
index d353a865..aa8039d5 100644
--- a/EnvelopeGenerator.Test/EnvelopeGenerator.Test.vbproj
+++ b/EnvelopeGenerator.Test/EnvelopeGenerator.Test.vbproj
@@ -61,11 +61,17 @@
..\..\DDMonorepo\Controls.DocumentViewer\bin\Debug\DigitalData.Controls.DocumentViewer.dll
+
+ ..\..\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll
+
False
..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll
+
+ ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll
+
..\packages\NLog.5.0.5\lib\net46\NLog.dll
@@ -101,14 +107,24 @@
frmFieldEditor.vb
+
+ frmFinalizePDF.vb
+
+
+ Form
+
True
Application.myapp
+ True
frmFieldEditor.vb
+
+ frmFinalizePDF.vb
+
VbMyResourcesResXFileCodeGenerator
diff --git a/EnvelopeGenerator.Test/My Project/Application.Designer.vb b/EnvelopeGenerator.Test/My Project/Application.Designer.vb
index c5971d09..141e93d3 100644
--- a/EnvelopeGenerator.Test/My Project/Application.Designer.vb
+++ b/EnvelopeGenerator.Test/My Project/Application.Designer.vb
@@ -1,10 +1,10 @@
'------------------------------------------------------------------------------
'
-' This code was generated by a tool.
-' Runtime Version:4.0.30319.42000
+' Dieser Code wurde von einem Tool generiert.
+' Laufzeitversion:4.0.30319.42000
'
-' Changes to this file may cause incorrect behavior and will be lost if
-' the code is regenerated.
+' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
+' der Code erneut generiert wird.
'
'------------------------------------------------------------------------------
@@ -13,15 +13,15 @@ Option Explicit On
Namespace My
-
- 'NOTE: This file is auto-generated; do not modify it directly. To make changes,
- ' or if you encounter build errors in this file, go to the Project Designer
- ' (go to Project Properties or double-click the My Project node in
- ' Solution Explorer), and make changes on the Application tab.
+
+ 'HINWEIS: Diese Datei wird automatisch generiert und darf nicht direkt bearbeitet werden. Wenn Sie Änderungen vornehmen möchten
+ ' oder in dieser Datei Buildfehler auftreten, wechseln Sie zum Projekt-Designer.
+ ' (Wechseln Sie dazu zu den Projekteigenschaften, oder doppelklicken Sie auf den Knoten "Mein Projekt" im
+ ' Projektmappen-Explorer). Nehmen Sie auf der Registerkarte "Anwendung" entsprechende Änderungen vor.
'
Partial Friend Class MyApplication
-
- _
+
+ _
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = false
@@ -29,10 +29,10 @@ Namespace My
Me.SaveMySettingsOnExit = true
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
End Sub
-
- _
+
+ _
Protected Overrides Sub OnCreateMainForm()
- Me.MainForm = Global.EnvelopeGenerator.frmFieldEditor
+ Me.MainForm = Global.EnvelopeGenerator.frmFinalizePDF
End Sub
End Class
End Namespace
diff --git a/EnvelopeGenerator.Test/My Project/Application.myapp b/EnvelopeGenerator.Test/My Project/Application.myapp
index 1243847f..3626ace3 100644
--- a/EnvelopeGenerator.Test/My Project/Application.myapp
+++ b/EnvelopeGenerator.Test/My Project/Application.myapp
@@ -1,11 +1,11 @@
-
+
true
- Form1
+ frmFinalizePDF
false
0
true
0
- 0
true
-
+ false
+
\ No newline at end of file
diff --git a/EnvelopeGenerator.Test/frmFinalizePDF.Designer.vb b/EnvelopeGenerator.Test/frmFinalizePDF.Designer.vb
new file mode 100644
index 00000000..6d430222
--- /dev/null
+++ b/EnvelopeGenerator.Test/frmFinalizePDF.Designer.vb
@@ -0,0 +1,110 @@
+ _
+Partial Class frmFinalizePDF
+ Inherits System.Windows.Forms.Form
+
+ 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ Try
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ Finally
+ MyBase.Dispose(disposing)
+ End Try
+ End Sub
+
+ 'Wird vom Windows Form-Designer benötigt.
+ Private components As System.ComponentModel.IContainer
+
+ 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
+ 'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
+ 'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
+ _
+ Private Sub InitializeComponent()
+ Me.txtReceiver = New System.Windows.Forms.TextBox()
+ Me.txtEnvelope = New System.Windows.Forms.TextBox()
+ Me.Label1 = New System.Windows.Forms.Label()
+ Me.Label2 = New System.Windows.Forms.Label()
+ Me.Button1 = New System.Windows.Forms.Button()
+ Me.PictureBox1 = New System.Windows.Forms.PictureBox()
+ CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
+ Me.SuspendLayout()
+ '
+ 'txtReceiver
+ '
+ Me.txtReceiver.Location = New System.Drawing.Point(57, 65)
+ Me.txtReceiver.Name = "txtReceiver"
+ Me.txtReceiver.Size = New System.Drawing.Size(100, 20)
+ Me.txtReceiver.TabIndex = 0
+ Me.txtReceiver.Text = "11"
+ '
+ 'txtEnvelope
+ '
+ Me.txtEnvelope.Location = New System.Drawing.Point(57, 23)
+ Me.txtEnvelope.Name = "txtEnvelope"
+ Me.txtEnvelope.Size = New System.Drawing.Size(100, 20)
+ Me.txtEnvelope.TabIndex = 0
+ Me.txtEnvelope.Text = "10"
+ '
+ 'Label1
+ '
+ Me.Label1.AutoSize = True
+ Me.Label1.Location = New System.Drawing.Point(54, 9)
+ Me.Label1.Name = "Label1"
+ Me.Label1.Size = New System.Drawing.Size(61, 13)
+ Me.Label1.TabIndex = 1
+ Me.Label1.Text = "EnvelopeId"
+ '
+ 'Label2
+ '
+ Me.Label2.AutoSize = True
+ Me.Label2.Location = New System.Drawing.Point(54, 46)
+ Me.Label2.Name = "Label2"
+ Me.Label2.Size = New System.Drawing.Size(59, 13)
+ Me.Label2.TabIndex = 1
+ Me.Label2.Text = "ReceiverId"
+ '
+ 'Button1
+ '
+ Me.Button1.Location = New System.Drawing.Point(57, 102)
+ Me.Button1.Name = "Button1"
+ Me.Button1.Size = New System.Drawing.Size(75, 23)
+ Me.Button1.TabIndex = 2
+ Me.Button1.Text = "Energie!"
+ Me.Button1.UseVisualStyleBackColor = True
+ '
+ 'PictureBox1
+ '
+ Me.PictureBox1.Location = New System.Drawing.Point(384, 92)
+ Me.PictureBox1.Name = "PictureBox1"
+ Me.PictureBox1.Size = New System.Drawing.Size(341, 170)
+ Me.PictureBox1.TabIndex = 3
+ Me.PictureBox1.TabStop = False
+ '
+ 'frmFinalizePDF
+ '
+ Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+ Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+ Me.ClientSize = New System.Drawing.Size(800, 450)
+ Me.Controls.Add(Me.PictureBox1)
+ Me.Controls.Add(Me.Button1)
+ Me.Controls.Add(Me.Label2)
+ Me.Controls.Add(Me.Label1)
+ Me.Controls.Add(Me.txtEnvelope)
+ Me.Controls.Add(Me.txtReceiver)
+ Me.Name = "frmFinalizePDF"
+ Me.Text = "frmFinalizePDF"
+ CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
+ Me.ResumeLayout(False)
+ Me.PerformLayout()
+
+ End Sub
+
+ Friend WithEvents txtReceiver As TextBox
+ Friend WithEvents txtEnvelope As TextBox
+ Friend WithEvents Label1 As Label
+ Friend WithEvents Label2 As Label
+ Friend WithEvents Button1 As Button
+ Friend WithEvents PictureBox1 As PictureBox
+End Class
diff --git a/EnvelopeGenerator.Test/frmFinalizePDF.resx b/EnvelopeGenerator.Test/frmFinalizePDF.resx
new file mode 100644
index 00000000..1af7de15
--- /dev/null
+++ b/EnvelopeGenerator.Test/frmFinalizePDF.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/EnvelopeGenerator.Test/frmFinalizePDF.vb b/EnvelopeGenerator.Test/frmFinalizePDF.vb
new file mode 100644
index 00000000..3c09e208
--- /dev/null
+++ b/EnvelopeGenerator.Test/frmFinalizePDF.vb
@@ -0,0 +1,96 @@
+Imports System.IO
+Imports DevExpress.Utils
+Imports DigitalData.Modules.Database
+Imports DigitalData.Modules.Logging
+Imports GdPicture14
+Imports Newtonsoft.Json
+
+Public Class frmFinalizePDF
+ Private Const CONNECTIONSTRING = "Server=sDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=+bk8oAbbQP1AzoHtvZUbd+Mbok2f8Fl4miEx1qssJ5yEaEWoQJ9prg4L14fURpPnqi1WMNs9fE4=;"
+
+ Private Database As MSSQLServer
+ Private LogConfig As LogConfig
+
+ Private Viewer As GdPicture14.GdViewer
+ Private Manager As AnnotationManager
+
+
+
+ Private Sub frmFinalizePDF_Load(sender As Object, e As EventArgs) Handles MyBase.Load
+ LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath)
+ Database = New MSSQLServer(LogConfig, MSSQLServer.DecryptConnectionString(CONNECTIONSTRING))
+
+ Manager = New AnnotationManager()
+ Dim oLicense = New LicenseManager()
+ oLicense.RegisterKEY("21182889975216572111813147150675976632")
+ End Sub
+
+ Private Function LoadAnnotationData() As String
+ Dim oSql = $"SELECT VALUE FROM [TBSIG_DOCUMENT_STATUS] WHERE ENVELOPE_ID = {txtEnvelope.Text} AND RECEIVER_ID = {txtReceiver.Text}"
+ Return Database.GetScalarValue(oSql)
+
+ End Function
+
+ Private Function LoadEnvelopeDocument() As String
+ Dim oSql = $"SELECT FILEPATH FROM [TBSIG_ENVELOPE_DOCUMENT] WHERE ENVELOPE_ID = {txtEnvelope.Text}"
+ Return Database.GetScalarValue(oSql)
+
+ End Function
+
+ Public Class AnnotationData
+
+ Public Property annotations As List(Of Annotation)
+ Public Property attachments As Dictionary(Of String, Attachment)
+ End Class
+
+ Public Class Annotation
+ Public Property id As String
+ Public Property bbox As List(Of Double)
+ Public Property type As String
+ Public Property isSignature As Boolean
+ Public Property imageAttachmentId As String
+ End Class
+
+
+
+ Public Class Attachment
+ Public Property binary As String
+ Public Property contentType As String
+ End Class
+
+ Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
+ Dim oAnnotationData = LoadAnnotationData()
+ Dim oDocumentPath = LoadEnvelopeDocument()
+
+ Dim oConverter = JsonConvert.DeserializeObject(Of AnnotationData)(oAnnotationData)
+
+ Dim oImages = oConverter.annotations.Where(Function(a) a.type = "pspdfkit/image").ToList()
+
+ Manager.InitFromFile(Application.StartupPath & "/source.pdf")
+
+ For Each oImage In oImages
+ Dim oAttachment = oConverter.attachments.Where(Function(a) a.Key = oImage.imageAttachmentId).Single()
+ Dim oBytes = Convert.FromBase64String(oAttachment.Value.binary)
+
+
+ 'Using oStream As New MemoryStream(oBytes)
+ ' Using oFileStream As New FileStream($"{oImage.imageAttachmentId}.png", FileMode.OpenOrCreate)
+ ' oStream.CopyTo(oFileStream)
+ ' oStream.Flush()
+ ' End Using
+ 'End Using
+ Dim x = oImage.bbox.Item(0) / 72
+ Dim y = oImage.bbox.Item(1) / 72
+ Dim w = oImage.bbox.Item(2) / 72
+ Dim h = oImage.bbox.Item(3) / 72
+
+ Manager.AddEmbeddedImageAnnotFromBase64(oAttachment.Value.binary, x, y, w, h)
+
+
+
+ Next
+
+ Manager.SaveDocumentToPDF("pdf.pdf")
+ Manager.Close()
+ End Sub
+End Class
\ No newline at end of file
diff --git a/EnvelopeGenerator.Test/packages.config b/EnvelopeGenerator.Test/packages.config
index ce98cd21..0ddda560 100644
--- a/EnvelopeGenerator.Test/packages.config
+++ b/EnvelopeGenerator.Test/packages.config
@@ -1,4 +1,5 @@
+
\ No newline at end of file