PDFDriverInit

The PDFDriverInit method can be used to create a new printer when the application is launched and remove it when the application is closed.

 

Syntax

ActiveX:

System.Int32 PDFDriverInit(System.String PrinterName)

DLL:

HANDLE PDFDriverInit(LPCSTR szPrinter)

 

Parameters

PrinterName , szPrinter

Name of the printer as it shows in the printers control panel.

 

Remarks

The function will first attempt to connect to an existing printer. If it does not find any printer with the name provided by PrinterName, it will attempt to install a new printer. The function fails if it cannot find a printer with the specified name and cannot install a new printer. The printer referenced by PrinterName is removed when the application exits or the DriverEnd function is called.

Installing or removing a printer requires administrative privileges.

These methods return a HANDLE which is 32-bits with the 32-bit version of CDINTF and 64-bit otherwise. This handle cannot be converted to a 32-bit integer.

This method works slower than DriveInit, because it requires the installation of a new printer.

 

End-users should not use this method, because it would compromise the license information and the printer could be deactivated.

 

Member of CDIntfEx.CDIntfEx.

 

Example

<Flags()>
Public Enum FILENAMEOPTIONS As Integer
    ' Please check FileNameOptions for the complete flags version
    NoPrompt = &H1
    UseFileName = &H2
    Concatenate = &H4
    DisableCompression = &H8
    EmbedFonts = &H10
    BroadcastMessages = &H20
    PrintWatermark = &H40
End Enum
 
 
Public Sub Sample()
    ' Constants for Activation codes
    Const strLicenseTo As String = "Amyuni PDF Converter Evaluation"
    Const strActivationCode As String = "07EFCDAB0100010025AFF180A1B9441306C5739F7D452154DB83BB9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
    Const AMYUNIPRINTERNAME As String = "Amyuni PDF Converter"
 
    ' Declare a new cdintfex object if it does not exist in the form.
    Dim PDF As New CDIntfEx.CDIntfEx
 
    ' The function will first attempt to connect to an existing printer. 
    ' If it does not find any printer with the name provided by PrinterName, 
    ' it will attempt to install a new printer.
    PDF.PDFDriverInit(AMYUNIPRINTERNAME)
 
    ' The SetDefaultPrinter function sets the system default printer to the one
    ' initialized by the DriverInit functions.
    PDF.SetDefaultPrinter()
 
    ' Resulting PDF document stored here
    PDF.DefaultDirectory = "C:\Temp"
 
    ' Set Printer options
    PDF.FileNameOptionsEx = FILENAMEOPTIONS.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
    PDF.EnablePrinter(strLicenseTo, strActivationCode)
 
    ' The BatchConvert method converts a number of files to PDF.
    PDF.BatchConvert("C:\Temp\*.docx")
 
    ' The RestoreDefaultPrinter function resets the system default printer 
    ' to the printer that was the default before the call to SetDefaultPrinter.
    PDF.RestoreDefaultPrinter()
 
    ' This function will attempt to remove the printer because the handle was created using PDFDriverInit
    PDF.DriverEnd()
 
    ' Destroy PDF object
    PDF = Nothing    
