From 8c281ff35d5a5af915942c4a014385ad9d9e43ec Mon Sep 17 00:00:00 2001
From: raviextrieve <129574979+raviextrieve@users.noreply.github.com>
Date: Mon, 5 Feb 2024 16:26:01 +0530
Subject: [PATCH] Add files via upload
---
C#/App.config | 6 +
C#/ImageWizHelper.cs | 285 ++++++++++++++++++++++++++++++++
C#/ImageWizHelperCS.csproj | 74 +++++++++
C#/ImageWizHelperCS.csproj.user | 11 ++
C#/Program.cs | 198 ++++++++++++++++++++++
C#/Properties/AssemblyInfo.cs | 36 ++++
6 files changed, 610 insertions(+)
create mode 100644 C#/App.config
create mode 100644 C#/ImageWizHelper.cs
create mode 100644 C#/ImageWizHelperCS.csproj
create mode 100644 C#/ImageWizHelperCS.csproj.user
create mode 100644 C#/Program.cs
create mode 100644 C#/Properties/AssemblyInfo.cs
diff --git a/C#/App.config b/C#/App.config
new file mode 100644
index 0000000..00bfd11
--- /dev/null
+++ b/C#/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/C#/ImageWizHelper.cs b/C#/ImageWizHelper.cs
new file mode 100644
index 0000000..10eaffc
--- /dev/null
+++ b/C#/ImageWizHelper.cs
@@ -0,0 +1,285 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ImageWizHelperCS
+{
+ public enum Layout
+ {
+ A0,
+ A1,
+ A2,
+ A3,
+ A4,
+ A5,
+ A6,
+ A7
+ };
+
+ public enum ImageDPI
+ {
+ DPI_100 = 100,
+ DPI_150 = 150,
+ DPI_200 = 200,
+ DPI_300 = 300,
+ DPI_500 = 500,
+ DPI_600 = 600
+ };
+
+ public enum ResetOption
+ {
+ No_DPI_change, // DPI will not be resetted this case .
+ ResetAllDPI, // Every image DPI will be resetted to selected DPI. Dimension also will be changed according to DPI
+ ResetNonDPI // If DPI is not available then DPI will setted for the image. Dimension also will be changed according to DPI
+ };
+
+ public enum ImageQuality
+ {
+ unknown = -1,
+ Photo_Quality = 70,
+ Document_Quality = 40,
+ Compressed_Document = 20
+ };
+
+ [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Ansi)]
+ public struct RECT
+ {
+ public Int32 left;
+ public Int32 top;
+ public Int32 right;
+ public Int32 bottom;
+ }
+
+ public enum ConversionType
+ {
+ CONVERSIONTYPE_NO_CONVERSION = 0,
+ CONVERSIONTYPE_CONVERT_TO_BW = 1,
+ CONVERSIONTYPE_CONVERT_TO_GREY = 2
+ }
+
+ public class ImageWizHelper
+ {
+ const string DLL_NAME = "ImageWizHelper.dll";
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CharSet = CharSet.Ansi)]
+ static extern IntPtr Initialize(String LogFileName);
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CharSet = CharSet.Ansi)]
+ static extern Int32 Terminate(IntPtr ImageWizHelper);
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CharSet = CharSet.Ansi)]
+ static extern Int32 GetLastErrorCode();
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CharSet = CharSet.Ansi)]
+ static extern Int32 GetErrorDescription(Int32 error, StringBuilder desc_buffer, ref Int32 desc_len);//StringBuilder desc_buffer
+
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ static extern Int32 UnlockLibraryWithModuleIdentity(String licPath, StringBuilder err_buff);
+
+ [DllImport("ImageWizHelper.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 GetPageCountInImageFile(IntPtr ImageWizHelper, string filename, string pwd);
+
+ [DllImport("ImageWizHelper.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 getImageQuality(IntPtr ImageWizHelper, IntPtr objQuality);
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 CompressToTIFF(IntPtr ImageWizHelper, String[] InFileName, Int32 InFileCount, String OutputFileName, ResetOption Option);
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 CompressToPDF(IntPtr ImageWizHelper, String[] InFileName, Int32 InFileCount, String OutputFileName, ResetOption Option);
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 CompressToJpeg(IntPtr ImageWizHelper, String InFileName, String OutputFileName, ResetOption Option);
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 SetDPI(IntPtr ImageWizHelper, ImageDPI Dpi);
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 SetImageQuality(IntPtr ImageWizHelper, ImageQuality Quality);
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern void EnableExifRotation(IntPtr ImageWizHelper);
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern void DisableExifRotation(IntPtr ImageWizHelper);
+
+ [DllImport("ImageWizHelper.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 GetErrorDescription(Int32 ErrorValue, StringBuilder ErrorDesc, Int32 MaxLen);
+
+ [DllImport("ImageWizHelper.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 GetMaskImage(IntPtr ImageWizHelper, String FileName, String OutputFileName, Int32 PageNum, [MarshalAs(UnmanagedType.LPArray)] RECT[] RectData, Int32 RectCount, Int32 maskValue);
+
+ [DllImport("ImageWizHelper.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 CompressPagesToTiff_Array(IntPtr ImageWizHelper, String InputFileName, String OutputFileName, Int32[] PageArray, Int32 PageArrayCount, Boolean Append, ResetOption Option);
+
+ [DllImport("ImageWizHelper.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 CompressPagesToTiff_Range(IntPtr ImageWizHelper, String InputFileName, String OutputFileName, Int32 StartPageNum, Int32 EndPageNum, Boolean Append, ResetOption Option);
+
+ [DllImport("ImageWizHelper.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 SetConversion(IntPtr ImageWizHelper, Int32 Conversion);
+
+ [DllImport("ImageWizHelper.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 GetConversion(IntPtr ImageWizHelper, ref Int32 Conversion);
+
+ [DllImport("ImageWizHelper.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ private static extern Int32 AppendToTiff(IntPtr ImageWizHelper, String InputFile, String OutPutFile, ResetOption Option);
+
+ //Win API def
+ [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Ansi)]
+ private static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)]String lpFileName);
+
+ public IntPtr ImageWizHandle { get; set; }
+ String licPath = String.Empty;
+ String[] lic_name = { "ImageWizHelper_extrieve_windows", "ImageWizHelper_extrieve_windows_with_data_pdf" };//license name
+
+ public String DllName = "ImageWizHelper.dll";
+ public ImageWizHelper(String dll_path)
+ {
+ //Console.WriteLine(CurrentPath);
+ String dllPath = Path.Combine(dll_path, DllName);//****Here We Are Taking The Dll Path From Where We Have Plased The Dll. Full Path With Name.
+ String LogFileName = Path.Combine(dll_path, "ImageWizHelper_Error.log");
+ if (File.Exists(dllPath))
+ {
+ //****Here We are Loading The Dll****
+ if(LoadLibrary(dllPath) == IntPtr.Zero) throw new Exception("Dll isn't Load Successfully|" + dll_path + "|" + DLL_NAME);
+ StringBuilder error_info = new StringBuilder(1024);
+ if (UnlockLibrary(dll_path, error_info) == 0)//unlock library using input.
+ {
+ if (error_info.Length > 0)
+ throw new Exception(error_info.ToString());
+ }
+
+ ImageWizHandle = Initialize(LogFileName); //Initilizing the Handle of ImageWizHelper
+ if (ImageWizHandle == IntPtr.Zero) throw new Exception("unable to load memory");
+ }
+ }
+ public void UninitializeHelper()
+ {
+ if (ImageWizHandle != IntPtr.Zero)
+ {
+ Terminate(ImageWizHandle);
+ ImageWizHandle = IntPtr.Zero;
+ }
+ }
+ public Int32 GetPageCount(string filename, string pwd)
+ {
+ return GetPageCountInImageFile(ImageWizHandle, filename, pwd);
+ }
+
+ public Int32 getErrorDescription(Int32 error, StringBuilder error_buff, Int32 len)
+ {
+ return GetErrorDescription(error, error_buff, len);
+ }
+
+ //function for unlock the library using unlock functionality
+ public Int32 UnlockLibrary(String lic_path, StringBuilder err_buff)
+ {
+ Int32 index = lic_path.IndexOf("bin");
+ String path = Path.Combine(lic_path.Substring(0, (lic_path.Length - lic_path.Substring(index).Length)), "DLL");//path of DLL
+ if(!Directory.Exists(path))
+ {
+ Directory.CreateDirectory(path);//if doesn't exist create directory of DLL
+ }
+ String licfile_path1 = Path.Combine(path, lic_name[0] + ".lic");
+ String licfile_path2 = licfile_path2 = Path.Combine(path, lic_name[1] + ".lic");
+
+ if (File.Exists(licfile_path1) && File.Exists(licfile_path2))
+ {
+ throw new Exception("license should be only one");
+ }
+
+ if (File.Exists(licfile_path1))
+ {
+ return UnlockLibraryWithModuleIdentity(licfile_path1, err_buff);
+ }
+ else if (File.Exists(licfile_path2))
+ {
+ UnlockLibraryWithModuleIdentity(licfile_path2, err_buff);
+ }
+ else
+ {
+ Console.WriteLine(path);
+ throw new Exception("license doesn't exist in the DLL directory");
+ }
+ return 0;
+ }
+ public Int32 CompressAndAddToTIFF(String[] InFileName, String OutputFileName, ResetOption Option)
+ {
+ return CompressToTIFF(ImageWizHandle, InFileName, InFileName.Length, OutputFileName, Option);
+ }
+ public int AppendToTIFF(String inputFile, String outputFile, ResetOption resetOption)
+ {
+ return AppendToTiff(ImageWizHandle, inputFile, outputFile, ResetOption.ResetAllDPI);
+ }
+ public Int32 CompressAndAddToPDF(String[] InFileName, String outputFile, ResetOption Option)
+ {
+ return CompressToPDF(ImageWizHandle, InFileName, InFileName.Length, outputFile, Option);
+ }
+ public Int32 CompressAndAddToJPG(String[] InFileName, String outputFile, ResetOption Option)
+ {
+ return CompressToPDF(ImageWizHandle, InFileName, InFileName.Length, outputFile, Option);
+ }
+ public Int32 GetMaskedImage(String inputFileName, String outputFile, Int32 PageNum, RECT[] RectData)
+ {
+ return GetMaskImage(ImageWizHandle, inputFileName, outputFile, PageNum, RectData, RectData.Length, 1);
+ }
+
+ public Int32 CompressToTiff_By_PageArray(String inputFileName, String outputFile, Int32[] PageArray, Boolean Append, ResetOption option)
+ {
+ return CompressPagesToTiff_Array(ImageWizHandle, inputFileName, outputFile, PageArray, PageArray.Length, Append, option);
+ }
+
+ public Int32 CompressToTiff_By_PageRange(String inputFileName, String outputFileName, Int32 startPage, Int32 EndPage, Boolean Append, ResetOption option = ResetOption.ResetAllDPI)
+ {
+ return CompressPagesToTiff_Range(ImageWizHandle, inputFileName, outputFileName, startPage, EndPage, Append, option);
+ }
+
+ public Int32 AppentTo_Tiff(String InputFile, String OutputFile, ResetOption option)
+ {
+ return AppendToTiff(ImageWizHandle, InputFile, OutputFile, option);
+ }
+ public Int32 SetConversion(ConversionType convertionType)
+ {
+ return SetConversion(ImageWizHandle, (Int32)convertionType);
+ }
+ public Int32 SetUpDPI(ImageDPI DPI)
+ {
+ return SetDPI(ImageWizHandle, DPI);
+ }
+
+ public Int32 SetupBPP(Int32 ConvType)
+ {
+ return SetConversion(ImageWizHandle, ConvType);
+ }
+
+ public ImageQuality GetImageQuality()
+ {
+ IntPtr objquality;
+ objquality = new IntPtr();
+
+ int ret = getImageQuality(ImageWizHandle, objquality);
+
+ if (ret != 0) { return ImageQuality.unknown; }
+
+ return ImageQuality.Photo_Quality;
+
+ }
+ public Int32 GetConversionType()
+ {
+ Int32 ConvType = 0;
+ GetConversion(ImageWizHandle, ref ConvType);
+ return ConvType;
+ }
+
+ public Int32 TerminateHandle(IntPtr Handle)
+ {
+ return Terminate(Handle);
+ }
+ }
+}
diff --git a/C#/ImageWizHelperCS.csproj b/C#/ImageWizHelperCS.csproj
new file mode 100644
index 0000000..e3e17ea
--- /dev/null
+++ b/C#/ImageWizHelperCS.csproj
@@ -0,0 +1,74 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {CDDCE8D7-043C-41EB-9710-AF75D623A36C}
+ Exe
+ ImageWizHelperDemo
+ ImageWizHelperDemo
+ v4.6.1
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE
+ full
+ x86
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+ bin\x86\Release\
+ TRACE
+ true
+ pdbonly
+ x86
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/C#/ImageWizHelperCS.csproj.user b/C#/ImageWizHelperCS.csproj.user
new file mode 100644
index 0000000..3c8c37a
--- /dev/null
+++ b/C#/ImageWizHelperCS.csproj.user
@@ -0,0 +1,11 @@
+
+
+
+ -i "D:\WithWork\Abhishek\TestImageWizHelperTool\InputFile\PAN_HRIC.jpg" -o "D:\Rajesh\TestProject\ImageWizHelperDemo\output\a.tiff" -ct "tiff"
+ true
+
+
+ -i "D:\WithWork\Abhishek\TestImageWizHelperTool\Input\RD UAM Points %281%29.pdf" -o "D:\WithWork\Abhishek\TestImageWizHelperTool\output\a.tiff" -ct "pdf"
+ false
+
+
\ No newline at end of file
diff --git a/C#/Program.cs b/C#/Program.cs
new file mode 100644
index 0000000..b56b12c
--- /dev/null
+++ b/C#/Program.cs
@@ -0,0 +1,198 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ImageWizHelperCS
+{
+ class Program
+ {
+ public static String InputFile { get; set; }// decalre input file to store the input image path.
+ public static String OutputFile { get; set; }//decalre output file to store the output image path with file name and extension
+ public static String app_name { get; set; }//decalre app name to store the current application name calling the ImageWizHelper DLL.
+ public static String compression_type { get; set; }//decalre compression type to store the compression format "TIFF"/"PDF"/"JPG"
+
+ //function for read argument
+ static Boolean ReadArguments(String[] args)
+ {
+ int index = 0;
+ if (args.Length == 0)//**checking have any argument or not
+ {
+ DefineUsage();
+ return false;
+ }
+ do
+ {
+ if (index == args.Length)
+ break;
+
+ switch (args[index].ToUpper())
+ {
+ case "-I":
+ if (index == args.Length) return false;
+ index++;
+ InputFile = args[index];
+ break;
+ case "-O":
+ if (index == args.Length) return false;
+ index++;
+ OutputFile = args[index];
+ break;
+ //case "-AN":
+ // if (index == args.Length) return false;
+ // index++;
+ // app_name = args[index];
+ // break;
+ case "-CT":
+ if (index == args.Length) return false;
+ index++;
+ compression_type = args[index];
+ break;
+ }
+ index++;
+ } while (true);
+ if (compression_type == null)//default compression type
+ {
+ compression_type = "TIFF";
+ }
+ return true;
+ }
+
+ //this fuction will call when argument is null.
+ static void DefineUsage()
+ {
+ Console.WriteLine("Exe path"+" " + "-I " + "-O