Exemple #1
0
        public PrinterHint GetHeader(int pagewidth,string text)
        {
            int captionHeight = 45;
            Font font = new Font("����",20);
            Graphics g=this.button1.CreateGraphics();
            int height=(int)g.MeasureString(text, font).Height;
            int width = (int)g.MeasureString(text, font).Width;
            g.Dispose();
            PrinterHint header = new PrinterHint();
            header.Rectangle = new Rectangle(0, 0, pagewidth, height + captionHeight+12);
            header.PrintInEveryPage = true;
            header.Border = BordersEdgeStyle.None;
            TitleDraw title = new TitleDraw(text);
            title.Font = font;
            title.Rectangle = new Rectangle((pagewidth-width)/2, 0, width, height);
            title.Border = BordersEdgeStyle.Bottom;

            TitleDraw line = new TitleDraw("");
            line.Rectangle = new Rectangle((pagewidth - width) / 2, 2, width, height);
            line.Border = BordersEdgeStyle.Bottom;
            header.Add(title);
            header.Add(line);

            StringFormat sf = new StringFormat();
            sf.LineAlignment = StringAlignment.Far;
            Font cap = new Font("����", 14);
            TextDraw header2 = new TextDraw("��ѵ��λ��                �������ͣ�          �������ڣ�      ��   ��   ��");
            header2.Formater = sf;
            header2.Font = cap;
            header2.Rectangle = new Rectangle(0, height + 7, pagewidth, captionHeight);

            header2.Border = BordersEdgeStyle.None;
            CompanyInfo compInfo = StaticCacheManager.GetConfig<CompanyInfo>();

            TextDraw comp = new TextDraw(compInfo.NickName);
             comp.Formater = sf;
             comp.Font = cap;
             comp.Rectangle = new Rectangle(100, height + 7, 200, captionHeight);
            comp.Border = BordersEdgeStyle.None;
            header.Add(comp);
            header.Add(header2);
            return header;
        }
