//--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // p a t t e r n D e f i n e D p i 6 0 0                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Define 600 dots-per-inch user-defined patterns to match the        //
        // pre-defined patterns.                                              //
        // The format 20 pattern header defines X & Y resolutions, which we   //
        // are setting to 600 dots-per-inch.                                  //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void patternDefineDpi600(BinaryWriter prnWriter,
                                                Int32 baseID)
        {
            const UInt16 dpi = 600;

            Byte[] hddrFmt_20 = { 0x14, 0x00, 0x01, 0x00,
                                  0x00, 0x10, 0x00, 0x10,
                                  0x02, 0x58, 0x02, 0x58 };

            for (Int32 i = 0; i < _patternsCt; i++)
            {
                hddrFmt_20[4] = (Byte)((_patternHeights[i] & 0xff00) >> 8);
                hddrFmt_20[5] = (Byte)(_patternHeights[i] & 0x00ff);

                hddrFmt_20[6] = (Byte)((_patternWidths[i] & 0xff00) >> 8);
                hddrFmt_20[7] = (Byte)(_patternWidths[i] & 0x00ff);

                hddrFmt_20[8] = (Byte)((dpi & 0xff00) >> 8);
                hddrFmt_20[9] = (Byte)(dpi & 0x00ff);

                hddrFmt_20[10] = (Byte)((dpi & 0xff00) >> 8);
                hddrFmt_20[11] = (Byte)(dpi & 0x00ff);

                PCLWriter.patternDefine(
                    prnWriter, (Int16)(baseID + _patternIds[i]),
                    hddrFmt_20,
                    PCLPatternDefs.getBytes(
                        PCLPatternDefs.eType.CrossHatch, i));
            }
        }
Пример #2
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e J o b T r a i l e r                                //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write termination sequences to output file.                        //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generateJobTrailer(BinaryWriter prnWriter,
                                               Boolean flagMacroRemove,
                                               Boolean flagMainForm,
                                               Boolean flagRearForm,
                                               Int32 macroIdMain,
                                               Int32 macroIdRear)
        {
            if (flagMacroRemove)
            {
                if (flagMainForm)
                {
                    PCLWriter.macroControl(
                        prnWriter,
                        (Int16)macroIdMain,
                        PCLWriter.eMacroControl.Delete);
                }

                if (flagRearForm)
                {
                    PCLWriter.macroControl(
                        prnWriter,
                        (Int16)macroIdRear,
                        PCLWriter.eMacroControl.Delete);
                }
            }

            PCLWriter.stdJobTrailer(prnWriter, false, -1);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e P a g e S e t                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write test data page(s) to output file.                            //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generatePageSet(BinaryWriter prnWriter,
                                            Int32 indxPaperSize,
                                            Int32 indxPaperType,
                                            Int32 indxOrientation,
                                            Boolean formAsMacro,
                                            Boolean incStdPage,
                                            UInt16 paperWidth,
                                            UInt16 paperLength,
                                            UInt16 logXOffset,
                                            Int16 logLeftOffset,
                                            Int16 logTopOffset,
                                            UInt16 logPageWidth,
                                            UInt16 logPageHeight)
        {
            if (incStdPage)
            {
                generatePage(prnWriter,
                             indxPaperSize,
                             indxPaperType,
                             indxOrientation,
                             formAsMacro,
                             true,
                             paperWidth,
                             paperLength,
                             logXOffset,
                             logLeftOffset,
                             logTopOffset,
                             logPageWidth,
                             logPageHeight);
            }

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

            PCLWriter.defLogPage(prnWriter,
                                 indxOrientation,
                                 logLeftOffset,
                                 logTopOffset,
                                 logPageWidth,
                                 logPageHeight);

            PCLWriter.marginLeft(prnWriter, 0);

            PCLWriter.marginTop(prnWriter, 0);

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

            generatePage(prnWriter,
                         indxPaperSize,
                         indxPaperType,
                         indxOrientation,
                         formAsMacro,
                         false,
                         paperWidth,
                         paperLength,
                         logXOffset,
                         logLeftOffset,
                         logTopOffset,
                         logPageWidth,
                         logPageHeight);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // p a t t e r n D e l e t e S e t                                    //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Delete user-defined patterns.                                      //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void patternDeleteSet(BinaryWriter prnWriter,
                                             Int32 baseID)
        {
            for (Int32 i = 0; i < _patternsCt; i++)
            {
                PCLWriter.patternDelete(
                    prnWriter, (Int16)(baseID + _patternIds[i]));
            }
        }
        //--------------------------------------------------------------------//
        //                                                        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)
        {
            PCLWriter.stdJobHeader(prnWriter, "");

            PCLWriter.pageHeader(prnWriter,
                                 paperSize,
                                 paperType,
                                 orientation,
                                 PCLPlexModes.eSimplex);
        }
Пример #6
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e O v e r l a y R e a r                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write background data sequences fopr rear overlay to output file.  //
        // Optionally top and tail these with macro definition sequences.     //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generateOverlayRear(BinaryWriter prnWriter,
                                                Boolean formAsMacro,
                                                Int16 macroId,
                                                Single scaleFactor)
        {
            Int16 posX,
                  posY,
                  posYInc;

            Int32 ptSizeHddr = (Int32)(scaleFactor * 24),
                  ptSizeMain = (Int32)(scaleFactor * 18);

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, macroId,
                                       PCLWriter.eMacroControl.StartDef);
            }

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

            posYInc = (Int16)(scaleFactor * _posYIncMain);

            posX = (Int16)((scaleFactor * _posXName) - _logPageOffset);
            posY = (Int16)(scaleFactor * _posYHddr);

            PCLWriter.font(prnWriter, true,
                           "19U", "s1p" + ptSizeHddr + "v0s3b16602T");

            PCLWriter.text(prnWriter, posX, posY, 0, "Tray map test (PCL)");

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

            posY = (Int16)(scaleFactor * _posYDesc);

            PCLWriter.font(prnWriter, true, "", "s" + ptSizeMain + "V");

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

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

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

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

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, macroId,
                                       PCLWriter.eMacroControl.StopDef);
            }
        }
Пример #7
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e O v e r l a y D e l e t e s                        //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Delete overlays.                                                   //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generateOverlayDeletes(BinaryWriter prnWriter,
                                                   Int32 formCountFront,
                                                   Int32 formCountRear,
                                                   Int16[] macroIdsFront,
                                                   Int16[] macroIdsRear)
        {
            for (Int32 i = 0; i < formCountFront; i++)
            {
                PCLWriter.macroControl(prnWriter, macroIdsFront[i],
                                       PCLWriter.eMacroControl.Delete);
            }

            for (Int32 i = 0; i < formCountRear; i++)
            {
                PCLWriter.macroControl(prnWriter, macroIdsRear[i],
                                       PCLWriter.eMacroControl.Delete);
            }
        }
        //--------------------------------------------------------------------//
        //                                                        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 indxPaperSize,
                                              Int32 indxPaperType,
                                              Int32 indxOrientation,
                                              Boolean formAsMacro,
                                              UInt16 logXOffset)
        {
            PCLWriter.stdJobHeader(prnWriter, "");

            if (formAsMacro)
            {
                generateOverlay(prnWriter, true, logXOffset,
                                indxPaperSize, indxOrientation);
            }

            PCLWriter.pageHeader(prnWriter,
                                 indxPaperSize,
                                 indxPaperType,
                                 indxOrientation,
                                 PCLPlexModes.eSimplex);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // p a t t e r n D e f i n e D p i 3 0 0                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Define default user-defined patterns to match the pre-defined      //
        // patterns.                                                          //
        // The format 0 pattern header does not define a resolution, so (we   //
        // assume) that the pattern will use the default 300 dots-per-inch.   //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void patternDefineDpi300(BinaryWriter prnWriter,
                                                Int32 baseID)
        {
            Byte[] hddrFmt_0 = { 0x00, 0x00, 0x01, 0x00,
                                 0x00, 0x10, 0x00, 0x10 };

            for (Int32 i = 0; i < _patternsCt; i++)
            {
                hddrFmt_0[4] = (Byte)((_patternHeights[i] & 0xff00) >> 8);
                hddrFmt_0[5] = (Byte)(_patternHeights[i] & 0x00ff);

                hddrFmt_0[6] = (Byte)((_patternWidths[i] & 0xff00) >> 8);
                hddrFmt_0[7] = (Byte)(_patternWidths[i] & 0x00ff);

                PCLWriter.patternDefine(
                    prnWriter, (Int16)(baseID + _patternIds[i]),
                    hddrFmt_0,
                    PCLPatternDefs.getBytes(
                        PCLPatternDefs.eType.CrossHatch, i));
            }
        }
