ModifyPaperSize

 

Modifies an existing paper in the printer’s paper list. The function can only modify paper sizes added with the user interface or the AddPaperSize API function. It cannot modify the default paper sizes such as A4 or Letter. The printing application must be restarted for the changes to take effect.

 

Paper sizes added using the AddPaperSize 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 papers size permanently for all users, the new paper size should be added to the Printer Driver’s INI files.

 

ModifyPaperSize(pDevMode As Long, szPaperName As String, szNewPaperName As String, lWidth As Integer, lHeight as Integer, lUnit as Integer) As Integer

 

Input value pDevMode:

Pointer to the BlackIceDEVMODE structure of the printer.

 

Input value szPaperName:

Name of the existing paper size to modify.

 

Input value szNewPaperName:

New name of the paper size.

 

Input value lWidth:

New width of the new paper size. The lUnit parameter specifies the units.

 

Input value lHeight:

New height of the new paper size. The lUnit parameter specifies the units.

 

Input value lUnit:

Specifies the units of lWidth and lHeight, can be one of the following values:

0: hundredths of inches

1: teths of millimeters

2: pixels

 

Return value:

On success: The windows paper code of the paper that was modified, that can be used with the SetPaperSize function.

The function returns 0, if an error happens or the paper with the given name does not exist or it is not modifiable.

Code Example:

 

// load the DEVMODE structure
long pDevMode = BlackIceDEVMODE.LoadBlackIceDEVMODE(printerName);

 

// add or modify paper size
int paperCode = BlackIceDEVMODE.AddPaperSize(pDevMode, "Test Paper", 1000, 1000, 1);
if (paperCode == 0)
{
   paperCode = BlackIceDEVMODE.ModifyPaperSize(pDevMode, "Test Paper",
    "Test Paper", 1000, 1000, 1);
}

 

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