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

Question

Question

DocumentExporter is not defined? PdfExportOptions is not declared?

asked on June 2, 2022

I have this script that is working just fine in another WF. But I move it here, and I get these errors. Nothing about the code is different from where I took it. I get the error of "DocumentExporter" is not defined. Also, I am getting 'PdfExportOptions' is not declared. What do I need to do to fix this? 

Also a bonus, I created a token called _modifiedPath and want to have it put that text in a file path. I am doing it right? 

 

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports Laserfiche.RepositoryAccess
imports Laserfiche.DocumentServices

Namespace WorkflowActivity.Scripting.zither
    '''<summary>
    '''Provides one or more methods that can be run when the workflow scripting activity is performed.
    '''</summary>
    Public Class Script1
        Inherits RAScriptClass92
        '''<summary>
        '''This method is run when the activity is performed.
        '''</summary>
        Protected Overrides Sub Execute()
            'Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session

            dim ex as new DocumentExporter


                dim doc as DocumentInfo = Document.GetDocumentInfo(integer.Parse(GetTokenValue("Entry ID")),RASession)
                ex.ExportPdf(doc, doc.AllPages,PdfExportOptions.None, "\\fsstl06\userdirs\Scanning\Emma_Securian\" & GetTokenValue("_modifiedPath") & GetTokenValue("Entry Name") & ".pdf")


        End Sub
    End Class
End Namespace

 

 

0 0

Answer

SELECTED ANSWER
replied on June 2, 2022

Did you add a reference to Laserfiche.DocumentServices (in the Project Explorer pane)? Is the reference for the same version as your Laserfiche.RepositoryAccess (given that your script says " RAScriptClass92 ", they both should be version 9.2)?

0 0
replied on June 2, 2022

Designer is running 11.0.2012.264. The LF client is 11.0.2201.233. 
The most updated version I see of Laserfiche.DocumentServices and Laserfiche.RepositoryAccess is 10.4. There was no choice for 11 there, which I would expect would be my choice because we are using LF 11, which we just updated to last week.

But alas, I chose the 9.2 version for both DS and RA, and changed script back to be 'Inherits RAScriptClass92. As long as the versions of both of these references and the RAScriptClass agreeing on the same version, it should work, correct?

Thanks so much for saving me hours. 

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports Laserfiche.RepositoryAccess
Imports Laserfiche.DocumentServices

Namespace WorkflowActivity.Scripting.zither
    Public Class Script1
        Inherits RAScriptClass92
           Protected Overrides Sub Execute()
            dim ex as new DocumentExporter
                dim doc as DocumentInfo = Document.GetDocumentInfo(integer.Parse(GetTokenValue("Entry ID")),RASession)
                ex.ExportPdf(doc, doc.AllPages,PdfExportOptions.None, "\\fsstl06\userdirs\Scanning\Emma_Securian\" & GetTokenValue("_modifiedPath") & GetTokenValue("Entry Name") & ".pdf")
        End Sub
    End Class
End Namespace

 

0 0
replied on June 13, 2022

Yes, that should be fine, though the latest version of these libraries are always preferred.

0 0

Replies

replied on June 2, 2022

Paul,

As for your 'bonus' question; make sure the token for _modifiedPath resolves with an '\' on the end of it or manually add one when you concatenate the path.

ex.ExportPdf(doc, doc.AllPages,PdfExportOptions.None, "\\fsstl06\userdirs\Scanning\Emma_Securian\" & GetTokenValue("_modifiedPath") & "\" & GetTokenValue("Entry Name") & ".pdf")

 

0 0
replied on June 3, 2022

It worked on the first try, Cliff. Within LF, should all paths (including just folders) end with a \ ? 

0 0
replied on June 3, 2022

Paul,

Not quite tracking what you are asking.  In your example code above you are concatenating a set of string values to get a full path for a document.  In order for that full path to be valid each folder segment needs to be separated with the '\' character.

For example; if your _modifiedPath token resolves to the string "MyFolder" and your Entry Name token resolves to the string "MyDocument" then the resulting full path will be "\\fsstl06\userdirs\Scanning\Emma_Securian\MyFolderMyDocument.pdf", which is incorrect.

If the string value that the _modifiedPath token resolves to does not end with the character "\" then you have to manually insert it during the concatenation so that the final full path is "\\fsstl06\userdirs\Scanning\Emma_Securian\MyFolder\MyDocument.pdf".

All that being said, from a programming perspective the better solution would be to use the Combine method on the System.IO.Path class to concatenate a full path for a file.

https://docs.microsoft.com/en-us/dotnet/api/system.io.path.combine?view=net-6.0

0 0
replied on June 3, 2022

_modifiedPath has the \ in it with a regular expression, so it's good. My short reply was just checking to see if file paths needed to end in a \ if the last part of it is a folder rather than a file. Seems like it's a good practice. I am ecstatic it works though. Now if only I can muddle through all the new problems created by our recent upgrade....I have made already a couple of new posts today. This answers site is my LF dojo. :)

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

Sign in to reply to this post.