Пример #10
0
        //--------------------------------------------------------------------//
        //                                                        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 indxPaperSize,
                                              Int32 indxPaperType,
                                              Int32 indxOrientation,
                                              Int32 indxPlexMode,
                                              String pjlCommand,
                                              Boolean formAsMacro,
                                              Boolean customPaperSize,
                                              UInt16 paperWidth,
                                              UInt16 paperLength,
                                              UInt16 logXOffset,
                                              Single scaleText)
        {
            PCLWriter.stdJobHeader(prnWriter, pjlCommand);

            if (formAsMacro)
            {
                generateOverlay(prnWriter, true,
                                paperWidth, paperLength, logXOffset, scaleText);
            }

            if (customPaperSize)
            {
                PCLWriter.pageHeaderCustom(prnWriter,
                                           indxPaperType,
                                           indxOrientation,
                                           indxPlexMode,
                                           paperWidth,
                                           paperLength);
            }
            else
            {
                PCLWriter.pageHeader(prnWriter,
                                     indxPaperSize,
                                     indxPaperType,
                                     indxOrientation,
                                     indxPlexMode);
            }
        }
Пример #11
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e P a g e S e t                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write set of test data pages to output file.                       //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generatePageSet(BinaryWriter prnWriter,
                                            Int32 pageCount,
                                            Int32 indxPaperSize,
                                            Int32 indxPaperType,
                                            Int32 indxOrientation,
                                            Int32 indxOrientRear,
                                            Int32 indxPlexMode,
                                            Boolean flagSimplexJob,
                                            Boolean flagMainForm,
                                            Boolean flagRearForm,
                                            Boolean flagMainOnPrnDisk,
                                            Boolean flagRearOnPrnDisk,
                                            Boolean flagRearBPlate,
                                            Boolean flagPrintDescText,
                                            String formFileMain,
                                            String formFileRear,
                                            eMacroMethod indxMethod,
                                            Int32 macroIdMain,
                                            Int32 macroIdRear)
        {
            Boolean flagFrontFace;

            flagFrontFace = true;

            for (Int32 pageNo = 1; pageNo <= pageCount; pageNo++)
            {
                //------------------------------------------------------------//
                //                                                            //
                // Generate test page.                                        //
                //                                                            //
                //------------------------------------------------------------//

                generatePage(prnWriter,
                             pageNo,
                             pageCount,
                             indxPaperSize,
                             indxPaperType,
                             indxOrientation,
                             indxOrientRear,
                             indxPlexMode,
                             flagFrontFace,
                             flagSimplexJob,
                             flagMainForm,
                             flagRearForm,
                             flagMainOnPrnDisk,
                             flagRearOnPrnDisk,
                             flagRearBPlate,
                             flagPrintDescText,
                             formFileMain,
                             formFileRear,
                             indxMethod,
                             macroIdMain,
                             macroIdRear);

                //------------------------------------------------------------//
                //                                                            //
                // Toggle front/rear face indicator.                          //
                //                                                            //
                //------------------------------------------------------------//

                if ((!flagSimplexJob) && (!flagRearBPlate))
                {
                    flagFrontFace = !flagFrontFace;
                }
            }

            //----------------------------------------------------------------//
            //                                                                //
            // If the macro method is 'Overlay', it seems that a terminating  //
            // FormFeed character is required to trigger the (end of page)    //
            // overlay on the last page - without it, only the variable data  //
            // is printed on that page!                                       //
            //                                                                //
            //----------------------------------------------------------------//

            if (indxMethod == eMacroMethod.Overlay)
            {
                PCLWriter.formFeed(prnWriter);
            }
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e O v e r l a y                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write background data sequences to output file.                    //
        // Optionally top and tail these with macro (user-defined stream)     //
        // definition sequences.                                              //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generateOverlay(BinaryWriter prnWriter,
                                            Boolean formAsMacro,
                                            UInt16 logXOffset,
                                            Int32 indxPaperSize,
                                            Int32 indxOrientation)
        {
            Int16 posX,
                  posY;

            Int16 ptSize;

            Int16 boxX,
                  boxY,
                  boxHeight,
                  boxWidth;

            Byte stroke = 1;

            //----------------------------------------------------------------//
            //                                                                //
            // Header                                                         //
            //                                                                //
            //----------------------------------------------------------------//

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, _macroId,
                                       PCLWriter.eMacroControl.StartDef);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Box.                                                           //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.Shading,
                                 60);

            boxX = (Int16)((_unitsPerInch / 2) - logXOffset);
            boxY = (Int16)(_unitsPerInch / 2);

            boxWidth  = (Int16)(_paperWidth - _unitsPerInch);
            boxHeight = (Int16)(_paperHeight - _unitsPerInch);

            PCLWriter.rectangleOutline(prnWriter, boxX, boxY,
                                       boxHeight, boxWidth, stroke,
                                       false, false);

            //----------------------------------------------------------------//
            //                                                                //
            // Text.                                                          //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.SolidBlack,
                                 0);

            ptSize = 15;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontCourier,
                                                     PCLFonts.eVariant.Bold,
                                                     ptSize, 0));

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

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "PCL cross-hatch patterns:");

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

            ptSize = 12;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontCourier,
                                                     PCLFonts.eVariant.Regular,
                                                     ptSize, 0));

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

            posY = _posYDesc1;

            for (Int32 i = 0; i < _patternsCt; i++)
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               "#" + _patternIds[i].ToString() + ": ");

                posY += _lineInc;
            }

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

            ptSize = 10;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontCourier,
                                                     PCLFonts.eVariant.Regular,
                                                     ptSize, 0));

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

            posY = _posYDesc1 + (_lineInc / 4);

            for (Int32 i = 0; i < _patternsCt; i++)
            {
                PCLWriter.text(prnWriter, posX, posY, 0,
                               _patternDescs[i] + ":");

                posY += _lineInc;
            }

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

            ptSize = 8;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontCourier,
                                                     PCLFonts.eVariant.Regular,
                                                     ptSize, 0));

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

            posY = _posYDesc2;
            posX = (Int16)(_posXData1 - logXOffset);

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

            posX = (Int16)(_posXData2 - logXOffset);

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "User-defined 300 dpi");

            posX = (Int16)(_posXData3 - logXOffset);

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "User-defined 600 dpi");

            //----------------------------------------------------------------//
            //                                                                //
            // Overlay end.                                                   //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.SolidBlack,
                                 0);

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, 0,
                                       PCLWriter.eMacroControl.StopDef);
            }
        }
        //--------------------------------------------------------------------//
        //                                                        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,
                                         UInt16 logXOffset)
        {
            Int16 posX,
                  posY,
                  rectX,
                  rectY,
                  rectHeight,
                  rectWidth;

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

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

            rectHeight = (Int16)(_lineInc / 2);
            rectWidth  = _lineInc;

            //----------------------------------------------------------------//
            //                                                                //
            // Pre-defined cross-hatch pattenrs.                              //
            //                                                                //
            //----------------------------------------------------------------//

            posX = (Int16)(_posXData1 - logXOffset);
            posY = _posYData;

            rectX = posX;
            rectY = posY;

            for (Int32 i = 0; i < _patternsCt; i++)
            {
                PCLWriter.rectangleXHatch(prnWriter, rectX, rectY,
                                          rectHeight, rectWidth,
                                          (Int16)_patternIds[i]);

                rectY += _lineInc;
            }

            //----------------------------------------------------------------//
            //                                                                //
            // User-defined 300 dpi cross-hatch patterns.                     //
            //                                                                //
            //----------------------------------------------------------------//

            posX = (Int16)(_posXData2 - logXOffset);
            posY = _posYData;

            rectX = posX;
            rectY = posY;

            for (Int32 i = 0; i < _patternsCt; i++)
            {
                PCLWriter.rectangleUserFill(
                    prnWriter, rectX, rectY,
                    rectHeight, rectWidth,
                    (Int16)(_patternBase_300 + _patternIds[i]),
                    false, false);

                rectY += _lineInc;
            }

            //----------------------------------------------------------------//
            //                                                                //
            // User-defined 600 dpi cross-hatch patterns.                     //
            //                                                                //
            //----------------------------------------------------------------//

            posX = (Int16)(_posXData3 - logXOffset);
            posY = _posYData;

            rectX = posX;
            rectY = posY;

            for (Int32 i = 0; i < _patternsCt; i++)
            {
                PCLWriter.rectangleUserFill(
                    prnWriter, rectX, rectY,
                    rectHeight, rectWidth,
                    (Int16)(_patternBase_600 + _patternIds[i]),
                    false, false);

                rectY += _lineInc;
            }

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

            PCLWriter.formFeed(prnWriter);
        }
