I have been using the following script to generate tiff pages from pdf documents:
namespace WorkflowActivity.Scripting.SDKScript
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using Laserfiche.RepositoryAccess;
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()
{
//Variables to change for each setup
string repositoryName = "RepositoryName";
string ServerNameIp = "LaserficheServerName";
string entryToBeConv = "EntryIDofEntryToBeConverted";
int timeToWaitIfFails = 30000;
//Script
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = @"C:\Program Files (x86)\Laserfiche\Client\LF.exe";
startInfo.Arguments = "-W -L\""+repositoryName+"\"";
process.StartInfo = startInfo;
process.Start();
System.Threading.Thread.Sleep(5000);
try
{
using (ClientManager lfclient = new ClientManager())
{
IList<ClientInstance> OpenLFClients = lfclient.GetAllClientInstances();
ClientInstance singleLF = OpenLFClients[0];
LaunchOptions options = new LaunchOptions();
options.ServerName = ServerNameIp;
options.RepositoryName = repositoryName;
options.HiddenWindow = true;
MainWindow main;
singleLF = lfclient.LogIn(options, out main);
GeneratePagesOptions optionsPages = new GeneratePagesOptions();
optionsPages.ShowUI = false;
int entryid = Convert.ToInt32(GetTokenValue(entryToBeConv));
List<int> id = new List<int>();
id.Add(entryid);
main.GeneratePages(id, optionsPages);
singleLF.Close(false);
SetTokenValue("Completed", true);
}
}
catch(Exception ex)
{
System.Threading.Thread.Sleep(timeToWaitIfFails);
}
process.Kill();
}
}
}
Ordinarily, I'd use this in conjunction with "Create Entry" and "Move Pages" to create a new Tiff version of the document, then use "Delete Entry" to get rid of the PDF.
The question is, is there a way to delete the PDF version of the original document, leaving the Tiff version with the original Entry ID/metadata/etc? I have a use case where this would be useful. I know there must be a way to do this with an SDK script, since it's a functionality built into the client, like page generation, but I don't know how to script it.
Any ideas?