New PDF Digital Signature

Amyuni PDF Converter allows to digital sign a new PDF using the SetPrinterParamInt and SetPrinterParamStr Methods.

 

 

Parameters

DS_DigitalSignature

Integer.  Defines if the document should be signed. Using "1" will enable the signature.

DS_SignedBy

String.  Friendly name of the digital signature as it appears to the user when the digital certificate is installed on the system. In most cases, this is the full name of the person signing the document.

DS_Reason

String.  Reason for signing the document. It can be an empty string if no reason is specified.

DS_ImageFile

String.  Full path of the file containing the image that is associated with the signature. This is optional, a digital signature does not always contain an image.

DS_Location

String.  Physical location of the person who signed the document. This parameter is optional.

DS_PageNumber

Integer.  Page number on which to insert the signature. Page numbers start with 1, the value -1 indicates the last page in the document.

DS_HorzPos, DS_VertPos

Integer.  Horizontal and vertical position of the digital signature in mm (56.7 Twips ≃ 1 mm).

DS_Width, DS_Height

Integer.  Width and height of the digital signature in mm (56.7 Twips ≃ 1 mm).

DS_Flags

Integer.  Combination of flags that determine how the digital signature appears on the page.  A value of 0 indicates that the signature is invisible.

 

Item to show

DLL Constants

Value

(Dec)

Value

(Hex)

Hidden Signature

 

0

0x000

Signer name

SIGNATURE_DISPLAY_SIGNER

1

0x001

Reason for signing

SIGNATURE_DISPLAY_REASON

2

0x002

Location

SIGNATURE_DISPLAY_LOCATION

4

0x004

Associated image

SIGNATURE_DISPLAY_IMAGE

8

0x008

Certificate

SIGNATURE_DISPLAY_CERTIFICATE

16

0x010

Date of signing

SIGNATURE_DISPLAY_DATE

32

0x020

Signature type

SIGNATURE_DISPLAY_TYPE

64

0x040

Show All

 

255

0x0FF

Enabling PAdES

SIGNATURE_LEVEL_PADES

256

0x100

Enabling PAdES with LTV support

 (Long Term Validation)

SIGNATURE_LEVEL_PADES_LTV

512

0x200

 

 

 

Example

<Flags()>

Public Enum acFileNameOptions 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

 

<Flags()>

Public Enum DIGITALSIGNATURE As Integer

    SIGNATURE_DISPLAY_SIGNER = &H1

    SIGNATURE_DISPLAY_REASON = &H2

    SIGNATURE_DISPLAY_LOCATION = &H4

    SIGNATURE_DISPLAY_IMAGE = &H8

    SIGNATURE_DISPLAY_CERTIFICATE = &H10

    SIGNATURE_DISPLAY_DATE = &H20

    SIGNATURE_DISPLAY_TYPE = &H40

    SIGNATURE_LEVEL_PADES = &H100

    SIGNATURE_LEVEL_PADES_LTV = &H200

End Enum

 

Public Sub Sample()

    ' Constants for Activation codes

    Const strLicenseTo As String = "Amyuni PDF Converter Evaluation"

    Const strActivationCode As String = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

    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

 

    ' 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

    PDF.DriverInit(AMYUNIPRINTERNAME)

 

    ' The SetDefaultPrinter function sets the system default printer to the one

    ' initialized by the DriverInit functions.

    PDF.SetDefaultPrinter()

 

    ' The EnablePrinter() method needs to be called right before each print job.

    ' and before the configuration

    ' Calling the EnablePrinter() method will start a 20 second time-out value

    PDF.EnablePrinter(strLicenseTo, strActivationCode)

 

    ' Resulting PDF document stored here

    PDF.DefaultDirectory = "C:\Temp"

 

    ' Set Printer options

    PDF.FileNameOptionsEx = acFileNameOptions.NoPrompt

 

    ' Configuring the Digital Signature

    PDF.SetPrinterParamInt("DS_DigitalSignature", 1)

    PDF.SetPrinterParamStr("DS_SignedBy", "Amyuni Dev Signature")

    PDF.SetPrinterParamStr("DS_Reason", "Testing")

    PDF.SetPrinterParamStr("DS_ImageFile", "c:\temp\signature.jpg")

    PDF.SetPrinterParamStr("DS_Location", "Montreal")

    PDF.SetPrinterParamInt("DS_PageNumber", 1)

    PDF.SetPrinterParamInt("DS_HorPos", 100)

    PDF.SetPrinterParamInt("DS_VerPos", 100)

    PDF.SetPrinterParamInt("DS_SigWidth", 400)

    PDF.SetPrinterParamInt("DS_SigHeight", 200)

    PDF.SetPrinterParamInt("DS_Flags", DIGITALSIGNATURE.SIGNATURE_DISPLAY_SIGNER Or

            DIGITALSIGNATURE.SIGNATURE_DISPLAY_REASON Or DIGITALSIGNATURE.SIGNATURE_DISPLAY_LOCATION Or

            DIGITALSIGNATURE.SIGNATURE_DISPLAY_IMAGE)

 

    ' 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

    PDF = Nothing    

