//--------------------------------------------------------------------//
        //                                                        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 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,
                                         Boolean stdPage,
                                         UInt16 paperWidth,
                                         UInt16 paperLength,
                                         UInt16 logXOffset,
                                         Int16 logLeftOffset,
                                         Int16 logTopOffset,
                                         UInt16 logPageWidth,
                                         UInt16 logPageHeight)
        {
            const UInt16 dcptsPerInch = 720;

            const Double unitsToInches      = (1.00 / _unitsPerInch);
            const Double unitsToMilliMetres = (25.4 / _unitsPerInch);

            const Double dcptsToInches      = (1.00 / dcptsPerInch);
            const Double dcptsToMilliMetres = (25.4 / dcptsPerInch);

            Int16 posX,
                  posY;

            Int16 lineInc,
                  ptSize;

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

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, _macroId,
                                       PCLWriter.eMacroControl.Call);
            }
            else
            {
                generateOverlay(prnWriter, false,
                                paperWidth, paperLength, logXOffset);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Header.                                                        //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize = 15;

            PCLWriter.font(prnWriter, true, "19U",
                           "s1p" + ptSize + "v0s0b16602T");

            posX = (Int16)(_posXDesc - logXOffset);
            posY = _posYHddr;

            if (stdPage)
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               "PCL Standard Logical Page sample");
            }
            else
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               "PCL Define Logical Page sample");
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Paper description data.                                        //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize  = 10;
            lineInc = _rulerDiv * 2;

            PCLWriter.font(prnWriter, true, "19U",
                           "s0p" + (120 / ptSize) + "h0s3b4099T");

            posX = (Int16)((_posXDesc + (_rulerCell * 2)) - logXOffset);
            posY = _posYDesc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           PCLPaperSizes.getName(indxPaperSize));

            posY += lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           PCLOrientations.getName(indxOrientation));

            posY += lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           (paperWidth * unitsToMilliMetres).ToString("F0") +
                           "mm = " +
                           (paperWidth * unitsToInches).ToString("F2") +
                           "\"");

            posY += lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           (paperLength * unitsToMilliMetres).ToString("F0") +
                           "mm = " +
                           (paperLength * unitsToInches).ToString("F2") +
                           "\"");

            if (stdPage)
            {
                posY += lineInc;

                PCLWriter.text(prnWriter, posX, posY, 0,
                               "standard");

                posY += lineInc;

                PCLWriter.text(prnWriter, posX, posY, 0,
                               "standard");

                posY += lineInc;

                PCLWriter.text(prnWriter, posX, posY, 0,
                               "standard");

                posY += lineInc;

                PCLWriter.text(prnWriter, posX, posY, 0,
                               "standard");

                PCLWriter.formFeed(prnWriter);
            }
            else
            {
                posY += lineInc;

                PCLWriter.text(prnWriter, posX, posY, 0,
                               logLeftOffset.ToString("F0") +
                               " decipoints = " +
                               (logLeftOffset * dcptsToMilliMetres).ToString("F0") +
                               "mm = " +
                               (logLeftOffset * dcptsToInches).ToString("F2") +
                               "\"");

                posY += lineInc;

                PCLWriter.text(prnWriter, posX, posY, 0,
                               logTopOffset.ToString("F0") +
                               " decipoints = " +
                               (logTopOffset * dcptsToMilliMetres).ToString("F0") +
                               "mm = " +
                               (logTopOffset * dcptsToInches).ToString("F2") +
                               "\"");

                posY += lineInc;

                PCLWriter.text(prnWriter, posX, posY, 0,
                               logPageWidth.ToString("F0") +
                               " decipoints = " +
                               (logPageWidth * dcptsToMilliMetres).ToString("F0") +
                               "mm = " +
                               (logPageWidth * dcptsToInches).ToString("F2") +
                               "\"");

                posY += lineInc;

                PCLWriter.text(prnWriter, posX, posY, 0,
                               logPageHeight.ToString("F0") +
                               " decipoints = " +
                               (logPageHeight * dcptsToMilliMetres).ToString("F0") +
                               "mm = " +
                               (logPageHeight * dcptsToInches).ToString("F2") +
                               "\"");
            }
        }
        //--------------------------------------------------------------------//
        //                                                        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);
        }
