Technical manual CIB jsMerge

Technical Interface

C++ Example

#include <iostream>
#include "CibJSMerge.h"
 
#define BUFSIZE 4*1024
 
int main(int argc, char** argv)
{
      CibJsMergeJobHandle job = NULL;
      int errorCode;
      char buf[BUFSIZE];
      int res = 0;
 
      try
      {
            if( CibJsMergeJobCreate(&job) != 0 )
                  throw std::string("could not create merge job");
 
            if( CibJsMergeGetVersionText(buf, BUFSIZE) != 0 )
                  throw std::string("could not read version text");
            std::cout << "Using version: " << buf << std::endl;
 
            // set some properties
            res += CibJsMergeJobSetProperty(job, "licenseKey", "xxx");
            res += CibJsMergeJobSetProperty(job, "licenseCompany", "yyy");
 
            res += CibJsMergeJobSetProperty(job, "inputfile", "input.odt");
            res += CibJsMergeJobSetPropertyW(job, L"outputfile", L"out.odt");
 
            if( res != 0 )
                  throw std::string("could not set the required properties");
 
            if( CibJsMergeJobRun(job) != 0 )
            {
                  if( CibJsMergeJobGetErrorCode(job, &errorCode) != 0 )
                        throw std::string("could not read the error code");
 
                  if( CibJsMergeJobGetErrorMessage(job, buf, BUFSIZE) != 0)
                        throw std::string("could not read the error message");
 
                  std::cout << "Error " << errorCode << ": " << buf << std::endl;
            }
            else
                  std::cout << "OK: Finfished successfully" << std::endl;
 
      }
      catch( std::string &e )
      {
            std::cout << "Exception: " << e << std::endl;
      }
 
      if(job)
            CibJsMergeJobFree(&job); }