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

Question

Question

Generate Pages then OCR Docs with SDK

SDK
asked on June 2, 2021

I've written an SDK script to generate pages on documents using Client Automation. I've also written an SDK script to OCR documents. When you OCR documents manually in the repository, it also handles generating the pages first. However, the SDK command to OCR documents only works on documents that already have image pages.

 

I was trying to have the script generate pages on each document before it OCRs, but the OCR method requires a DocumentInfo object, which requires a Session object, which Client Automation does not use.

 

Is there a way to have Generate Pages (CAT) and OCR "share" the same Session object? Or possibly a way to "extract" a Session object out of an existing Client Automation connection? Since I'm using a repository Admin account, I can't log in separately for each due to the concurrent session limit.

 

Thanks

0 0

Answer

SELECTED ANSWER
replied on June 3, 2021

The CAT RepositoryConnection class can be used to create a RepositoryAccess Session object. From the ClientWindow object, call GetCurrentRepository() to get the RepositoryConnection. Then call GetConnectionString(11.0) to get the serialized connection string. Use this to create a new Session object by calling Session.CreateFromSerializedLFConnection. See this post for sample code.

2 0
replied on June 3, 2021

Thanks, Robert. This worked great.

0 0

Replies

replied on June 2, 2021 Show version history

Hi Brian,

Laserfiche 11 introduced the ability for Laserfiche Distributed Computing Cluster (DCC) 11 to perform Page Generation along with OCR. DCC Page Generation is invoked through a new Workflow 11 activity called Schedule Page Generation and OCR is invoked through Schedule OCR. Could that possibly address your use case?

1 0
replied on June 2, 2021

Hi Samuel,

 

Thanks for the info. That definitely seems helpful, but in this particular situation, we're using a script specifically because the previous solution with Workflow and DCC was not working.

0 0
replied on June 2, 2021

Was the previous solution using WF11/DCC11 and do you recall what wasn't working? Possibly something that was fixed in the new major version.

0 0
replied on June 2, 2021

Hi Samuel,

 

Apparently Laserfiche thinks the issues with the DCC solution are hardware spec related since the machine didn't meet the minimum CPU requirement.

0 0
replied on June 2, 2021

Ah, is this related to Case 217354 you recently opened about a Laserfiche Cloud system? I see it was marked as a verified bug sent to Development for a fix.

If the DCC hardware spec one is separate, could you reply with the case number? DCC definitely does not require a 2.93 GHz or faster CPU - the minimum specs for it are just old. A modern ~2.1 GHz CPU almost certainly outperforms any 2.93 GHz CPU from the time the minimum spec was written. I've run DCC on plenty of modern "slower" machines.

0 0
replied on June 2, 2021

No, that case is about something else. I'm not doing any OCRing for that project.

 

The case I'm referring to isn't my case, but it's 216920.

0 0
replied on June 7, 2021

Hi Samuel, does this page generation with DCC 11 carry PDF annotations over to the generated image pages? I have learned today that Forms cannot do this, but I'm wondering if DCC/Workflow can.

 

Thanks

0 0
replied on June 10, 2021

Just following up.

 

Thanks

0 0
replied on June 10, 2021

Hi Brian, thanks for the poke. Yes, DCC 11 Page Generation does support converting PDF annotations to Laserfiche annotations. You can select the option from the Schedule PDF Page Generation Workflow activity.

2 0
replied on June 10, 2021

Thanks for the info, Samuel

0 0
replied on January 24 Show version history

Hello Team,

I am using workflow designer 11 and CAT ( client automation dll) to generate pdf pages. Somehow script activity was not working for me and giving me an error for version 11 but its working fine under the version 10.4

Seems its working fine for workflow designer 10.4 but for same workflow its showing an error for version 11. You can check error attached. "Timeout waiting for client startup".

 