End Sub

[Flags]

public enum acFileNameOptions

{

    // Please check FileNameOptions for the complete flags version

    NoPrompt = 0x00000001,

    UseFileName = 0x00000002,

    Concatenate = 0x00000004,

    DisableCompression = 0x00000008,

    EmbedFonts = 0x00000010,

    BroadcastMessages = 0x00000020,

    PrintWatermark = 0x00000040

}

[Flags]

public enum DIGITALSIGNATURE

{

    SIGNATURE_DISPLAY_SIGNER = 0x001,

    SIGNATURE_DISPLAY_REASON = 0x002,

    SIGNATURE_DISPLAY_LOCATION = 0x004,

    SIGNATURE_DISPLAY_IMAGE = 0x008,

    SIGNATURE_DISPLAY_CERTIFICATE = 0x010,

    SIGNATURE_DISPLAY_DATE = 0x020,

    SIGNATURE_DISPLAY_TYPE = 0x040,

    SIGNATURE_LEVEL_PADES = 0x100,

    SIGNATURE_LEVEL_PADES_LTV = 0x200

}

public void Sample()

{

    // Constants for Activation codes

    const string strLicenseTo = "Amyuni PDF Converter Evaluation";

    const string strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";

    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();

 

    // 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

    PDF.DriverInit(AMYUNIPRINTERNAME);

 

    // The SetDefaultPrinter function sets the system default printer to the one

    // initialized by the DriverInit functions.

    PDF.SetDefaultPrinter();

 

    // The EnablePrinter() method needs to be called right before each print job.

    // and before the configuration

    // Calling the EnablePrinter() method will start a 20 second time-out value

    PDF.EnablePrinter(strLicenseTo, strActivationCode);

 

    // Resulting PDF document stored here

    PDF.DefaultDirectory = @"C:\Temp";

 

    // Set Printer options

    PDF.FileNameOptionsEx = (int)acFileNameOptions.NoPrompt;

 

    // Configuring the Digital Signature

    PDF.SetPrinterParamInt("DS_DigitalSignature", 1);

    PDF.SetPrinterParamStr("DS_SignedBy", "Amyuni Dev Signature");

    PDF.SetPrinterParamStr("DS_Reason", "Testing");

    PDF.SetPrinterParamStr("DS_ImageFile", "c:\temp\signature.jpg");

    PDF.SetPrinterParamStr("DS_Location", "Montreal");

    PDF.SetPrinterParamInt("DS_PageNumber", 1);

    PDF.SetPrinterParamInt("DS_HorPos", 100);

    PDF.SetPrinterParamInt("DS_VerPos", 100);

    PDF.SetPrinterParamInt("DS_SigWidth", 400);

    PDF.SetPrinterParamInt("DS_SigHeight", 200);

    PDF.SetPrinterParamInt("DS_Flags", (int)(DIGITALSIGNATURE.SIGNATURE_DISPLAY_SIGNER |

            DIGITALSIGNATURE.SIGNATURE_DISPLAY_REASON | DIGITALSIGNATURE.SIGNATURE_DISPLAY_LOCATION |

            DIGITALSIGNATURE.SIGNATURE_DISPLAY_IMAGE)));

 

    // 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();

 

 

}