Example #5
0
        //--------------------------------------------------------------------//
        //                                                        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 flagMainOnPrnDisk,
                                         Boolean flagRearOnPrnDisk,
                                         Boolean flagRearBPlate,
                                         Boolean flagPrintDescText,
                                         String formFileMain,
                                         String formFileRear,
                                         eMacroMethod indxMethod,
                                         Int32 macroIdMain,
                                         Int32 macroIdRear)
        {
            const Int16 incPosY = 150;

            Boolean altOrient;
            Boolean pageUsesForm;
            Boolean firstPage;

            Int16 posX,
                  posY;

            Int32 macroId;
            Int32 indxOrient;

            altOrient = (indxOrientation != indxOrientRear);
            firstPage = (pageNo == 1);

            if (flagFrontFace)
            {
                indxOrient   = indxOrientation;
                pageUsesForm = flagMainForm;
                macroId      = macroIdMain;
            }
            else
            {
                indxOrient = indxOrientRear;

                if (flagRearForm)
                {
                    pageUsesForm = flagRearForm;
                    macroId      = macroIdRear;
                }
                else
                {
                    pageUsesForm = flagMainForm;
                    macroId      = macroIdMain;
                }
            }

            if (firstPage)
            {
                //------------------------------------------------------------//
                //                                                            //
                // Generate first (or only) page header.                      //
                //                                                            //
                //------------------------------------------------------------//

                PCLWriter.pageHeader(prnWriter,
                                     indxPaperSize,
                                     indxPaperType,
                                     indxOrientation,
                                     indxPlexMode);

                if (indxMethod == eMacroMethod.Overlay)
                {
                    PCLWriter.macroControl(prnWriter,
                                           (Int16)macroIdMain,
                                           PCLWriter.eMacroControl.Overlay);
                }
            }
            else
            {
                //----------------------------------------------------------------//
                //                                                                //
                // Not first page:                                                //
                // - for simplex jobs:                                            //
                //      - write 'form feed' sequence.                             //
                // - for duplex jobs:                                             //
                //      - write 'page side' sequence.                             //
                //      - if rear face, and alternate orientations specified,     //
                //        write 'set orientation' sequence.                       //
                //                                                                //
                //----------------------------------------------------------------//

                if (flagSimplexJob)
                {
                    PCLWriter.formFeed(prnWriter);
                }
                else
                {
                    PCLWriter.pageFace(prnWriter, flagFrontFace);

                    if (altOrient)
                    {
                        PCLWriter.pageOrientation(
                            prnWriter,
                            PCLOrientations.getIdPCL(indxOrient).ToString());
                    }
                }
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Write any required 'begin page' macro 'call' or 'execute'      //
            // sequence.                                                      //
            //                                                                //
            //----------------------------------------------------------------//

            if (pageUsesForm)
            {
                if (indxMethod == eMacroMethod.CallBegin)
                {
                    PCLWriter.macroControl(prnWriter,
                                           (Int16)macroId,
                                           PCLWriter.eMacroControl.Call);
                }
                else if (indxMethod == eMacroMethod.ExecuteBegin)
                {
                    PCLWriter.macroControl(prnWriter,
                                           (Int16)macroId,
                                           PCLWriter.eMacroControl.Execute);
                }
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Write descriptive text headers.                                //
            //                                                                //
            //----------------------------------------------------------------//

            if (flagPrintDescText)
            {
                //------------------------------------------------------------//
                //                                                            //
                // Write headers.                                             //
                //                                                            //
                //------------------------------------------------------------//

                PCLWriter.font(prnWriter, true, "19U", "s0p12h0s0b4099T");

                posX = 600 - _logPageOffset;
                posY = 1350;

                PCLWriter.text(prnWriter, posX, posY, 0, "Page:");

                if (firstPage)
                {
                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0, "Paper size:");

                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0, "Paper type:");

                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0, "Plex mode:");

                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0, "Method:");

                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0, "Orientation:");

                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0, "Rear orientation:");

                    posY += incPosY;

                    if (flagMainOnPrnDisk)
                    {
                        PCLWriter.text(prnWriter, posX, posY, 0,
                                       "Main form printer file:");
                    }
                    else
                    {
                        PCLWriter.text(prnWriter, posX, posY, 0,
                                       "Main form download file:");
                    }

                    posY += incPosY;

                    if (flagRearOnPrnDisk)
                    {
                        PCLWriter.text(prnWriter, posX, posY, 0,
                                       "Rear form printer file:");
                    }
                    else
                    {
                        PCLWriter.text(prnWriter, posX, posY, 0,
                                       "Rear form download file:");
                    }

                    posY += incPosY;

                    if ((flagRearForm) && (flagRearBPlate))
                    {
                        PCLWriter.text(prnWriter, posX, posY, 0,
                                       "Rear Form is boilerplate");
                    }
                }

                //------------------------------------------------------------//
                //                                                            //
                // Write variable data.                                       //
                //                                                            //
                //------------------------------------------------------------//

                PCLWriter.font(prnWriter, true, "19U", "s0p12h0s3b4099T");

                posX = 1920 - _logPageOffset;
                posY = 1350;

                PCLWriter.text(prnWriter, posX, posY, 0,
                               pageNo.ToString() + " of " +
                               pageCount.ToString());

                if (firstPage)
                {
                    String textOrientRear;

                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0,
                                   PCLPaperSizes.getName(indxPaperSize));

                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0,
                                   PCLPaperTypes.getName(indxPaperType));

                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0,
                                   PCLPlexModes.getName(indxPlexMode));

                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0,
                                   macroMethodNames[(Int32)indxMethod]);

                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0,
                                   PCLOrientations.getName(indxOrientation));

                    if (flagSimplexJob)
                    {
                        textOrientRear = "<not applicable>";
                    }
                    else if (altOrient)
                    {
                        textOrientRear = PCLOrientations.getName(indxOrientRear);
                    }
                    else
                    {
                        textOrientRear = "<not set>";
                    }

                    posY += incPosY;

                    PCLWriter.text(prnWriter, posX, posY, 0,
                                   textOrientRear);

                    posY += incPosY;

                    if (flagMainForm)
                    {
                        const Int32 maxLen  = 51;
                        const Int32 halfLen = (maxLen - 5) / 2;

                        Int32 len = formFileMain.Length;

                        if (len < maxLen)
                        {
                            PCLWriter.text(prnWriter, posX, posY, 0, formFileMain);
                        }
                        else
                        {
                            PCLWriter.text(prnWriter, posX, posY, 0,
                                           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)
                        {
                            PCLWriter.text(prnWriter, posX, posY, 0, formFileRear);
                        }
                        else
                        {
                            PCLWriter.text(prnWriter, posX, posY, 0,
                                           formFileRear.Substring(0, halfLen) +
                                           " ... " +
                                           formFileRear.Substring(len - halfLen,
                                                                  halfLen));
                        }
                    }
                }
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Write any required 'end of page' macro 'call' or 'execute'     //
            // sequences.                                                     //
            //                                                                //
            //----------------------------------------------------------------//

            if (pageUsesForm)
            {
                if (indxMethod == eMacroMethod.CallEnd)
                {
                    PCLWriter.macroControl(prnWriter,
                                           (Int16)macroId,
                                           PCLWriter.eMacroControl.Call);
                }
                else if (indxMethod == eMacroMethod.ExecuteEnd)
                {
                    PCLWriter.macroControl(prnWriter,
                                           (Int16)macroId,
                                           PCLWriter.eMacroControl.Execute);
                }
            }

            //------------------------------------------------------------//
            //                                                            //
            // Generate rear boilerplate side if necessary.               //
            //                                                            //
            //------------------------------------------------------------//

            if ((flagRearForm) && (flagRearBPlate))
            {
                PCLWriter.pageFace(prnWriter, false);

                if (altOrient)
                {
                    PCLWriter.pageOrientation(
                        prnWriter,
                        PCLOrientations.getIdPCL(indxOrientRear).ToString());
                }

                if ((indxMethod == eMacroMethod.CallBegin) ||
                    (indxMethod == eMacroMethod.CallEnd))
                {
                    PCLWriter.macroControl(prnWriter,
                                           (Int16)macroIdRear,
                                           PCLWriter.eMacroControl.Call);
                }
                else if ((indxMethod == eMacroMethod.ExecuteBegin) ||
                         (indxMethod == eMacroMethod.ExecuteEnd))
                {
                    PCLWriter.macroControl(prnWriter,
                                           (Int16)macroIdRear,
                                           PCLWriter.eMacroControl.Execute);
                }
            }
        }