Пример #14
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e O v e r l a y                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write background data sequences to output file.                    //
        // Optionally top and tail these with macro (user-defined stream)     //
        // definition sequences.                                              //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generateOverlay(BinaryWriter prnWriter,
                                            Boolean formAsMacro,
                                            UInt16 logXOffset,
                                            Int32 indxPaperSize,
                                            Int32 indxOrientation)
        {
            Int16 posX,
                  posY;

            Int16 ptSize;

            Int16 boxX,
                  boxY,
                  boxHeight,
                  boxWidth,
                  rectX,
                  rectY,
                  rectHeight,
                  rectWidth;

            Byte stroke = 1;

            //----------------------------------------------------------------//
            //                                                                //
            // Header                                                         //
            //                                                                //
            //----------------------------------------------------------------//

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, _macroId,
                                       PCLWriter.eMacroControl.StartDef);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Box.                                                           //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.Shading,
                                 60);

            boxX = (Int16)((_unitsPerInch / 2) - logXOffset);
            boxY = (Int16)(_unitsPerInch / 2);

            boxWidth  = (Int16)(_paperWidth - _unitsPerInch);
            boxHeight = (Int16)(_paperHeight - _unitsPerInch);

            PCLWriter.rectangleOutline(prnWriter, boxX, boxY,
                                       boxHeight, boxWidth, stroke,
                                       false, false);

            //----------------------------------------------------------------//
            //                                                                //
            // Text.                                                          //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.SolidBlack,
                                 0);

            ptSize = 15;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontCourier,
                                                     PCLFonts.eVariant.Bold,
                                                     ptSize, 0));

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

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "PCL text & background:");

            ptSize = 12;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontCourier,
                                                     PCLFonts.eVariant.Regular,
                                                     ptSize, 0));

            posY = _posYDesc;

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

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "Shade " + _shade_1 + "%:");

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "Shade " + _shade_2 + "%:");

            posY += _lineInc;

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

            //----------------------------------------------------------------//
            //                                                                //
            // Background shading.                                            //
            //                                                                //
            //----------------------------------------------------------------//

            posX = (Int16)(_posXData - logXOffset);
            posY = _posYData - (_lineInc / 2);

            rectX = posX;
            rectY = posY;

            rectHeight = (Int16)((_lineInc * 3) / 5);
            rectWidth  = (Int16)((_unitsPerInch * 9) / 10);

            PCLWriter.patternTransparency(prnWriter, false);

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.SolidBlack,
                                 0);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectX += rectWidth;

            PCLWriter.rectangleShaded(prnWriter, rectX, rectY,
                                      rectHeight, rectWidth, _shade_1,
                                      false, false);

            rectX += rectWidth;

            PCLWriter.rectangleShaded(prnWriter, rectX, rectY,
                                      rectHeight, rectWidth, _shade_2,
                                      false, false);

            rectX  = posX;
            rectY += _lineInc;

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectX += rectWidth;

            PCLWriter.rectangleShaded(prnWriter, rectX, rectY,
                                      rectHeight, rectWidth, _shade_1,
                                      false, false);

            rectX += rectWidth;

            PCLWriter.rectangleShaded(prnWriter, rectX, rectY,
                                      rectHeight, rectWidth, _shade_2,
                                      false, false);

            rectX  = posX;
            rectY += _lineInc;

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectX += rectWidth;

            PCLWriter.rectangleShaded(prnWriter, rectX, rectY,
                                      rectHeight, rectWidth, _shade_1,
                                      false, false);

            rectX += rectWidth;

            PCLWriter.rectangleShaded(prnWriter, rectX, rectY,
                                      rectHeight, rectWidth, _shade_2,
                                      false, false);

            rectX  = posX;
            rectY += _lineInc;

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectX += rectWidth;

            PCLWriter.rectangleShaded(prnWriter, rectX, rectY,
                                      rectHeight, rectWidth, _shade_1,
                                      false, false);

            rectX += rectWidth;

            PCLWriter.rectangleShaded(prnWriter, rectX, rectY,
                                      rectHeight, rectWidth, _shade_2,
                                      false, false);

            //----------------------------------------------------------------//
            //                                                                //
            // Overlay end.                                                   //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.SolidBlack,
                                 0);

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, 0,
                                       PCLWriter.eMacroControl.StopDef);
            }
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e J o b T r a i l e r                                //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write tray map termination sequences to output file.               //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generateJobTrailer(BinaryWriter prnWriter,
                                               Boolean formAsMacro)
        {
            PCLWriter.stdJobTrailer(prnWriter, formAsMacro, _macroId);
        }
Пример #16
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // w r i t e H d d r                                                  //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate symbol set download header sequence and fixed part of     //
        // header.                                                            //
        //                                                                    //
        //--------------------------------------------------------------------//

        private void writeHddr(UInt16 symSetNo,
                               UInt16 codeMin,
                               UInt16 codeMax,
                               UInt64 charCollReq,
                               Byte symSetType)
        {
            Int32 mapSize;
            Int32 descSize;

            UInt16 valUInt16;

            UInt32 valUInt32;

            Byte [] hddrDesc = new Byte [cSizeHddrFixed];

            //----------------------------------------------------------------//
            //                                                                //
            // Calculate total size of header.                                //
            // Write PCL 'download header' escape sequence.                   //
            //                                                                //
            //----------------------------------------------------------------//

            mapSize  = (codeMax - codeMin + 1) * 2;
            descSize = mapSize + cSizeHddrFixed;

            PCLWriter.symSetDownloadDesc(_binWriter, (UInt32)descSize);

            //----------------------------------------------------------------//
            //                                                                //
            // Write font header descriptor.                                  //
            //                                                                //
            //----------------------------------------------------------------//

            hddrDesc [0] = msByte(cSizeHddrFixed);
            hddrDesc [1] = lsByte(cSizeHddrFixed);

            hddrDesc [2] = msByte(symSetNo);    // Symbol set Kind1 Id MSB
            hddrDesc [3] = lsByte(symSetNo);    // Symbol set Kind1 Id LSB

            hddrDesc [4] = 3;                   // Format = Unicode
            hddrDesc [5] = symSetType;          // Type
            hddrDesc [6] = msByte(codeMin);     // First code MSB
            hddrDesc [7] = lsByte(codeMin);     // First code LSB
            hddrDesc [8] = msByte(codeMax);     // Last code MSB
            hddrDesc [9] = lsByte(codeMax);     // Last code LSB

            valUInt32     = msUInt32(charCollReq);
            valUInt16     = msUInt16(valUInt32);
            hddrDesc [10] = msByte(valUInt16);  // Char. Req. byte 0
            hddrDesc [11] = lsByte(valUInt16);  // Char. Req. byte 1

            valUInt16     = lsUInt16(valUInt32);
            hddrDesc [12] = msByte(valUInt16);  // Char. Req. byte 2
            hddrDesc [13] = lsByte(valUInt16);  // Char. Req. byte 3

            valUInt32     = lsUInt32(charCollReq);
            valUInt16     = msUInt16(valUInt32);
            hddrDesc [14] = msByte(valUInt16);  // Char. Req. byte 4
            hddrDesc [15] = lsByte(valUInt16);  // Char. Req. byte 5

            valUInt16     = lsUInt16(valUInt32);
            hddrDesc [16] = msByte(valUInt16);  // Char. Req. byte 6
            hddrDesc [17] = lsByte(valUInt16);  // Char. Req. byte 7

            writeBuffer(cSizeHddrFixed, hddrDesc);
        }
        //--------------------------------------------------------------------//
        //                                                        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") +
                               "\"");
            }
        }
Пример #18
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,
                                         UInt16 logXOffset)
        {
            String sampleText = "000000000000000";

            Int16 posX,
                  posY;

            Int16 ptSize;

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

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

            //----------------------------------------------------------------//
            //                                                                //
            // Text.                                                          //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize = 36;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontArial,
                                                     PCLFonts.eVariant.Regular,
                                                     ptSize, 0));

            //----------------------------------------------------------------//
            // Black                                                          //
            //----------------------------------------------------------------//

            posX = (Int16)(_posXData - logXOffset);
            posY = _posYData;

            PCLWriter.patternTransparency(prnWriter, false);

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.SolidBlack,
                                 0);

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

            //----------------------------------------------------------------//
            // Shade 1                                                        //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLWriter.patternTransparency(prnWriter, true);

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.Shading,
                                 _shade_1);

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

            //----------------------------------------------------------------//
            // Shade 2                                                        //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLWriter.patternTransparency(prnWriter, true);

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.Shading,
                                 _shade_2);

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

            //----------------------------------------------------------------//
            // White                                                          //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLWriter.patternTransparency(prnWriter, true);

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.SolidWhite,
                                 0);

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

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

            PCLWriter.formFeed(prnWriter);
        }
