You are viewing limited content. For full access, please sign in.

Question

Question

Getting field data using RA to export as pdf

SDK
asked on October 7, 2015

I have a custom workflow activity that uses LFSO80 and PDFExporter80 that I am trying to convert to an SDK Script that will use RA and DocumentServices. I figured out how to do the connection wrapper, and I am able to export the file out as a .pdf but am having trouble figuring out how to retrieve and use field values to build out the file path and document names dynamically. Can anyone help me with how to do this? The original activity code is below:

Imports Laserfiche.Workflow.Activities
Imports Laserfiche.Workflow.ComponentModel
Imports LFSO80Lib
Imports System.IO
Imports PdfExporter80

 


Public Class Activity1
    Inherits LaserficheActivity
    Protected Overrides Function OnExecuteCode(ByVal context As Laserfiche.Workflow.ComponentModel.LaserficheExecutionContext) As System.Workflow.ComponentModel.ActivityExecutionStatus

        Dim doc As LFDocument = context.Entry

        Dim dpages As LFDocumentPages = doc.Pages
        dpages.MarkAllPages()
        Dim DocName As String
        DocName = doc.Name

        Dim FD As LFFieldData = doc.FieldData
        ' Gets the field value from the field data.
        Dim FieldVal As String = FD.FieldAsString("Path")

        Dim ExportFolder As String
        ExportFolder = (FieldVal)

        Dim PdfOptions As New ExportOptions
        PdfOptions.SetLayers(DocumentLayers.All)
       

        Dim PdfExp As New PdfExporter
        PdfExp.SetOptions(PdfOptions)
        Dim Arr() As Byte = PdfExp.ExportPages(doc)

        Dim Pdf As New FileStream(ExportFolder & "\" & DocName & ".pdf", FileMode.Create)
        Pdf.Write(Arr, 0, Arr.Length)


        Return MyBase.OnExecuteCode(context)
    End Function
End Class

0 0

Replies

replied on October 7, 2015 Show version history

If you would like to have the document name that is within Laserfiche you can use

My.Computer.FileSystem.CreateDirectory(
  "C:\Documents and Settings\All Users\Documents\NewDirectory")
I got that line from https://msdn.microsoft.com/en-us/library/9wzc03ze.aspx. You can use tokens to create the string for the folder path.

You would need  to use the function GetTokenValue(TokenName) and pass in the token that you would like to pull. You may have to convert the type for the method mentioned. Given that you want to create the custom folder path you will have to test out have the folders created. You can use the tokens to create a custom path. The one thing you may have to do is have the Workflow service run under a service account that would have access to create folders.

1 0
replied on October 8, 2015

Thank you so much. GetTokenValue will work very well for what i'm doing.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.