// 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 "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

    #define AMYUNIPRINTERNAME "Amyuni PDF 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 PDF = DriverInit(AMYUNIPRINTERNAME);

 

    // The CDISetDefaultPrinter function sets the system default printer to the one

    // initialized by the DriverInit functions.

    CDISetDefaultPrinter(PDF);

 

    // The EnablePrinter() method needs to be called right before each print job.

    // and before the configuration

    // Calling the EnablePrinter() method will start a 20 second time-out value

    EnablePrinter(PDF, strLicenseTo, strActivationCode);

 

    // Resulting PDF document stored here

    SetDefaultDirectory(PDF, "c:\\Temp");

 

    // Set Printer options

    SetFileNameOptions(PDF, NoPrompt);

 

    // Configuring the Digital Signature

    SetPrinterParamInt(PDF, "DS_DigitalSignature", 1);

    SetPrinterParamStr(PDF, "DS_SignedBy", "Amyuni Dev Signature");

    SetPrinterParamStr(PDF, "DS_Reason", "Testing");

    SetPrinterParamStr(PDF, "DS_ImageFile", "c:\temp\signature.jpg");

    SetPrinterParamStr(PDF, "DS_Location", "Montreal");

    SetPrinterParamInt(PDF, "DS_PageNumber", 1);

    SetPrinterParamInt(PDF, "DS_HorPos", 100);

    SetPrinterParamInt(PDF, "DS_VerPos", 100);

    SetPrinterParamInt(PDF, "DS_SigWidth", 400);

    SetPrinterParamInt(PDF, "DS_SigHeight", 200);

    SetPrinterParamInt(PDF, "DS_Flags", SIGNATURE_DISPLAY_SIGNER |

           SIGNATURE_DISPLAY_REASON | SIGNATURE_DISPLAY_LOCATION |

            SIGNATURE_DISPLAY_IMAGE);

 

    // 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 simply detach from an existing printer because the handle was created using DriverInit

    DriverEnd(PDF); 

 

    // Destroy PDF object

    PDF = nullptr;    

 

    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),

        Concatenate(0x00000004),

        DisableCompression(0x00000008),

        EmbedFonts(0x00000010),

        BroadcastMessages(0x00000020),

        PrintWatermark(0x00000040);

        public int value;

        public acFileNameOptions(int value)

        {

            this.value = value;

        }

        public Object value(){

            return value;

        }

    }

    public enum DIGITALSIGNATURE

    {

        SIGNATURE_DISPLAY_SIGNER(0x001),

        SIGNATURE_DISPLAY_REASON(0x002),

        SIGNATURE_DISPLAY_LOCATION(0x004),

        SIGNATURE_DISPLAY_IMAGE(0x008),

        SIGNATURE_DISPLAY_CERTIFICATE(0x010),

        SIGNATURE_DISPLAY_DATE(0x020),

        SIGNATURE_DISPLAY_TYPE(0x040),

        SIGNATURE_LEVEL_PADES(0x100),

        SIGNATURE_LEVEL_PADES_LTV(0x200);

        public int value;

        public DIGITALSIGNATURE(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 = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";

        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.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(pdf,"DriverInit",AMYUNIPRINTERNAME);

 

        // The SetDefaultPrinter function sets the system default printer to the one

        // initialized by the DriverInit functions.

        Dispatch.call(pdf,"SetDefaultPrinter");

 

        // The EnablePrinter() method needs to be called right before each print job.

        // and before the configuration

        // Calling the EnablePrinter() method will start a 20 second time-out value

        Dispatch.call(pdf,"EnablePrinter", strLicenseTo, strActivationCode); 

 

        // Resulting PDF document stored here

        Dispatch.put(pdf,"DefaultDirectory","c:\\Temp");

 

        // Set Printer options

        Dispatch.put(pdf,"FileNameOptionsEx",acFileNameOptions.NoPrompt.value);

 

        Dispatch.put(pdf, "SetPrinterParamStr", "PostProcessing", viewerExe);

        // Configuring the Digital Signature

        Dispatch.put(pdf, "SetPrinterParamStr", "DS_DigitalSignature", 1);

        Dispatch.put(pdf, "SetPrinterParamStr", "DS_SignedBy", "Amyuni Dev Signature");

        Dispatch.put(pdf, "SetPrinterParamStr", "DS_Reason", "Testing");

        Dispatch.put(pdf, "SetPrinterParamStr", "DS_ImageFile", "c:\temp\signature.jpg");

        Dispatch.put(pdf, "SetPrinterParamStr", "DS_Location", "Montreal");

        Dispatch.put(pdf, "SetPrinterParamStr", "DS_PageNumber", 1);

        Dispatch.put(pdf, "SetPrinterParamStr", "DS_HorPos", 100);

        Dispatch.put(pdf, "SetPrinterParamStr", "DS_VerPos", 100);

        Dispatch.put(pdf, "SetPrinterParamStr", "DS_SigWidth", 400);

        Dispatch.put(pdf, "SetPrinterParamStr", "DS_SigHeight", 200);

        Dispatch.put(pdf, "SetPrinterParamStr", "DS_Flags", DIGITALSIGNATURE.SIGNATURE_DISPLAY_SIGNER.value |

            DIGITALSIGNATURE.SIGNATURE_DISPLAY_REASON.value | DIGITALSIGNATURE.SIGNATURE_DISPLAY_LOCATION.value |

            DIGITALSIGNATURE.SIGNATURE_DISPLAY_IMAGE.value);

 

 

        // 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 simply detach from an existing printer because the handle was created using DriverInit

        Dispatch.call(pdf,"DriverEnd");

 

        // Destroy PDF object

        pdf = null;        

    }

}