Пример #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 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);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // w r i t e C h a r                                                  //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write PCL format character data:                                   //
        //                                                                    //
        //    <esc>*c#E         Character Code:                               //
        //                      #      = decimal character code               //
        //    <esc>(s#W[data]   Character Descriptor / Data                   //
        //                      #      = number of bytes of data              //
        //                      [data] = font character data                  //
        //                                                                    //
        // Note that the function may be called recursively, if a glyph is    //
        // composite (i.e. made up of two or more components).                //
        //                                                                    //
        //--------------------------------------------------------------------//

        private void writeChar(UInt16 charCode,
                               UInt16 codepoint,
                               UInt16 glyphId,
                               UInt16 depth,
                               UInt16 maxGlyphId)
        {
            UInt16 glyphWidth    = 0,
                   glyphHeight   = 0,
                   charBlockSize = 0,
                   charDataSize  = 0;

            Int16 glyphLSB = 0,
                  glyphTSB = 0;

            UInt32 glyphOffset = 0,
                   glyphLength = 0;

            Boolean glyphComposite = false;

            Byte checksumMod256;

            Byte[] charHddr      = new Byte[cSizeCharHddr];
            Byte[] charGlyphHddr = new Byte[cSizeCharGlyphHddr];
            Byte[] charTrail     = new Byte[cSizeCharTrail];
            Byte[] glyphData     = null;

            //----------------------------------------------------------------//
            //                                                                //
            // Mark glyph as used.                                            //
            // These markers are checked for composite sub-glyphs.            //
            //                                                                //
            //----------------------------------------------------------------//

            _ttfHandler.glyphReferencedMark(glyphId);

            //----------------------------------------------------------------//
            //                                                                //
            // Get glyph details:                                             //
            //    advance width.                                              //
            //    left-side bearing.                                          //
            //    offset and length of the glyph data in the TTF file.        //
            //                                                                //
            //----------------------------------------------------------------//

            _ttfHandler.getGlyphData(glyphId,
                                     ref glyphWidth,
                                     ref glyphHeight,   // not used here
                                     ref glyphLSB,
                                     ref glyphTSB,      // not used here
                                     ref glyphOffset,
                                     ref glyphLength,
                                     ref glyphComposite);

            //----------------------------------------------------------------//
            //                                                                //
            // Log character details.                                         //
            //                                                                //
            //----------------------------------------------------------------//

            ToolSoftFontGenLog.logCharDetails(_tableLog,
                                              false,
                                              glyphComposite,
                                              charCode,
                                              codepoint,
                                              glyphId,
                                              depth,
                                              glyphWidth,
                                              glyphHeight,
                                              glyphLSB,
                                              glyphTSB,
                                              glyphOffset,
                                              glyphLength);

            //----------------------------------------------------------------//
            //                                                                //
            // Calculate total size of header.                                //
            //                                                                //
            // Write PCL 'Character Code' escape sequence.                    //
            // Write PCL 'Character Definition' escape sequence.              //
            //                                                                //
            //----------------------------------------------------------------//

            charBlockSize = (UInt16)(cSizeCharHddr + cSizeCharGlyphHddr +
                                     glyphLength + cSizeCharTrail);

            PCLWriter.charDownloadCode(_binWriter, charCode);

            PCLWriter.charDownloadDesc(_binWriter, charBlockSize);

            //----------------------------------------------------------------//
            //                                                                //
            // Write Format 15 header.                                        //
            // This character format is used with both Format 15 and          //
            // Format 16 font headers.                                        //
            //                                                                //
            //----------------------------------------------------------------//

            charHddr[0] = 15;                   // Format = 15
            charHddr[1] = 0;                    // Continuation = false
            charHddr[2] = 2;                    // Descriptor size
            charHddr[3] = 15;                   // Class = 15

            _baseHandler.writeBuffer(cSizeCharHddr, charHddr);

            //----------------------------------------------------------------//
            //                                                                //
            // Write glyph header.                                            //
            // This counts towards the checksum recorded in the trailer.      //
            //                                                                //
            //----------------------------------------------------------------//

            checksumMod256 = 0;

            charDataSize = (UInt16)(cSizeCharGlyphHddr + glyphLength);

            charGlyphHddr[0] = msByte(charDataSize);
            charGlyphHddr[1] = lsByte(charDataSize);
            charGlyphHddr[2] = msByte(glyphId);
            charGlyphHddr[3] = lsByte(glyphId);

            _baseHandler.writeCharFragment(cSizeCharGlyphHddr,
                                           charGlyphHddr,
                                           ref checksumMod256);

            //----------------------------------------------------------------//
            //                                                                //
            // Write TrueType glyph data (copied from TrueType font file).    //
            // The data is read into a dynamically allocated buffer because:  //
            //    -  This avoids the complication of having a fixed-length    //
            //       buffer and a loop to read the data in chunks.            //
            //    -  Not having a static buffer allows the function to be     //
            //       called recursively.                                      //
            //                                                                //
            //----------------------------------------------------------------//

            if (glyphLength > 0)
            {
                Boolean flagOK = true;

                glyphData = new Byte[glyphLength];

                flagOK = _ttfHandler.readByteArray((Int32)glyphOffset,
                                                   (Int32)glyphLength,
                                                   ref glyphData);
                // TODO: what if flagOK = true (i.e. read fails?

                _baseHandler.writeCharFragment((Int32)glyphLength,
                                               glyphData,
                                               ref checksumMod256);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Write trailer (Reserved byte and Checksum byte).               //
            //                                                                //
            //----------------------------------------------------------------//

            checksumMod256 = (Byte)((256 - checksumMod256) % 256);

            charTrail[0] = 0;                   // Reserved byte
            charTrail[1] = checksumMod256;      // Checksum byte

            _baseHandler.writeBuffer(cSizeCharTrail, charTrail);

            //----------------------------------------------------------------//
            //                                                                //
            // Handler composite glyphs.                                      //
            //                                                                //
            //----------------------------------------------------------------//

            if (glyphComposite)
            {
                // if we move this to TTFHandler, do the maxGlyphId check there instead

                Int32 indBuf;

                UInt16 glyphCompFlags,
                       glyphCompId;

                indBuf = 10; // point to first set of component data //

                do
                {
                    glyphCompFlags = (UInt16)((glyphData[indBuf] << 8) +
                                              glyphData[indBuf + 1]);
                    glyphCompId = (UInt16)((glyphData[indBuf + 2] << 8) +
                                           glyphData[indBuf + 3]);

                    if (glyphCompId > maxGlyphId)
                    {
                        // flagOK = false;

                        ToolSoftFontGenLog.logError(
                            _tableLog, MessageBoxImage.Error,
                            "Composite glyph identifier " + glyphCompId +
                            " > maximum of " + maxGlyphId);
                    }
                    else
                    {
                        if (_ttfHandler.glyphReferencedCheck(glyphCompId))
                        {
                            ToolSoftFontGenLog.logCharDetails(
                                _tableLog,
                                true,
                                _ttfHandler.glyphCompositeCheck(glyphCompId),
                                0,
                                0,
                                glyphCompId,
                                depth,
                                0,
                                0,
                                0,
                                0,
                                0,
                                0);
                        }
                        else
                        {
                            // flagOK =
                            writeChar(0xffff, 0, glyphCompId,
                                      (UInt16)(depth + 1), maxGlyphId);
                        }
                    }

                    // if flagOK
                    {
                        indBuf += 4;

                        if ((glyphCompFlags &
                             ToolSoftFontGenTTF.mask_glyf_compFlag_ARG_1_AND_2_ARE_WORDS) != 0)
                        {
                            indBuf += 4;
                        }
                        else
                        {
                            indBuf += 2;
                        }

                        if ((glyphCompFlags &
                             ToolSoftFontGenTTF.mask_glyf_compFlag_WE_HAVE_A_TWO_BY_TWO) != 0)
                        {
                            indBuf += 8;
                        }
                        else if ((glyphCompFlags &
                                  ToolSoftFontGenTTF.mask_glyf_compFlag_WE_HAVE_AN_X_AND_Y_SCALE) != 0)
                        {
                            indBuf += 4;
                        }
                        else if ((glyphCompFlags &
                                  ToolSoftFontGenTTF.mask_glyf_compFlag_WE_HAVE_A_SCALE) != 0)
                        {
                            indBuf += 2;
                        }
                    }
                } while ((glyphCompFlags &
                          ToolSoftFontGenTTF.mask_glyf_compFlag_MORE_COMPONENTS) != 0);
            }
        }
Пример #21
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e O v e r l a y F r o n t                            //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write background data sequences for front overlay to output file.  //
        // Optionally top and tail these with macro definition sequences.     //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generateOverlayFront(BinaryWriter prnWriter,
                                                 Boolean formAsMacro,
                                                 Int16 macroId,
                                                 Single scaleFactor)
        {
            Int16 rectHeight = (Int16)(scaleFactor * (_unitsPerInch / 2));
            Int16 rectWidth  = (Int16)(scaleFactor * ((_unitsPerInch * 7) / 2));
            Int16 rectStroke = (Int16)(scaleFactor * (_unitsPerInch / 200));

            Int32 ptSizeHddr = (Int32)(scaleFactor * 24),
                  ptSizeMain = (Int32)(scaleFactor * 18),
                  ptSizeSub  = (Int32)(scaleFactor * 8);

            Int16 posX,
                  posY,
                  posYInc;

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, macroId,
                                       PCLWriter.eMacroControl.StartDef);
            }

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

            posYInc = (Int16)(scaleFactor * _posYIncMain);
            posX    = (Int16)((scaleFactor * _posXName) - _logPageOffset);
            posY    = (Int16)(scaleFactor * _posYHddr);

            PCLWriter.font(prnWriter, true,
                           "19U", "s1p" + ptSizeHddr + "v0s3b16602T");

            PCLWriter.text(prnWriter, posX, posY, 0, "Tray map test (PCL)");

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

            posY = (Int16)(scaleFactor * _posYDesc);

            PCLWriter.font(prnWriter, true, "", "s" + ptSizeMain + "V");

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

            posY += posYInc;
            PCLWriter.text(prnWriter, posX, posY, 0, "Paper Size:");

            posY += posYInc;
            PCLWriter.text(prnWriter, posX, posY, 0, "Paper Type:");

            posY += posYInc;
            PCLWriter.text(prnWriter, posX, posY, 0, "Plex Mode:");

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

            posY += posYInc;
            PCLWriter.text(prnWriter, posX, posY, 0, "PCL Tray ID:");

            posY += posYInc;
            PCLWriter.text(prnWriter, posX, posY, 0, "Printer Tray:");

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

            posX = (Int16)((scaleFactor * (_posXValue + _posXIncSub)) -
                           _logPageOffset);
            posY += (Int16)(scaleFactor * _posYIncSub);

            PCLWriter.font(prnWriter, true,
                           "19U", "s1p" + ptSizeSub + "v0s3b16602T");

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "record the tray name/number used in this box");

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

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

            PCLWriter.rectangleOutline(prnWriter, posX, posY,
                                       rectHeight, rectWidth, rectStroke,
                                       false, false);

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

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, macroId,
                                       PCLWriter.eMacroControl.StopDef);
            }
        }
