Beispiel #1
0
        public override void RunCommand(object sender)
        {
            //get variable path or URL to source file
            var vSourceFilePath = v_FilePath.ConvertToUserVariable(sender);
            // get source type of file either from a physical file or from a URL
            var vSourceFileType = v_FileSourceType.ConvertToUserVariable(sender);

            if (vSourceFileType == "File URL")
            {
                //create temp directory
                var tempDir  = Core.IO.Folders.GetFolder(Folders.FolderType.TempFolder);
                var tempFile = System.IO.Path.Combine(tempDir, $"{ Guid.NewGuid()}.pdf");

                //check if directory does not exist then create directory
                if (!System.IO.Directory.Exists(tempDir))
                {
                    System.IO.Directory.CreateDirectory(tempDir);
                }

                // Create webClient to download the file for extraction
                var webclient = new System.Net.WebClient();
                var uri       = new Uri(vSourceFilePath);
                webclient.DownloadFile(uri, tempFile);

                // check if file is downloaded successfully
                if (System.IO.File.Exists(tempFile))
                {
                    vSourceFilePath = tempFile;
                }

                // Free not needed resources
                uri = null;
                if (webclient != null)
                {
                    webclient.Dispose();
                    webclient = null;
                }
            }

            // Check if file exists before proceeding
            if (!System.IO.File.Exists(vSourceFilePath))
            {
                throw new System.IO.FileNotFoundException("Could not find file: " + vSourceFilePath);
            }

            //create process interface
            JavaInterface javaInterface = new JavaInterface();

            //get output from process
            var result = javaInterface.ExtractPDFText(vSourceFilePath);

            //apply to variable
            result.StoreInUserVariable(sender, v_applyToVariableName);
        }
        public override void RunCommand(object sender)
        {
            var engine = (AutomationEngineInstance)sender;

            //get variable path or URL to source file
            var vSourceFilePath = v_FilePath.ConvertUserVariableToString(engine);

            if (v_FileSourceType == "File URL")
            {
                //create temp directory
                var tempDir  = Folders.GetFolder(FolderType.TempFolder);
                var tempFile = Path.Combine(tempDir, $"{ Guid.NewGuid()}.pdf");

                //check if directory does not exist then create directory
                if (!Directory.Exists(tempDir))
                {
                    Directory.CreateDirectory(tempDir);
                }

                // Create webClient to download the file for extraction
                var webclient = new WebClient();
                var uri       = new Uri(vSourceFilePath);
                webclient.DownloadFile(uri, tempFile);

                // check if file is downloaded successfully
                if (File.Exists(tempFile))
                {
                    vSourceFilePath = tempFile;
                }

                // Free not needed resources
                uri = null;
                if (webclient != null)
                {
                    webclient.Dispose();
                    webclient = null;
                }
            }

            // Check if file exists before proceeding
            if (!File.Exists(vSourceFilePath))
            {
                throw new FileNotFoundException("Could not find file: " + vSourceFilePath);
            }

            //create process interface
            JavaInterface javaInterface = new JavaInterface();

            //get output from process
            var result = javaInterface.ExtractPDFText(vSourceFilePath);

            //apply to variable
            result.StoreInUserVariable(engine, v_OutputUserVariableName);
        }
Beispiel #3
0
        public override void RunCommand(object sender)
        {
            //get variable path to source file
            var vSourceFilePath = v_FilePath.ConvertToUserVariable(sender);

            //create process interface
            JavaInterface javaInterface = new JavaInterface();

            //get output from process
            var result = javaInterface.ExtractPDFText(vSourceFilePath);

            //apply to variable
            result.StoreInUserVariable(sender, v_applyToVariableName);
        }
Beispiel #4
0
        public override void RunCommand(object sender)
        {
            //get variable path to source file
            var vSourceFilePath = v_FilePath.ConvertToUserVariable(sender);


            if (!System.IO.File.Exists(vSourceFilePath))
            {
                throw new System.IO.FileNotFoundException("Could not find file: " + vSourceFilePath);
            }

            //create process interface
            JavaInterface javaInterface = new JavaInterface();

            //get output from process
            var result = javaInterface.ExtractPDFText(vSourceFilePath);

            //apply to variable
            result.StoreInUserVariable(sender, v_applyToVariableName);
        }