Attributes

The Attributes property can be used to modify or read the default attributes of an installed printer.

Syntax

ActiveX:

System.Int32 Attributes

DLL:

long SetPrinterAttributes(HANDLE hPrinter, DWORD dwAttributes)
DWORD GetPrinterAttributes(HANDLE hPrinter)

 

Parameters

Attributes, dwAttributes

[in, out] Printer attributes as defined by the Windows® operating system.

hPrinter

Handle to printer returned by any of the DriverInit function calls.

 

Return Value

SetPrinterAttributes returns 1 if successful, 0 otherwise; GetPrinterAttributes returns the current attributes of the printer.

 

Remarks

Modifying the printer attributes requires administrative rights.

The list of attributes that can be set for a printer are defined in the MSDN documentation under the PRINTER_INFO_2 structure (https://msdn.microsoft.com/en-us/library/dd162845(VS.85).aspx). The attributes are values assigned to the Attributes member of the PRINTER_INFO_2 structure.

 

Member of CDIntfEx.CDIntfEx.

Example

 

<Flags()>

Public Enum PRINTERATTRIBUTE As Integer

    PRINTER_ATTRIBUTE_QUEUED = &H1

    PRINTER_ATTRIBUTE_DIRECT = &H2

    PRINTER_ATTRIBUTE_DEFAULT = &H4

    PRINTER_ATTRIBUTE_SHARED = &H8

    PRINTER_ATTRIBUTE_NETWORK = &H10

    PRINTER_ATTRIBUTE_HIDDEN = &H20

    PRINTER_ATTRIBUTE_LOCAL = &H40

 

    PRINTER_ATTRIBUTE_ENABLE_DEVQ = &H80

    PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS = &H100

    PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST = &H200

 

    PRINTER_ATTRIBUTE_WORK_OFFLINE = &H400

    PRINTER_ATTRIBUTE_ENABLE_BIDI = &H800

    PRINTER_ATTRIBUTE_RAW_ONLY = &H1000

    PRINTER_ATTRIBUTE_PUBLISHED = &H2000

End Enum

 

 

<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

    MultilingualSupport = &H80

    EncryptDocument = &H100

    FullEmbed = &H200

End Enum

 

 

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

 

    ' Set an Attribute

    DOCX.Attributes = PRINTERATTRIBUTE.PRINTER_ATTRIBUTE_LOCAL

 

    ' The BatchConvert method converts a number of files to DOCX.

    DOCX.BatchConvert("C:\Temp\*.ppt")

 

    ' Get an Attribute

    MsgBox(DOCX.Attributes)

 

    ' 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 PRINTERATTRIBUTE

{

    PRINTER_ATTRIBUTE_QUEUED = 0x00000001,

    PRINTER_ATTRIBUTE_DIRECT = 0x00000002,

    PRINTER_ATTRIBUTE_DEFAULT = 0x00000004,

    PRINTER_ATTRIBUTE_SHARED = 0x00000008,

    PRINTER_ATTRIBUTE_NETWORK = 0x00000010,

    PRINTER_ATTRIBUTE_HIDDEN = 0x00000020,

    PRINTER_ATTRIBUTE_LOCAL = 0x00000040,

 

    PRINTER_ATTRIBUTE_ENABLE_DEVQ = 0x00000080,

    PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS = 0x00000100,

    PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST = 0x00000200,

 

    PRINTER_ATTRIBUTE_WORK_OFFLINE = 0x00000400,

    PRINTER_ATTRIBUTE_ENABLE_BIDI = 0x00000800,

    PRINTER_ATTRIBUTE_RAW_ONLY = 0x00001000,

    PRINTER_ATTRIBUTE_PUBLISHED = 0x00002000

}

 

 

[Flags]

public enum acFileNameOptions

{

    // Please check FileNameOptions for the complete flags version

    NoPrompt = 0x00000001,

    UseFileName = 0x00000002,

    Concatenate = 0x00000004,

    DisableCompression = 0x00000008,

    EmbedFonts = 0x00000010,

    BroadcastMessages = 0x00000020,

    MultilingualSupport = 0x00000080,

    EncryptDocument = 0x00000100,

    FullEmbed = 0x00000200

}

 

 

private 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 doesn't 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);

 

    // Set an Attribute

    DOCX.Attributes =(int)PRINTERATTRIBUTE.PRINTER_ATTRIBUTE_LOCAL;

 

    // The BatchConvert method converts a number of files to DOCX.

    DOCX.BatchConvert(@"C:\Temp\*.ppt");

 

    // Get an Attribute

    MessageBox.Show(DOCX.Attributes.ToString());

 

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

 

    // Set an Attribute

    SetPrinterAttributes(DOCX, PRINTER_ATTRIBUTE_LOCAL);

 

    // The BatchConvert method converts a number of files to DOCX.

    BatchConvertEx(DOCX, "C:\\Temp\\*.ppt");

 

    // Get an Attribute

    cout << GetPrinterAttributes(DOCX);

 

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

    {

        PRINTER_ATTRIBUTE_QUEUED(0x00000001),

        PRINTER_ATTRIBUTE_DIRECT(0x00000002),

        PRINTER_ATTRIBUTE_DEFAULT(0x00000004),

        PRINTER_ATTRIBUTE_SHARED(0x00000008),

        PRINTER_ATTRIBUTE_NETWORK(0x00000010),

        PRINTER_ATTRIBUTE_HIDDEN(0x00000020),

        PRINTER_ATTRIBUTE_LOCAL(0x00000040),

 

        PRINTER_ATTRIBUTE_ENABLE_DEVQ(0x00000080),

        PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS(0x00000100),

        PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST(0x00000200),

 

        PRINTER_ATTRIBUTE_WORK_OFFLINE(0x00000400),

        PRINTER_ATTRIBUTE_ENABLE_BIDI(0x00000800),

        PRINTER_ATTRIBUTE_RAW_ONLY(0x00001000),

        PRINTER_ATTRIBUTE_PUBLISHED(0x00002000);

        private int value;

        private PRINTER_ATTRIBUTE(int value)

        {

            this.value = value;

        }

        public Object value(){

            return value;

        }

    }

 

 

    public enum acFileNameOptions

    {

        // Please check FileNameOptions for the complete flags version

        NoPrompt(0x00000001),

        UseFileName(0x00000002),

        Concatenate(0x00000004),

        DisableCompression(0x00000008),

        EmbedFonts(0x00000010),

        BroadcastMessages(0x00000020);

        MultilingualSupport(0x00000080),

        EncryptDocument(0x00000100),

        FullEmbed(0x00000200),

        private int value;

        private 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

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

 

        // Set Printer options

        Dispatch.put(docx, "Attributes", PRINTERATTRIBUTE.PRINTER_ATTRIBUTE_LOCAL.value);

 

        // The BatchConvert method converts a number of files to DOCX.

        Dispatch.call(docx,"BatchConvert","c:\\Temp\\*.ppt");

 

        // Get an Attribute

        Dispatch.call(docx, "Attributes");

 

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

    }

}

 

 