Пример #22
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e J o b T r a i l e r                                //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write termination sequences to output file.                        //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generateJobTrailer(BinaryWriter prnWriter)
        {
            PCLWriter.stdJobTrailer(prnWriter, false, 0);
        }
Пример #23
0
        //--------------------------------------------------------------------//
        //                                                        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)
        {
            PCLWriter.stdJobHeader(prnWriter, "");
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // w r i t e H d d r                                                  //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate font header descriptor, segmented data and checksum byte. //
        //                                                                    //
        //--------------------------------------------------------------------//

        private Boolean writeHddr(ref Boolean monoSpaced,
                                  Boolean fmt16,
                                  Boolean segGTLast,
                                  Boolean usePCLT,
                                  Boolean glyphZeroExists,
                                  Boolean symSetUnbound,
                                  Boolean tabvmtxPresent,
                                  Boolean flagVMetrics,
                                  Byte symSetType,
                                  UInt16 firstCode,
                                  UInt16 lastCode,
                                  UInt16 numChars,
                                  UInt16 unitsPerEm,
                                  UInt16 symSet,
                                  UInt16 style,
                                  SByte strokeWeight,
                                  UInt16 typeface,
                                  UInt64 charCollComp,
                                  Byte [] conversionText)
        {
            Boolean flagOK = true;

            UInt16 cellWidth  = 0,
                   cellHeight = 0,
                   textWidth  = 0,
                   textHeight = 0,
                   pitch      = 0,
                   xHeight    = 0,
                   capHeight  = 0,
                   mUlinePosU = 0,
                   mUlineDep  = 0;

            Int16 mUlinePos = 0;

            UInt32 fontNo = 0;

            Int32 sum;
            Int32 convTextLen;
            Int32 hddrLen;

            Byte mod256;
            Byte serifStyle = 0;
            Byte fontFormat;
            Byte fontType;
            Byte fontSpacing;

            SByte widthType = 0;

            Byte [] fontNamePCLT = new Byte [ToolSoftFontGenTTF.cSizeFontname];
            Byte [] panoseData   = new Byte [ToolSoftFontGenTTF.cSizePanose];
            Byte [] hddrDesc     = new Byte [cSizeHddrDesc];

            //----------------------------------------------------------------//
            //                                                                //
            // Get relevant PCL data from TrueType font.                      //
            //                                                                //
            //----------------------------------------------------------------//

            monoSpaced = false;

            _ttfHandler.getPCLFontHeaderData(usePCLT,
                                             ref monoSpaced,
                                             ref cellWidth,
                                             ref cellHeight,
                                             ref textWidth,
                                             ref textHeight,
                                             ref pitch,
                                             ref xHeight,
                                             ref capHeight,
                                             ref mUlinePos,
                                             ref mUlineDep,
                                             ref fontNo,
                                             ref serifStyle,
                                             ref widthType,
                                             ref fontNamePCLT,
                                             ref panoseData);

            mUlinePosU = (UInt16)mUlinePos;

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

            if (fmt16)
            {
                fontFormat = 16;            // Format = Universal
            }
            else
            {
                fontFormat = 15;            // Format = TrueType scalable
            }
            if (monoSpaced)
            {
                fontSpacing = 0;            // Spacing = Fixed-pitch
            }
            else
            {
                fontSpacing = 1;            // Spacing = Proportional
            }
            if (symSetUnbound)
            {
                fontType  = 11;             // Type = unbound Unicode-indexed
                firstCode = 0;
                lastCode  = numChars;
            }
            else
            {
                fontType = symSetType;      // Type = as per target symbol set
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Calculate total size of header.                                //
            // Write PCL 'download header' escape sequence.                   //
            //                                                                //
            //----------------------------------------------------------------//

            convTextLen = conversionText.Length;

            hddrLen = cSizeHddrDesc +
                      _baseHandler.getHddrSegmentsLen(
                false,
                fmt16,
                glyphZeroExists,
                symSetUnbound,
                tabvmtxPresent,
                flagVMetrics,
                convTextLen) +
                      cSizeHddrTrail;

            if ((hddrLen > cSizeHddrFmt15Max) && (!fmt16))
            {
                flagOK = false;

                MessageBox.Show("Header length of '" + hddrLen +
                                "' is incompatible with 'format 15'" +
                                " font.",
                                "Soft font header invalid",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            else
            {
                PCLWriter.fontDownloadHddr(_binWriter, (UInt32)hddrLen);

                //------------------------------------------------------------//
                //                                                            //
                // Write font header descriptor.                              //
                //                                                            //
                //------------------------------------------------------------//

                hddrDesc [0] = msByte(cSizeHddrDesc);
                hddrDesc [1] = lsByte(cSizeHddrDesc);

                hddrDesc [2]  = fontFormat;               // Font Format
                hddrDesc [3]  = fontType;                 // Font Type
                hddrDesc [4]  = msByte(style);            // Style MSB
                hddrDesc [5]  = 0;                        // Reserved
                hddrDesc [6]  = 0;                        // Baseline Position MSB
                hddrDesc [7]  = 0;                        // Baseline Position LSB
                hddrDesc [8]  = msByte(cellWidth);        // Cell width MSB
                hddrDesc [9]  = lsByte(cellWidth);        // Cell Width LSB
                hddrDesc [10] = msByte(cellHeight);       // Cell Height MSB
                hddrDesc [11] = lsByte(cellHeight);       // Cell Height LSB
                hddrDesc [12] = 0;                        // Orientation
                hddrDesc [13] = fontSpacing;              // Spacing
                hddrDesc [14] = msByte(symSet);           // Symbol Set MSB
                hddrDesc [15] = lsByte(symSet);           // Symbol Set LSB
                hddrDesc [16] = msByte(pitch);            // Pitch MSB
                hddrDesc [17] = lsByte(pitch);            // Pitch LSB
                hddrDesc [18] = 0;                        // Height MSB
                hddrDesc [19] = 0;                        // Height LSB
                hddrDesc [20] = msByte(xHeight);          // xHeight MSB
                hddrDesc [21] = msByte(xHeight);          // xHeight LSB
                hddrDesc [22] = (Byte)widthType;          // Width Type
                hddrDesc [23] = lsByte(style);            // Style LSB
                hddrDesc [24] = (Byte)strokeWeight;       // Stroke Weight
                hddrDesc [25] = lsByte(typeface);         // Typeface LSB
                hddrDesc [26] = msByte(typeface);         // Typeface MSB
                hddrDesc [27] = serifStyle;               // Serif Style
                hddrDesc [28] = 2;                        // Quality = Letter
                hddrDesc [29] = 0;                        // Placement
                hddrDesc [30] = 0;                        // Underline Position
                hddrDesc [31] = 0;                        // Underline Thickness
                hddrDesc [32] = msByte(textHeight);       // Text Height MSB
                hddrDesc [33] = lsByte(textHeight);       // Text Height LSB
                hddrDesc [34] = msByte(textWidth);        // Text Width MSB
                hddrDesc [35] = lsByte(textWidth);        // Text Width LSB
                hddrDesc [36] = msByte(firstCode);        // First Code MSB
                hddrDesc [37] = lsByte(firstCode);        // First Code LSB
                hddrDesc [38] = msByte(lastCode);         // Last Code MSB
                hddrDesc [39] = lsByte(lastCode);         // Last Code LSB
                hddrDesc [40] = 0;                        // Pitch Extended
                hddrDesc [41] = 0;                        // Height Extended
                hddrDesc [42] = msByte(capHeight);        // Cap Height MSB
                hddrDesc [43] = lsByte(capHeight);        // Cap Height LSB
                hddrDesc [44] = msByte(msUInt16(fontNo)); // Font No. byte 0
                hddrDesc [45] = lsByte(msUInt16(fontNo)); // Font No. byte 1
                hddrDesc [46] = msByte(lsUInt16(fontNo)); // Font No. byte 2
                hddrDesc [47] = lsByte(lsUInt16(fontNo)); // Font No. byte 3
                hddrDesc [48] = fontNamePCLT [0];         // Font Name byte 0
                hddrDesc [49] = fontNamePCLT [1];         // Font Name byte 1
                hddrDesc [50] = fontNamePCLT [2];         // Font Name byte 2
                hddrDesc [51] = fontNamePCLT [3];         // Font Name byte 3
                hddrDesc [52] = fontNamePCLT [4];         // Font Name byte 4
                hddrDesc [53] = fontNamePCLT [5];         // Font Name byte 5
                hddrDesc [54] = fontNamePCLT [6];         // Font Name byte 6
                hddrDesc [55] = fontNamePCLT [7];         // Font Name byte 7
                hddrDesc [56] = fontNamePCLT [8];         // Font Name byte 8
                hddrDesc [57] = fontNamePCLT [9];         // Font Name byte 9
                hddrDesc [58] = fontNamePCLT [10];        // Font Name byte 10
                hddrDesc [59] = fontNamePCLT [11];        // Font Name byte 11
                hddrDesc [60] = fontNamePCLT [12];        // Font Name byte 12
                hddrDesc [61] = fontNamePCLT [13];        // Font Name byte 13
                hddrDesc [62] = fontNamePCLT [14];        // Font Name byte 14
                hddrDesc [63] = fontNamePCLT [15];        // Font Name byte 15
                hddrDesc [64] = msByte(unitsPerEm);       // Scale Factor MSB
                hddrDesc [65] = lsByte(unitsPerEm);       // Scale Factor LSB
                hddrDesc [66] = msByte(mUlinePosU);       // Master U-line Pos. MSB
                hddrDesc [67] = lsByte(mUlinePosU);       // Master U-line Pos. LSB
                hddrDesc [68] = msByte(mUlineDep);        // Master U-line Dep. MSB
                hddrDesc [69] = lsByte(mUlineDep);        // Master U-line Dep. LSB
                hddrDesc [70] = 1;                        // Scaling Tech. = TrueType
                hddrDesc [71] = 0;                        // Variety

                _baseHandler.writeBuffer(cSizeHddrDesc, hddrDesc);

                //------------------------------------------------------------//
                //                                                            //
                // Start calculating checksum byte from byte 64 onwards of    //
                // header.                                                    //
                //                                                            //
                //------------------------------------------------------------//

                sum = 0;

                for (Int32 i = 64; i < cSizeHddrDesc; i++)
                {
                    sum += hddrDesc [i];
                }

                mod256 = (Byte)(sum % 256);

                //------------------------------------------------------------//
                //                                                            //
                // Write header segmented data.                               //
                //                                                            //
                //------------------------------------------------------------//

                flagOK = _baseHandler.writeHddrSegments(false,
                                                        fmt16,
                                                        segGTLast,
                                                        glyphZeroExists,
                                                        symSetUnbound,
                                                        tabvmtxPresent,
                                                        flagVMetrics,
                                                        charCollComp,
                                                        conversionText,
                                                        panoseData,
                                                        ref mod256);

                if (flagOK)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Write 'reserved byte' and (calculated) checksum byte.  //
                    //                                                        //
                    //--------------------------------------------------------//

                    mod256 = (Byte)((256 - mod256) % 256);

                    Byte [] trailer = new Byte [cSizeHddrTrail];

                    trailer [0] = 0;
                    trailer [1] = mod256;

                    _baseHandler.writeBuffer(cSizeHddrTrail, trailer);
                }
            }

            return(flagOK);
        }
Пример #25
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);
                }
            }
        }
