//--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e J o b                                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate test data.                                                //
        //                                                                    //
        // Some sequences are built up as (Unicode) strings, then converted   //
        // to byte arrays before writing out - this works OK because all the  //
        // characters we're using are within the ASCII range (0x00-0x7f) and  //
        // are hence represented using a single byte in the UTF-8 encoding.   //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void generateJob(BinaryWriter prnWriter,
                                       Int32 indxPaperSize,
                                       Int32 indxPaperType,
                                       Int32 indxOrientation,
                                       Boolean formAsMacro,
                                       UInt32 codePoint,
                                       Int32 indxFont,
                                       PCLFonts.eVariant fontVar)
        {
            PCLOrientations.eAspect aspect;

            UInt16 logXOffset;

            //----------------------------------------------------------------//

            aspect = PCLOrientations.getAspect(indxOrientation);

            logXOffset = PCLPaperSizes.getLogicalOffset(indxPaperSize,
                                                        _unitsPerInch, aspect);

            _logPageWidth = PCLPaperSizes.getLogPageWidth(indxPaperSize,
                                                          _unitsPerInch,
                                                          aspect);

            _logPageHeight = PCLPaperSizes.getLogPageLength(indxPaperSize,
                                                            _unitsPerInch,
                                                            aspect);

            _paperWidth = PCLPaperSizes.getPaperWidth(indxPaperSize,
                                                      _unitsPerInch,
                                                      aspect);

            _paperHeight = PCLPaperSizes.getPaperLength(indxPaperSize,
                                                        _unitsPerInch,
                                                        aspect);

            //----------------------------------------------------------------//

            generateJobHeader(prnWriter,
                              indxPaperSize,
                              indxPaperType,
                              indxOrientation,
                              formAsMacro,
                              logXOffset);

            generatePage(prnWriter,
                         indxPaperSize,
                         indxPaperType,
                         indxOrientation,
                         formAsMacro,
                         logXOffset,
                         codePoint,
                         indxFont,
                         fontVar);

            generateJobTrailer(prnWriter, formAsMacro);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e J o b                                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate test data.                                                //
        //                                                                    //
        // Some sequences are built up as (Unicode) strings, then converted   //
        // to byte arrays before writing out - this works OK because all the  //
        // characters we're using are within the ASCII range (0x00-0x7f) and  //
        // are hence represented using a single byte in the UTF-8 encoding.   //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void generateJob(BinaryWriter prnWriter,
                                       Int32 indxPaperSize,
                                       Int32 indxPaperType,
                                       Int32 indxOrientation,
                                       Boolean formAsMacro)
        {
            PCLOrientations.eAspect aspect;

            UInt16 logXOffset;

            //----------------------------------------------------------------//

            aspect = PCLOrientations.getAspect(indxOrientation);

            logXOffset = PCLPaperSizes.getLogicalOffset(indxPaperSize,
                                                        _unitsPerInch, aspect);

            _logPageWidth = PCLPaperSizes.getLogPageWidth(indxPaperSize,
                                                          _unitsPerInch,
                                                          aspect);

            _logPageHeight = PCLPaperSizes.getLogPageLength(indxPaperSize,
                                                            _unitsPerInch,
                                                            aspect);

            _paperWidth = PCLPaperSizes.getPaperWidth(indxPaperSize,
                                                      _unitsPerInch,
                                                      aspect);

            _paperHeight = PCLPaperSizes.getPaperLength(indxPaperSize,
                                                        _unitsPerInch,
                                                        aspect);

            //----------------------------------------------------------------//

            getPatternData();

            generateJobHeader(prnWriter,
                              indxPaperSize,
                              indxPaperType,
                              indxOrientation,
                              formAsMacro,
                              logXOffset);

            patternDefineDpi300(prnWriter, _patternBase_300);

            patternDefineDpi600(prnWriter, _patternBase_600);

            generatePage(prnWriter,
                         indxPaperSize,
                         indxPaperType,
                         indxOrientation,
                         formAsMacro,
                         logXOffset);

            patternDeleteSet(prnWriter, _patternBase_300);

            patternDeleteSet(prnWriter, _patternBase_600);

            generateJobTrailer(prnWriter, formAsMacro);
        }