End Sub
[Flags]
public enum FILENAMEOPTIONS
{
    // Please check FileNameOptions for the complete flags version
    NoPrompt = 0x00000001,
    UseFileName = 0x00000002,
    Concatenate = 0x00000004,
    DisableCompression = 0x00000008,
    EmbedFonts = 0x00000010,
    BroadcastMessages = 0x00000020,
    PrintWatermark = 0x00000040
}
 
 
public void Sample()
{
    // Constants for Activation codes
    const string strLicenseTo = "Amyuni PDF Converter Evaluation";
    const string strActivationCode = "07EFCDAB0100010025AFF180A1B9441306C5739F7D452154DB83BB9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";
    const string AMYUNIPRINTERNAME = "Amyuni PDF Converter";
 
    // Declare a new cdintfex object if it does not exist in the form.
    CDIntfEx.CDIntfEx PDF = new CDIntfEx.CDIntfEx();
 
    // The function will first attempt to connect to an existing printer. 
    // If it does not find any printer with the name provided by PrinterName, 
    // it will attempt to install a new printer.
    PDF.PDFDriverInit(AMYUNIPRINTERNAME);
 
    // The SetDefaultPrinter function sets the system default printer to the one
    // initialized by the DriverInit functions.
    PDF.SetDefaultPrinter();
 
    // Resulting PDF document stored here
    PDF.DefaultDirectory = @"C:\Temp";
 
    // Set Printer options
    PDF.FileNameOptionsEx =(int)FILENAMEOPTIONS.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
    PDF.EnablePrinter(strLicenseTo, strActivationCode);
 
    // The BatchConvert method converts a number of files to PDF.
    PDF.BatchConvert(@"C:\Temp\*.docx");
 
    // The RestoreDefaultPrinter function resets the system default printer 
    // to the printer that was the default before the call to SetDefaultPrinter.
    PDF.RestoreDefaultPrinter();
 
    // This function will attempt to remove the printer because the handle was created using PDFDriverInit
    PDF.DriverEnd();
 
    // Destroy PDF object
    PDF = null;    
}
// PDF 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  "Amyuni PDF Converter Evaluation"
    #define strActivationCode "07EFCDAB0100010025AFF180A1B9441306C5739F7D452154DB83BB9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
    #define AMYUNIPRINTERNAME "Amyuni PDF Converter"
 
    // The function will first attempt to connect to an existing printer. 
    // If it does not find any printer with the name provided by PrinterName, 
    // it will attempt to install a new printer.
    HANDLE PDF = PDFDriverInit(AMYUNIPRINTERNAME);
 
    // The CDISetDefaultPrinter function sets the system default printer to the one
    // initialized by the DriverInit functions.
    CDISetDefaultPrinter(PDF);
 
    // Resulting PDF document stored here
    SetDefaultDirectory(PDF, "C:\\Temp");
 
    // Set Printer options
    SetFileNameOptions(PDF, 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(PDF, strLicenseTo, strActivationCode);
 
    // The BatchConvert method converts a number of files to PDF.
    BatchConvertEx(PDF, "C:\\Temp\\*.docx");
 
    // The RestoreDefaultPrinter function resets the system default printer 
    // to the printer that was the default before the call to SetDefaultPrinter.
    RestoreDefaultPrinter(PDF);
 
    // This function will attempt to remove the printer because the handle was created using PDFDriverInit
    DriverEnd(PDF);  
 
    // Destroy PDF object
    PDF = NULL;    
 
    return 0;
}
package Example;
 
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
 
