示例#1
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);
        }
示例#2
0
        //--------------------------------------------------------------------//
        //                                                        F i e l d s //
        // Class variables.                                                   //
        //                                                                    //
        //--------------------------------------------------------------------//

        //--------------------------------------------------------------------//
        //                                                        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 indxPaperSize,
            Int32 indxPaperType,
            Int32 indxOrientation,
            Int32 indxOrientRear,
            Int32 indxPlexMode,
            Int32 testPageCount,
            Boolean flagMainEncapsulated,
            Boolean flagRearEncapsulated,
            Boolean flagMacroRemove,
            Boolean flagMainForm,
            Boolean flagRearForm,
            Boolean flagMainOnPrnDisk,
            Boolean flagRearOnPrnDisk,
            Boolean flagRearBPlate,
            Boolean flagPrintDescText,
            String formFileMain,
            String formFileRear,
            eMacroMethod indxMethod,
            Int32 macroIdMain,
            Int32 macroIdRear)
        {
            Boolean flagSimplexJob = PCLPlexModes.isSimplex(indxPlexMode);

            generateJobHeader(prnWriter,
                              indxPaperSize,
                              indxPaperType,
                              indxOrientation,
                              indxPlexMode,
                              flagSimplexJob,
                              flagMainEncapsulated,
                              flagRearEncapsulated,
                              flagMacroRemove,
                              flagMainForm,
                              flagRearForm,
                              flagMainOnPrnDisk,
                              flagRearOnPrnDisk,
                              formFileMain,
                              formFileRear,
                              indxMethod,
                              macroIdMain,
                              macroIdRear);

            generatePageSet(prnWriter,
                            testPageCount,
                            indxPaperSize,
                            indxPaperType,
                            indxOrientation,
                            indxOrientRear,
                            indxPlexMode,
                            flagSimplexJob,
                            flagMainForm,
                            flagRearForm,
                            flagMainOnPrnDisk,
                            flagRearOnPrnDisk,
                            flagRearBPlate,
                            flagPrintDescText,
                            formFileMain,
                            formFileRear,
                            indxMethod,
                            macroIdMain,
                            macroIdRear);

            generateJobTrailer(prnWriter,
                               flagMacroRemove,
                               flagMainForm,
                               flagRearForm,
                               macroIdMain,
                               macroIdRear);
        }
示例#3
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e O v e r l a y S e t                                //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Because each sheet may be a different size, the information to be  //
        // printed may need to be scaled to fit the individual sheets, and    //
        // separate (scaled) macros may also be required.                     //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void generateOverlaySet(BinaryWriter prnWriter,
                                              Int32 pageCount,
                                              Int32[]      indxPaperSize,
                                              Int32[]      indxPlexMode,
                                              Single[]     scaleFactors,
                                              ref Int32 formCountFront,
                                              ref Int32 formCountRear,
                                              ref Int32[]  indxFormsFront,
                                              ref Int32[]  indxFormsRear,
                                              ref Int16[]  macroIdsFront,
                                              ref Int16[]  macroIdsRear)
        {
            const Int32 noForm = -1;

            Int16 crntFormFront,
                  crntFormRear;

            Boolean[] duplexSheet = new Boolean[pageCount];

            //----------------------------------------------------------------//
            //                                                                //
            // Which sheets are duplex?.                                      //
            //                                                                //
            //----------------------------------------------------------------//

            for (Int32 i = 0; i < pageCount; i++)
            {
                if (PCLPlexModes.isSimplex(indxPlexMode[i]))
                {
                    duplexSheet[i] = false;
                }
                else
                {
                    duplexSheet[i] = true;
                }
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Establish the forms required for the front side of the sheets. //
            // A different one is required for each paper size.               //
            //                                                                //
            //----------------------------------------------------------------//
            //----------------------------------------------------------------//
            // First sheet.                                                   //
            //----------------------------------------------------------------//

            crntFormFront = 0;

            macroIdsFront[crntFormFront] =
                (Int16)(_macroIdBaseFront + crntFormFront);

            generateOverlayFront(prnWriter, true,
                                 macroIdsFront[crntFormFront],
                                 scaleFactors[0]);

            indxFormsFront[0] = crntFormFront++;

            //----------------------------------------------------------------//
            // Subsequent sheets.                                             //
            //----------------------------------------------------------------//

            for (Int32 i = 1; i < pageCount; i++)
            {
                Boolean matchFound = false;

                for (Int32 j = 0; j < i; j++)
                {
                    if (indxPaperSize[i] == indxPaperSize[j])
                    {
                        //----------------------------------------------------//
                        // Same paper size as a previous sheet.               //
                        //----------------------------------------------------//

                        matchFound = true;

                        indxFormsFront[i] = indxFormsFront[j];

                        j = i; // force end loop //
                    }
                }

                if (!matchFound)
                {
                    //----------------------------------------------------//
                    // New paper size.                                    //
                    //----------------------------------------------------//

                    macroIdsFront[crntFormFront] =
                        (Int16)(_macroIdBaseFront + crntFormFront);

                    generateOverlayFront(prnWriter, true,
                                         macroIdsFront[crntFormFront],
                                         scaleFactors[i]);

                    indxFormsFront[i] = crntFormFront++;
                }
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Establish the forms required for the rear side of the sheets.  //
            // A different one is required for each paper size.               //
            //                                                                //
            //----------------------------------------------------------------//
            //----------------------------------------------------------------//
            // First sheet.                                                   //
            //----------------------------------------------------------------//

            crntFormRear = 0;

            if (duplexSheet[0])
            {
                macroIdsRear[crntFormRear] =
                    (Int16)(_macroIdBaseRear + crntFormRear);

                generateOverlayRear(prnWriter, true,
                                    macroIdsRear[crntFormRear],
                                    scaleFactors[0]);

                indxFormsRear[0] = crntFormRear++;
            }
            else
            {
                indxFormsRear[0] = noForm;
            }

            //----------------------------------------------------------------//
            // Subsequent sheets.                                             //
            //----------------------------------------------------------------//

            for (Int32 i = 1; i < pageCount; i++)
            {
                if (!duplexSheet[i])
                {
                    indxFormsRear[i] = noForm;
                }
                else
                {
                    Boolean matchFound = false;

                    for (Int32 j = 0; j < i; j++)
                    {
                        if (indxPaperSize[i] == indxPaperSize[j] &&
                            duplexSheet[j])
                        {
                            //------------------------------------------------//
                            // Same paper size as a previous duplex sheet.    //
                            //------------------------------------------------//

                            matchFound = true;

                            indxFormsRear[i] = indxFormsRear[j];

                            j = i; // force end loop //
                        }
                    }

                    //----------------------------------------------------//
                    // New paper size.                                    //
                    //----------------------------------------------------//

                    if (!matchFound)
                    {
                        macroIdsRear[crntFormRear] =
                            (Int16)(_macroIdBaseRear + crntFormRear);

                        generateOverlayRear(prnWriter, true,
                                            macroIdsRear[crntFormRear],
                                            scaleFactors[i]);

                        indxFormsRear[i] = crntFormRear++;
                    }
                }
            }

            formCountFront = crntFormFront;
            formCountRear  = crntFormRear;
        }
        //--------------------------------------------------------------------//
        //                                                        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);
            }
        }