This method retrieves the names, size numbers, and dimensions of the paper from the printer designated by the printer name.
Parameters
Name | Explanation |
---|---|
PaperNames | The string containing the retrieved paper names |
PaperNumbers | The array containing the retrieved paper size numbers
(1)In Visual C++, pass the pointer to the first element of the array (2)In Visual Basic, Dim Pnum(0 To 2) As Integer then set Pnum(0) |
Width, Height | The array containing the retrieved paper dimensions
(1)In Visual C++, pass the pointer to the first element of the array (2)In Visual Basic, Dim Width(0 To 2) As Integer then set Width |
Return Value
Returns the number of retrieved items. Returns 0 if unsuccessful.
Explanation
The EnumPaperSizes method retrieves the names, size numbers, and dimensions of the paper from the printer designated by the printer name. If you need to know the number of elements in the array, the GetArrayNum method can be used to retrieve this. The PaperNames string will be returned as "xxxxx,xxxxx,xxxxx,¥¥¥¥¥¥¥¥," (delimited by commas and ends with a comma). The Width and Height parameters retreieve each paper size in 0.1mm units.
For scripting languages and other programs that require variant types, please refer to the EnumPaperSizesVariant method.
Note: In VB.NET and C#.NET, you cannot retrieve the string for PaperNames. Use InvokeMembers instead. For details, please see the code example below.
Sample code:
Visual Basic
Dim Size As Long
Dim PaperNames As String
Dim PaperNumbers() As Integer
Dim Width() As Long
Dim Height() As Long
Dim Ret As Long
Size = ImageKit1.PrintDraw.GetArrayNum(0)
If Size < 1 Then Exit Sub
ReDim PaperNumbers(Size)
ReDim Width(Size)
ReDim Height(Size)
Ret = ImageKit1.PrintDraw.EnumPaperSizes(PaperNames, PaperNumbers(0), Width(0), Height(0))
' various programming code
..........
Visual C++
long Size;
BSTR PaperNames;
short *PaperNumbers;
long *Width;
long * Height;
ImageKit1.GetPrintDraw().SetPrinterName("EPSON LP-8200C");
Size = ImageKit1.GetPrintDraw().GetArrayNum(0);
if (Size < 1) return;
PaperNumbers = (short *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(short) * Size);
Width = (short *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(long) * Size);
Height = (short *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(long) * Size);
__try {
ImageKit1->PrintDraw->EnumPaperSizes(&PaperNames, PaperNumbers, Width, Height);
// various programming code
...........
} __finally {
HeapFree(GetProcessHeap(), 0, PaperNumbers);
HeapFree(GetProcessHeap(), 0, Width);
HeapFree(GetProcessHeap(), 0, Height);
}
Visual Basic.NET
ImageKit1.PrintDraw.PrinterName = "EPSON LP-8200C"
Dim t As Type = Type.GetTypeFromProgID("ImageKit8.PrintDraw")
Dim p As New System.Reflection.ParameterModifier(4)
p(0) = True
p(1) = True
p(2) = True
p(3) = True
Dim mods() As System.Reflection.ParameterModifier = {p}
Dim args() As Object = {"", Nothing}
Dim Size As Long = CType(t.InvokeMember("EnumPaperSizesVariant", System.Reflection.BindingFlags.InvokeMethod, Nothing, ImageKit1.PrintDraw, args, mods, Nothing, Nothing), Integer)
If Size < 1 Then Exit Sub
Dim PaperNames As String = CType(args(0), String)
Dim PaperNumbers As Short() = CType(args(1), Short())
Dim Width As Integer() = CType(args(2), Integer())
Dim Height As Integer() = CType(args(3), Integer())
' various programming code
..........
Visual C#.NET
ImageKit1.PrintDraw.PrinterName = "EPSON LP-8200C";
Type t = Type.GetTypeFromProgID("ImageKit8.PrintDraw");
System.Reflection.ParameterModifier p = new System.Reflection.ParameterModifier(4);
p[0] = true;
p[1] = true;
p[2] = true;
p[3] = true;
System.Reflection.ParameterModifier[] mods = {p};
object[] args = { "", null, null, null };
int Size = (int)t.InvokeMember("EnumPaperSizesVariant", System.Reflection.BindingFlags.InvokeMethod, null, ImageKit1.PrintDraw, args, mods, null, null);
if (Size < 1) return;
string PaperNames = (string)args[0];
short[] PaperNumbers = (short[])args[1];
int[] Width = (int[])args[2];
int[] Height = (int[])args[3];
// various programming code
..........