Пример #26
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e O v e r l a y                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write background data sequences to output file.                    //
        // Optionally top and tail these with macro (user-defined stream)     //
        // definition sequences.                                              //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generateOverlay(BinaryWriter prnWriter,
                                            Boolean formAsMacro,
                                            UInt16 logXOffset,
                                            Int32 indxPaperSize,
                                            Int32 indxOrientation)
        {
            Int16 posX,
                  posY;

            Int16 ptSize;

            Int16 boxX,
                  boxY,
                  boxHeight,
                  boxWidth;

            Int16 rectX,
                  rectY,
                  rectHeight,
                  rectWidth;

            Byte stroke = 1;

            //----------------------------------------------------------------//
            //                                                                //
            // Header                                                         //
            //                                                                //
            //----------------------------------------------------------------//

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, _macroId,
                                       PCLWriter.eMacroControl.StartDef);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Box.                                                           //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.Shading,
                                 60);

            boxX = (Int16)((_unitsPerInch / 2) - logXOffset);
            boxY = (Int16)(_unitsPerInch / 2);

            boxWidth  = (Int16)(_paperWidth - _unitsPerInch);
            boxHeight = (Int16)(_paperHeight - _unitsPerInch);

            PCLWriter.rectangleOutline(prnWriter, boxX, boxY,
                                       boxHeight, boxWidth, stroke,
                                       false, false);

            //----------------------------------------------------------------//
            //                                                                //
            // Text.                                                          //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.SolidBlack,
                                 0);

            ptSize = 15;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontCourier,
                                                     PCLFonts.eVariant.Bold,
                                                     ptSize, 0));

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

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "PCL imaging colour mode:");

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

            ptSize = 12;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontCourier,
                                                     PCLFonts.eVariant.Regular,
                                                     ptSize, 0));
            posY += _incInch / 2;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "Sample 4-colour palette:");

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

            posX = (Int16)(_posXDesc1 - logXOffset);
            posY = _posYDesc1;

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

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

            posX = (Int16)(_posXDesc2 - logXOffset);
            posY = _posYDesc2;

            posX = (Int16)(_posXDesc2 - logXOffset);

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

            posX += _colInc;

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

            posX += _colInc;

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

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

            posX = (Int16)(_posXDesc3 - logXOffset);
            posY = _posYDesc3;

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

            posX += _incInch;

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

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

            posX = (Int16)(_posXDesc4 - logXOffset);
            posY = _posYDesc4;

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

            posY += _lineInc;

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

            posY += _lineInc;

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

            posY += _lineInc;

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

            //----------------------------------------------------------------//
            //                                                                //
            // Background shade.                                              //
            //                                                                //
            //----------------------------------------------------------------//

            rectX      = (Int16)(_posXDesc2 - (_incInch / 4) - logXOffset);
            rectY      = _posYDesc2 + (_incInch / 4);
            rectWidth  = (_incInch * 17) / 4;
            rectHeight = (_incInch * 7) / 2;

            PCLWriter.rectangleShaded(prnWriter, rectX, rectY,
                                      rectHeight, rectWidth, 5,
                                      false, false);

            //----------------------------------------------------------------//
            //                                                                //
            // Overlay end.                                                   //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.patternSet(prnWriter,
                                 PCLWriter.ePatternType.SolidBlack,
                                 0);

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, 0,
                                       PCLWriter.eMacroControl.StopDef);
            }
        }