Exemple #2
0
        public PrinterHint GetFooter(int pageWidth)
        {
            Font font = new Font("����",15);

            PrinterHint footer = new PrinterHint();
            footer.Border = BordersEdgeStyle.None;
            footer.Rectangle = new Rectangle(-2, 0, pageWidth+2, 147);
            /*��ʱ�򲻴��߳���*/
            //RecetangleDraw outer = new RecetangleDraw();
            TextDraw outer = new TextDraw(" ");
            outer.Font = font;
            outer.Border = BordersEdgeStyle.All;
            outer.Rectangle = new Rectangle(-1, 0, pageWidth +2, 3 * 34);

            TextDraw inner = new TextDraw(" ");
            inner.Font = font;
            inner.Border = BordersEdgeStyle.All;
            //RecetangleDraw inner = new RecetangleDraw();
            inner.Rectangle = new Rectangle(2, 3, pageWidth -4, 3 * 34-5);
            /*��ʱ�򲻴��߳���*/
            footer.Add(outer);
            footer.Add(inner);

            StringFormat sf = new StringFormat();
            sf.LineAlignment = StringAlignment.Center;
            sf.Alignment = StringAlignment.Center;

            TextDraw txt1 = new TextDraw("����Ա");
            txt1.Font = font;
            txt1.Rectangle = new Rectangle(2, 3, footerWidth, footer1Height);
            txt1.Border = BordersEdgeStyle.Right;
            txt1.Formater = sf;
            footer.Add(txt1);

            TextDraw txt2 = new TextDraw("ǩ��");
            txt2.Font = font;
            txt2.Rectangle = new Rectangle(2, footer1Height+3, footerWidth, footer1Height);
            txt2.Border = BordersEdgeStyle.Right;
            txt2.Formater = sf;
            footer.Add(txt2);

            RecetangleDraw space1 = new RecetangleDraw();
            space1.Rectangle = new Rectangle(2 + footerWidth, 3, spaceWidth, 2 * footer1Height);
            space1.Border = BordersEdgeStyle.Right;
            footer.Add(space1);

            TextDraw txt3 = new TextDraw("����Ա");
            txt3.Font = font;
            txt3.Rectangle = new Rectangle(2 + spaceWidth + footerWidth, 3, footerWidth, footer1Height);
            txt3.Border = BordersEdgeStyle.Right;
            txt3.Formater = sf;
            footer.Add(txt3);

            TextDraw txt4 = new TextDraw("ǩ��");
            txt4.Font = font;
            txt4.Rectangle = new Rectangle(2 + spaceWidth + footerWidth, footer1Height + 3, footerWidth, footer1Height);
            txt4.Border = BordersEdgeStyle.Right;
            txt4.Formater = sf;
            footer.Add(txt4);

            RecetangleDraw space2 = new RecetangleDraw();
            space2.Rectangle = new Rectangle(2 + 2 * footerWidth + spaceWidth, 3, spaceWidth, 2 * footer1Height);
            space2.Border = BordersEdgeStyle.Right;
            footer.Add(space2);

            TextDraw txt5 = new TextDraw("����Ա");
            txt5.Font = font;
            txt5.Rectangle = new Rectangle(2 + 2 * (spaceWidth + footerWidth), 3, footerWidth, footer1Height);
            txt5.Border = BordersEdgeStyle.Right;
            txt5.Formater = sf;
            footer.Add(txt5);

            TextDraw txt6 = new TextDraw("ǩ��");
            txt6.Font = font;
            txt6.Rectangle = new Rectangle(2 + 2 * (spaceWidth + footerWidth), footer1Height + 3, footerWidth, footer1Height);
            txt6.Border = BordersEdgeStyle.Right;
            txt6.Formater = sf;
            footer.Add(txt6);

            RecetangleDraw space3 = new RecetangleDraw();
            space3.Rectangle = new Rectangle(2 + 3 * footerWidth + 2 * spaceWidth, 3, spaceWidth - 10, footer1Height*2);
            space3.Border = BordersEdgeStyle.Right;
            footer.Add(space3);

            TextDraw txt7 = new TextDraw("�����");
            txt7.Font = font;
            txt7.Rectangle = new Rectangle(2 + 3 * (spaceWidth + footerWidth) - 10, 3, footerWidth - 6, footer1Height*2);
            txt7.Border = BordersEdgeStyle.Right;
            txt7.Formater = sf;
            footer.Add(txt7);

            TextDraw txt8 = new TextDraw("����������_______");
            txt8.Font = font;
            txt8.Rectangle = new Rectangle(2, 3 + 2*footer1Height, footerWidth2, 45);
            footer.Add(txt8);

            TextDraw txt9 = new TextDraw("�ϸ�������_______");
            txt9.Font = font;
            txt9.Rectangle = new Rectangle(2 + footerWidth2, 3 + 2 * footer1Height, footerWidth2, 45);
            footer.Add(txt9);

            TextDraw txt10 = new TextDraw("���ϸ�������_____");
            txt10.Font = font;
            txt10.Rectangle = new Rectangle(2 + 2 * footerWidth2, 3 + 2 * footer1Height, footerWidth2, 45);
            footer.Add(txt10);

            TextDraw txt11 = new TextDraw("ȱ��������______");
            txt11.Font = font;
            txt11.Rectangle = new Rectangle(2 + 3 * footerWidth2, 3 + 2 * footer1Height, pageWidth - 4 - 3 * footerWidth2, 45);
            footer.Add(txt11);

            TextDraw text = new TextDraw("   ע���˱���д��ȫ�������������д����Ϳ����Ч��");
            text.Border = BordersEdgeStyle.None;

            text.Font = font;
            text.Rectangle = new Rectangle(0, 102, pageWidth, 40);
            footer.Add(text);
            footer.PrintInEveryPage = true;
            return footer;
        }
        protected virtual PrinterHint BuildHeader()
        {
            StringFormat sf = new StringFormat();
            sf.LineAlignment = StringAlignment.Far;
            sf.Alignment = StringAlignment.Far;

            StringFormat sf2 = new StringFormat();
            sf2.LineAlignment = StringAlignment.Center;
            sf2.Alignment = StringAlignment.Center;

            CompanyInfo comp = StaticCacheManager.GetConfig<CompanyInfo>();

            int pagewidth = customMargin.Width;
            int captionHeight = 70;
            Font font = new Font("����", 20);
            Font cap = new Font("����", 14);
            int height = 25;
            PrinterHint header = new PrinterHint();
            header.Rectangle = new Rectangle(0, 0, pagewidth, height + captionHeight + 12);
            header.PrintInEveryPage = false;
            header.Border = BordersEdgeStyle.None;
            //��ӡ��λ����
            TitleDraw title = new TitleDraw(comp.NickName+" "+System.DateTime.Now.ToShortDateString());
            title.Font = cap;
            title.Rectangle = new Rectangle(0, 0, pagewidth, height);
            title.Border = BordersEdgeStyle.None;
            title.Formater = sf;
            //��ӡ������
            TitleDraw titleMain = new TitleDraw(this.headerTitle);
            titleMain.Font = font;
            titleMain.Rectangle = new Rectangle(0, height, pagewidth, captionHeight);
            titleMain.Border = BordersEdgeStyle.None;
            titleMain.Formater = sf2;
            header.Add(title);
            header.Add(titleMain);
            return header;
        }