PaperSize

The PaperSize property is used to define the default output paper size. The default paper size is usually used by applications when creating a new document.

 

Syntax

ActiveX:

System.Int16 PaperSize

DLL:

long GetPaperSize(HANDLE hPrinter)
long SetPaperSize(HANDLE hPrinter, long nPaperSize)

 

Parameters

PaperSize, nPaperSize

[in, out] Paper size identifier as defined by the Windows® operating system. The default value is either Letter or A4 depending on the country where the product is used.

 

Value

Paper Size

1

Letter 8 1/2 x 11 in

5

Legal 8 1/2 x 14 in

9

A4 210 x 297 mm

8

A3 297 x 420 mm

256

Custom size

hPrinter

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

 

Remarks

These functions can be used in two situations:

  1. The developer needs to modify the default values for the printer; in this case SetDefaultConfig should be called after modifying this setting to set the value as default for all applications. Application developers should not call this function for every printout but only after printer initialization.

  2. The printer device context is created using the function CreateDC. This function uses the settings provided by these functions and there is no need to call SetDefaultConfig.

Member of CDIntfEx.CDIntfEx.

 

Example

<Flags()>

Public Enum PAPERSIZE As Integer

    Letter = 1

    Legal = 5

    A4 = 9

    A2 = 8

    CustomSize = 256

End Enum

 

 

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

 

    ' Set PaperSize

    DOCX.PaperSize = PAPERSIZE.Legal

 

    ' Apply Settings

    DOCX.SetDefaultConfig()

 

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

    Letter = 1,

    Legal = 5,

    A4 = 9,

    A2 = 8,

    CustomSize = 256

}

 

 

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

 

    // Set PaperSize

    DOCX.PaperSize =(int)PAPERSIZE.Legal;

 

    // Apply Settings

    DOCX.SetDefaultConfig();

 

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

 

enum PAPERSIZE {

    Letter = 1,

    Legal = 5,

    A4 = 9,

    A2 = 8,

    CustomSize = 256

};

 

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 Papersize

    SetPaperSize(DOCX, PAPERSIZE::Legal);

 

    // Apply Settings

    SetDefaultConfig(DOCX);

 

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

    {

        Letter(1),

        Legal(5),

        A4(9),

        A2(8),

        CustomSize(256);

        public int value;

        public PAPERSIZE(int value)

        {

            this.value = value;

        }

        public Object value(){

            return value;

        }

    }

 

    public enum acFileNameOptions

        {

            // Please check FileNameOptions for the complete version of the flags

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

 

        // Set Printer options

        Dispatch.put(docx, "PaperSize", PAPERSIZE.Legal.value);

 

        // Apply Settings

        Dispatch.call(docx, "SetDefaultConfig");

 

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

 

        // Close Printer

        Dispatch.call(docx,"DriverEnd");

 

        // Destroy DOCX object

        docx = null;        

    }

}

$PAPERSIZE = @{

    Letter = 1

    Legal = 5

    A4 = 9

    A2 = 8

    CustomSize = 256

}

 

 

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

 

#Set PaperSize

[System.__ComObject].InvokeMember('PaperSize', [System.Reflection.BindingFlags]::SetProperty,$null,$DOCX,$PAPERSIZE::Legal)

 

#Apply Settings

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

 

#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

' PaperSize constants

Const Letter = 1

Const Legal = 5

Const A4 = 9

Const A2 = 8

Const CustomSize = 256

 

' 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

 

' Set PaperSize

DOCX.PaperSize = Legal

 

' Apply Settings

DOCX.SetDefaultConfig

 

' 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