public class Sample {
    public enum FILENAMEOPTIONS
    {
        // Please check FileNameOptions for the complete flags version
        NoPrompt(0x00000001),
        UseFileName(0x00000002),
        Concatenate(0x00000004),
        DisableCompression(0x00000008),
        EmbedFonts(0x00000010),
        BroadcastMessages(0x00000020),
        PrintWatermark(0x00000040);
        public int value;
        public FILENAMEOPTIONS(int value)
        {
            this.value = value;
        }
        public Object value(){
            return value;
        }
    }
 
 
    public static void main(String[] args)
    {
        // Constants for Activation codes
        String strLicenseTo  = "Amyuni PDF Converter Evaluation";
        String strActivationCode = "07EFCDAB0100010025AFF180A1B9441306C5739F7D452154DB83BB9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";
        String AMYUNIPRINTERNAME = "Amyuni PDF Converter";
 
        // Declare a new cdintfex object if it does not exist in the form.
        ActiveXComponent pdf = new ActiveXComponent("CDIntfEx.CDIntfEx.6.0"); 
 
        // The function will first attempt to connect to an existing printer. 
        // If it does not find any printer with the name provided by PrinterName, 
        // it will attempt to install a new printer.
        Dispatch.call(pdf,"PDFDriverInit",AMYUNIPRINTERNAME);
 
        // The SetDefaultPrinter function sets the system default printer to the one
        // initialized by the DriverInit functions.
        Dispatch.call(pdf,"SetDefaultPrinter");
 
        // Resulting PDF document stored here
        Dispatch.put(pdf,"DefaultDirectory","c:\\Temp");
 
        // Set Printer options
        Dispatch.put(pdf,"FileNameOptionsEx",FILENAMEOPTIONS.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(pdf,"EnablePrinter", strLicenseTo, strActivationCode); 
 
        // The BatchConvert method converts a number of files to PDF.
        Dispatch.call(pdf,"BatchConvert","c:\\Temp\\*.docx");
 
        // The RestoreDefaultPrinter function resets the system default printer 
        // to the printer that was the default before the call to SetDefaultPrinter.
        Dispatch.call(pdf,"RestoreDefaultPrinter"); 
 
        // This function will attempt to remove the printer because the handle was created using PDFDriverInit
        Dispatch.call(pdf,"DriverEnd");
 
        // Destroy PDF object
        pdf = null;        
    }
}
$FILENAMEOPTIONS = @{
    NoPrompt = 0x00000001
    UseFileName = 0x00000002
    Concatenate = 0x00000004
    DisableCompression = 0x00000008
    EmbedFonts = 0x00000010
    BroadcastMessages = 0x00000020
    PrintWatermark = 0x00000040
} 
#Please check FileNameOptions for the complete flags version
 
# Constants for Activation codes
$strLicenseTo  =  "Amyuni PDF Converter Evaluation"
$strActivationCode = "07EFCDAB0100010025AFF180A1B9441306C5739F7D452154DB83BB9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
$AMYUNIPRINTERNAME = "Amyuni PDF Converter"
 
#Declare a new cdintfex object if it does not exist in the form.
$PDF = New-Object -ComObject CDIntfEx.CDIntfEx.6.0
 
#The function will first attempt to connect to an existing printer. 
#If it does not find any printer with the name provided by PrinterName, 
#it will attempt to install a new printer.
[System.__ComObject].InvokeMember('PDFDriverInit' ,[System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$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,$PDF,$null)
 
#Resulting PDF document stored here
[System.__ComObject].InvokeMember('DefaultDirectory' ,[System.Reflection.BindingFlags]::SetProperty,$null,$PDF,"C:\Temp")
 
#Set Printer options
[System.__ComObject].InvokeMember('FileNameOptionsEx' ,[System.Reflection.BindingFlags]::SetProperty,$null,$PDF,$FILENAMEOPTIONS::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,$PDF, @($strLicenseTo, $strActivationCode))
 
#The BatchConvert method converts a number of files to PDF.
[System.__ComObject].InvokeMember('BatchConvert' ,[System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, "C:\Temp\*.docx")
 
#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,$PDF,$null)
 
#This function will attempt to remove the printer because the handle was created using PDFDriverInit
[System.__ComObject].InvokeMember('DriverEnd' ,[System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$null)
 
#Destroy PDF object
$PDF = $null
' FileNameOptions constants
' Please check FileNameOptions for the complete flags version    
Const NoPrompt = &H1
Const UseFileName = &H2
Const Concatenate = &H4
Const DisableCompression = &H8
Const EmbedFonts = &H10
Const BroadcastMessages = &H20
Const PrintWatermark = &H40
Const MultilingualSupport = &H80
Const EncryptDocument = &H100
Const FullEmbed = &H200
 
' Constants for Activation codes
Const strLicenseTo = "Amyuni PDF Converter Evaluation"
Const strActivationCode = "07EFCDAB0100010025AFF180A1B9441306C5739F7D452154DB83BB9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
Const AMYUNIPRINTERNAME = "Amyuni PDF Converter"
 
' Declare a new cdintfex object
Dim PDF
Set PDF = CreateObject("CDIntfEx.CDIntfEx.6.0")
 
' The function will first attempt to connect to an existing printer. 
' If it does not find any printer with the name provided by PrinterName, 
' it will attempt to install a new printer.
PDF.PDFDriverInit AMYUNIPRINTERNAME
 
' The SetDefaultPrinter function sets the system default printer to the one
' initialized by the DriverInit functions.
PDF.SetDefaultPrinter
 
' Resulting PDF document stored here
PDF.DefaultDirectory = "C:\Temp"
 
' Set Printer options
PDF.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
PDF.EnablePrinter strLicenseTo, strActivationCode
 
' The BatchConvert method converts a number of files to PDF.
PDF.BatchConvert "C:\Temp\*.docx"
 
' The RestoreDefaultPrinter function resets the system default printer
' to the printer that was the default before the call to SetDefaultPrinter.
PDF.RestoreDefaultPrinter
 
' This function will simply detach from an existing printer because the handle was created using DriverInit    
PDF.DriverEnd
 
' Destroy PDF object
Set PDF = Nothing