예제 #3
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e J o b                                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate test data.                                                //
        //                                                                    //
        // Most sequences are built up as (Unicode) strings, then converted   //
        // to byte arrays before writing out - this works OK because all the  //
        // characters we're using are within the ASCII range (0x00-0x7f) and  //
        // are hence represented using a single byte in the UTF-8 encoding.   //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void generateJob(BinaryWriter prnWriter,
                                       Int32 pageCount,
                                       Int32[]      indxPaperSize,
                                       Int32[]      indxPaperType,
                                       Int32[]      indxPaperTray,
                                       Int32[]      indxPlexMode,
                                       Int32[]      indxOrientFront,
                                       Int32[]      indxOrientRear,
                                       Boolean formAsMacro)
        {
            Int32[] indxFormsFront = new Int32[pageCount];
            Int32[] indxFormsRear  = new Int32[pageCount];

            Int16[] macroIdsFront = new Int16[pageCount];
            Int16[] macroIdsRear  = new Int16[pageCount];

            Single[] scaleFactors = new Single[pageCount];

            Int32 formCountFront = 0;
            Int32 formCountRear  = 0;

            //----------------------------------------------------------------//
            //                                                                //
            // Set up the scaling data for each sheet, relative to the A4     //
            // paper size dimensions.                                         //
            //                                                                //
            //----------------------------------------------------------------//

            Single A4LengthPort =
                (Single)PCLPaperSizes.getPaperLength(
                    (Int32)PCLPaperSizes.eIndex.ISO_A4,
                    _unitsPerInch,
                    PCLOrientations.eAspect.Portrait);

            for (Int32 i = 0; i < pageCount; i++)
            {
                scaleFactors[i] = (Single)
                                  (PCLPaperSizes.getPaperLength(
                                       indxPaperSize[i],
                                       _unitsPerInch,
                                       PCLOrientations.eAspect.Portrait) /
                                   A4LengthPort);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // We'll also set the logical page offset value to be used on all //
            // pages (and all overlays) from the value for the front of the   //
            // first sheet.                                                   //
            // This may be inaccurate for subsequent sheets (but only if they //
            // use different page sizes and/or orientations), but the error   //
            // will be minimal (at most, about 30 'dots', or 0.05 inch).      //
            //                                                                //
            //----------------------------------------------------------------//

            _logPageOffset = PCLPaperSizes.getLogicalOffset(
                indxPaperSize[0],
                _unitsPerInch,
                PCLOrientations.getAspect(indxOrientFront[0]));

            //----------------------------------------------------------------//
            //                                                                //
            // Generate the print job.                                        //
            //                                                                //
            //----------------------------------------------------------------//

            generateJobHeader(prnWriter);


            if (formAsMacro)
            {
                generateOverlaySet(prnWriter,
                                   pageCount,
                                   indxPaperSize,
                                   indxPlexMode,
                                   scaleFactors,
                                   ref formCountFront,
                                   ref formCountRear,
                                   ref indxFormsFront,
                                   ref indxFormsRear,
                                   ref macroIdsFront,
                                   ref macroIdsRear);
            }

            generatePageSet(prnWriter,
                            pageCount,
                            indxPaperSize,
                            indxPaperType,
                            indxPaperTray,
                            indxPlexMode,
                            indxOrientFront,
                            indxOrientRear,
                            indxFormsFront,
                            indxFormsRear,
                            macroIdsFront,
                            macroIdsRear,
                            scaleFactors,
                            formAsMacro);

            if (formAsMacro)
            {
                generateOverlayDeletes(prnWriter,
                                       formCountFront, formCountRear,
                                       macroIdsFront, macroIdsRear);
            }

            generateJobTrailer(prnWriter);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e J o b                                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate test data.                                                //
        //                                                                    //
        // Some sequences are built up as (Unicode) strings, then converted   //
        // to byte arrays before writing out - this works OK because all the  //
        // characters we're using are within the ASCII range (0x00-0x7f) and  //
        // are hence represented using a single byte in the UTF-8 encoding.   //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void generateJob(BinaryWriter prnWriter,
                                       Int32 indxPaperSize,
                                       Int32 indxPaperType,
                                       Int32 indxOrientation,
                                       Int16 logLeftOffset,
                                       Int16 logTopOffset,
                                       UInt16 logPageWidth,
                                       UInt16 logPageHeight,
                                       Boolean formAsMacro,
                                       Boolean incStdPage)
        {
            const PCLOrientations.eAspect aspectPort
                = PCLOrientations.eAspect.Portrait;

            PCLOrientations.eAspect aspect;

            UInt16 paperWidth,
                   paperLength,
                   paperLengthPort,
                   logXOffset;

            //----------------------------------------------------------------//

            aspect = PCLOrientations.getAspect(indxOrientation);

            paperLength = PCLPaperSizes.getPaperLength(indxPaperSize,
                                                       _unitsPerInch, aspect);

            paperWidth = PCLPaperSizes.getPaperWidth(indxPaperSize,
                                                     _unitsPerInch, aspect);

            logXOffset = PCLPaperSizes.getLogicalOffset(indxPaperSize,
                                                        _unitsPerInch, aspect);

            paperLengthPort = PCLPaperSizes.getPaperLength(indxPaperSize,
                                                           _unitsPerInch,
                                                           aspectPort);

            //----------------------------------------------------------------//

            aspect = PCLOrientations.getAspect(indxOrientation);

            logXOffset = PCLPaperSizes.getLogicalOffset(indxPaperSize,
                                                        _unitsPerInch, aspect);

            //----------------------------------------------------------------//

            generateJobHeader(prnWriter,
                              indxPaperSize,
                              indxPaperType,
                              indxOrientation,
                              formAsMacro,
                              paperWidth,
                              paperLength,
                              logXOffset);

            generatePageSet(prnWriter,
                            indxPaperSize,
                            indxPaperType,
                            indxOrientation,
                            formAsMacro,
                            incStdPage,
                            paperWidth,
                            paperLength,
                            logXOffset,
                            logLeftOffset,
                            logTopOffset,
                            logPageWidth,
                            logPageHeight);

            generateJobTrailer(prnWriter, formAsMacro);
        }
        //--------------------------------------------------------------------//
        //                                                        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 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);
            }
        }