$acFileNameOptions = @{

    NoPrompt = 0x00000001

    UseFileName = 0x00000002

    Concatenate = 0x00000004

    DisableCompression = 0x00000008

    EmbedFonts = 0x00000010

    BroadcastMessages = 0x00000020

    PrintWatermark = 0x00000040

}

$DIGITALSIGNATURE = @{

    SIGNATURE_DISPLAY_SIGNER = 0x001

    SIGNATURE_DISPLAY_REASON = 0x002

    SIGNATURE_DISPLAY_LOCATION = 0x004

    SIGNATURE_DISPLAY_IMAGE = 0x008

    SIGNATURE_DISPLAY_CERTIFICATE = 0x010

    SIGNATURE_DISPLAY_DATE = 0x020

    SIGNATURE_DISPLAY_TYPE = 0x040

    SIGNATURE_LEVEL_PADES = 0x100

    SIGNATURE_LEVEL_PADES_LTV = 0x200

}

#Please check FileNameOptions for the complete flags version

 

# Constants for Activation codes

$strLicenseTo  =  "Amyuni PDF Converter Evaluation"

$strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

$AMYUNIPRINTERNAME = "Amyuni PDF Converter"

 

# Declare a new cdintfex object if it does not exist in the form.

$PDF = 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,$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) 

 

# The EnablePrinter() method needs to be called right before each print job.

# and before the configuration

# Calling the EnablePrinter() method will start a 20 second time-out value