Example #6
0
        //--------------------------------------------------------------------//
        //                                                        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);
        }
Example #7
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);
        }
Example #8
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 //
        // i n i t i a l i s e                                                //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Initialise 'target' data.                                          //
        //                                                                    //
        //--------------------------------------------------------------------//

        private void initialise()
        {
            Int32 index;

            _initialised = false;

            //----------------------------------------------------------------//
            //                                                                //
            // Populate form.                                                 //
            //                                                                //
            //----------------------------------------------------------------//

            cbPDL.Items.Clear();

            _ctPDLs = _subsetPDLs.Length;

            for (Int32 i = 0; i < _ctPDLs; i++)
            {
                index = _subsetPDLs[i];

                cbPDL.Items.Add(Enum.GetName(
                                    typeof(ToolCommonData.ePrintLang), i));
            }

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

            cbOrientation.Items.Clear();

            _ctOrientations = _subsetOrientations.Length;

            for (Int32 i = 0; i < _ctOrientations; i++)
            {
                index = _subsetOrientations[i];

                cbOrientation.Items.Add(PCLOrientations.getName(index));
            }

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

            cbPaperSize.Items.Clear();

            _ctPaperSizes = _subsetPaperSizes.Length;

            for (Int32 i = 0; i < _ctPaperSizes; i++)
            {
                index = _subsetPaperSizes[i];

                cbPaperSize.Items.Add(PCLPaperSizes.getName(index));
            }

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

            cbPaperType.Items.Clear();

            _ctPaperTypes = _subsetPaperTypes.Length;

            for (Int32 i = 0; i < _ctPaperTypes; i++)
            {
                index = _subsetPaperTypes[i];

                cbPaperType.Items.Add(PCLPaperTypes.getName(index));
            }

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

            cbResolution.Items.Clear();

            _ctRasterResolutions = PCLRasterResolutions.getCount();

            for (Int32 i = 0; i < _ctRasterResolutions; i++)
            {
                cbResolution.Items.Add(
                    PCLRasterResolutions.getValue(i).ToString());
            }

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

            resetTarget();

            //----------------------------------------------------------------//
            //                                                                //
            // Reinstate settings from persistent storage.                    //
            //                                                                //
            //----------------------------------------------------------------//

            metricsLoad();

            grpProps.Visibility = Visibility.Hidden;

            txtDestPosX.Text = _destPosX.ToString("F2");
            txtDestPosY.Text = _destPosY.ToString("F2");

            txtDestScaleX.Text = _destScalePercentX.ToString();
            txtDestScaleY.Text = _destScalePercentY.ToString();

            txtFilename.Text = _bitmapFilename;

            pdlOptionsRestore();

            cbPDL.SelectedIndex = (Byte)_indxPDL;

            _initialised = true;
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // i n i t i a l i s e                                                //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Initialise 'target' data.                                          //
        //                                                                    //
        //--------------------------------------------------------------------//

        private void initialise()
        {
            Int32 index;

            _initialised = false;

            //----------------------------------------------------------------//
            //                                                                //
            // Populate form.                                                 //
            //                                                                //
            //----------------------------------------------------------------//

            cbPDL.Items.Clear();

            _ctPDLs = _subsetPDLs.Length;

            for (Int32 i = 0; i < _ctPDLs; i++)
            {
                index = _subsetPDLs[i];

                cbPDL.Items.Add(Enum.GetName(
                                    typeof(ToolCommonData.ePrintLang), i));
            }

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

            cbOrientation.Items.Clear();

            _ctOrientations = _subsetOrientations.Length;

            for (Int32 i = 0; i < _ctOrientations; i++)
            {
                index = _subsetOrientations[i];

                cbOrientation.Items.Add(PCLOrientations.getName(index));
            }

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

            cbPaperSize.Items.Clear();

            _ctPaperSizes = _subsetPaperSizes.Length;

            for (Int32 i = 0; i < _ctPaperSizes; i++)
            {
                index = _subsetPaperSizes[i];

                cbPaperSize.Items.Add(PCLPaperSizes.getName(index));
            }

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

            cbPaperType.Items.Clear();

            _ctPaperTypes = _subsetPaperTypes.Length;

            for (Int32 i = 0; i < _ctPaperTypes; i++)
            {
                index = _subsetPaperTypes[i];

                cbPaperType.Items.Add(PCLPaperTypes.getName(index));
            }

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

            /*
             * cbResolution.Items.Clear();
             * /*
             * _ctRasterResolutions = PCLRasterResolutions.getCount();
             *
             * for (Int32 i = 0; i < _ctRasterResolutions; i++)
             * {
             *  cbResolution.Items.Add(
             *      PCLRasterResolutions.getValue(i).ToString());
             * }
             */
            //----------------------------------------------------------------//

            resetTarget();

            //----------------------------------------------------------------//
            //                                                                //
            // Reinstate settings from persistent storage.                    //
            //                                                                //
            //----------------------------------------------------------------//
            metricsLoad();

            /*
             * grpProps.Visibility = Visibility.Hidden;
             *
             * txtDestPosX.Text = _destPosX.ToString("F2");
             * txtDestPosY.Text = _destPosY.ToString("F2");
             *
             * txtDestScaleX.Text = _destScalePercentX.ToString();
             * txtDestScaleY.Text = _destScalePercentY.ToString();
             *
             * txtFilename.Text = _bitmapFilename;
             */

            pdlOptionsRestore();

            cbPDL.SelectedIndex = (Byte)_indxPDL;

            _uGridPattern = new UniformGrid();

            gridPattern.Children.Add(_uGridPattern);

            _uGridPattern.Rows    = 16;
            _uGridPattern.Columns = 16;

            Int32 btnCt = _uGridPattern.Rows * _uGridPattern.Columns;

            _patternStateBtns = new Boolean[btnCt];

            //   btn_04.Style = (Style)FindResource("PrimaryButton");
            //   btn_04.Style = (Style)("{StaticResource PrimaryButton}");
            //   btn_04.Style = PrimaryButton;

            for (Int32 i = 0; i < btnCt; i++)
            {
                ToggleButton x = new ToggleButton();

                x.Background = Brushes.White;
                x.IsChecked  = false;
                x.Style      = (Style)FindResource("ToggleButton");

                _uGridPattern.Children.Add(x);

                _patternStateBtns[i] = false;
            }

            _initialised = true;
        }
        //--------------------------------------------------------------------//
        //                                                        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);
            }
        }