namespace WorkflowActivity.Scripting.PageGenerationScript
{
    using System;
    using System.IO;
    using System.Threading;
    using System.Linq;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using Laserfiche.DocumentServices;
    using Laserfiche.ClientAutomation;
    using System.Diagnostics;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : RAScriptClass104
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {

            string usrName = "admin";
            string usrPass = "admin";
            var processID = -1;


            using (ClientManager lfclient = new ClientManager())
            {
                WorkflowApi.TrackInformation("client manager");
                LaunchOptions options = new LaunchOptions();
                WorkflowApi.TrackInformation("LaunchOptions");
                options.ServerName = RASession.Repository.ServerName;
                options.RepositoryName = RASession.Repository.Name;
                options.UserName = usrName;
                options.Password = usrPass;
                options.HiddenWindow = true;
                options.ShowSplashScreen = false;
                WorkflowApi.TrackInformation("options");
                MainWindow FolderBrowser = null;
                WorkflowApi.TrackInformation("Main Window");
               // ClientInstance singleLFexe = null;
                 WorkflowApi.TrackInformation("Client instance");
                try
                {
                    //singleLFexe = lfclient.LaunchClient(options);
                    lfclient.LogIn(options, out FolderBrowser);

                    WorkflowApi.TrackInformation("single LF.exe");
                 //   processID = singleLFexe.ProcessID;
                 //   WorkflowApi.TrackInformation("ProcessID");
                 //   SetTokenValue("ProcessID", processID);
                   // IEnumerable<ClientWindow> OpenWindows = singleLFexe.GetAllClientWindows();
                   // FolderBrowser = OpenWindows.First() as MainWindow;

                    GeneratePagesOptions gpOptions = new GeneratePagesOptions();
                    //DocumentInfo di = (DocumentInfo)BoundEntryInfo;
                    //MsgBox(di.Extension);
                    //if(di.Extension == "pdf")
                    gpOptions.ForceSnapshot = false;
                    //else
                    //gpOptions.ForceSnapshot = true;
                    gpOptions.ShowUI = false;
                    List<int> docs = new List<int>();

                    try
                    {
                        docs.Add(this.BoundEntryId);
                        WorkflowApi.TrackInformation("Starting page generation for: " + this.BoundEntryInfo.Name + "(" + this.BoundEntryId+ ")");
                        FolderBrowser.GeneratePages(docs, gpOptions);
                        WorkflowApi.TrackInformation("Pages generated successfully for: " + this.BoundEntryInfo.Name + "(" + this.BoundEntryId+ ")");
                      //  DocumentInfo entinfo = Document.GetDocumentInfo(this.BoundEntryId,RASession);
                       // entinfo.DeleteEdoc(); //delete electronic document
                       // entinfo.Save(); //delete and save

                        WorkflowApi.TrackInformation("in");
                        FolderBrowser.Close();
                      //  singleLFexe.Dispose();
                        lfclient.Dispose();
                        WorkflowApi.TrackInformation("out");
                        processID = -1;
                         SetTokenValue("ProcessID", processID);
                    }
                    catch(System.Exception excp)
                    {
                        //FolderBrowser.Close();
                       // singleLFexe.Dispose();
                        //lfclient.Dispose();
                        WorkflowApi.TrackError( "Error during page generation for " + this.BoundEntryInfo.Name + "(" + this.BoundEntryId+ ") exception: " + excp.Message);
                    }

                    //FolderBrowser.Close();
                    //singleLFexe.Dispose();
                   // lfclient.Dispose();
                }
                catch(System.Exception exp)
                {
                     WorkflowApi.TrackError(exp.Message.ToString());
                  //  FolderBrowser.Close();
                    //singleLFexe.Dispose();
                   //lfclient.Dispose();
                   // WorkflowApi.TrackError( "Error loading Client for page generation...attempt " + GetTokenValue("Repeat_Iteration").ToString() + " will try again in " + GetTokenValue("CalculateDelayTime_Delaytime").ToString() + "mins exception: " + exp.Message );
                }
            }

        }
    }
}
 

workflow error.png
0 0
replied on January 24

Using ClientAutomation.dll in Workflow scripts is not supported.

1 0
replied on January 24 Show version history

To automate PDF page generation and OCR tasks with Workflow, please use the native integration between Laserfiche Workflow and Distributed Computing Clustering as described here: https://answers.laserfiche.com/questions/187738/Generate-Pages-then-OCR-Docs-with-SDK#187747. There should be no need for custom scripting to perform those tasks in most cases.

0 0
replied on January 31

Hello Miruna/Samuel,

We have same script running on 10.4 workflow server and client version.

 

What's wrong with 11 version ?

 

Thanks,

Pratik

 

0 0
replied on January 31

It was never supported. It may work under certain conditions, but it is not supported.

Your error says the desktop client did not start, which is expected because Workflow runs as a service, so there is no user session to launch Windows applications in.

Your script may appear to be working in testing, usually because you are logged into the server to run the Workflow Designer and test your script. So at that point, there is a user session for the desktop client to launch in.

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

Sign in to reply to this post.