$PRINTERATTRIBUTE = @{

    PRINTER_ATTRIBUTE_QUEUED = 0x00000001

    PRINTER_ATTRIBUTE_DIRECT = 0x00000002

    PRINTER_ATTRIBUTE_DEFAULT = 0x00000004

    PRINTER_ATTRIBUTE_SHARED = 0x00000008

    PRINTER_ATTRIBUTE_NETWORK = 0x00000010

    PRINTER_ATTRIBUTE_HIDDEN = 0x00000020

    PRINTER_ATTRIBUTE_LOCAL = 0x00000040

 

    PRINTER_ATTRIBUTE_ENABLE_DEVQ = 0x00000080

    PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS = 0x00000100

    PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST = 0x00000200

 

    PRINTER_ATTRIBUTE_WORK_OFFLINE = 0x00000400

    PRINTER_ATTRIBUTE_ENABLE_BIDI = 0x00000800

    PRINTER_ATTRIBUTE_RAW_ONLY = 0x00001000

    PRINTER_ATTRIBUTE_PUBLISHED = 0x00002000

}

 

 

$acFileNameOptions = @{

    NoPrompt = 0x00000001

    UseFileName = 0x00000002

    Concatenate = 0x00000004

    DisableCompression = 0x00000008

    EmbedFonts = 0x00000010

    BroadcastMessages = 0x00000020

    MultilingualSupport = 0x00000080

    EncryptDocument = 0x00000100

    FullEmbed = 0x00000200

}

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

 

#Set an Attribute

[System.__ComObject].InvokeMember('Attributes', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX,$PRINTERATTRIBUTE::PRINTER_ATTRIBUTE_LOCAL)

 

#The BatchConvert method converts a number of files to DOCX.

[System.__ComObject].InvokeMember('BatchConvert', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX, "C:\Temp\*.ppt")

 

#Get an Attribute

[System.__ComObject].InvokeMember('Attributes', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX,$nullL)

 

#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

 

' Printer Attribute constants

Const PRINTER_ATTRIBUTE_QUEUED = &H1

Const PRINTER_ATTRIBUTE_DIRECT = &H2

Const PRINTER_ATTRIBUTE_DEFAULT = &H4

Const PRINTER_ATTRIBUTE_SHARED = &H8

Const PRINTER_ATTRIBUTE_NETWORK = &H10

Const PRINTER_ATTRIBUTE_HIDDEN = &H20

Const PRINTER_ATTRIBUTE_LOCAL = &H40

Const PRINTER_ATTRIBUTE_ENABLE_DEVQ = &H80

Const PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS = &H100

Const PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST = &H200

Const PRINTER_ATTRIBUTE_WORK_OFFLINE = &H400

Const PRINTER_ATTRIBUTE_ENABLE_BIDI = &H800

Const PRINTER_ATTRIBUTE_RAW_ONLY = &H1000

Const PRINTER_ATTRIBUTE_PUBLISHED = &H2000

 

' 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 MultilingualSupport = &H80

Const EncryptDocument = &H100

Const FullEmbed = &H200

 

' 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

 

' Set an Attribute

DOCX.Attributes = PRINTER_ATTRIBUTE_LOCAL

 

' The BatchConvert method converts a number of files to DOCX.

DOCX.BatchConvert "C:\Temp\*.ppt"

 

' Get an Attribute

WScript.Echo DOCX.Attributes

 

' 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