Пример #27
0
        //--------------------------------------------------------------------//
        //                                                        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 indxPaperSize,
            Int32 indxPaperType,
            Int32 indxOrientation,
            Int32 indxPlexMode,
            Boolean flagSimplexJob,
            Boolean flagMainEncapsulated,
            Boolean flagRearEncapsulated,
            Boolean flagMacroRemove,
            Boolean flagMainForm,
            Boolean flagRearForm,
            Boolean flagMainOnPrnDisk,
            Boolean flagRearOnPrnDisk,
            String formFileMain,
            String formFileRear,
            eMacroMethod indxMethod,
            Int32 macroIdMain,
            Int32 macroIdRear)
        {
            PCLWriter.stdJobHeader(prnWriter, "");

            if (flagMainForm)
            {
                //------------------------------------------------------------//
                //                                                            //
                // Main (or only) form in use.                                //
                //                                                            //
                //------------------------------------------------------------//

                if (flagMainOnPrnDisk)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Associate macro identifier with specified file held on //
                    // printer hard disk.                                     //
                    //                                                        //
                    // Make macro 'permanent' if remove flag not specified.   //
                    // Note that this doesn't appear to work with identifiers //
                    // associated with printer disk files, but we'll leave it //
                    // in anyway, in case it works on some devices.           //
                    //                                                        //
                    //--------------------------------------------------------//

                    PCLWriter.macroFileIdAssociate(prnWriter,
                                                   (UInt16)macroIdMain,
                                                   formFileMain);

                    if (!flagMacroRemove)
                    {
                        PCLWriter.macroControl(
                            prnWriter,
                            (Int16)macroIdMain,
                            PCLWriter.eMacroControl.MakePermanent);
                    }
                }
                else
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Download contents of specified file.                   //
                    //                                                        //
                    //--------------------------------------------------------//

                    if (!flagMainEncapsulated)
                    {
                        PCLWriter.macroControl(prnWriter,
                                               (Int16)macroIdMain,
                                               PCLWriter.eMacroControl.StartDef);
                    }

                    PCLDownloadMacro.macroFileCopy(prnWriter, formFileMain);

                    if (!flagMainEncapsulated)
                    {
                        PCLWriter.macroControl(prnWriter,
                                               (Int16)macroIdMain,
                                               PCLWriter.eMacroControl.StopDef);
                    }

                    if (!flagMacroRemove)
                    {
                        PCLWriter.macroControl(
                            prnWriter,
                            (Int16)macroIdMain,
                            PCLWriter.eMacroControl.MakePermanent);
                    }
                }
            }

            if (!flagSimplexJob)
            {
                if (flagRearForm)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Rear form in use.                                      //
                    //                                                        //
                    //--------------------------------------------------------//

                    if (flagRearOnPrnDisk)
                    {
                        //----------------------------------------------------//
                        //                                                    //
                        // Associate macro identifier with specified file     //
                        // held on printer hard disk.                         //
                        //                                                    //
                        // Make macro 'permanent' if remove flag not          //
                        // specified.                                         //
                        // Note that this doesn't appear to work with         //
                        // identifiers associated with printer disk files,    //
                        // but we'll leave it in anyway, in case it works on  //
                        // some devices.                                      //
                        //                                                    //
                        //----------------------------------------------------//

                        PCLWriter.macroFileIdAssociate(prnWriter,
                                                       (UInt16)macroIdRear,
                                                       formFileRear);

                        if (!flagMacroRemove)
                        {
                            PCLWriter.macroControl(
                                prnWriter,
                                (Int16)macroIdRear,
                                PCLWriter.eMacroControl.MakePermanent);
                        }
                    }
                    else
                    {
                        //----------------------------------------------------//
                        //                                                    //
                        // Download contents of specified file.               //
                        //                                                    //
                        //----------------------------------------------------//

                        if (!flagRearEncapsulated)
                        {
                            PCLWriter.macroControl(
                                prnWriter,
                                (Int16)macroIdRear,
                                PCLWriter.eMacroControl.StartDef);
                        }

                        PCLDownloadMacro.macroFileCopy(prnWriter, formFileRear);

                        if (!flagRearEncapsulated)
                        {
                            PCLWriter.macroControl(
                                prnWriter,
                                (Int16)macroIdRear,
                                PCLWriter.eMacroControl.StopDef);
                        }

                        if (!flagMacroRemove)
                        {
                            PCLWriter.macroControl(
                                prnWriter,
                                (Int16)macroIdRear,
                                PCLWriter.eMacroControl.MakePermanent);
                        }
                    }
                }
            }
        }
Пример #28
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,
                                         UInt16 logXOffset)
        {
            Int16 posX,
                  posY,
                  rectX,
                  rectY,
                  rectHeight,
                  rectWidth;

            Int16 ptSize;

            Int32 temp;

            Byte [] palette_0 = new Byte[3],
            palette_1 = new Byte[3],
            palette_2 = new Byte[3],
            palette_3 = new Byte[3];

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

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

            rectHeight = (Int16)(_lineInc / 2);
            rectWidth  = _lineInc;

            //----------------------------------------------------------------//
            //                                                                //
            // Set pattern transparency to Opaque so that white samples show  //
            // on the shaded background.                                      //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.patternTransparency(prnWriter,
                                          true);

            //----------------------------------------------------------------//
            //                                                                //
            // Colour definitions.                                            //
            //                                                                //
            //----------------------------------------------------------------//

            temp = sampleDef [0];

            palette_0 [2] = (Byte)(temp & 0xff);
            temp          = temp >> 8;
            palette_0 [1] = (Byte)(temp & 0xff);
            temp          = temp >> 8;
            palette_0 [0] = (Byte)(temp & 0xff);

            temp = sampleDef [1];

            palette_1 [2] = (Byte)(temp & 0xff);
            temp          = temp >> 8;
            palette_1 [1] = (Byte)(temp & 0xff);
            temp          = temp >> 8;
            palette_1 [0] = (Byte)(temp & 0xff);

            temp = sampleDef [2];

            palette_2 [2] = (Byte)(temp & 0xff);
            temp          = temp >> 8;
            palette_2 [1] = (Byte)(temp & 0xff);
            temp          = temp >> 8;
            palette_2 [0] = (Byte)(temp & 0xff);

            temp = sampleDef [3];

            palette_3 [2] = (Byte)(temp & 0xff);
            temp          = temp >> 8;
            palette_3 [1] = (Byte)(temp & 0xff);
            temp          = temp >> 8;
            palette_3 [0] = (Byte)(temp & 0xff);

            //----------------------------------------------------------------//
            //                                                                //
            // Write details.                                                 //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize = 12;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontCourier,
                                                     PCLFonts.eVariant.Regular,
                                                     ptSize, 0));

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

            posX = (Int16)(_posXDesc4 - logXOffset);
            posY = _posYDesc4;

            posX += _incInch;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "0x" +
                           palette_0 [0].ToString("x2") +
                           palette_0 [1].ToString("x2") +
                           palette_0 [2].ToString("x2"));

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "0x" +
                           palette_1 [0].ToString("x2") +
                           palette_1 [1].ToString("x2") +
                           palette_1 [2].ToString("x2"));

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "0x" +
                           palette_2 [0].ToString("x2") +
                           palette_2 [1].ToString("x2") +
                           palette_2 [2].ToString("x2"));

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "0x" +
                           palette_3 [0].ToString("x2") +
                           palette_3 [1].ToString("x2") +
                           palette_3 [2].ToString("x2"));

            //----------------------------------------------------------------//
            //                                                                //
            // RGB colour space.                                              //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.configureImageData(prnWriter,
                                         0,     // colour space = RGB
                                         1,     // PEM = Direct-by-pixel
                                         2,     // 2 bitsPerindex -> 4 colours
                                         8,     // bits per component - ignored
                                         8,     // bits per component - ignored
                                         8);    // bits per component - ignored

            PCLWriter.paletteEntry(prnWriter,
                                   0,
                                   palette_0 [0], palette_0 [1], palette_0 [2]);

            PCLWriter.paletteEntry(prnWriter,
                                   1,
                                   palette_1 [0], palette_1 [1], palette_1 [2]);

            PCLWriter.paletteEntry(prnWriter,
                                   2,
                                   palette_2 [0], palette_2 [1], palette_2 [2]);

            PCLWriter.paletteEntry(prnWriter,
                                   3,
                                   palette_3 [0], palette_3 [1], palette_3 [2]);

            posX = (Int16)(_posXData - logXOffset);
            posY = _posYData;

            rectX = posX;
            rectY = posY;

            PCLWriter.setForegroundColour(prnWriter, 0);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectY += _lineInc;

            PCLWriter.setForegroundColour(prnWriter, 1);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectY += _lineInc;

            PCLWriter.setForegroundColour(prnWriter, 2);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectY += _lineInc;

            PCLWriter.setForegroundColour(prnWriter, 3);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            //----------------------------------------------------------------//
            //                                                                //
            // CMY colour space.                                              //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.configureImageData(prnWriter,
                                         1,     // colour space = CMY
                                         1,     // PEM = Direct-by-pixel
                                         2,     // 2 bitsPerindex -> 4 colours
                                         8,     // bits per component - ignored
                                         8,     // bits per component - ignored
                                         8);    // bits per component - ignored

            PCLWriter.paletteEntry(prnWriter,
                                   0,
                                   palette_0[0], palette_0[1], palette_0[2]);

            PCLWriter.paletteEntry(prnWriter,
                                   1,
                                   palette_1[0], palette_1[1], palette_1[2]);

            PCLWriter.paletteEntry(prnWriter,
                                   2,
                                   palette_2[0], palette_2[1], palette_2[2]);

            PCLWriter.paletteEntry(prnWriter,
                                   3,
                                   palette_3[0], palette_3[1], palette_3[2]);

            posX += _colInc;

            rectX = posX;
            rectY = posY;

            PCLWriter.setForegroundColour(prnWriter, 0);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectY += _lineInc;

            PCLWriter.setForegroundColour(prnWriter, 1);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectY += _lineInc;

            PCLWriter.setForegroundColour(prnWriter, 2);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectY += _lineInc;

            PCLWriter.setForegroundColour(prnWriter, 3);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            //----------------------------------------------------------------//
            //                                                                //
            // SRGB colour space.                                             //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.configureImageData(prnWriter,
                                         2,     // colour space = SRGB
                                         1,     // PEM = Direct-by-pixel
                                         2,     // 2 bitsPerindex -> 4 colours
                                         8,     // bits per component - ignored
                                         8,     // bits per component - ignored
                                         8);    // bits per component - ignored

            PCLWriter.paletteEntry(prnWriter,
                                   0,
                                   palette_0[0], palette_0[1], palette_0[2]);

            PCLWriter.paletteEntry(prnWriter,
                                   1,
                                   palette_1[0], palette_1[1], palette_1[2]);

            PCLWriter.paletteEntry(prnWriter,
                                   2,
                                   palette_2[0], palette_2[1], palette_2[2]);

            PCLWriter.paletteEntry(prnWriter,
                                   3,
                                   palette_3[0], palette_3[1], palette_3[2]);

            posX += _colInc;

            rectX = posX;
            rectY = posY;

            PCLWriter.setForegroundColour(prnWriter, 0);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectY += _lineInc;

            PCLWriter.setForegroundColour(prnWriter, 1);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectY += _lineInc;

            PCLWriter.setForegroundColour(prnWriter, 2);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

            rectY += _lineInc;

            PCLWriter.setForegroundColour(prnWriter, 3);

            PCLWriter.rectangleSolid(prnWriter, rectX, rectY,
                                     rectHeight, rectWidth, false,
                                     false, false);

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

            PCLWriter.formFeed(prnWriter);
        }
