//--------------------------------------------------------------------// // 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 indxPaperSize, Int32 indxPaperType, Int32 indxOrientation, Boolean formAsMacro) { const Int32 sizeStd = 1024; Byte[] bufStd = new Byte[sizeStd]; String sampleText = "000000000000000"; Int16 posX, posY; Int32 indStd; Int16 ptSize; indStd = 0; //----------------------------------------------------------------// if (indxOrientation < PCLOrientations.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.Orientation, PCLOrientations.getIdPCLXL(indxOrientation)); } if (indxPaperSize < PCLPaperSizes.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaSize, PCLPaperSizes.getIdPCLXL(indxPaperSize)); } if ((indxPaperType < PCLPaperTypes.getCount()) && (PCLPaperTypes.getType(indxPaperType) != PCLPaperTypes.eEntryType.NotSet)) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaType, PCLPaperTypes.getName(indxPaperType)); } PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.SimplexPageMode, (Byte)PCLXLAttrEnums.eVal.eSimplexFrontSide); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.BeginPage); PCLXLWriter.addAttrUint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.PageOrigin, 0, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPageOrigin); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.ColorSpace, (Byte)PCLXLAttrEnums.eVal.eGray); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetColorSpace); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.StreamName, _formName); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.ExecStream); prnWriter.Write(bufStd, 0, indStd); indStd = 0; } else { generateOverlay(prnWriter, false, indxPaperSize, indxOrientation); } //----------------------------------------------------------------// // // // Text. // // // //----------------------------------------------------------------// ptSize = 34; PCLXLWriter.font(prnWriter, false, ptSize, _symSet_19U, _fontNameArial); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.NullPen, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPenSource); //----------------------------------------------------------------// // Black // //----------------------------------------------------------------// posX = _posXData; posY = _posYData; PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); prnWriter.Write(bufStd, 0, indStd); indStd = 0; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, sampleText); //----------------------------------------------------------------// // Shade 1 // //----------------------------------------------------------------// posY += _lineInc; PCLXLWriter.addAttrSint16(ref bufStd, ref indStd, PCLXLAttributes.eTag.PatternSelectID, _patternId_DarkGrey); PCLXLWriter.addAttrSint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.PatternOrigin, 0, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); prnWriter.Write(bufStd, 0, indStd); indStd = 0; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, sampleText); //----------------------------------------------------------------// // Shade 2 // //----------------------------------------------------------------// posY += _lineInc; PCLXLWriter.addAttrSint16(ref bufStd, ref indStd, PCLXLAttributes.eTag.PatternSelectID, _patternId_LightGrey); PCLXLWriter.addAttrSint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.PatternOrigin, 0, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); prnWriter.Write(bufStd, 0, indStd); indStd = 0; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, sampleText); //----------------------------------------------------------------// // White // //----------------------------------------------------------------// posY += _lineInc; PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.GrayLevel, 255); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); prnWriter.Write(bufStd, 0, indStd); indStd = 0; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, sampleText); //----------------------------------------------------------------// 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 indxPaperSize, Int32 indxPaperType, Int32 indxOrientation, Boolean formAsMacro) { const Int32 sizeStd = 1024; Byte[] bufStd = new Byte[sizeStd]; String sampleText = "0123456789"; String sampleTextA = "01234"; String sampleTextB = "56789"; Int16 posX, posY; Int32 indStd; Int16 ptSize; indStd = 0; //----------------------------------------------------------------// if (indxOrientation < PCLOrientations.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.Orientation, PCLOrientations.getIdPCLXL(indxOrientation)); } if (indxPaperSize < PCLPaperSizes.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaSize, PCLPaperSizes.getIdPCLXL(indxPaperSize)); } if ((indxPaperType < PCLPaperTypes.getCount()) && (PCLPaperTypes.getType(indxPaperType) != PCLPaperTypes.eEntryType.NotSet)) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaType, PCLPaperTypes.getName(indxPaperType)); } PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.SimplexPageMode, (Byte)PCLXLAttrEnums.eVal.eSimplexFrontSide); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.BeginPage); PCLXLWriter.addAttrUint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.PageOrigin, 0, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPageOrigin); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.ColorSpace, (Byte)PCLXLAttrEnums.eVal.eGray); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetColorSpace); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.StreamName, _formName); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.ExecStream); prnWriter.Write(bufStd, 0, indStd); indStd = 0; } else { generateOverlay(prnWriter, false, indxPaperSize, indxOrientation); } //----------------------------------------------------------------// // // // Descriptive text. // // // //----------------------------------------------------------------// ptSize = 18; 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.NullPen, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.font(prnWriter, false, ptSize, _symSet_19U, _fontNameCourier); posX = _posXData1; posY = _posYData; posY += _lineInc; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "Arial"); posY += _lineInc; prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// // // // Embellished text. // // // //----------------------------------------------------------------// ptSize = 36; PCLXLWriter.font(prnWriter, false, ptSize, _symSet_19U, _fontNameArial); posX = _posXData2; posY = _posYData; posY += _lineInc; PCLXLWriter.charAngle(prnWriter, false, 0); PCLXLWriter.charBold(prnWriter, false, 0); PCLXLWriter.charScale(prnWriter, false, (Single)1.0, (Single)1.0); PCLXLWriter.charShear(prnWriter, false, (Single)0.0, (Single)0.0); PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, sampleText); //----------------------------------------------------------------// posY += _lineInc; PCLXLWriter.charAngle(prnWriter, false, -30); PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_ArialRegular, ptSize, posX, posY, sampleText); //----------------------------------------------------------------// posY += _lineInc; PCLXLWriter.charShear(prnWriter, false, (Single)0.0, (Single)0.0); PCLXLWriter.charScale(prnWriter, false, (Single)2.0, (Single)1.0); PCLXLWriter.charAngle(prnWriter, false, -45); PCLXLWriter.textAngled(prnWriter, false, PCLXLWriter.advances_ArialRegular, ptSize, posX, posY, -45, sampleTextA); posX = (Int16)(posX + ((7 * _incInch) / 4)); posY += _lineInc; PCLXLWriter.charScale(prnWriter, false, (Single)1.0, (Single)2.0); PCLXLWriter.charAngle(prnWriter, false, 30); PCLXLWriter.textAngled(prnWriter, false, PCLXLWriter.advances_ArialRegular, ptSize, posX, posY, 30, sampleTextB); //----------------------------------------------------------------// prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// 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 O v e r l a y // //--------------------------------------------------------------------// // // // Write background data sequences to output file. // // Optionally top and tail these with macro (user-defined stream) // // definition sequences. // // // //--------------------------------------------------------------------// private static void generateOverlay(BinaryWriter prnWriter, Boolean formAsMacro, Int32 indxPaperSize, Int32 indxOrientation) { const Int32 lenBuf = 1024; Byte[] buffer = new Byte[lenBuf]; Int16 ptSize; Int32 indBuf; Int16 posX, posY; UInt16 boxX1, boxX2, boxY1, boxY2; Int16 rectX, rectY, rectHeight, rectWidth; Byte stroke = 1; //----------------------------------------------------------------// indBuf = 0; //----------------------------------------------------------------// // // // Header // // Parts of overlay use different brush and/or pen definitions, // // so enclosed in a GS block. // // // //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.streamHeader(prnWriter, true, _formName); } PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.PushGS); //----------------------------------------------------------------// // // // Colour space, pen & brush definitions. // // // //----------------------------------------------------------------// PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.ColorSpace, (Byte)PCLXLAttrEnums.eVal.eGray); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.PaletteDepth, (Byte)PCLXLAttrEnums.eVal.e8Bit); PCLXLWriter.addAttrUbyteArray(ref buffer, ref indBuf, PCLXLAttributes.eTag.PaletteData, 2, PCLXLWriter.monoPalette); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetColorSpace); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.NullBrush, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.PenWidth, stroke); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenWidth); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// // // // Box. // // // //----------------------------------------------------------------// boxX1 = _unitsPerInch / 2; // half-inch left margin boxY1 = _unitsPerInch / 2; // half-inch top-margin boxX2 = (UInt16)(PCLPaperSizes.getPaperWidth( indxPaperSize, _unitsPerInch, PCLOrientations.eAspect.Portrait) - boxX1); boxY2 = (UInt16)(PCLPaperSizes.getPaperLength( indxPaperSize, _unitsPerInch, PCLOrientations.eAspect.Portrait) - boxY1); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPatternTxMode); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetSourceTxMode); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 100); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.PenWidth, 5); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenWidth); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.NullBrush, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16XY(ref buffer, ref indBuf, PCLXLAttributes.eTag.EllipseDimension, 100, 100); PCLXLWriter.addAttrUint16Box(ref buffer, ref indBuf, PCLXLAttributes.eTag.BoundingBox, boxX1, boxY1, boxX2, boxY2); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.RoundRectangle); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// // // // Text. // // // //----------------------------------------------------------------// PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 100); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.NullPen, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); ptSize = 15; PCLXLWriter.font(prnWriter, formAsMacro, ptSize, _symSet_19U, _fontNameCourierBold); posX = _posXDesc; posY = _posYHddr; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "PCL XL Text & Background:"); ptSize = 12; PCLXLWriter.font(prnWriter, formAsMacro, ptSize, _symSet_19U, _fontNameCourier); posY = _posYDesc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "Black:"); posY += _lineInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "Shade = " + "Dark Gray:"); posY += _lineInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "Shade = " + "Light Gray:"); posY += _lineInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "White:"); //----------------------------------------------------------------// // // // Background shading. // // // //----------------------------------------------------------------// patternDefineDpi300(prnWriter, formAsMacro); rectHeight = (Int16)((_lineInc * 3) / 5); rectWidth = (Int16)((_unitsPerInch * 9) / 10); posX = _posXData; posY = _posYData - (_lineInc / 2); //----------------------------------------------------------------// PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); rectX = posX; rectY = posY; for (Int32 i = 0; i < 4; i++) { PCLXLWriter.addAttrUint16Box(ref buffer, ref indBuf, PCLXLAttributes.eTag.BoundingBox, (UInt16)rectX, (UInt16)rectY, (UInt16)(rectX + rectWidth), (UInt16)(rectY + rectHeight)); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.Rectangle); rectY += _lineInc; } PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// PCLXLWriter.addAttrSint16(ref buffer, ref indBuf, PCLXLAttributes.eTag.PatternSelectID, _patternId_DarkGrey); PCLXLWriter.addAttrSint16XY(ref buffer, ref indBuf, PCLXLAttributes.eTag.PatternOrigin, 0, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); rectX += rectWidth; rectY = posY; for (Int32 i = 0; i < 4; i++) { PCLXLWriter.addAttrUint16Box(ref buffer, ref indBuf, PCLXLAttributes.eTag.BoundingBox, (UInt16)rectX, (UInt16)rectY, (UInt16)(rectX + rectWidth), (UInt16)(rectY + rectHeight)); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.Rectangle); rectY += _lineInc; } PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// PCLXLWriter.addAttrSint16(ref buffer, ref indBuf, PCLXLAttributes.eTag.PatternSelectID, _patternId_LightGrey); PCLXLWriter.addAttrSint16XY(ref buffer, ref indBuf, PCLXLAttributes.eTag.PatternOrigin, 0, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); rectX += rectWidth; rectY = posY; for (Int32 i = 0; i < 4; i++) { PCLXLWriter.addAttrUint16Box(ref buffer, ref indBuf, PCLXLAttributes.eTag.BoundingBox, (UInt16)rectX, (UInt16)rectY, (UInt16)(rectX + rectWidth), (UInt16)(rectY + rectHeight)); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.Rectangle); rectY += _lineInc; } PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// // // // Overlay end. // // // //----------------------------------------------------------------// PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.PopGS); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); if (formAsMacro) { PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.EndStream); prnWriter.Write(buffer, 0, indBuf); } }
//--------------------------------------------------------------------// // 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 indxPaperSize, Int32 indxPaperType, Int32 indxOrientation, Boolean formAsMacro) { const Int32 sizeStd = 1024; Byte[] bufStd = new Byte[sizeStd]; Int16 posX, posY, rectX, rectY, rectHeight, rectWidth; Int32 indStd; Int16 ptSize; indStd = 0; //----------------------------------------------------------------// if (indxOrientation < PCLOrientations.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.Orientation, PCLOrientations.getIdPCLXL(indxOrientation)); } if (indxPaperSize < PCLPaperSizes.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaSize, PCLPaperSizes.getIdPCLXL(indxPaperSize)); } if ((indxPaperType < PCLPaperTypes.getCount()) && (PCLPaperTypes.getType(indxPaperType) != PCLPaperTypes.eEntryType.NotSet)) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaType, PCLPaperTypes.getName(indxPaperType)); } PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.SimplexPageMode, (Byte)PCLXLAttrEnums.eVal.eSimplexFrontSide); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.BeginPage); PCLXLWriter.addAttrUint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.PageOrigin, 0, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPageOrigin); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.ColorSpace, (Byte)PCLXLAttrEnums.eVal.eGray); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetColorSpace); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.StreamName, _formName); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.ExecStream); prnWriter.Write(bufStd, 0, indStd); indStd = 0; } else { generateOverlay(prnWriter, false, indxPaperSize, indxOrientation); } //----------------------------------------------------------------// // // // Pre-defined shading - not present in PCL XL. // // // //----------------------------------------------------------------// ptSize = 15; PCLXLWriter.font(prnWriter, false, ptSize, _symSet_19U, _fontNameArial); 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.NullPen, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPenSource); posX = _posXData1; posY = _posYDesc1 + (_lineInc / 4); for (Int32 i = 0; i < _patternsCt; i++) { PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "n/a"); posY += _lineInc; } prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// // // // User-defined shading. // // // //----------------------------------------------------------------// rectHeight = (Int16)(_lineInc / 2); rectWidth = _lineInc; PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.ColorSpace, (Byte)PCLXLAttrEnums.eVal.eGray); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.PaletteDepth, (Byte)PCLXLAttrEnums.eVal.e8Bit); PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.PaletteData, 2, PCLXLWriter.monoPalette); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetColorSpace); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.NullPen, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPatternTxMode); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// // // // User-defined 300 dpi shading. // // // //----------------------------------------------------------------// rectX = _posXData2; rectY = _posYData; patternDefineDpi300(prnWriter, _patternBase_300); for (Int32 i = 0; i < _patternsCt; i++) { PCLXLWriter.addAttrSint16( ref bufStd, ref indStd, PCLXLAttributes.eTag.PatternSelectID, (Int16)(_patternBase_300 + _patternIds[i])); PCLXLWriter.addAttrSint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.PatternOrigin, 0, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16Box(ref bufStd, ref indStd, PCLXLAttributes.eTag.BoundingBox, (UInt16)rectX, (UInt16)rectY, (UInt16)(rectX + rectWidth), (UInt16)(rectY + rectHeight)); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.Rectangle); rectY += _lineInc; } prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// // // // User-defined 600 dpi shading. // // // //----------------------------------------------------------------// rectX = _posXData3; rectY = _posYData; patternDefineDpi600(prnWriter, _patternBase_600); for (Int32 i = 0; i < _patternsCt; i++) { PCLXLWriter.addAttrSint16( ref bufStd, ref indStd, PCLXLAttributes.eTag.PatternSelectID, (Int16)(_patternBase_600 + _patternIds[i])); PCLXLWriter.addAttrSint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.PatternOrigin, 0, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16Box(ref bufStd, ref indStd, PCLXLAttributes.eTag.BoundingBox, (UInt16)rectX, (UInt16)rectY, (UInt16)(rectX + rectWidth), (UInt16)(rectY + rectHeight)); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.Rectangle); rectY += _lineInc; } prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// 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 O v e r l a y // //--------------------------------------------------------------------// // // // Write background data sequences to output file. // // Optionally top and tail these with macro (user-defined stream) // // definition sequences. // // // //--------------------------------------------------------------------// private static void generateOverlay(BinaryWriter prnWriter, Boolean formAsMacro, Int32 indxPaperSize, Int32 indxOrientation) { const Int32 lenBuf = 1024; Byte[] buffer = new Byte[lenBuf]; Int16 ptSize; Int32 indBuf; Int16 posX, posY; UInt16 boxX1, boxX2, boxY1, boxY2; Byte stroke = 1; //----------------------------------------------------------------// indBuf = 0; //----------------------------------------------------------------// // // // Header // // // //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.streamHeader(prnWriter, true, _formName); } PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.PushGS); //----------------------------------------------------------------// // // // Colour space, pen & brush definitions. // // // //----------------------------------------------------------------// 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.NullBrush, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.PenWidth, stroke); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenWidth); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// // // // Box. // // This uses different brush and/or pen definitions, so enclosed // // in a GS block. // // // //----------------------------------------------------------------// boxX1 = _unitsPerInch / 2; // half-inch left margin boxY1 = _unitsPerInch / 2; // half-inch top-margin boxX2 = (UInt16)(PCLPaperSizes.getPaperWidth( indxPaperSize, _unitsPerInch, PCLOrientations.eAspect.Portrait) - boxX1); boxY2 = (UInt16)(PCLPaperSizes.getPaperLength( indxPaperSize, _unitsPerInch, PCLOrientations.eAspect.Portrait) - boxY1); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPatternTxMode); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetSourceTxMode); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 100); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.PenWidth, 5); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenWidth); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.NullBrush, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16XY(ref buffer, ref indBuf, PCLXLAttributes.eTag.EllipseDimension, 100, 100); PCLXLWriter.addAttrUint16Box(ref buffer, ref indBuf, PCLXLAttributes.eTag.BoundingBox, boxX1, boxY1, boxX2, boxY2); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.RoundRectangle); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// // // // Text. // // // //----------------------------------------------------------------// PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 100); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.NullPen, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); ptSize = 15; PCLXLWriter.font(prnWriter, formAsMacro, ptSize, _symSet_19U, _fontNameCourierBold); posX = _posXDesc; posY = _posYDesc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "PCL XL Text Rotation:"); ptSize = 12; PCLXLWriter.font(prnWriter, formAsMacro, ptSize, _symSet_19U, _fontNameCourier); posY += _lineInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "Font"); posY += _lineInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "Angle | scale | X & Y spacing"); //----------------------------------------------------------------// // // // Overlay end. // // // //----------------------------------------------------------------// PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.PopGS); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); if (formAsMacro) { PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.EndStream); prnWriter.Write(buffer, 0, indBuf); } }
//--------------------------------------------------------------------// // 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 indxPaperSize, Int32 indxPaperType, Int32 indxOrientation, Boolean formAsMacro, UInt32 codePoint, Int32 indxFont, PCLFonts.eVariant fontVar) { const Int32 sizeStd = 1024; Byte[] bufStd = new Byte[sizeStd]; UInt16[] textArray = { 0x00 }; Int16 posX, posY; Int32 indStd; Int16 ptSize; Byte[] utf8Seq = new Byte[4]; Int32 utf8Len = 0; String utf8HexVal = ""; //----------------------------------------------------------------// indStd = 0; //----------------------------------------------------------------// if (indxOrientation < PCLOrientations.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.Orientation, PCLOrientations.getIdPCLXL(indxOrientation)); } if (indxPaperSize < PCLPaperSizes.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaSize, PCLPaperSizes.getIdPCLXL(indxPaperSize)); } if ((indxPaperType < PCLPaperTypes.getCount()) && (PCLPaperTypes.getType(indxPaperType) != PCLPaperTypes.eEntryType.NotSet)) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaType, PCLPaperTypes.getName(indxPaperType)); } PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.SimplexPageMode, (Byte)PCLXLAttrEnums.eVal.eSimplexFrontSide); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.BeginPage); PCLXLWriter.addAttrUint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.PageOrigin, 0, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPageOrigin); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.ColorSpace, (Byte)PCLXLAttrEnums.eVal.eGray); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetColorSpace); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.StreamName, _formName); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.ExecStream); prnWriter.Write(bufStd, 0, indStd); indStd = 0; } else { generateOverlay(prnWriter, false, indxPaperSize, indxOrientation); } prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// // // // Code-point data. // // // //----------------------------------------------------------------// ptSize = 18; PCLXLWriter.font(prnWriter, false, ptSize, _symSet_19U, _fontNameArial); 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.NullPen, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPenSource); posX = _posXData; posY = _posYData; if (codePoint < 0x010000) { PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_ArialRegular, ptSize, posX, posY, "U+" + codePoint.ToString("x4")); } else { // should not happen 'cos XL only supports 16-bit values ! PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_ArialRegular, ptSize, posX, posY, "U+" + codePoint.ToString("x6")); } PrnParseDataUTF8.convertUTF32ToUTF8Bytes(codePoint, ref utf8Len, ref utf8Seq); PrnParseDataUTF8.convertUTF32ToUTF8HexString(codePoint, true, ref utf8HexVal); posY += _lineInc; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_ArialRegular, ptSize, posX, posY, utf8HexVal); //----------------------------------------------------------------// // // // Font data. // // // //----------------------------------------------------------------// posY += _lineInc; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_ArialRegular, ptSize, posX, posY, PCLFonts.getName(indxFont) + " " + Enum.GetName(typeof(PCLFonts.eVariant), fontVar)); posY += _lineInc; ptSize = 36; PCLXLWriter.font(prnWriter, false, ptSize, _symSet_18N, PCLFonts.getPCLXLName(indxFont, fontVar)); textArray[0] = (UInt16)codePoint; PCLXLWriter.textChar(prnWriter, false, 0, // ***** dummy value ***** ptSize, posX, posY, (UInt16)codePoint); //----------------------------------------------------------------// 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 O v e r l a y // //--------------------------------------------------------------------// // // // Write background data sequences to output file. // // Optionally top and tail these with macro (user-defined stream) // // definition sequences. // // // //--------------------------------------------------------------------// private static void generateOverlay(BinaryWriter prnWriter, Boolean formAsMacro, Int32 indxPaperSize, Int32 indxOrientation) { const Int32 lenBuf = 1024; Byte[] buffer = new Byte[lenBuf]; Int16 ptSize; Int32 indBuf; Int16 posX, posY; UInt16 boxX1, boxX2, boxY1, boxY2; Byte stroke = 1; //----------------------------------------------------------------// indBuf = 0; //----------------------------------------------------------------// // // // Header // // // //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.streamHeader(prnWriter, true, _formName); } PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.PushGS); //----------------------------------------------------------------// // // // Colour space, pen & brush definitions. // // // //----------------------------------------------------------------// 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.NullBrush, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.PenWidth, stroke); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenWidth); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// // // // Box. // // // //----------------------------------------------------------------// boxX1 = _unitsPerInch / 2; // half-inch left margin boxY1 = _unitsPerInch / 2; // half-inch top-margin boxX2 = (UInt16)(PCLPaperSizes.getPaperWidth( indxPaperSize, _unitsPerInch, PCLOrientations.eAspect.Portrait) - boxX1); boxY2 = (UInt16)(PCLPaperSizes.getPaperLength( indxPaperSize, _unitsPerInch, PCLOrientations.eAspect.Portrait) - boxY1); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPatternTxMode); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetSourceTxMode); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 100); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.PenWidth, 5); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenWidth); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.NullBrush, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16XY(ref buffer, ref indBuf, PCLXLAttributes.eTag.EllipseDimension, 100, 100); PCLXLWriter.addAttrUint16Box(ref buffer, ref indBuf, PCLXLAttributes.eTag.BoundingBox, boxX1, boxY1, boxX2, boxY2); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.RoundRectangle); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// // // // Text. // // // //----------------------------------------------------------------// PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 100); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.NullPen, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); ptSize = 15; PCLXLWriter.font(prnWriter, formAsMacro, ptSize, _symSet_19U, _fontNameCourierBold); posX = _posXDesc; posY = _posYHddr; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "PCL XL cross-hatch patterns:"); //----------------------------------------------------------------// ptSize = 12; PCLXLWriter.font(prnWriter, formAsMacro, ptSize, _symSet_19U, _fontNameCourier); posY = _posYDesc1; for (Int32 i = 0; i < _patternsCt; i++) { PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "#" + _patternIds[i].ToString() + ": "); posY += _lineInc; } //----------------------------------------------------------------// ptSize = 10; PCLXLWriter.font(prnWriter, formAsMacro, ptSize, _symSet_19U, _fontNameCourier); //----------------------------------------------------------------// posY = _posYDesc1 + (_lineInc / 4); for (Int32 i = 0; i < _patternsCt; i++) { PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, _patternDescs[i] + ":"); posY += _lineInc; } //----------------------------------------------------------------// ptSize = 8; PCLXLWriter.font(prnWriter, formAsMacro, ptSize, _symSet_19U, _fontNameCourier); //----------------------------------------------------------------// posY = _posYDesc2; posX = _posXData1; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "Predefined"); posX = _posXData2; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "User-defined 300 dpi"); posX = _posXData3; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "User-defined 600 dpi"); //----------------------------------------------------------------// // // // Overlay end. // // // //----------------------------------------------------------------// PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.PopGS); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); if (formAsMacro) { PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.EndStream); prnWriter.Write(buffer, 0, indBuf); } }
//--------------------------------------------------------------------// // M e t h o d // // g e n e r a t e O v e r l a y // //--------------------------------------------------------------------// // // // Write background data sequences to output file. // // Optionally top and tail these with macro (user-defined stream) // // definition sequences. // // // //--------------------------------------------------------------------// private static void generateOverlay(BinaryWriter prnWriter, Boolean formAsMacro, Int32 indxPaperSize, Int32 indxOrientation) { const Int32 lenBuf = 1024; Byte[] buffer = new Byte[lenBuf]; Int16 ptSize; Int32 indBuf; Int16 posX, posY; UInt16 boxX1, boxX2, boxY1, boxY2; Int16 rectX, rectY, rectHeight, rectWidth; Byte stroke = 1; //----------------------------------------------------------------// indBuf = 0; //----------------------------------------------------------------// // // // Header // // // //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.streamHeader(prnWriter, true, _formName); } PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.PushGS); //----------------------------------------------------------------// // // // Colour space, pen & brush definitions. // // // //----------------------------------------------------------------// 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.NullBrush, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.PenWidth, stroke); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenWidth); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// // // // Box. // // // //----------------------------------------------------------------// boxX1 = _unitsPerInch / 2; // half-inch left margin boxY1 = _unitsPerInch / 2; // half-inch top-margin boxX2 = (UInt16)(PCLPaperSizes.getPaperWidth( indxPaperSize, _unitsPerInch, PCLOrientations.eAspect.Portrait) - boxX1); boxY2 = (UInt16)(PCLPaperSizes.getPaperLength( indxPaperSize, _unitsPerInch, PCLOrientations.eAspect.Portrait) - boxY1); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPatternTxMode); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetSourceTxMode); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 100); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.PenWidth, 5); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenWidth); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.NullBrush, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16XY(ref buffer, ref indBuf, PCLXLAttributes.eTag.EllipseDimension, 100, 100); PCLXLWriter.addAttrUint16Box(ref buffer, ref indBuf, PCLXLAttributes.eTag.BoundingBox, boxX1, boxY1, boxX2, boxY2); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.RoundRectangle); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// // // // Text. // // // //----------------------------------------------------------------// PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 100); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.NullPen, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); ptSize = 15; PCLXLWriter.font(prnWriter, formAsMacro, ptSize, _symSet_19U, _fontNameCourierBold); posX = _posXDesc; posY = _posYHddr; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "PCL XL Gray colour mode:"); //----------------------------------------------------------------// ptSize = 12; PCLXLWriter.font(prnWriter, formAsMacro, ptSize, _symSet_19U, _fontNameCourier); posY += _incInch / 2; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "Sample 4-shade palette:"); //----------------------------------------------------------------// posX = _posXDesc2; posY = _posYDesc2; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "Gray"); //----------------------------------------------------------------// posX = _posXDesc3; posY = _posYDesc3; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "index"); posX += _incInch; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "value"); //----------------------------------------------------------------// posX = _posXDesc4; posY = _posYDesc4; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "0"); posY += _lineInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "1"); posY += _lineInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "2"); posY += _lineInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "3"); //----------------------------------------------------------------// // // // Background shade. // // // //----------------------------------------------------------------// rectX = _posXDesc2 - (_incInch / 4); rectY = _posYDesc2 + (_incInch / 4); rectWidth = (_incInch * 13) / 10; rectHeight = (_incInch * 7) / 2; PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.ColorSpace, (Byte)PCLXLAttrEnums.eVal.eGray); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.PaletteDepth, (Byte)PCLXLAttrEnums.eVal.e8Bit); PCLXLWriter.addAttrUbyteArray(ref buffer, ref indBuf, PCLXLAttributes.eTag.PaletteData, 2, PCLXLWriter.monoPalette); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetColorSpace); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); patternDefineDpi600(prnWriter, _patternId_1, formAsMacro); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.NullPen, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPatternTxMode); PCLXLWriter.addAttrSint16(ref buffer, ref indBuf, PCLXLAttributes.eTag.PatternSelectID, 601); PCLXLWriter.addAttrSint16XY(ref buffer, ref indBuf, PCLXLAttributes.eTag.PatternOrigin, 0, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16Box(ref buffer, ref indBuf, PCLXLAttributes.eTag.BoundingBox, (UInt16)rectX, (UInt16)rectY, (UInt16)(rectX + rectWidth), (UInt16)(rectY + rectHeight)); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.Rectangle); //----------------------------------------------------------------// // // // Overlay end. // // // //----------------------------------------------------------------// PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.PopGS); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); if (formAsMacro) { PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.EndStream); prnWriter.Write(buffer, 0, indBuf); } }
//--------------------------------------------------------------------// // 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 indxPaperSize, Int32 indxPaperType, Int32 indxOrientation, Int32[] sampleDef, Boolean formAsMacro) { const Int32 sizeStd = 1024; Byte[] bufStd = new Byte[sizeStd]; Int16 posX, posY, rectX, rectY, rectHeight, rectWidth; Int32 indStd; Int16 ptSize; // Int32 temp; Byte shade_0, shade_1, shade_2, shade_3; indStd = 0; //----------------------------------------------------------------// if (indxOrientation < PCLOrientations.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.Orientation, PCLOrientations.getIdPCLXL(indxOrientation)); } if (indxPaperSize < PCLPaperSizes.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaSize, PCLPaperSizes.getIdPCLXL(indxPaperSize)); } if ((indxPaperType < PCLPaperTypes.getCount()) && (PCLPaperTypes.getType(indxPaperType) != PCLPaperTypes.eEntryType.NotSet)) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaType, PCLPaperTypes.getName(indxPaperType)); } PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.SimplexPageMode, (Byte)PCLXLAttrEnums.eVal.eSimplexFrontSide); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.BeginPage); PCLXLWriter.addAttrUint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.PageOrigin, 0, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPageOrigin); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.ColorSpace, (Byte)PCLXLAttrEnums.eVal.eGray); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetColorSpace); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.StreamName, _formName); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.ExecStream); prnWriter.Write(bufStd, 0, indStd); indStd = 0; } else { generateOverlay(prnWriter, false, indxPaperSize, indxOrientation); } //----------------------------------------------------------------// rectHeight = (Int16)(_lineInc / 2); rectWidth = _lineInc; //----------------------------------------------------------------// // // // Colour definitions. // // // //----------------------------------------------------------------// shade_0 = (Byte)(sampleDef[0] & 0xff); shade_1 = (Byte)(sampleDef[1] & 0xff); shade_2 = (Byte)(sampleDef[2] & 0xff); shade_3 = (Byte)(sampleDef[3] & 0xff); //----------------------------------------------------------------// // // // Write details. // // // //----------------------------------------------------------------// ptSize = 12; PCLXLWriter.font(prnWriter, false, ptSize, _symSet_19U, _fontNameCourier); posX = _posXDesc; posY = _posYHddr; //----------------------------------------------------------------// posX = _posXDesc4; posY = _posYDesc4; posX += _incInch; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "0x" + shade_0.ToString("x2")); posY += _lineInc; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "0x" + shade_1.ToString("x2")); posY += _lineInc; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "0x" + shade_2.ToString("x2")); posY += _lineInc; PCLXLWriter.text(prnWriter, false, false, PCLXLWriter.advances_Courier, ptSize, posX, posY, "0x" + shade_3.ToString("x2")); //----------------------------------------------------------------// // // // Gray colour space. // // // //----------------------------------------------------------------// posX = _posXData; posY = _posYData; rectX = posX; rectY = posY; 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.NullPen, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.GrayLevel, shade_0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16Box(ref bufStd, ref indStd, PCLXLAttributes.eTag.BoundingBox, (UInt16)rectX, (UInt16)rectY, (UInt16)(rectX + rectWidth), (UInt16)(rectY + rectHeight)); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.Rectangle); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// rectY += _lineInc; PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.GrayLevel, shade_1); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16Box(ref bufStd, ref indStd, PCLXLAttributes.eTag.BoundingBox, (UInt16)rectX, (UInt16)rectY, (UInt16)(rectX + rectWidth), (UInt16)(rectY + rectHeight)); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.Rectangle); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// rectY += _lineInc; PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.GrayLevel, shade_2); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16Box(ref bufStd, ref indStd, PCLXLAttributes.eTag.BoundingBox, (UInt16)rectX, (UInt16)rectY, (UInt16)(rectX + rectWidth), (UInt16)(rectY + rectHeight)); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.Rectangle); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// rectY += _lineInc; PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.GrayLevel, shade_3); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16Box(ref bufStd, ref indStd, PCLXLAttributes.eTag.BoundingBox, (UInt16)rectX, (UInt16)rectY, (UInt16)(rectX + rectWidth), (UInt16)(rectY + rectHeight)); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.Rectangle); prnWriter.Write(bufStd, 0, indStd); indStd = 0; //----------------------------------------------------------------// 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 O v e r l a y R e a r // //--------------------------------------------------------------------// // // // Write background data sequences for rear overlay to output file. // // Optionally top and tail these with macro (user-defined stream) // // definition sequences. // // // //--------------------------------------------------------------------// private static void generateOverlayRear(BinaryWriter prnWriter, Boolean formAsMacro, String formName, Single scaleFactor) { const Int32 lenBuf = 1024; Byte[] buffer = new Byte[lenBuf]; Int32 indBuf; Int16 posX, posY, posYInc; Int32 ptSizeHddr = (Int32)(scaleFactor * 24), ptSizeMain = (Int32)(scaleFactor * 18); indBuf = 0; if (formAsMacro) { PCLXLWriter.streamHeader(prnWriter, true, formName); } //----------------------------------------------------------------// 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, 128); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// PCLXLWriter.font(prnWriter, formAsMacro, ptSizeHddr, 629, "Arial Bd"); //----------------------------------------------------------------// posYInc = (Int16)(scaleFactor * _posYIncMain); posX = (Int16)(scaleFactor * _posXName); posY = (Int16)(scaleFactor * _posYHddr); PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeHddr, posX, posY, "Tray map test (PCL XL)"); //----------------------------------------------------------------// PCLXLWriter.font(prnWriter, formAsMacro, ptSizeMain, 629, "Arial Bd"); //----------------------------------------------------------------// posY = (Int16)(scaleFactor * _posYDesc); PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeMain, posX, posY, "Page Number:"); posY += (Int16)(posYInc * 4); PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeMain, posX, posY, "Orientation:"); //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.EndStream); prnWriter.Write(buffer, 0, indBuf); } }
//--------------------------------------------------------------------// // 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 O v e r l a y F r o n t // //--------------------------------------------------------------------// // // // Write background data sequences for front overlay to output file. // // Optionally top and tail these with macro (user-defined stream) // // definition sequences. // // // //--------------------------------------------------------------------// private static void generateOverlayFront(BinaryWriter prnWriter, Boolean formAsMacro, String formName, Single scaleFactor) { const Int32 lenBuf = 1024; Int16 rectHeight = (Int16)(scaleFactor * (_unitsPerInch / 2)); Int16 rectWidth = (Int16)(scaleFactor * ((_unitsPerInch * 7) / 2)); Int16 rectStroke = (Int16)(scaleFactor * (_unitsPerInch / 200)); Int16 rectCorner = (Int16)(scaleFactor * (_unitsPerInch / 3)); Int16 ptSizeHddr = (Int16)(scaleFactor * 24), ptSizeMain = (Int16)(scaleFactor * 18), ptSizeSub = (Int16)(scaleFactor * 8); Byte[] buffer = new Byte[lenBuf]; Int32 indBuf; Int16 posX, posY, posYInc; indBuf = 0; if (formAsMacro) { PCLXLWriter.streamHeader(prnWriter, true, formName); } //----------------------------------------------------------------// 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, 128); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// PCLXLWriter.font(prnWriter, formAsMacro, ptSizeHddr, 629, "Arial Bd"); //----------------------------------------------------------------// posYInc = (Int16)(scaleFactor * _posYIncMain); posX = (Int16)(scaleFactor * _posXName); posY = (Int16)(scaleFactor * _posYHddr); PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeHddr, posX, posY, "Tray map test (PCL XL)"); //----------------------------------------------------------------// PCLXLWriter.font(prnWriter, formAsMacro, ptSizeMain, 629, "Arial Bd"); //----------------------------------------------------------------// posY = (Int16)(scaleFactor * _posYDesc); PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeMain, posX, posY, "Page Number:"); posY += posYInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeMain, posX, posY, "Paper Size:"); posY += posYInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeMain, posX, posY, "Paper Type:"); posY += posYInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeMain, posX, posY, "Plex Mode:"); posY += posYInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeMain, posX, posY, "Orientation:"); posY += posYInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeMain, posX, posY, "PCL XL Tray ID:"); posY += posYInc; PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeMain, posX, posY, "Printer Tray:"); //----------------------------------------------------------------// PCLXLWriter.font(prnWriter, formAsMacro, ptSizeSub, 629, "Arial Bd"); //----------------------------------------------------------------// posX = (Int16)(scaleFactor * (_posXValue + _posXIncSub)); posY += (Int16)(scaleFactor * _posYIncSub); PCLXLWriter.text(prnWriter, formAsMacro, false, PCLXLWriter.advances_ArialBold, ptSizeSub, posX, posY, "record the tray name/number used in this box"); //----------------------------------------------------------------// posX = (Int16)(scaleFactor * _posXValue); posY -= (Int16)(scaleFactor * (_posXIncSub * 2)); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.PushGS); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPatternTxMode); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.TxMode, (Byte)PCLXLAttrEnums.eVal.eTransparent); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetSourceTxMode); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.GrayLevel, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenSource); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.PenWidth, (Byte)rectStroke); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetPenWidth); PCLXLWriter.addAttrUbyte(ref buffer, ref indBuf, PCLXLAttributes.eTag.NullBrush, 0); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUint16XY(ref buffer, ref indBuf, PCLXLAttributes.eTag.EllipseDimension, (UInt16)rectCorner, (UInt16)rectCorner); PCLXLWriter.addAttrUint16Box(ref buffer, ref indBuf, PCLXLAttributes.eTag.BoundingBox, (UInt16)posX, (UInt16)posY, (UInt16)(posX + rectWidth), (UInt16)(posY + rectHeight)); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.RoundRectangle); PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.PopGS); PCLXLWriter.writeStreamBlock(prnWriter, formAsMacro, buffer, ref indBuf); //----------------------------------------------------------------// if (formAsMacro) { PCLXLWriter.addOperator(ref buffer, ref indBuf, PCLXLOperators.eTag.EndStream); prnWriter.Write(buffer, 0, indBuf); } }
//--------------------------------------------------------------------// // 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); } }
//--------------------------------------------------------------------// // M e t h o d // // g e n e r a t e J o b H e a d e r // //--------------------------------------------------------------------// // // // Write stream initialisation sequences to output file. // // // //--------------------------------------------------------------------// private static void generateJobHeader(BinaryWriter prnWriter, Int32 paperSize, Int32 paperType, Int32 orientation) { const Int32 sizeStd = 1024; Byte[] bufStd = new Byte[sizeStd]; Int32 indStd; PCLXLWriter.stdJobHeader(prnWriter, ""); indStd = 0; if (orientation < PCLOrientations.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.Orientation, PCLOrientations.getIdPCLXL(orientation)); } if (paperSize < PCLPaperSizes.getCount()) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaSize, PCLPaperSizes.getIdPCLXL(paperSize)); } if ((paperType < PCLPaperTypes.getCount()) && (PCLPaperTypes.getType(paperType) != PCLPaperTypes.eEntryType.NotSet)) { PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.MediaType, PCLPaperTypes.getName(paperType)); } PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.SimplexPageMode, (Byte)PCLXLAttrEnums.eVal.eSimplexFrontSide); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.BeginPage); PCLXLWriter.addAttrUint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.PageOrigin, 0, 0); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPageOrigin); PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.RGBColor, 3, PCLXLWriter.rgbBlack); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetBrushSource); PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.RGBColor, 3, PCLXLWriter.rgbBlack); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetPenSource); prnWriter.Write(bufStd, 0, indStd); }
//--------------------------------------------------------------------// // M e t h o d // // g e n e r a t e I m a g e H e a d e r // //--------------------------------------------------------------------// // // // Write image initialisation sequences to output file. // // // //--------------------------------------------------------------------// private static void generateImageHeader(BinaryWriter prnWriter, UInt16 srcBitsPerPixel, Int32 srcWidth, Int32 srcHeight, Int32 srcResX, Int32 srcResY, Single destPosX, Single destPosY, Int32 destScalePercentX, Int32 destScalePercentY, UInt32 srcPaletteEntries, Boolean srcBlackWhite) { const Int32 sizeStd = 256; Byte[] bufStd = new Byte[sizeStd]; Int32 indStd = 0; Int32 destWidth = 0, destHeight = 0; UInt32 paletteEntries = 0, paletteSize = 0; Byte colourDepth = 0, colourMapping = 0, colourSpace = 0; //----------------------------------------------------------------// // // // Calculate destination size. // // // //----------------------------------------------------------------// if (srcResX == 0) { srcResX = 96; // DefaultSourceBitmapResolution; } else { srcResX = (Int32)(srcResX / 39.37); } if (srcResY == 0) { srcResY = 96; // DefaultSourceBitmapResolution; } else { srcResY = (Int32)(srcResY / 39.37); } destWidth = ((srcWidth * PCLXLWriter._sessionUPI) / srcResX) * (destScalePercentX / 100); destHeight = ((srcHeight * PCLXLWriter._sessionUPI) / srcResY) * (destScalePercentY / 100); //----------------------------------------------------------------// // // // Set position. // // // //----------------------------------------------------------------// PCLXLWriter.addAttrSint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.Point, (Int16)(destPosX * PCLXLWriter._sessionUPI), (Int16)(destPosY * PCLXLWriter._sessionUPI)); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetCursor); //----------------------------------------------------------------// // // // Set colour space. // // // // Note that we only support the following bitmap types: // // // // - 1-bit black and white: // // Colour space: Gray (1 plane) // // Encoding: indirect-pixel // // Palette: elements = 2 (= 2^1) // // planes = 1 // // length = 2 (= 2 * 1) bytes. // // Image data: Each image pixel is defined by 1 bit // // which is used an an index into the // // 2-element palette. // // // // - 1-bit colour // // Colour space: RGB (3 plane) // // Encoding: indirect-pixel // // Palette: elements = 2 (= 2^1) // // planes = 3 // // length = 6 (= 2 * 3) bytes. // // Image data: Each image pixel is defined by 1 bit // // which is used an an index into the // // 2-element palette. // // // // - 4-bit: // // Colour space: RGB (3-plane) // // Encoding: indirect-pixel // // Palette: elements = 16 (= 2^4) // // planes = 3 // // length = 48 (= 16 * 3) bytes. // // Image data: Each group of 4 bits defines an image // // pixel by use as an index into the // // 16-element palette. // // // // - 24-bit: // // Colour space: RGB (3-plane) // // Encoding: direct-pixel // // Palette: none // // Image data: Each group of 24 bits defines an image // // pixel as three 8-bit values, directly // // specifying the RGB values. // // // //----------------------------------------------------------------// if (srcBlackWhite) { colourSpace = (Byte)PCLXLAttrEnums.eVal.eGray; colourDepth = (Byte)PCLXLAttrEnums.eVal.e1Bit; colourMapping = (Byte)PCLXLAttrEnums.eVal.eIndexedPixel; paletteEntries = 2; paletteSize = 2; } else if (srcBitsPerPixel == 1) { colourSpace = (Byte)PCLXLAttrEnums.eVal.eRGB; colourDepth = (Byte)PCLXLAttrEnums.eVal.e1Bit; colourMapping = (Byte)PCLXLAttrEnums.eVal.eIndexedPixel; paletteEntries = 0x00000001 << 1; paletteSize = 3 * paletteEntries; // one per plane } else if (srcBitsPerPixel == 4) { colourSpace = (Byte)PCLXLAttrEnums.eVal.eRGB; colourDepth = (Byte)PCLXLAttrEnums.eVal.e4Bit; colourMapping = (Byte)PCLXLAttrEnums.eVal.eIndexedPixel; paletteEntries = 0x00000001 << 4; paletteSize = 3 * paletteEntries; // one per plane } else if (srcBitsPerPixel == 24) { colourSpace = (Byte)PCLXLAttrEnums.eVal.eRGB; colourDepth = (Byte)PCLXLAttrEnums.eVal.e8Bit; colourMapping = (Byte)PCLXLAttrEnums.eVal.eDirectPixel; paletteEntries = 0; paletteSize = 0; } PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.PushGS); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.ColorSpace, colourSpace); if (paletteEntries != 0) { PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.PaletteDepth, (byte)PCLXLAttrEnums.eVal.e8Bit); if (srcBlackWhite) { byte[] tempUByteArray = new byte[2]; tempUByteArray[0] = 0; tempUByteArray[1] = 255; PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.PaletteData, 2, tempUByteArray); } else { Int32 offset; Byte red = 0x00, green = 0x00, blue = 0x00; Byte[] tempUByteArray = new Byte[paletteSize]; for (Int32 i = 0; i < srcPaletteEntries; i++) { offset = i * 3; ToolImageBitmapCore.getBmpPaletteEntry(i, ref red, ref green, ref blue); tempUByteArray[offset] = red; tempUByteArray[offset + 1] = green; tempUByteArray[offset + 2] = blue; } PCLXLWriter.addAttrUbyteArray(ref bufStd, ref indStd, PCLXLAttributes.eTag.PaletteData, (Int16)paletteSize, tempUByteArray); } } PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.SetColorSpace); //------------------------------------------------------------// // // // Generate BeginImage operator. // // // //------------------------------------------------------------// PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.ColorMapping, colourMapping); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.ColorDepth, colourDepth); PCLXLWriter.addAttrUint16(ref bufStd, ref indStd, PCLXLAttributes.eTag.SourceWidth, (UInt16)srcWidth); PCLXLWriter.addAttrUint16(ref bufStd, ref indStd, PCLXLAttributes.eTag.SourceHeight, (UInt16)srcHeight); PCLXLWriter.addAttrUint16XY(ref bufStd, ref indStd, PCLXLAttributes.eTag.DestinationSize, (UInt16)destWidth, (UInt16)destHeight); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.BeginImage); prnWriter.Write(bufStd, 0, indStd); }
//--------------------------------------------------------------------// // M e t h o d // // g e n e r a t e I m a g e D a t a // //--------------------------------------------------------------------// // // // Generate ReadImage operator(s) and associated embedded data. // // // //--------------------------------------------------------------------// private static void generateImageData(BinaryWriter prnWriter, UInt16 srcBitsPerPixel, Int32 srcWidth, Int32 srcHeight) { const Int32 maxImageBlock = 2048; const Int32 sizeStd = 64; Byte[] bufStd = new Byte[sizeStd]; Int32 indStd = 0; Boolean firstBlock = true, indexed = true; Int32 bytesPerRow, padBytes; Int32 imageCrntLine, imageHeight, imageRowMult, imageBlockHeight, imageBlockSize; //------------------------------------------------------------// if (srcBitsPerPixel == 1) { indexed = true; bytesPerRow = srcWidth / 8; if ((srcWidth % 8) != 0) { bytesPerRow++; } } else if (srcBitsPerPixel == 4) { indexed = true; bytesPerRow = srcWidth / 2; if ((srcWidth % 2) != 0) { bytesPerRow++; } } else // if (srcBitsPerPixel == 24) { indexed = false; bytesPerRow = srcWidth * 3; } padBytes = bytesPerRow % 4; if (padBytes != 0) { padBytes = 4 - padBytes; bytesPerRow += padBytes; } imageCrntLine = 0; imageHeight = srcHeight; imageRowMult = (Int32)Math.Floor((Double)maxImageBlock / (Double)bytesPerRow); if (imageRowMult == 0) { imageRowMult = 1; } Byte[] bufSub = new Byte[bytesPerRow]; for (Int32 i = 0; i < imageHeight; i += imageRowMult) { if ((imageCrntLine + imageRowMult) >= imageHeight) { imageBlockHeight = imageHeight - imageCrntLine; } else { imageBlockHeight = imageRowMult; } imageBlockSize = imageBlockHeight * bytesPerRow; PCLXLWriter.addAttrUint16(ref bufStd, ref indStd, PCLXLAttributes.eTag.StartLine, (UInt16)imageCrntLine); PCLXLWriter.addAttrUint16(ref bufStd, ref indStd, PCLXLAttributes.eTag.BlockHeight, (UInt16)imageBlockHeight); PCLXLWriter.addAttrUbyte(ref bufStd, ref indStd, PCLXLAttributes.eTag.CompressMode, (Byte)PCLXLAttrEnums.eVal.eNoCompression); PCLXLWriter.addOperator(ref bufStd, ref indStd, PCLXLOperators.eTag.ReadImage); PCLXLWriter.addEmbedDataIntro(ref bufStd, ref indStd, imageBlockSize); prnWriter.Write(bufStd, 0, indStd); indStd = 0; for (Int32 j = 0; j < imageRowMult; j++) { if ((i + j) >= imageHeight) { j = imageRowMult; } else { ToolImageBitmapCore.getNextImageBlock(ref bufSub, bytesPerRow, firstBlock); // if (srcBitsPerPixel == 24) if (!indexed) { // change BGR components to RGB // Byte temp; Int32 endLine = bytesPerRow - 2; for (Int32 k = 0; k <= endLine; k += 3) { if (bufSub[k] != bufSub[k + 2]) { temp = bufSub[k]; bufSub[k] = bufSub[k + 2]; bufSub[k + 2] = temp; } } } firstBlock = false; prnWriter.Write(bufSub, 0, bytesPerRow); } } imageCrntLine += imageBlockHeight; } }