diff --git a/EnvelopeGenerator.Test/EnvelopeGenerator.Test.vbproj b/EnvelopeGenerator.Test/EnvelopeGenerator.Test.vbproj
index 41a703af..f798ac41 100644
--- a/EnvelopeGenerator.Test/EnvelopeGenerator.Test.vbproj
+++ b/EnvelopeGenerator.Test/EnvelopeGenerator.Test.vbproj
@@ -133,7 +133,6 @@
True
-
frmFieldEditor.vb
diff --git a/EnvelopeGenerator.Test/My Project/Application.Designer.vb b/EnvelopeGenerator.Test/My Project/Application.Designer.vb
index bbde8f46..141e93d3 100644
--- a/EnvelopeGenerator.Test/My Project/Application.Designer.vb
+++ b/EnvelopeGenerator.Test/My Project/Application.Designer.vb
@@ -32,7 +32,7 @@ Namespace My
_
Protected Overrides Sub OnCreateMainForm()
- Me.MainForm = Global.EnvelopeGenerator.frmReportViewer
+ 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 e67246c4..3626ace3 100644
--- a/EnvelopeGenerator.Test/My Project/Application.myapp
+++ b/EnvelopeGenerator.Test/My Project/Application.myapp
@@ -1,7 +1,7 @@
true
- frmReportViewer
+ frmFinalizePDF
false
0
true
diff --git a/EnvelopeGenerator.Test/PDFBurner.vb b/EnvelopeGenerator.Test/PDFBurner.vb
deleted file mode 100644
index 76e88872..00000000
--- a/EnvelopeGenerator.Test/PDFBurner.vb
+++ /dev/null
@@ -1,162 +0,0 @@
-Imports DevExpress.Pdf
-Imports DigitalData.Modules.Base
-Imports DigitalData.Modules.Logging
-Imports EnvelopeGenerator.PDFBurner
-Imports GdPicture14
-Imports Newtonsoft.Json
-
-Public Class PDFBurner
- Inherits BaseClass
-
- Private ReadOnly LicenseKey As String
- Private ReadOnly Manager As AnnotationManager
- Private ReadOnly LicenseManager As LicenseManager
-
- Private Const ANNOTATION_TYPE_IMAGE = "pspdfkit/image"
- Private Const ANNOTATION_TYPE_INK = "pspdfkit/ink"
-
- Public Sub New(pLogConfig As LogConfig, pGDPictureLicenseKey As String)
- MyBase.New(pLogConfig)
-
- LicenseKey = pGDPictureLicenseKey
- LicenseManager = New LicenseManager()
- LicenseManager.RegisterKEY(pGDPictureLicenseKey)
-
- Manager = New AnnotationManager()
- End Sub
-
- Public Function BurnInstantJSONAnnotationsToPDF(pSourcePath As String, pInstantJSONList As List(Of String), pDestinationPath As String) As Boolean
- If Manager.InitFromFile(pSourcePath) <> GdPictureStatus.OK Then
- Logger.Warn("Could not open file [{0}] for burning.", pSourcePath)
- Return False
- End If
-
- For Each oJSON In pInstantJSONList
- If AddInstantJSONAnnotationToPDF(oJSON) = False Then
- Logger.Warn("Adding Annotation failed. Exiting")
- Return False
- End If
- Next
-
- Try
- Manager.BurnAnnotationsToPage(RemoveInitialAnnots:=True, VectorMode:=True)
- Manager.SaveDocumentToPDF(pDestinationPath)
- Manager.Close()
-
- Return True
- Catch ex As Exception
- Logger.Warn("Could not burn and save annotations to file [{0}]!", pDestinationPath)
- Logger.Error(ex)
-
- Return False
- End Try
- End Function
-
- Private Function AddInstantJSONAnnotationToPDF(pInstantJSON As String) As Boolean
- Try
- Dim oAnnotationData = JsonConvert.DeserializeObject(Of AnnotationData)(pInstantJSON)
-
- For Each oAnnotation In oAnnotationData.annotations
- Select Case oAnnotation.type
- Case ANNOTATION_TYPE_IMAGE
- AddImageAnnotation(oAnnotation, oAnnotationData.attachments)
- Case ANNOTATION_TYPE_INK
- AddInkAnnotation(oAnnotation)
- End Select
- Next
-
- Return True
- Catch ex As Exception
- Logger.Warn("Could not create annotation from InstantJSON")
- Logger.Error(ex)
- Return False
- End Try
- End Function
-
- Private Function AddImageAnnotation(pAnnotation As Annotation, pAttachments As Dictionary(Of String, Attachment)) As Boolean
- Try
- Dim oAttachment = pAttachments.Where(Function(a) a.Key = pAnnotation.imageAttachmentId).
- SingleOrDefault()
-
- ' Convert pixels to Inches
- Dim oBounds = pAnnotation.bbox.Select(AddressOf ToInches).ToList()
-
- Dim oX = oBounds.Item(0)
- Dim oY = oBounds.Item(1)
- Dim oWidth = oBounds.Item(2)
- Dim oHeight = oBounds.Item(3)
-
- Manager.AddEmbeddedImageAnnotFromBase64(oAttachment.Value.binary, oX, oY, oWidth, oHeight)
-
- Return True
- Catch ex As Exception
- Logger.Warn("Could not add image annotation!")
- Logger.Error(ex)
-
- Return False
- End Try
- End Function
-
- Private Function AddInkAnnotation(pAnnotation As Annotation) As Boolean
- Try
- Dim oSegments = pAnnotation.lines.points
- Dim oColor = ColorTranslator.FromHtml(pAnnotation.strokeColor)
- Manager.SelectPage(pAnnotation.pageIndex)
-
- For Each oSegment As List(Of List(Of Single)) In oSegments
- Dim oPoints = oSegment.
- Select(AddressOf ToPointF).
- ToArray()
-
-
- Manager.AddFreeHandAnnot(oColor, oPoints)
- Next
-
- Return True
- Catch ex As Exception
- Logger.Warn("Could not add image annotation!")
- Logger.Error(ex)
-
- Return False
- End Try
-
- End Function
-
- Private Function ToPointF(pPoints As List(Of Single)) As PointF
- Dim oPoints = pPoints.Select(AddressOf ToInches).ToList()
- Return New PointF(oPoints.Item(0), oPoints.Item(1))
- End Function
-
- Private Function ToInches(pValue As Double) As Double
- Return pValue / 72
- End Function
-
- Private Function ToInches(pValue As Single) As Single
- Return pValue / 72
- End Function
-
- Friend Class AnnotationData
- Public Property annotations As List(Of Annotation)
- Public Property attachments As Dictionary(Of String, Attachment)
- End Class
-
- Friend 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
- Public Property lines As Lines
- Public Property pageIndex As Integer
- Public Property strokeColor As String
- End Class
-
- Friend Class Lines
- Public Property points As List(Of List(Of List(Of Single)))
- End Class
-
- Friend Class Attachment
- Public Property binary As String
- Public Property contentType As String
- End Class
-End Class
diff --git a/EnvelopeGenerator.Test/frmFinalizePDF.vb b/EnvelopeGenerator.Test/frmFinalizePDF.vb
index b817bb55..326b5e60 100644
--- a/EnvelopeGenerator.Test/frmFinalizePDF.vb
+++ b/EnvelopeGenerator.Test/frmFinalizePDF.vb
@@ -1,10 +1,8 @@
-Imports System.IO
-Imports DevExpress.Utils
-Imports DigitalData.Modules.Database
+Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports GdPicture14
-Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
+Imports EnvelopeGenerator.Common.Jobs
Public Class frmFinalizePDF
Private Const CONNECTIONSTRING = "Server=sDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=+bk8oAbbQP1AzoHtvZUbd+Mbok2f8Fl4miEx1qssJ5yEaEWoQJ9prg4L14fURpPnqi1WMNs9fE4=;"
@@ -12,7 +10,7 @@ Public Class frmFinalizePDF
Private Database As MSSQLServer
Private LogConfig As LogConfig
- Private Viewer As GdPicture14.GdViewer
+ Private Viewer As GdViewer
Private Manager As AnnotationManager
Private PDFBurner As PDFBurner
@@ -46,8 +44,6 @@ Public Class frmFinalizePDF
End Function
-
-
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim oDocumentPath = LoadEnvelopeDocument()
Dim oTable = LoadAnnotationDataForEnvelope()