Beispiel #1
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e P a g e                                            //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write individual test data page sequences to output file.          //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generatePage(BinaryWriter prnWriter,
                                         Int32 indxPaperSize,
                                         Int32 indxPaperType,
                                         Int32 indxOrientation,
                                         Boolean formAsMacro,
                                         UInt32 codePoint,
                                         Int32 indxFont,
                                         PCLFonts.eVariant fontVar)
        {
            const Int32 sizeStd = 1024;

            Byte[] bufStd = new Byte[sizeStd];

            UInt16[] textArray = { 0x00 };

            Int16 posX,
                  posY;

            Int32 indStd;

            Int16 ptSize;

            Byte[] utf8Seq = new Byte[4];
            Int32  utf8Len = 0;

            String utf8HexVal = "";

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

            indStd = 0;

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

            if (indxOrientation < PCLOrientations.getCount())
            {
                PCLXLWriter.addAttrUbyte(ref bufStd,
                                         ref indStd,
                                         PCLXLAttributes.eTag.Orientation,
                                         PCLOrientations.getIdPCLXL(indxOrientation));
            }

            if (indxPaperSize < PCLPaperSizes.getCount())
            {
                PCLXLWriter.addAttrUbyte(ref bufStd,
                                         ref indStd,
                                         PCLXLAttributes.eTag.MediaSize,
                                         PCLPaperSizes.getIdPCLXL(indxPaperSize));
            }

            if ((indxPaperType < PCLPaperTypes.getCount()) &&
                (PCLPaperTypes.getType(indxPaperType) !=
                 PCLPaperTypes.eEntryType.NotSet))
            {
                PCLXLWriter.addAttrUbyteArray(ref bufStd,
                                              ref indStd,
                                              PCLXLAttributes.eTag.MediaType,
                                              PCLPaperTypes.getName(indxPaperType));
            }

            PCLXLWriter.addAttrUbyte(ref bufStd,
                                     ref indStd,
                                     PCLXLAttributes.eTag.SimplexPageMode,
                                     (Byte)PCLXLAttrEnums.eVal.eSimplexFrontSide);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.BeginPage);

            PCLXLWriter.addAttrUint16XY(ref bufStd,
                                        ref indStd,
                                        PCLXLAttributes.eTag.PageOrigin,
                                        0, 0);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.SetPageOrigin);

            PCLXLWriter.addAttrUbyte(ref bufStd,
                                     ref indStd,
                                     PCLXLAttributes.eTag.ColorSpace,
                                     (Byte)PCLXLAttrEnums.eVal.eGray);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.SetColorSpace);

            prnWriter.Write(bufStd, 0, indStd);
            indStd = 0;

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

            if (formAsMacro)
            {
                PCLXLWriter.addAttrUbyteArray(ref bufStd,
                                              ref indStd,
                                              PCLXLAttributes.eTag.StreamName,
                                              _formName);

                PCLXLWriter.addOperator(ref bufStd,
                                        ref indStd,
                                        PCLXLOperators.eTag.ExecStream);

                prnWriter.Write(bufStd, 0, indStd);
                indStd = 0;
            }
            else
            {
                generateOverlay(prnWriter, false,
                                indxPaperSize, indxOrientation);
            }

            prnWriter.Write(bufStd, 0, indStd);

            indStd = 0;


            //----------------------------------------------------------------//
            //                                                                //
            // Code-point data.                                               //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize = 18;

            PCLXLWriter.font(prnWriter, false, ptSize,
                             _symSet_19U, _fontNameArial);

            PCLXLWriter.addAttrUbyte(ref bufStd,
                                     ref indStd,
                                     PCLXLAttributes.eTag.GrayLevel,
                                     0);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.SetBrushSource);

            PCLXLWriter.addAttrUbyte(ref bufStd,
                                     ref indStd,
                                     PCLXLAttributes.eTag.NullPen,
                                     0);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.SetPenSource);

            posX = _posXData;
            posY = _posYData;

            if (codePoint < 0x010000)
            {
                PCLXLWriter.text(prnWriter, false, false,
                                 PCLXLWriter.advances_ArialRegular, ptSize,
                                 posX, posY,
                                 "U+" + codePoint.ToString("x4"));
            }
            else
            {
                // should not happen 'cos XL only supports 16-bit values !
                PCLXLWriter.text(prnWriter, false, false,
                                 PCLXLWriter.advances_ArialRegular, ptSize,
                                 posX, posY,
                                 "U+" + codePoint.ToString("x6"));
            }

            PrnParseDataUTF8.convertUTF32ToUTF8Bytes(codePoint,
                                                     ref utf8Len,
                                                     ref utf8Seq);

            PrnParseDataUTF8.convertUTF32ToUTF8HexString(codePoint,
                                                         true,
                                                         ref utf8HexVal);

            posY += _lineInc;

            PCLXLWriter.text(prnWriter, false, false,
                             PCLXLWriter.advances_ArialRegular, ptSize,
                             posX, posY,
                             utf8HexVal);

            //----------------------------------------------------------------//
            //                                                                //
            // Font data.                                                     //
            //                                                                //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLXLWriter.text(prnWriter, false, false,
                             PCLXLWriter.advances_ArialRegular, ptSize,
                             posX, posY,
                             PCLFonts.getName(indxFont) +
                             " " +
                             Enum.GetName(typeof(PCLFonts.eVariant), fontVar));

            posY += _lineInc;

            ptSize = 36;

            PCLXLWriter.font(prnWriter, false, ptSize,
                             _symSet_18N,
                             PCLFonts.getPCLXLName(indxFont,
                                                   fontVar));

            textArray[0] = (UInt16)codePoint;

            PCLXLWriter.textChar(prnWriter, false,
                                 0,           // ***** dummy value *****
                                 ptSize,
                                 posX, posY,
                                 (UInt16)codePoint);

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

            PCLXLWriter.addAttrUint16(ref bufStd,
                                      ref indStd,
                                      PCLXLAttributes.eTag.PageCopies,
                                      1);

            PCLXLWriter.addOperator(ref bufStd,
                                    ref indStd,
                                    PCLXLOperators.eTag.EndPage);

            prnWriter.Write(bufStd, 0, indStd);
        }