Пример #29
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e S y m S e t                                        //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate symbol set definition.                                    //
        //                                                                    //
        //--------------------------------------------------------------------//

        public Boolean generateSymSet(ref String symSetFilename,
                                      Boolean flagIgnoreC0,
                                      Boolean flagIgnoreC1,
                                      UInt16 symSetNo,
                                      UInt16 codeMin,
                                      UInt16 codeMax,
                                      UInt64 charCollReq,
                                      UInt16 [] symSetMap,
                                      PCLSymSetTypes.eIndex symSetType)
        {
            Boolean flagOK = true;

            //----------------------------------------------------------------//
            //                                                                //
            // Open print file and stream.                                    //
            //                                                                //
            //----------------------------------------------------------------//

            try
            {
                streamOpen(ref symSetFilename,
                           ref _binWriter,
                           ref _opStream);
            }

            catch (Exception exc)
            {
                flagOK = false;

                MessageBox.Show(exc.ToString(),
                                "Failure to open symbol set file",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }

            if (flagOK)
            {
                //------------------------------------------------------------//
                //                                                            //
                // Generate symbol set file contents.                         //
                //                                                            //
                //------------------------------------------------------------//

                try
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Write symbol set identifier sequence.                  //
                    //                                                        //
                    //--------------------------------------------------------//

                    PCLWriter.symSetDownloadCode(_binWriter,
                                                 (UInt16)symSetNo);

                    //--------------------------------------------------------//
                    //                                                        //
                    // Write symbol set descriptor header.                    //
                    //                                                        //
                    //--------------------------------------------------------//

                    writeHddr(symSetNo, codeMin, codeMax, charCollReq,
                              PCLSymSetTypes.getIdPCL((Int32)symSetType));

                    //--------------------------------------------------------//
                    //                                                        //
                    // Write symbol set map data.                             //
                    //                                                        //
                    //--------------------------------------------------------//

                    writeMapData(flagIgnoreC1, codeMin, codeMax, symSetMap);

                    //--------------------------------------------------------//
                    //                                                        //
                    // Write symbol set save sequence.                        //
                    //                                                        //
                    //--------------------------------------------------------//

                    PCLWriter.symSetDownloadSave(_binWriter, true);

                    //--------------------------------------------------------//
                    //                                                        //
                    // Close streams and files.                               //
                    //                                                        //
                    //--------------------------------------------------------//

                    _binWriter.Close();
                    _opStream.Close();
                }

                catch (Exception exc)
                {
                    flagOK = false;

                    MessageBox.Show(exc.ToString(),
                                    "Failure to write symbol set file",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }

            return(flagOK);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e O v e r l a y                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write background data sequences to output file.                    //
        // Optionally top and tail these with macro (user-defined stream)     //
        // definition sequences.                                              //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generateOverlay(BinaryWriter prnWriter,
                                            Boolean formAsMacro,
                                            UInt16 paperWidth,
                                            UInt16 paperLength,
                                            UInt16 logXOffset)
        {
            Int16 rulerWidth;
            Int16 rulerHeight;

            Int16 rulerCellsX;
            Int16 rulerCellsY;

            Int16 posX,
                  posY;

            Int16 lineInc,
                  ptSize;

            Int16 stroke = 1;

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

            rulerCellsX = (Int16)((paperWidth / _unitsPerInch) + 1);
            rulerCellsY = (Int16)((paperLength / _unitsPerInch) + 1);
            rulerWidth  = (Int16)(rulerCellsX * _unitsPerInch);
            rulerHeight = (Int16)(rulerCellsY * _unitsPerInch);

            //----------------------------------------------------------------//
            //                                                                //
            // Header                                                         //
            //                                                                //
            //----------------------------------------------------------------//

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, _macroId,
                                       PCLWriter.eMacroControl.StartDef);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Horizontal ruler.                                              //
            //                                                                //
            //----------------------------------------------------------------//

            posX = 0;
            posY = _rulerHOriginY;

            PCLWriter.lineHorizontal(prnWriter, posX, posY, rulerWidth, stroke);

            posY -= (_rulerDiv / 2);

            for (Int32 i = 0; i < rulerCellsX; i++)
            {
                PCLWriter.lineVertical(prnWriter, posX, posY,
                                       _rulerDiv * 2, stroke);

                posX += _rulerDiv;

                for (Int32 j = 1; j < _rulerDivPerCell; j++)
                {
                    PCLWriter.lineVertical(prnWriter, posX, posY,
                                           _rulerDiv, stroke);

                    posX += _rulerDiv;
                }
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Vertical ruler.                                                //
            //                                                                //
            //----------------------------------------------------------------//

            posX = _rulerVOriginX;
            posY = 0;

            PCLWriter.lineVertical(prnWriter, posX, posY, rulerHeight, stroke);

            posX -= (_rulerDiv / 2);

            for (Int32 i = 0; i < rulerCellsY; i++)
            {
                PCLWriter.lineHorizontal(prnWriter, posX, posY,
                                         _rulerDiv * 2, stroke);

                posY += _rulerDiv;

                for (Int32 j = 1; j < _rulerDivPerCell; j++)
                {
                    PCLWriter.lineHorizontal(prnWriter, posX, posY,
                                             _rulerDiv, stroke);

                    posY += _rulerDiv;
                }
            }

            //----------------------------------------------------------------//
            //                                                                //
            // Left logical page margin - vertical line.                      //
            //                                                                //
            //----------------------------------------------------------------//

            PCLWriter.lineVertical(prnWriter, 0, 0,
                                   rulerHeight, stroke);

            //----------------------------------------------------------------//
            //                                                                //
            // Text.                                                          //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize  = 10;
            lineInc = (_rulerDiv * 2);

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

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

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

            posY += lineInc;

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

            posY += lineInc;

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

            posY += lineInc;

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

            posY += lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "Logical page left offset:");

            posY += lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "Logical page top offset:");

            posY += lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "Logical page width:");

            posY += lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "Logical page height:");

            //----------------------------------------------------------------//
            //                                                                //
            // Overlay end.                                                   //
            //                                                                //
            //----------------------------------------------------------------//

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, 0, PCLWriter.eMacroControl.StopDef);
            }
        }