AddPaperSizeEx

 

Adds a new paper to the paper list of the printer. This function adds the new paper list to the registry of the current user. The printing application must be restarted for the changes to take effect.

 

Paper sizes added using the AddPaperSize or AddPaperSizeEx function or from the Printing Preferences dialog will be deleted when the user presses the Restore Defaults button on the Printing Preferences dialog. To add a paper size permanently for all users, the new paper size should be added to the Printer Driver’s INI files.

 

AddPaperSizeEx(pDevMode As Long, szPaperName As String, dwWidth As Integer, dwHeight As Integer, dwUnit As Integer, bRollPaper As Boolean) As Integer

 

Parameters

 

Input value pDevMode:

Pointer to the BlackIceDEVMODE structure of the printer.

 

Input value szPaperName:

Name of the new paper size.

 

Input value dwWidth:

Width of the new paper size. The dwUnit parameter specifies the units.

 

Input value dwHeight:

Height of the new paper size. The dwUnit parameter specifies the units.

 

Input value dwUnit:

Specifies the units of dwWidth and dwHeight, which can be one of the following values:

0: hundredths of inches

1: tenths of millimeters

2: pixels

 

Input value bRollPaper:

Specifies if the added paper size is a roll paper size. For roll paper sizes, the Printer Driver automatically cuts off the empty space below the printed page content. The dwHeight parameter will specify the maximum height of the page.

 

Return value

 

On success: The Windows paper code of the newly added paper that can be used with the SetPaperSize function.

The function returns 0 if an error happens or if a paper with the given name already exists.

 

Programming Notes

 

None

 

Code Example

 

// load the DEVMODE structure

long pDevMode = BlackIceDEVMODE.LoadBlackIceDEVMODE(printerName);

 

// add or modify paper size

int paperCode = BlackIceDEVMODE.AddPaperSizeEx(pDevMode, "Roll Paper", 800, 3000, 1, true);

if (paperCode == 0)

{

   paperCode = BlackIceDEVMODE.ModifyPaperSizeEx(pDevMode, "Roll Paper",

    "Roll Paper", 800, 3000, 1, true);

}

 

// Set the new paper size and other settings

BlackIceDEVMODE.SetPaperSize((short)paperCode, pDevMode);

...

 

// save the settings for the current user and release the structure

BlackIceDEVMODE.SaveBlackIceDEVMODE(printerName, pDevMode);

BlackIceDEVMODE.ReleaseBlackIceDEVMODE(pDevMode);

// copy the current user's settings to all users on the system

BlackIceDEVMODE.CopySettingsForAllUsers(printerName);

 

NOTE: For 32-bit applications, use pDevMode as Integer, instead of Long.