Software Companions - Gerber and HPGL Viewers

Tools for Viewing, Printing, Markup and Conversion 

scConverter DLL
Frequently Asked Questions

Usage


Usage

How do I use the exported functions in a C++ application (not using COM)?

Here is a code sample demonstrating how to use the exported DLL functions in C++:

#define SC_PDF       0     //Create a normal editable file using 1.6 standard.
#define SC_PDF_A     1     //Create a PDF/A-2B write protected file for archiving.

//scConverter.dll exported functions
typedef int ( *SC_SET_PDFSTANDARD)( long Format );
typedef int ( *SC_SET_PDFLARGEFORMAT)( long Enable );
typedef int ( *SC_SET_PDFLAYERS)( long Enable );
typedef int ( *SC_SET_TIFFSINGLESTRIP)( long Enable );
typedef int ( *SC_SET_IMPORTERPATH)( WCHAR *Path);
typedef int ( *SC_CONVERT_FILE)(  WCHAR *pSerialNumber, WCHAR *pInputFile, WCHAR *pOutputFile, 
                                  WCHAR *pFormat, double dScale, long lBitsPerPixel, long lDPI );
	
int ConvertFile( WCHAR *InputFile, WCHAR *OutputFile, WCHAR Format, long BitsPerPixel, long DPI)
{
   int result;
   HINSTANCE  hLib = LoadLibrary( _T("scConverter.dll") );
   if (!hLib) return -1;
   //Get function pointers
   SC_CONVERT_FILE         ConvertFileFunc       = (SC_CONVERT_FILE)GetProcAddress(  hLib, "scConvertFile" );
   SC_SET_PDFSTANDARD      SetPDFStandardFunc    = (SC_SET_PDFSTANDARD)GetProcAddress(  hLib, "scSetPDFWriteFormat" );
   SC_SET_PDFLARGEFORMAT   SetPDFLargeFormatFunc = (SC_SET_PDFLARGEFORMAT)GetProcAddress(  hLib, "scSetPDFLargeFormat" );
   SC_SET_PDFLAYERS        SetPDFLayersFunc      = (SC_SET_PDFLAYERS)GetProcAddress(  hLib, "scSetPDFLayers" );
   SC_SET_TIFFSINGLESTRIP  SetTIFFSingleStripFunc= (SC_SET_TIFFSINGLESTRIP)GetProcAddress(  hLib, "scSetTIFFSingleStrip" );
   SC_SET_IMPORTERPATH     SetImporterPathFunc   = (SC_SET_IMPORTERPATH)GetProcAddress(  hLib, "scImportersPath" );

   //Setup and do the conversion
   SetPDFStandardFunc( SC_PDF_A ); 
   SetPDFLayersFunc( 1 );
   SetTIFFSingleStripFunc( 1 );
   SetPDFLargeFormatFunc( 1 );
   //Replace first paremeter _T("") with your serial number   
   result = ConvertFileFunc( _T(""), InputFile, OutputFile, Format, 1.0, BitsPerPixel, DPI );
   FreeLibrary( hLib );
   return result;
}

Sample usage of this function:
   //create PDF
   ConvertFile( _T("c:\\temp\\test.plt"), _T("c:\\temp\test.pdf"), _T("PDF"), 1.0, 0, 0 ); 
       
   //create monochrome TIFF, 300 dots per inch   
   ConvertFile( _T("c:\\temp\\test.plt"), _T("c:\\temp\test.tif"), _T("TIFF"), 1.0, 1, 300 );  
   
   //create true color TIFF, 200 dots per inch
   ConvertFile( _T("c:\\temp\\test.plt"), _T("c:\\temp\test.tif"), _T("TIFF"), 1.0, 24, 200 );
     
   
Back to top
How do I use the COM interface without using MFC or ATL in a C++ application?

Below you will find a code sample on how to create an instance of the component and then use it (no MFC/ATL):

int ConvertFile( WCHAR *InputFile, WCHAR *OutputFile, WCHAR *pFormat, double Scale, long BitsPerPixel, long DPI )
{
   int nRetCode = 0; 
   if (SUCCEEDED(::CoInitialize(NULL)))
   {
      IConverter *pIConverter = nullptr;
      HRESULT hr = CoCreateInstance(CLSID_Converter, NULL, CLSCTX_ALL, IID_IConverter, (void **) &pIConverter);  
      if (pIConverter)         
      {
         pIConverter->raw_SetSerialNumber( _T("") );	//Use your serial number here
         pIConverter->put_PDFWriteFormat(0);    //Editable  PDF 1.6, set to 1 for PDF/A
         pIConverter->put_PDFLayers(1);         //Enable PDF layers
         pIConverter->put_PDFWriteFormat(1);    //Enable large format PDF - allows maximum 60x60 meter extents
         pIConverter->put_TIFFSingleStrip(1);   //Create single strip TIFF files (usually gives smaller file size).
         hr = pIConverter->raw_Convert( InputFile,      //input filename, 
                                        OutputFile,     //output filename, 
                                        Format,         //format e.g.: PDF, TIFF, DWF etc, 
                                        Scale,          //Scaling
                                        BitsPerPixel,   //Bits per pixel, e.g.: 1 = monochrome, 24 = true color
                                        DPI );          //Dots per inch (resolution), e.g. 200, 300, 600 etc.
         if (hr != S_OK )
         {
            //Conversion failed - get error code
            long errorcode = 0;
            pIConverter->get_LastError(&errorcode);
            nRetCode = errorcode; 
         }

         pIConverter->Release();     //Release pointer to interface now
         pIConverter = nullptr;
      }
      else
      {
         nRetCode = (int)hr;       //scConverter.dll is not installed on this computer, or other COM problem, return hr
      }
      ::CoUninitialize();
   }
   return nRetCode;
}

Back to top