Example #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 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);
        }