Example #12
0
        //--------------------------------------------------------------------//
        //                                                        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 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);
        }
Example #15
0
        //--------------------------------------------------------------------//
        //                                                        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);
        }
Example #16
0
        //--------------------------------------------------------------------//
        //                                                        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,
                                         Int16 macroIdFront,
                                         Int16 macroIdRear,
                                         Single scaleFactor,
                                         Boolean formAsMacro)
        {
            Int16 posX,
                  posY,
                  posYInc;

            Int32 pitchMain = (Int32)(6 / scaleFactor);

            Boolean simplex = PCLPlexModes.isSimplex(indxPlexMode);

            PCLWriter.pageHeader(prnWriter,
                                 indxPaperSize,
                                 indxPaperType,
                                 indxOrientFront,
                                 indxPlexMode);

            if (indxPaperTray != -1)
            {
                PCLWriter.paperSource(prnWriter, (Int16)indxPaperTray);
            }

            if (!simplex)
            {
                PCLWriter.pageFace(prnWriter, true);
            }

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, macroIdFront,
                                       PCLWriter.eMacroControl.Call);
            }
            else
            {
                generateOverlayFront(prnWriter, false,
                                     _noForm, scaleFactor);
            }

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

            posYInc = (Int16)(scaleFactor * _posYIncMain);

            posX = (Int16)((scaleFactor * _posXValue) - _logPageOffset);
            posY = (Int16)((scaleFactor * _posYDesc));

            PCLWriter.font(prnWriter, true,
                           "19U", "s0p" + pitchMain + "h0s3b4099T");

            if (simplex)
            {
                PCLWriter.text(prnWriter, posX, posY, 0, pageNo.ToString() +
                               " of " +
                               pageCount.ToString());
            }
            else
            {
                PCLWriter.text(prnWriter, posX, posY, 0, pageNo.ToString() +
                               " of " +
                               pageCount.ToString());
            }

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

            posY += posYInc;

            if (indxPaperSize >= PCLPaperSizes.getCount())
            {
                PCLWriter.text(prnWriter, posX, posY, 0, "*** unknown ***");
            }
            else
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               PCLPaperSizes.getName(indxPaperSize));
            }

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

            posY += posYInc;

            if (indxPaperType >= PCLPaperTypes.getCount())
            {
                PCLWriter.text(prnWriter, posX, posY, 0, "*** unknown ***");
            }
            else if (PCLPaperTypes.getType(indxPaperType) ==
                     PCLPaperTypes.eEntryType.NotSet)
            {
                PCLWriter.text(prnWriter, posX, posY, 0, "<not set>");
            }
            else
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               PCLPaperTypes.getName(indxPaperType));
            }

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

            posY += posYInc;

            if (indxPlexMode >= PCLPlexModes.getCount())
            {
                PCLWriter.text(prnWriter, posX, posY, 0, "*** unknown ***");
            }
            else
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               PCLPlexModes.getName(indxPlexMode));
            }

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

            posY += posYInc;

            if (indxOrientFront >= PCLOrientations.getCount())
            {
                PCLWriter.text(prnWriter, posX, posY, 0, "*** unknown ***");
            }
            else
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               PCLOrientations.getName(indxOrientFront));
            }

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

            posY += posYInc;

            if (indxPaperTray == PCLTrayDatas.getIdNotSetPCL())
            {
                PCLWriter.text(prnWriter, posX, posY, 0, "<not set>");
            }
            else if (indxPaperTray == _trayIdAutoSelectPCL)
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               indxPaperTray.ToString() + " (auto-select)");
            }
            else
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               indxPaperTray.ToString());
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Rear face (if not simplex)                                     //
            //                                                                //
            //----------------------------------------------------------------//

            if (!simplex)
            {
                if (indxOrientRear != indxOrientFront)
                {
                    PCLWriter.pageOrientation(
                        prnWriter,
                        PCLOrientations.getIdPCL(indxOrientRear).ToString());
                }

                PCLWriter.pageFace(prnWriter, false);

                if (formAsMacro)
                {
                    PCLWriter.macroControl(prnWriter, macroIdRear,
                                           PCLWriter.eMacroControl.Call);
                }
                else
                {
                    generateOverlayRear(prnWriter, false,
                                        _noForm, scaleFactor);
                }

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

                posX = (Int16)((scaleFactor * _posXValue) - _logPageOffset);
                posY = (Int16)(scaleFactor * _posYDesc);

                PCLWriter.font(prnWriter, true,
                               "19U", "s0p" + pitchMain + "h0s3b4099T");

                PCLWriter.text(prnWriter, posX, posY, 0, pageNo.ToString() +
                               " (rear) of " +
                               pageCount.ToString());

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

                posY += (Int16)(posYInc * 4);

                if (indxOrientRear >= PCLOrientations.getCount())
                {
                    PCLWriter.text(prnWriter, posX, posY, 0, "*** unknown ***");
                }
                else
                {
                    PCLWriter.text(prnWriter, posX, posY, 0,
                                   PCLOrientations.getName(indxOrientRear));
                }
            }

            PCLWriter.formFeed(prnWriter);
        }
