谢谢

解决方案 »

  1.   

    继承printDoucment重载
    public class PersonalReportPrint: PrintDocument
    protected override void OnPrintPage(PrintPageEventArgs e)
    {
    base.OnPrintPage(e);
    float left =0;
    float top =0;
    float width =0;
    float height =0;
    float leftMargin =e.MarginBounds.Left;
    float topMargin =e.MarginBounds.Top;
    float rightMargin =e.MarginBounds.Right;
    float bottomMargin =e.MarginBounds.Bottom;
    float HeightEnglishFont =englishFont.GetHeight(e.Graphics);
    float HeightChineseFont =chineseFont.GetHeight(e.Graphics);
    float HeightTitleFont1 =titleFont1.GetHeight(e.Graphics);
    float HeightTitleFont2 =titleFont2.GetHeight(e.Graphics);
    float addHeight =10;
    float addHeightText =6;
    float addWidth =6;
    StringFormat stringFormatCenter =new StringFormat();
    stringFormatCenter.Alignment =StringAlignment.Center;
    stringFormatCenter.LineAlignment =StringAlignment.Center;
    StringFormat stringFormatNear =new StringFormat();
    stringFormatNear.Alignment =StringAlignment.Near ;
    stringFormatNear.LineAlignment =StringAlignment.Center ;
    StringFormat stringFormatNear1 =new StringFormat();
    stringFormatNear.Alignment =StringAlignment.Near ;

    StringFormat stringFormatFar =new StringFormat();
    stringFormatFar.Alignment =StringAlignment.Far ;
    stringFormatFar.LineAlignment =StringAlignment.Center; left =e.MarginBounds.Left;
    top =100;
    height =HeightChineseFont+addHeight;
    //string strTotalPoint_S=DataProvider.DataProviderManager.GetMemberTotalPointMeasureTeam(this.ActivityID,this.CardNumber,DateTime.Now);

    e.Graphics.DrawString("测  定  报  告",titleFont2,Brushes.Black,left+300,top,new StringFormat());
    RectangleF[] rec =new RectangleF[1];
    top+=(HeightTitleFont2*3);
    //省(自治区.直辖市)
    e.Graphics.DrawString("学校:",chineseFont,Brushes.Black,left,top,stringFormatNear);
    e.Graphics.DrawString(MemberBasicInfo_S.School,chineseFont,Brushes.Black,left+HeightChineseFont*3,top,stringFormatNear);
    //添加其它打印内容调用
    PersonalReportPrint p=new PersonalReportPrint();}
    p.Print();