Hi,
I am currently having an alignment issue - the first page is correctly aligned and then every page after the first is cut off on the left side. I am trying to print double-sided (giving the user the option of long edge or short edge) onto 11x17 inch paper. NOTE: When I manually print a PDF this way it comes out 100% correct. The following code is my print method:
private void invokeJSObjectPrint(object jsObj)
{
object printParamsObj = null;
object[] printerParam = new object[1];
Type T = jsObj.GetType();
printParamsObj = T.InvokeMember("getPrintParams", System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, jsObj, null);
Type printParamType = printParamsObj.GetType();
// get property values
object constantsProp = printParamType.InvokeMember("constants", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance, null, printParamsObj, null);
object interactionLevelProp = constantsProp.GetType().InvokeMember("interactionLevel", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance, null, constantsProp, null);
object duplexProp = constantsProp.GetType().InvokeMember("duplexTypes", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance, null, constantsProp, null);
object silentProp = interactionLevelProp.GetType().InvokeMember("silent", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance, null, interactionLevelProp, null);
object flagVals = constantsProp.GetType().InvokeMember("flagValues", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance, null, constantsProp, null);
object pSize = flagVals.GetType().InvokeMember("setPageSize", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance, null, flagVals, null);
object longEdge = duplexProp.GetType().InvokeMember("DuplexFlipLongEdge", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance, null, duplexProp, null);
object centerProp = flagVals.GetType().InvokeMember("suppressCenter", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance, null, flagVals, null);
object rotProp = flagVals.GetType().InvokeMember("suppressRotate", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance, null, flagVals, null);
// set property values
printerParam[0] = silentProp;
printParamType.InvokeMember("interactive", BindingFlags.SetProperty |
BindingFlags.Public | BindingFlags.Instance, null, printParamsObj, printerParam);
printerParam[0] = this.ocePrint.PrinterSettings.PrinterName;
printParamType.InvokeMember("printerName", BindingFlags.SetProperty |
BindingFlags.Public | BindingFlags.Instance, null, printParamsObj, printerParam);
printerParam[0] = centerProp;
printParamType.InvokeMember("flags", BindingFlags.SetProperty |
BindingFlags.Public | BindingFlags.Instance, null, printParamsObj, printerParam);
printerParam[0] = rotProp;
printParamType.InvokeMember("flags", BindingFlags.SetProperty |
BindingFlags.Public | BindingFlags.Instance, null, printParamsObj, printerParam);
printerParam[0] = pSize;
printParamType.InvokeMember("flags", BindingFlags.SetProperty |
BindingFlags.Public | BindingFlags.Instance, null, printParamsObj, printerParam);
printerParam[0] = longEdge;
printParamType.InvokeMember("duplexType", BindingFlags.SetProperty |
BindingFlags.Public | BindingFlags.Instance, null, printParamsObj, printerParam);
object[] printParamsObjArray = { printParamsObj };
// invoke print with the updated printer settings
if (printParamsObj != null)
{
T.InvokeMember("print", System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance, null, jsObj, printParamsObjArray);
}
}
The program opens a PDF document, and then calls this method. The key properties are the duplex mode and the setPageSize flag value; the suppressCenter/suppressRotate seemingly have no effect. Everything works as desired except for this alignment issue. Any help/suggestions would be greatly appreciated. Thank you.
North America
Europe, Middle East and Africa
Asia Pacific