//--------------------------------------------------------------------// // M e t h o d // // g e n e r a t e P a g e // //--------------------------------------------------------------------// // // // Write individual test data page sequences to output file. // // // //--------------------------------------------------------------------// private static void generatePage(BinaryWriter prnWriter, Int32 pageNo, Int32 pageCount, Int32 indxPaperSize, Int32 indxPaperType, Int32 indxPaperTray, Int32 indxPlexMode, Int32 indxOrientFront, Int32 indxOrientRear, String formNameFront, String formNameRear, Single scaleFactor, Boolean formAsMacro) { const Int32 sizeStd = 1024; Byte[] bufStd = new Byte[sizeStd]; Int32 indStd; Int32 ptSizeMain = (Int32)(scaleFactor * 20); Int16 posX, posY, posYInc; String tmpStr; Boolean simplex = PCLPlexModes.isSimplex(indxPlexMode); indStd = 0; PCLXLWriter.pageBegin(prnWriter, indxPaperSize, indxPaperType, indxPaperTray, indxOrientFront, indxPlexMode, true, // always true 'cos possible different Paper Type on each sheet true); //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.StreamName, formNameFront); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.ExecStream); prnWriter.Write(bufStd, 0, indStd); indStd = 0; } else { prnWriter.Write(bufStd, 0, indStd); indStd = 0; generateOverlayFront(prnWriter, false, "", scaleFactor); } //----------------------------------------------------------------// PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.ColorSpace, (Byte)PCLXLAttrEnums.eVal.eGray); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetColorSpace); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPenSource); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// PCLXLWriter.font(prnWriter, false, ptSizeMain, 629, "Courier Bd"); //----------------------------------------------------------------// posYInc = (Int16)(scaleFactor * _posYIncMain); posX = (Int16)(scaleFactor * _posXValue); posY = (Int16)(scaleFactor * _posYDesc); tmpStr = pageNo.ToString() + " of " + pageCount.ToString(); PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSizeMain, posX, posY, tmpStr); //----------------------------------------------------------------// posY += posYInc; if (indxPaperSize >= PCLPaperSizes.getCount()) { tmpStr = "*** unknown ***"; } else { tmpStr = PCLPaperSizes.getName(indxPaperSize); } PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSizeMain, posX, posY, tmpStr); //----------------------------------------------------------------// posY += posYInc; if (indxPaperType >= PCLPaperTypes.getCount()) { tmpStr = "*** unknown ***"; } else if (PCLPaperTypes.getType(indxPaperType) == PCLPaperTypes.eEntryType.NotSet) { tmpStr = "<not set>"; } else { tmpStr = PCLPaperTypes.getName(indxPaperType); } PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSizeMain, posX, posY, tmpStr); //----------------------------------------------------------------// posY += posYInc; if (indxPlexMode >= PCLPlexModes.getCount()) { tmpStr = "*** unknown ***"; } else { tmpStr = PCLPlexModes.getName(indxPlexMode); } PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSizeMain, posX, posY, tmpStr); //----------------------------------------------------------------// posY += posYInc; if (indxOrientFront >= PCLOrientations.getCount()) { tmpStr = "*** unknown ***"; } else { tmpStr = PCLOrientations.getName(indxOrientFront); } PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSizeMain, posX, posY, tmpStr); //----------------------------------------------------------------// posY += posYInc; if (indxPaperTray < 0) { tmpStr = "<not set>"; } else if (indxPaperTray == _trayIdAutoSelectPCLXL) { tmpStr = indxPaperTray.ToString() + " (auto-select)"; } else { tmpStr = indxPaperTray.ToString(); } PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSizeMain, posX, posY, tmpStr); //----------------------------------------------------------------// PCLXLWriter.addAttrUint16(ref bufStd, ref indStd, PCLXLAttributes.eTag.PageCopies, 1); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.EndPage); prnWriter.Write(bufStd, 0, indStd); //----------------------------------------------------------------// // // // Rear face (if not simplex) // // // //----------------------------------------------------------------// if (!simplex) { indStd = 0; PCLXLWriter.pageBegin(prnWriter, indxPaperSize, indxPaperType, indxPaperTray, indxOrientRear, indxPlexMode, true, // always true 'cos possible different Paper Type on each sheet false); //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.StreamName, formNameRear); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.ExecStream); prnWriter.Write(bufStd, 0, indStd); indStd = 0; } else { prnWriter.Write(bufStd, 0, indStd); indStd = 0; generateOverlayRear(prnWriter, false, "", scaleFactor); } //----------------------------------------------------------------// PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.ColorSpace, (Byte)PCLXLAttrEnums.eVal.eGray); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetColorSpace); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPenSource); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// PCLXLWriter.font(prnWriter, false, ptSizeMain, 629, "Courier Bd"); //----------------------------------------------------------------// posX = (Int16)(scaleFactor * _posXValue); posY = (Int16)(scaleFactor * _posYDesc); tmpStr = pageNo.ToString() + " (rear) of " + pageCount.ToString(); PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSizeMain, posX, posY, tmpStr); //----------------------------------------------------------------// posY += (Int16)(posYInc * 4); if (indxOrientRear >= PCLOrientations.getCount()) { tmpStr = "*** unknown ***"; } else { tmpStr = PCLOrientations.getName(indxOrientRear); } PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSizeMain, posX, posY, tmpStr); //----------------------------------------------------------------// PCLXLWriter.addAttrUint16(ref bufStd, ref indStd, PCLXLAttributes.eTag.PageCopies, 1); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.EndPage); prnWriter.Write(bufStd, 0, indStd); } }
//--------------------------------------------------------------------// // M e t h o d // // g e n e r a t e P a g e // //--------------------------------------------------------------------// // // // Write individual test data page sequences to output file. // // // //--------------------------------------------------------------------// private static void generatePage(BinaryWriter prnWriter, Int32 pageNo, Int32 pageCount, Int32 indxPaperSize, Int32 indxPaperType, Int32 indxOrientation, Int32 indxOrientRear, Int32 indxPlexMode, Boolean flagFrontFace, Boolean flagSimplexJob, Boolean flagMainForm, Boolean flagRearForm, Boolean flagRearBPlate, Boolean flagGSPushPop, Boolean flagPrintDescText, String formFileMain, String formFileRear, eStreamMethod indxMethod, String formNameMain, String formNameRear) { const Int32 lenBuf = 1024; const Int16 incPosY = 150; Byte[] buffer = new Byte[lenBuf]; Boolean altOrient; Boolean pageUsesForm; Boolean firstPage; Int16 posX, posY; String formName; Int32 indxOrient; Int32 indBuf = 0; Int32 crntPtSize; altOrient = (indxOrientation != indxOrientRear); firstPage = (pageNo == 1); if (flagFrontFace) { indxOrient = indxOrientation; pageUsesForm = flagMainForm; formName = formNameMain; } else { indxOrient = indxOrientRear; if (flagRearForm) { pageUsesForm = flagRearForm; formName = formNameRear; } else { pageUsesForm = flagMainForm; formName = formNameMain; } } //----------------------------------------------------------------// // // // Write 'BeginPage' operator and (if requested for begin page) // // the required stream 'execute' operator. // // // //----------------------------------------------------------------// PCLXLWriter.pageBegin(prnWriter, indxPaperSize, indxPaperType, -1, indxOrient, indxPlexMode, firstPage, flagFrontFace); if (pageUsesForm) { if (indxMethod == eStreamMethod.ExecuteBegin) { if (flagGSPushPop) { PCLXLWriter.addOperator( ref buffer, ref indBuf, PCLXLOperators.eTag.PushGS); prnWriter.Write(buffer, 0, indBuf); indBuf = 0; } PCLXLWriter.streamExec(prnWriter, false, formName); if (flagGSPushPop) { PCLXLWriter.addOperator( ref buffer, ref indBuf, PCLXLOperators.eTag.PopGS); prnWriter.Write(buffer, 0, indBuf); indBuf = 0; } } } //----------------------------------------------------------------// // // // Write descriptive text. // // // //----------------------------------------------------------------// if (flagPrintDescText) { //------------------------------------------------------------// // // // Headers. // // // //------------------------------------------------------------// crntPtSize = 10; PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.ColorSpace, (Byte)PCLXLAttrEnums.eVal.eGray); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetColorSpace); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); prnWriter.Write(buffer, 0, indBuf); indBuf = 0; PCLXLWriter.font(prnWriter, false, crntPtSize, _symSet_19U, "Courier "); posX = 600; posY = 1350; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, "Page:"); if (firstPage) { posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, "PaperSize:"); posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, "PaperType:"); posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, "Plex Mode:"); posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, "Method:"); posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, "Orientation:"); posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, "Rear Orientation:"); posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, "Main Form:"); posY += incPosY; if (flagRearForm) { if (flagRearBPlate) { PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, "Rear Boilerplate:"); } else { PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, "Rear Form:"); } } } //------------------------------------------------------------// // // // Write variable data. // // // //------------------------------------------------------------// crntPtSize = 10; PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); prnWriter.Write(buffer, 0, indBuf); indBuf = 0; PCLXLWriter.font(prnWriter, false, crntPtSize, _symSet_19U, "Courier Bd"); posX = 1800; posY = 1350; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, pageNo + " of " + pageCount); if (firstPage) { String textOrientRear; posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, PCLPaperSizes.getName(indxPaperSize)); posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, PCLPaperTypes.getName(indxPaperType)); posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, PCLPlexModes.getName(indxPlexMode)); posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, streamMethodNames[(Int32)indxMethod]); posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, PCLOrientations.getName(indxOrientation)); if (flagSimplexJob) { textOrientRear = "<not applicable>"; } else { textOrientRear = PCLOrientations.getName(indxOrientRear); } posY += incPosY; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, textOrientRear); posY += incPosY; if (flagMainForm) { const Int32 maxLen = 51; const Int32 halfLen = (maxLen - 5) / 2; Int32 len = formFileMain.Length; if (len < maxLen) { PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, formFileMain); } else { PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, formFileMain.Substring(0, halfLen) + " ... " + formFileMain.Substring(len - halfLen, halfLen)); } } posY += incPosY; if (flagRearForm) { const Int32 maxLen = 51; const Int32 halfLen = (maxLen - 5) / 2; Int32 len = formFileRear.Length; if (len < maxLen) { PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, formFileRear); } else { PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, crntPtSize, posX, posY, formFileRear.Substring(0, halfLen) + " ... " + formFileRear.Substring(len - halfLen, halfLen)); } } } } //----------------------------------------------------------------// // // // If requested for end page, write the required stream 'execute' // // operator. // // // //----------------------------------------------------------------// if (pageUsesForm) { if (indxMethod == eStreamMethod.ExecuteEnd) { if (flagGSPushPop) { PCLXLWriter.addOperator( ref buffer, ref indBuf, PCLXLOperators.eTag.PushGS); prnWriter.Write(buffer, 0, indBuf); indBuf = 0; } PCLXLWriter.streamExec(prnWriter, false, formName); if (flagGSPushPop) { PCLXLWriter.addOperator( ref buffer, ref indBuf, PCLXLOperators.eTag.PopGS); prnWriter.Write(buffer, 0, indBuf); indBuf = 0; } } } //----------------------------------------------------------------// // // // Write EndPage' operator and associated attribute list. // // // //----------------------------------------------------------------// PCLXLWriter.pageEnd(prnWriter, 1); //------------------------------------------------------------// // // // Generate rear boilerplate side if necessary. // // // //------------------------------------------------------------// if ((flagRearForm) && (flagRearBPlate)) { PCLXLWriter.pageBegin(prnWriter, indxPaperSize, indxPaperType, -1, indxOrientRear, indxPlexMode, firstPage, false); PCLXLWriter.streamExec(prnWriter, false, formNameRear); PCLXLWriter.pageEnd(prnWriter, 1); } }