Compare commits

...

5 Commits

4 changed files with 61 additions and 13 deletions

View File

@@ -15,6 +15,7 @@ Namespace Jobs.FinalizeDocument
Private Const ANNOTATION_TYPE_IMAGE = "pspdfkit/image" Private Const ANNOTATION_TYPE_IMAGE = "pspdfkit/image"
Private Const ANNOTATION_TYPE_INK = "pspdfkit/ink" Private Const ANNOTATION_TYPE_INK = "pspdfkit/ink"
Private Const ANNOTATION_TYPE_WIDGET = "pspdfkit/widget"
Public Sub New(pLogConfig As LogConfig, pGDPictureLicenseKey As String) Public Sub New(pLogConfig As LogConfig, pGDPictureLicenseKey As String)
MyBase.New(pLogConfig) MyBase.New(pLogConfig)
@@ -77,6 +78,12 @@ Namespace Jobs.FinalizeDocument
Case ANNOTATION_TYPE_INK Case ANNOTATION_TYPE_INK
AddInkAnnotation(oAnnotation) AddInkAnnotation(oAnnotation)
Case ANNOTATION_TYPE_WIDGET
'Add form field values
Dim formFieldValue = oAnnotationData.formFieldValues.FirstOrDefault(Function(fv) fv.name = oAnnotation.id)
If formFieldValue IsNot Nothing Then
AddFormFieldValue(oAnnotation, formFieldValue)
End If
End Select End Select
Next Next
@@ -137,6 +144,33 @@ Namespace Jobs.FinalizeDocument
End Function End Function
Private Function AddFormFieldValue(pAnnotation As Annotation, formFieldValue As FormFieldValue) As Boolean
Try
' 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.SelectPage(pAnnotation.pageIndex + 1)
' Add the text annotation
Dim ant = Manager.AddTextAnnot(oX, oY, oWidth, oHeight, formFieldValue.value)
' Set the font properties
ant.FontName = "Arial"
ant.FontSize = 8
ant.FontStyle = FontStyle.Italic
Manager.SaveAnnotationsToPage()
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 Private Function ToPointF(pPoints As List(Of Single)) As PointF
Dim oPoints = pPoints.Select(AddressOf ToInches).ToList() Dim oPoints = pPoints.Select(AddressOf ToInches).ToList()
Return New PointF(oPoints.Item(0), oPoints.Item(1)) Return New PointF(oPoints.Item(0), oPoints.Item(1))
@@ -153,6 +187,7 @@ Namespace Jobs.FinalizeDocument
Friend Class AnnotationData Friend Class AnnotationData
Public Property annotations As List(Of Annotation) Public Property annotations As List(Of Annotation)
Public Property attachments As Dictionary(Of String, Attachment) Public Property attachments As Dictionary(Of String, Attachment)
Public Property formFieldValues As List(Of FormFieldValue)
End Class End Class
Friend Class Annotation Friend Class Annotation
@@ -174,5 +209,10 @@ Namespace Jobs.FinalizeDocument
Public Property binary As String Public Property binary As String
Public Property contentType As String Public Property contentType As String
End Class End Class
Friend Class FormFieldValue
Public Property name As String
Public Property value As String
End Class
End Class End Class
End Namespace End Namespace

View File

@@ -1,10 +1,10 @@
'------------------------------------------------------------------------------ '------------------------------------------------------------------------------
' <auto-generated> ' <auto-generated>
' Dieser Code wurde von einem Tool generiert. ' This code was generated by a tool.
' Laufzeitversion:4.0.30319.42000 ' Runtime Version:4.0.30319.42000
' '
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn ' Changes to this file may cause incorrect behavior and will be lost if
' der Code erneut generiert wird. ' the code is regenerated.
' </auto-generated> ' </auto-generated>
'------------------------------------------------------------------------------ '------------------------------------------------------------------------------
@@ -14,10 +14,10 @@ Option Explicit On
Namespace My Namespace My
'HINWEIS: Diese Datei wird automatisch generiert und darf nicht direkt bearbeitet werden. Wenn Sie Änderungen vornehmen möchten 'NOTE: This file is auto-generated; do not modify it directly. To make changes,
' oder in dieser Datei Buildfehler auftreten, wechseln Sie zum Projekt-Designer. ' or if you encounter build errors in this file, go to the Project Designer
' (Wechseln Sie dazu zu den Projekteigenschaften, oder doppelklicken Sie auf den Knoten "Mein Projekt" im ' (go to Project Properties or double-click the My Project node in
' Projektmappen-Explorer). Nehmen Sie auf der Registerkarte "Anwendung" entsprechende Änderungen vor. ' Solution Explorer), and make changes on the Application tab.
' '
Partial Friend Class MyApplication Partial Friend Class MyApplication
@@ -32,7 +32,13 @@ Namespace My
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm() Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.EnvelopeGenerator.frmReportViewer Me.MainForm = Global.EnvelopeGenerator.frmFinalizePDF
End Sub End Sub
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
Me.MinimumSplashScreenDisplayTime = 0
Return MyBase.OnInitialize(commandLineArgs)
End Function
End Class End Class
End Namespace End Namespace

View File

@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <MyApplicationData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MySubMain>true</MySubMain> <MySubMain>true</MySubMain>
<MainForm>frmReportViewer</MainForm> <MainForm>frmFinalizePDF</MainForm>
<SingleInstance>false</SingleInstance> <SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode> <ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles> <EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode> <AuthenticationMode>0</AuthenticationMode>
<MinimumSplashScreenDisplayTime>0</MinimumSplashScreenDisplayTime>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit> <SaveMySettingsOnExit>true</SaveMySettingsOnExit>
<HighDpiMpde>false</HighDpiMpde> <HighDpiMpde>false</HighDpiMpde>
</MyApplicationData> </MyApplicationData>

View File

@@ -14,18 +14,19 @@ Public Class frmFinalizePDF
Private Viewer As GdViewer Private Viewer As GdViewer
Private Manager As AnnotationManager Private Manager As AnnotationManager
Private PDFBurner As FinalizeDocument.PDFBurner Private PDFBurner As FinalizeDocument.PDFBurner
Private pGDPictureLicenseKey As String = "21182889975216572111813147150675976632"
Private Sub frmFinalizePDF_Load(sender As Object, e As EventArgs) Handles MyBase.Load Private Sub frmFinalizePDF_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath) LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath)
Database = New MSSQLServer(LogConfig, MSSQLServer.DecryptConnectionString(CONNECTIONSTRING)) Database = New MSSQLServer(LogConfig, MSSQLServer.DecryptConnectionString(CONNECTIONSTRING))
PDFBurner = New FinalizeDocument.PDFBurner(LogConfig, "PS231031-44053-15086") PDFBurner = New FinalizeDocument.PDFBurner(LogConfig, pGDPictureLicenseKey)
Viewer = New GdViewer()
Manager = New AnnotationManager() Manager = New AnnotationManager()
Dim oLicense = New LicenseManager() Dim oLicense = New LicenseManager()
oLicense.RegisterKEY("PS231031-44053-15086") oLicense.RegisterKEY(pGDPictureLicenseKey)
End Sub End Sub
Private Function LoadAnnotationDataForReceiver() As String Private Function LoadAnnotationDataForReceiver() As String