1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
String PrtName = "<Nom de l'imprimante>";
int PwSize; //Largeur en mm
int PhSize; //Hauteur en mm
Variant vOOoPrtDescriptor = vOOoDocument.OleFunction("getPrinter");
for(int i=0; i<=vOOoPrtDescriptor.ArrayHighBound(1); i++)
{
Variant vOOoY = vOOoPrtDescriptor.GetElement(i);
if(AnsiString(vOOoY.OlePropertyGet("Name")) == "Name")
{
//String(vOOoY.OlePropertySet("Value")); // -> retourne le nom de l'imprimante actuelle
vOOoY.OlePropertySet("Value",PrtName.c_str());// Nom imprimante
vOOoPrtDescriptor.PutElement(vOOoY,i);
}
if(AnsiString(vOOoY.OlePropertyGet("Name")) == "PaperOrientation")
{
vOOoY.OlePropertySet("Value",0); //0: Portrait; 1: paysage
vOOoPrtDescriptor.PutElement(vOOoY,i);
}
if(AnsiString(vOOoY.OlePropertyGet("Name")) == "PaperFormat")
{
vOOoY.OlePropertySet("Value",0);// 0 à 8 = A3, A4, A5, B4, B5, LETTER, LEGAL, TABLOID, USER
vOOoPrtDescriptor.PutElement(vOOoY,i);
}
if(AnsiString(vOOoY.OlePropertyGet("Name")) == "PaperSize") // Cas "USER"
{
Variant vOOoY2 = vOOoY.OlePropertyGet("Value");
vOOoY2.OlePropertySet("Width", 100*PwSize);
vOOoY2.OlePropertySet("Height", 100*PhSize);
vOOoY.OlePropertySet("Value", vOOoY2);
vOOoPrtDescriptor.PutElement(vOOoY,i);
}
}
vOOoDocument.OleFunction("setPrinter", vOOoPrtDescriptor); |
Partager