Software Companions - Viewers and Converters

Using scConverter in C# .Net

How to add scConverter to your C# application

You can easily add scConverter to your C# application. In this small tutorial we will start with a completely new C# .Net project, and then add a reference to scConverter. This tutorial assumes that you've already installed the scConverter SDK, either 32 or 64 bit.
The picture below shows the VS2022 new project dialog where we choose to create a C# .NET Framework console application:


Create a new C# .Net Application

After you've created your project you can right-click the References section of the solution explorer as shown below:


Add scConverter reference

Then open the COM section and locate the scConverterLib type library and select it as show below:


Add scConverterLib type library to your project

Now we can use the scConverter in our code as follows:

namespace TestConverter
{
   internal class Program
   {
      static void Main(string[] args)
      {
         scConverterLib.Converter myconverter = new scConverterLib.Converter();
         if (myconverter != null)
         {

         }
      }
   }
}  

After you've added the code above it is now time to try to run the application to make sure scConverter is properly referenced.
If You installed just the 64-bit version of the SDK, you may get the following error message:


scConverter runtime error

If you do get this error, you can solve it by opening the project properties page. On this page you will find an option named Prefer 32-bit. Disable this option to allow your project to run in 64-bit mode. If you do prefer to keep the option enabled, you will need to install scConverter 32-bit SDK.


C# Project Properties

You can now start using other scConverter functions in your code. If you have purchased a license you will have received a serial number. You must use the SetSerialNumber function to unlock the converter.
Below you will find a complete code sample that can convert files from command line:

namespace TestConverter
{
   internal class Program
   {
      static void Main(string[] args)
      {
         scConverterLib.Converter myconverter = new scConverterLib.Converter();
         if (myconverter != null)
         {
            myconverter.SetSerialNumber("recevied serial number");
            myconverter.Convert(args[0],    //Input file name
                                args[1],    //Output file name
                                args[2],    //Output format, e.g.: TIFF, PDF, CALS
                                1.0,        //Scale
                                1,          //Bits per pixel - used only for raster output formats
                                600);       //Resolution (dots per inch) - used only for raster output formats
         }
      }
   }
}  

Other Online Resources

scConverter Documentation
Frequently Asked Questions (FAQ)
Sample Code
Support Forum