The EnablePrinter method can be used to install the permanent license and activation code for the product. The license and activation code define which features of the product are available to the users depending on the product they purchased.
For example, users of the DOCX Converter will have a different activation code than users of the mixed DOCX/RTF/HTML Converter product. EnablePrinter is also used in the developer versions of the products to activate the printer before every printout.
System.Int32 EnablePrinter(System.String Company, System.String Code)
long EnablePrinter(HANDLE hPrinter, LPCSTR szCompany, LPCSTR szCode)
Company, szCompany
Name of the company or public user having licensed the product
Code, szCode
License key provided by Amyuni Technologies when downloading or purchasing a product.
hPrinter
Handle to printer returned by any of the DriverInit function calls.
In the ActiveX: -1 if license expired, 0 if succeeded, exception in case of failure. In the DLL: 1 in case of success, 0 otherwise, but if license expired it returns 1.
This function is usually called after successful installation of the product. End-users would usually enter their license information through the printer configuration tab, whereas developers would call this function from their product installation routine. The default install.exe that is provided with the products can also be used to set the license information by adding the following switches to the command line:
-n CompanyName -c LicenseKey
Calling the EnablePrinter function after installing the printer requires administrative rights under Windows NT/2000/XP, calling the same function before every printout does not require administrative rights and can be used with users having limited privileges on the system.
In addition to calling EnablePrinter after installing the printer, this function should also be called right before printing any document. The printer will otherwise be disabled. If the developers have full control of the printing process, they can call this function right before calling their printing function.
If the application is an archiving or document management application that runs in the background and waits for other documents to be printed, this function can be called from the EnabledPre event that is fired by the printer.
Calling the EnablePrinter function after installing the printer requires administrative rights under Windows NT/2000/XP, calling the same function before every printout does not require administrative rights and can be used with users having limited privileges on the system.
In addition to calling EnablePrinter after installing the printer, this function should also be called right before printing any document. The printer will otherwise be disabled. If the developers have full control of the printing process, they can call this function right before calling their printing function. If the application is an archiving or document management application that runs in the background and waits for other documents to be printed, this function can be called from the EnabledPre event that is fired by the printer.
Member of CDIntfEx.CDIntfEx.
<Flags()>
Public Enum acFileNameOptions As Integer
' Please check FileNameOptions for the complete flags version
NoPrompt = &H1
UseFileName = &H2
EmbedFonts = &H10
BroadcastMessages = &H20
End Enum
Public Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "DOCX Converter Developer Evaluation"
Const strActivationCode As String = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"
Const AMYUNIPRINTERNAME As String = "Amyuni DOCX Converter"
' Declare a new cdintfex object if it does not exist in the form.
Dim DOCX As New CDIntfEx.CDIntfEx
' Get a reference to the installed printer.
' This will fail if the printer name passed to the DriverInit method is
' not found in the printer’s folder
DOCX.DriverInit(AMYUNIPRINTERNAME)
' The SetDefaultPrinter function sets the system default printer to the one
' initialized by the DriverInit functions.
DOCX.SetDefaultPrinter()
' Resulting DOCX document stored here
DOCX.DefaultDirectory = "C:\Temp"
' Set Printer options
DOCX.FileNameOptionsEx = acFileNameOptions.NoPrompt
' The EnablePrinter() method needs to be called right before each print job.
' Calling the EnablePrinter() method will start a 20 second time-out value
DOCX.EnablePrinter(strLicenseTo, strActivationCode)
' The BatchConvert method converts a number of files to DOCX.
DOCX.BatchConvert("C:\Temp\*.ppt")
' The RestoreDefaultPrinter function resets the system default printer
' to the printer that was the default before the call to SetDefaultPrinter.
DOCX.RestoreDefaultPrinter()
' This function will simply detach from an existing printer because the handle was created using DriverInit
DOCX.DriverEnd()
' Destroy DOCX object
DOCX = Nothing
End Sub
[Flags]
public enum acFileNameOptions
{
// Please check FileNameOptions for the complete flags version
NoPrompt = 0x00000001,
UseFileName = 0x00000002,
EmbedFonts = 0x00000010,
BroadcastMessages = 0x00000020,
}
public void Sample()
{
// Constants for Activation codes
const string strLicenseTo = "DOCX Converter Developer Evaluation";
const string strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190";
const string AMYUNIPRINTERNAME = "Amyuni DOCX Converter";
// Declare a new cdintfex object if it does not exist in the form.
CDIntfEx.CDIntfEx DOCX = new CDIntfEx.CDIntfEx();
// Get a reference to the installed printer.
// This will fail if the printer name passed to the DriverInit method is
// not found in the printer’s folder
DOCX.DriverInit(AMYUNIPRINTERNAME);
// The SetDefaultPrinter function sets the system default printer to the one
// initialized by the DriverInit functions.
DOCX.SetDefaultPrinter();
// Resulting DOCX document stored here
DOCX.DefaultDirectory = @"C:\Temp";
// Set Printer options
DOCX.FileNameOptionsEx =(int)acFileNameOptions.NoPrompt;
// The EnablePrinter() method needs to be called right before each print job.
// Calling the EnablePrinter() method will start a 20 second time-out value
DOCX.EnablePrinter(strLicenseTo, strActivationCode);
// The BatchConvert method converts a number of files to DOCX.
DOCX.BatchConvert(@"C:\Temp\*.ppt");
// The RestoreDefaultPrinter function resets the system default printer
// to the printer that was the default before the call to SetDefaultPrinter.
DOCX.RestoreDefaultPrinter();
// This function will simply detach from an existing printer because the handle was created using DriverInit
DOCX.DriverEnd();
// Destroy DOCX object
DOCX = null;
}
// DOCX Converter Cpp.cpp : Defines the entry point for the console application.
//
#include <Windows.h>
#include <string>
#include <iostream>
#include "CdIntf.h"
#pragma comment(lib, "CDIntf.lib")
using namespace std;
int main()
{
// Constants for Activation codes
#define strLicenseTo "DOCX Converter Developer Evaluation"
#define strActivationCode "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"
#define AMYUNIPRINTERNAME "Amyuni DOCX Converter"
// Get a reference to the installed printer.
// This will fail if the printer name passed to the DriverInit method is
// not found in the printer’s folder
HANDLE DOCX = DriverInit(AMYUNIPRINTERNAME);
// The CDISetDefaultPrinter function sets the system default printer to the one
// initialized by the DriverInit functions.
CDISetDefaultPrinter(DOCX);
// Resulting DOCX document stored here
SetDefaultDirectory(DOCX, "C:\\Temp");
// Set Printer options
SetFileNameOptions(DOCX, NoPrompt);
// The EnablePrinter() method needs to be called right before each print job.
// Calling the EnablePrinter() method will start a 20 second time-out value
EnablePrinter(DOCX, strLicenseTo, strActivationCode);
// The BatchConvert method converts a number of files to DOCX.
BatchConvertEx(DOCX, "C:\\Temp\\*.ppt");
// The RestoreDefaultPrinter function resets the system default printer
// to the printer that was the default before the call to SetDefaultPrinter.
RestoreDefaultPrinter(DOCX);
// This function will simply detach from an existing printer because the handle was created using DriverInit
DriverEnd(DOCX);
// Destroy DOCX object
DOCX = NULL;
return 0;
}
package Example;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
public class Sample {
public enum acFileNameOptions
{
// Please check FileNameOptions for the complete flags version
NoPrompt(0x00000001),
UseFileName(0x00000002),
EmbedFonts(0x00000010),
BroadcastMessages(0x00000020);
public int value;
public acFileNameOptions(int value)
{
this.value = value;
}
public Object value(){
return value;
}
}
public static void main(String[] args)
{
// Constants for Activation codes
String strLicenseTo = "DOCX Converter Developer Evaluation";
String strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190";
String AMYUNIPRINTERNAME = "Amyuni DOCX Converter";
// Declare a new cdintfex object if it does not exist in the form.
ActiveXComponent docx = new ActiveXComponent("CDIntfEx.CDIntfEx.6.5");
// Get a reference to the installed printer.
// This will fail if the printer name passed to the DriverInit method is
// not found in the printer’s folder
Dispatch.call(docx,"DriverInit",AMYUNIPRINTERNAME);
// The SetDefaultPrinter function sets the system default printer to the one
// initialized by the DriverInit functions.
Dispatch.call(docx,"SetDefaultPrinter");
// Resulting DOCX document stored here
Dispatch.put(docx,"DefaultDirectory","c:\\Temp");
// Set Printer options
Dispatch.put(docx,"FileNameOptionsEx",acFileNameOptions.NoPrompt.value);
// The EnablePrinter() method needs to be called right before each print job.
// Calling the EnablePrinter() method will start a 20 second time-out value
Dispatch.call(docx,"EnablePrinter", strLicenseTo, strActivationCode);
// The BatchConvert method converts a number of files to DOCX.
Dispatch.call(docx,"BatchConvert","c:\\Temp\\*.ppt");
// The RestoreDefaultPrinter function resets the system default printer
// to the printer that was the default before the call to SetDefaultPrinter.
Dispatch.call(docx,"RestoreDefaultPrinter");
// This function will simply detach from an existing printer because the handle was created using DriverInit
Dispatch.call(docx,"DriverEnd");
// Destroy DOCX object
docx = null;
}
}
$acFileNameOptions = @{
NoPrompt = 0x00000001
UseFileName = 0x00000002
EmbedFonts = 0x00000010
BroadcastMessages = 0x00000020
}
#Please check FileNameOptions for the complete flags version
# Constants for Activation codes
$strLicenseTo = "DOCX Converter Developer Evaluation"
$strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"
$AMYUNIPRINTERNAME = "Amyuni DOCX Converter"
#Declare a new cdintfex object if it does not exist in the form.
$DOCX = New-Object -ComObject CDIntfEx.CDIntfEx.6.5
#Get a reference to the installed printer.
#This will fail if the printer name passed to the DriverInit method is
#not found in the printer’s folder
[System.__ComObject].InvokeMember('DriverInit', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX,$AMYUNIPRINTERNAME)
#The SetDefaultPrinter function sets the system default printer to the one
#initialized by the DriverInit functions.
[System.__ComObject].InvokeMember('SetDefaultPrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX,$null)
#Resulting DOCX document stored here
[System.__ComObject].InvokeMember('DefaultDirectory', [System.Reflection.BindingFlags]::SetProperty,$null,$DOCX,"C:\Temp")
#Set Printer options
[System.__ComObject].InvokeMember('FileNameOptionsEx', [System.Reflection.BindingFlags]::SetProperty,$null,$DOCX,$acFileNameOptions::NoPrompt)
#The EnablePrinter() method needs to be called right before each print job.
#Calling the EnablePrinter() method will start a 20 second time-out value
[System.__ComObject].InvokeMember('EnablePrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX, @($strLicenseTo, $strActivationCode))
#The BatchConvert method converts a number of files to DOCX.
[System.__ComObject].InvokeMember('BatchConvert', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX, "C:\Temp\*.ppt")
#The RestoreDefaultPrinter function resets the system default printer
#to the printer that was the default before the call to SetDefaultPrinter.
[System.__ComObject].InvokeMember('RestoreDefaultPrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX,$null)
#This function will simply detach from an existing printer because the handle was created using DriverInit
[System.__ComObject].InvokeMember('DriverEnd', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX,$null)
#Destroy DOCX object
$DOCX = $null
' FileNameOptions constants
' Please check FileNameOptions for the complete flags version
Const NoPrompt = &H1
Const UseFileName = &H2
Const EmbedFonts = &H10
Const BroadcastMessages = &H20
' Constants for Activation codes
Const strLicenseTo = "DOCX Converter Developer Evaluation"
Const strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"
Const AMYUNIPRINTERNAME = "Amyuni DOCX Converter"
' Declare a new cdintfex object
Dim DOCX
Set DOCX = CreateObject("CDIntfEx.CDIntfEx.6.5")
' Get a reference to the installed printer.
' This will fail if the printer name passed to the DriverInit method is
' not found in the printer’s folder
DOCX.DriverInit AMYUNIPRINTERNAME
' The SetDefaultPrinter function sets the system default printer to the one
' initialized by the DriverInit functions.
DOCX.SetDefaultPrinter
' Resulting DOCX document stored here
DOCX.DefaultDirectory = "C:\Temp"
' Set Printer options
DOCX.FileNameOptionsEx = NoPrompt
' The EnablePrinter() method needs to be called right before each print job.
' Calling the EnablePrinter() method will start a 20 second time-out value
DOCX.EnablePrinter strLicenseTo, strActivationCode
' The BatchConvert method converts a number of files to DOCX.
DOCX.BatchConvert "C:\Temp\*.ppt"
' The RestoreDefaultPrinter function resets the system default printer
' to the printer that was the default before the call to SetDefaultPrinter.
DOCX.RestoreDefaultPrinter
' This function will simply detach from an existing printer because the handle was created using DriverInit
DOCX.DriverEnd
' Destroy DOCX object
Set DOCX = Nothing