예제 #7
0
        //--------------------------------------------------------------------//
        //                                                        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);
            }
        }
예제 #8
0
        //--------------------------------------------------------------------//
        //                                                        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);
            }
        }
예제 #9
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e J o b                                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate test data.                                                //
        //                                                                    //
        // Some sequences are built up as (Unicode) strings, then converted   //
        // to byte arrays before writing out - this works OK because all the  //
        // characters we're using are within the ASCII range (0x00-0x7f) and  //
        // are hence represented using a single byte in the UTF-8 encoding.   //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void generateJob(BinaryWriter prnWriter,
                                       Int32 pageCount,
                                       Int32[] indxPaperSize,
                                       Int32[] indxPaperType,
                                       Int32[] indxPaperTray,
                                       Int32[] indxPlexMode,
                                       Int32[] indxOrientFront,
                                       Int32[] indxOrientRear,
                                       Boolean formAsMacro)
        {
            Int32[] indxFormsFront = new Int32[pageCount];
            Int32[] indxFormsRear  = new Int32[pageCount];

            String[] formNamesFront = new String[pageCount];
            String[] formNamesRear  = new String[pageCount];

            Single[] scaleFactors = new Single[pageCount];

            Int32 formCountFront = 0;
            Int32 formCountRear  = 0;

            //----------------------------------------------------------------//
            //                                                                //
            // Set up the scaling data for each sheet, relative to the A4     //
            // paper size dimensions.                                         //
            //                                                                //
            //----------------------------------------------------------------//

            Single A4LengthPort =
                (Single)PCLPaperSizes.getPaperLength(
                    (Int32)PCLPaperSizes.eIndex.ISO_A4,
                    _unitsPerInch,
                    PCLOrientations.eAspect.Portrait);

            for (Int32 i = 0; i < pageCount; i++)
            {
                scaleFactors[i] = (Single)
                                  (PCLPaperSizes.getPaperLength(
                                       indxPaperSize[i],
                                       _unitsPerInch,
                                       PCLOrientations.eAspect.Portrait) /
                                   A4LengthPort);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Generate the print job.                                        //
            //                                                                //
            //----------------------------------------------------------------//

            generateJobHeader(prnWriter);

            if (formAsMacro)
            {
                generateOverlaySet(prnWriter,
                                   pageCount,
                                   indxPaperSize,
                                   indxPlexMode,
                                   scaleFactors,
                                   ref formCountFront,
                                   ref formCountRear,
                                   ref indxFormsFront,
                                   ref indxFormsRear,
                                   ref formNamesFront,
                                   ref formNamesRear);
            }

            generatePageSet(prnWriter,
                            pageCount,
                            indxPaperSize,
                            indxPaperType,
                            indxPaperTray,
                            indxPlexMode,
                            indxOrientFront,
                            indxOrientRear,
                            indxFormsFront,
                            indxFormsRear,
                            formNamesFront,
                            formNamesRear,
                            scaleFactors,
                            formAsMacro);

            if (formAsMacro)
            {
                generateOverlayDeletes(prnWriter,
                                       formCountFront, formCountRear,
                                       formNamesFront, formNamesRear);
            }

            generateJobTrailer(prnWriter);
        }
예제 #10
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e J o b                                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate test data.                                                //
        //                                                                    //
        // Some sequences are built up as (Unicode) strings, then converted   //
        // to byte arrays before writing out - this works OK because all the  //
        // characters we're using are within the ASCII range (0x00-0x7f) and  //
        // are hence represented using a single byte in the UTF-8 encoding.   //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void generateJob(BinaryWriter prnWriter,
                                       Int32 indxPaperSize,
                                       Int32 indxPaperType,
                                       Int32 indxOrientation,
                                       Int32 indxPlexMode,
                                       String pjlCommand,
                                       Boolean formAsMacro)
        {
            PCLOrientations.eAspect aspect;

            UInt16 paperWidth,
                   paperLength,
                   logXOffset;

            UInt16 A4Length,
                   A4Width;

            Single scaleText,
                   scaleTextLength,
                   scaleTextWidth;

            Boolean customPaperSize;

            //----------------------------------------------------------------//

            aspect = PCLOrientations.getAspect(indxOrientation);

            A4Length = PCLPaperSizes.getPaperLength(
                (Byte)PCLPaperSizes.eIndex.ISO_A4,
                _sessionUPI,
                aspect);

            A4Width = PCLPaperSizes.getPaperWidth(
                (Byte)PCLPaperSizes.eIndex.ISO_A4,
                _sessionUPI,
                aspect);

            if (PCLPaperSizes.isCustomSize(indxPaperSize))
            {
                customPaperSize = true;
            }
            //      else if (PCLPaperSizes.getIdPCL(indxPaperSize) == 0xff)
            //          customPaperSize = true;
            else
            {
                customPaperSize = false;
            }

            paperLength = PCLPaperSizes.getPaperLength(indxPaperSize,
                                                       _sessionUPI, aspect);

            paperWidth = PCLPaperSizes.getPaperWidth(indxPaperSize,
                                                     _sessionUPI, aspect);

            logXOffset = PCLPaperSizes.getLogicalOffset(indxPaperSize,
                                                        _sessionUPI, aspect);

            scaleTextLength = (Single)paperLength / A4Length;
            scaleTextWidth  = (Single)paperWidth / A4Width;

            if (scaleTextLength < scaleTextWidth)
            {
                scaleText = scaleTextLength;
            }
            else
            {
                scaleText = scaleTextWidth;
            }

            //----------------------------------------------------------------//

            generateJobHeader(prnWriter,
                              indxPaperSize,
                              indxPaperType,
                              indxOrientation,
                              indxPlexMode,
                              pjlCommand,
                              formAsMacro,
                              customPaperSize,
                              paperWidth,
                              paperLength,
                              logXOffset,
                              scaleText);

            generatePage(prnWriter,
                         indxPaperSize,
                         indxPaperType,
                         indxOrientation,
                         indxPlexMode,
                         pjlCommand,
                         formAsMacro,
                         customPaperSize,
                         false,
                         paperWidth,
                         paperLength,
                         logXOffset,
                         scaleText);

            if (PCLPlexModes.getPlexType(indxPlexMode) !=
                PCLPlexModes.ePlexType.Simplex)
            {
                generatePage(prnWriter,
                             indxPaperSize,
                             indxPaperType,
                             indxOrientation,
                             indxPlexMode,
                             pjlCommand,
                             formAsMacro,
                             customPaperSize,
                             true,
                             paperWidth,
                             paperLength,
                             logXOffset,
                             scaleText);
            }

            generateJobTrailer(prnWriter, formAsMacro);
        }