[System.__ComObject].InvokeMember('EnablePrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @($strLicenseTo, $strActivationCode))

 

# 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,$acFileNameOptions::NoPrompt)

 

[System.__ComObject].InvokeMember('SetPrinterParamInt', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_DigitalSignature", 1)) 

[System.__ComObject].InvokeMember('SetPrinterParamStr', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_SignedBy", 1)) 

 

# Configuring the Digital Signature

[System.__ComObject].InvokeMember('SetPrinterParamInt', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_DigitalSignature", 1))

[System.__ComObject].InvokeMember('SetPrinterParamStr', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_SignedBy", "Amyuni Dev Signature"))

[System.__ComObject].InvokeMember('SetPrinterParamStr', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_Reason", "Testing"))

[System.__ComObject].InvokeMember('SetPrinterParamStr', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_ImageFile", "c:\temp\signature.jpg"))

[System.__ComObject].InvokeMember('SetPrinterParamStr', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_Location", "Montreal"))

[System.__ComObject].InvokeMember('SetPrinterParamInt', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_PageNumber", 1))

[System.__ComObject].InvokeMember('SetPrinterParamInt', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_HorPos", 100))

[System.__ComObject].InvokeMember('SetPrinterParamInt', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_VerPos", 100))

[System.__ComObject].InvokeMember('SetPrinterParamInt', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_SigWidth", 400))

[System.__ComObject].InvokeMember('SetPrinterParamInt', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_SigHeight", 200))

[System.__ComObject].InvokeMember('SetPrinterParamInt', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @("DS_Flags", ($DIGITALSIGNATURE::SIGNATURE_DISPLAY_SIGNER -bOr $DIGITALSIGNATURE::SIGNATURE_DISPLAY_REASON -bOr 

    $DIGITALSIGNATURE::SIGNATURE_DISPLAY_LOCATION -bOr $DIGITALSIGNATURE::SIGNATURE_DISPLAY_IMAGE)))

 

#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 simply detach from an existing printer because the handle was created using DriverInit 

[System.__ComObject].InvokeMember('DriverEnd', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$null) 

 

#Destroy PDF object

$PDF = $null

' Please check FileNameOptions for the complete flags version

Const NoPrompt = 1

Const UseFileName = 2

Const Concatenate = 4

Const DisableCompression = 8

Const EmbedFonts = 16

Const BroadcastMessages = 32

Const PrintWatermark = 64

Const MultilingualSupport = 128

Const EncryptDocument = 256

Const FullEmbed = 512

 

' DigitalSignature Flags

Const SIGNATURE_DISPLAY_SIGNER = 1

Const SIGNATURE_DISPLAY_REASON = 2

Const SIGNATURE_DISPLAY_LOCATION = 4

Const SIGNATURE_DISPLAY_IMAGE = 8

Const SIGNATURE_DISPLAY_CERTIFICATE = 16

Const SIGNATURE_DISPLAY_DATE = 32

Const SIGNATURE_DISPLAY_TYPE = 64

Const SIGNATURE_LEVEL_PADES = 256

Const SIGNATURE_LEVEL_PADES_LTV = 512

 

' Constants for Activation codes

Const strLicenseTo = "Amyuni PDF Converter Evaluation"

Const strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

Const AMYUNIPRINTERNAME = "Amyuni PDF Converter"

 

' Declare a new cdintfex object

Dim PDF

Set PDF = 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

PDF.DriverInit AMYUNIPRINTERNAME

 

' The SetDefaultPrinter function sets the system default printer to the one

' initialized by the DriverInit functions.

PDF.SetDefaultPrinter

 

' The EnablePrinter() method needs to be called right before each print job.

' and before the configuration

' Calling the EnablePrinter() method will start a 20 second time-out value

PDF.EnablePrinter strLicenseTo, strActivationCode

 

' Resulting PDF document stored here

PDF.DefaultDirectory = "C:\Temp"

 

' Set Printer options

PDF.FileNameOptionsEx = NoPrompt

 

' Configuring the Digital Signature

PDF.SetPrinterParamInt "DS_DigitalSignature", 1

PDF.SetPrinterParamStr "DS_SignedBy", "Amyuni Dev Signature"

PDF.SetPrinterParamStr "DS_Reason", "Testing"

PDF.SetPrinterParamStr "DS_ImageFile", "c:\temp\signature.jpg"

PDF.SetPrinterParamStr "DS_Location", "Montreal"

PDF.SetPrinterParamInt "DS_PageNumber", 1

PDF.SetPrinterParamInt "DS_HorPos", 100

PDF.SetPrinterParamInt "DS_VerPos", 100

PDF.SetPrinterParamInt "DS_SigWidth", 400

PDF.SetPrinterParamInt "DS_SigHeight", 200

PDF.SetPrinterParamInt "DS_Flags", SIGNATURE_DISPLAY_SIGNER Or _

        SIGNATURE_DISPLAY_REASON Or SIGNATURE_DISPLAY_LOCATION Or _

        SIGNATURE_DISPLAY_IMAGE

 

' 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