Hi, I'm in need to extract xp keyword metadata from a multipage tiff file. This is generated in a scanner and the keywords are manually input by the operator. I need those to be assigned to a LF field.
As I´ve investigated the only possibility to do this extraction is via a scripting activity in a workflow
I've managed to get the C# code below but I can´t make it to run. Can anybody point me in the right direction to what his wrong/missing or better yet, complete/correct the code so it can run properly?
Imports System.Diagnostics
Imports Laserfiche.Workflow.Script
Public Class Script
Public Sub Execute()
' Obtener la ruta del archivo TIFF desde un token de entrada del flujo de trabajo
Dim filePath As String = WorkflowApi.GetTokenValue("FilePath")
Dim exifToolPath As String = "C:\Path\To\exiftool.exe" ' Cambia esta ruta según la ubicación de ExifTool
' Validar que las rutas no estén vacías
If String.IsNullOrEmpty(filePath) Or String.IsNullOrEmpty(exifToolPath) Then
WorkflowApi.Logger.Log("Error: La ruta del archivo TIFF o de ExifTool no está configurada.")
Return
End If
' Configurar el proceso para ejecutar ExifTool
Dim process As New Process()
process.StartInfo.FileName = exifToolPath
process.StartInfo.Arguments = "-XPKeywords """ & filePath & """"
process.StartInfo.RedirectStandardOutput = True
process.StartInfo.UseShellExecute = False
process.StartInfo.CreateNoWindow = True
Try
' Iniciar el proceso y leer la salida
process.Start()
Dim output As String = process.StandardOutput.ReadToEnd()
process.WaitForExit()
' Validar la salida de ExifTool
If Not String.IsNullOrEmpty(output) Then
' Guardar los XP Keywords en un token de salida
WorkflowApi.SetTokenValue("XPKeywords", output.Trim())
' Registrar los XP Keywords en el log
WorkflowApi.Logger.Log("XP Keywords extraídos: " & output.Trim())
Else
WorkflowApi.Logger.Log("No se encontraron XP Keywords en el archivo TIFF.")
End If
Catch ex As Exception
' Registrar cualquier error ocurrido durante la ejecución
WorkflowApi.Logger.Log("Error al ejecutar ExifTool: " & ex.Message)
Finally
' Liberar recursos del proceso
process.Dispose()
End Try
End Sub
End Class