Example #17
0
        //--------------------------------------------------------------------//
        //                                                        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 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);
        }
Example #19
0
        //--------------------------------------------------------------------//
        //                                                        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 indxPlexMode,
                                         String pjlCommand,
                                         Boolean formAsMacro,
                                         Boolean customPaperSize,
                                         Boolean rearFace,
                                         UInt16 paperWidth,
                                         UInt16 paperLength,
                                         UInt16 logXOffset,
                                         Single scaleText)
        {
            const String digitsTextA = "         1         2" +
                                       "         3         4" +
                                       "         5         6" +
                                       "         7         8" +
                                       "         9        10" +
                                       "        11        12" +
                                       "        13        14" +
                                       "        15        16" +
                                       "        17        18";

            const String digitsTextB = "12345678901234567890" +
                                       "12345678901234567890" +
                                       "12345678901234567890" +
                                       "12345678901234567890" +
                                       "12345678901234567890" +
                                       "12345678901234567890" +
                                       "12345678901234567890" +
                                       "12345678901234567890" +
                                       "12345678901234567890";

            const Double unitsToInches      = (1.00 / _sessionUPI);
            const Double unitsToMilliMetres = (25.4 / _sessionUPI);

            const Int16 bottomMargin = (Int16)(0.5 * _sessionUPI);

            Int16 squareRightX,
                  squareBottomY;

            Int16 posX,
                  posY;

            Int16 lineInc,
                  ptSize;

            Int32 ctA;

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

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, _macroId, PCLWriter.eMacroControl.Call);
            }
            else
            {
                generateOverlay(prnWriter, false,
                                paperWidth, paperLength, logXOffset, scaleText);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Corner squares.                                                //
            //                                                                //
            //----------------------------------------------------------------//

            squareRightX  = (Int16)(paperWidth - _boxOuterEdge - logXOffset);
            squareBottomY = (Int16)(paperLength - _boxOuterEdge);

            // Top-left.                                                      //

            posX = 0;
            posY = 0;

            generateSquare(prnWriter, posX, posY, false);

            // Top-right.                                                     //

            posX = squareRightX;
            posY = 0;

            generateSquare(prnWriter, posX, posY, false);

            // Bottom-left.                                                   //

            posX = 0;
            posY = squareBottomY;

            generateSquare(prnWriter, posX, posY, false);

            // Bottom-right.                                                  //

            posX = squareRightX;
            posY = squareBottomY;

            generateSquare(prnWriter, posX, posY, false);

            //----------------------------------------------------------------//
            //                                                                //
            // Paper description data.                                        //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize  = (Int16)(10 * scaleText);
            lineInc = (Int16)((_sessionUPI * scaleText) / 8);

            PCLWriter.font(prnWriter, true, "19U",
                           "s0p" + (120 / ptSize) + "h0s3b4099T");

            posX = (Int16)((_posXDesc + (_rulerCell * scaleText)) - logXOffset);
            posY = _posYDesc;

            if (customPaperSize)
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               PCLPaperSizes.getNameAndDesc(indxPaperSize));
            }
            else
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               PCLPaperSizes.getName(indxPaperSize));
            }

            posY += lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           PCLPaperTypes.getName(indxPaperType));

            posY += lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           PCLOrientations.getName(indxOrientation));

            posY += lineInc;

            if (rearFace)
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               PCLPlexModes.getName(indxPlexMode) +
                               ": rear face");
            }
            else
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               PCLPlexModes.getName(indxPlexMode));
            }

            posY += lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           (Math.Round((paperWidth *
                                        unitsToMilliMetres), 2)).ToString("F1") +
                           " mm = " +
                           (Math.Round((paperWidth *
                                        unitsToInches), 3)).ToString("F3") +
                           "\"");

            posY += lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           (Math.Round((paperLength *
                                        unitsToMilliMetres), 2)).ToString("F1") +
                           " mm = " +
                           (Math.Round((paperLength *
                                        unitsToInches), 3)).ToString("F3") +
                           "\"");

            posY += lineInc;

            if (pjlCommand == "")
            {
                PCLWriter.text(prnWriter, posX, posY, 0, "<none>");
            }
            else
            {
                PCLWriter.text(prnWriter, posX, posY, 0, pjlCommand);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Fixed-pitch 10cpi text - not rotated.                          //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.font(prnWriter, true, "19U", "s0p10h0s0b4099T");

            posY = _posYText;

            ctA = (paperWidth * 10) / _sessionUPI;

            PCLWriter.text(prnWriter, 0, posY, 0, digitsTextA.Substring(0, ctA));

            posY += _rulerDiv;

            PCLWriter.text(prnWriter, 0, posY, 0, digitsTextB.Substring(0, ctA));

            //----------------------------------------------------------------//
            //                                                                //
            // Rotate print direction by 180-degrees.                         //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.printDirection(prnWriter, 180);

            //----------------------------------------------------------------//
            //                                                                //
            // Fixed-pitch 10cpi text - 180-degree rotated.                   //
            //                                                                //
            //----------------------------------------------------------------//

            posY = (Int16)(paperLength - _posYText - (2 * bottomMargin));

            ctA = (paperWidth * 10) / _sessionUPI;

            PCLWriter.text(prnWriter, 0, posY, 0, digitsTextA.Substring(0, ctA));

            posY += _rulerDiv;

            PCLWriter.text(prnWriter, 0, posY, 0, digitsTextB.Substring(0, ctA));

            //----------------------------------------------------------------//
            //                                                                //
            // Left box: rotated (180-degree) orientation.                    //
            //                                                                //
            //----------------------------------------------------------------//

            posX = squareRightX;
            posY = (Int16)(((paperLength - _boxOuterEdge) / 2) - bottomMargin);

            generateSquare(prnWriter, posX, posY, false);

            //----------------------------------------------------------------//
            //                                                                //
            // Reset print direction to 0-degrees.                            //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.printDirection(prnWriter, 0);

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

            PCLWriter.formFeed(prnWriter);
        }