Js printing paper function code to obtain and set the specific information of the printing paper. For more information, see.
The Code is as follows:
// Print size, in MM
// Http://en.wikipedia.org/wiki/ISO_216
Var page = function (){
Var A0 = {name: "A0", width: 841, height: 1189}; // unit: MM
Var B0 = {name: "B0", width: 1000, height: 1414}; // unit: MM
Var C0 = {name: "C0", width: 917, height: 1297}; // unit: MM
// Obtain the previous Specification
Function getPrefixSize (name ){
Var list = name. split ('');
Var series = list [0];
Var number = parseInt (list [1]);
If (! IsNaN (number) & number> 0 ){
Return series + (number-1 );
}
}
// Obtain the size of the Specification
Function getSize (name ){
If (name = "C7/6 "){
Return {name: "C7/6", width: 81, height: 162 };
}
Var list = name. split ('');
Var series = list [0];
Var number = parseInt (list [1]);
If (isNaN (number )){
Return;
}
If (number = 0 ){
If (series = "A") {return A0 ;}
Else if (series = "B") {return B0 ;}
Else if (series = "C") {return C0 ;}
}
Return {name: name, width: parseInt (getSize (getPrefixSize (name). height/2), height: parseInt (getSize (getPrefixSize (name). width )};
}
Return {
GetSize: getSize
}
}();
Usage
The Code is as follows:
Page. getSize ('a4 ')