Example #1
0
        /// <summary>
        /// 计算纸张的大小  单位像素
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        public static PaperSizeF GetPaperSizePX(I3PageSetting setting)
        {
            PaperSizeF size = GetPaperSizeMM(setting);

            size.Width  = PaperSizeHelper.MM2PX(size.Width);
            size.Height = PaperSizeHelper.MM2PX(size.Height);
            return(size);
        }
Example #2
0
        /// <summary>
        /// 计算纸张的大小  单位mm
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        public static PaperSizeF GetPaperSizeMM(I3PageSetting setting)
        {
            PaperSizeF size = null;

            #region 根据纸张类型获取大小
            switch (setting.PaperType)
            {
            case PaperType.Custom:
                size = new PaperSizeF(setting.CustomPaperWidthMM, setting.CustomPaperHeightMM);
                break;

            case PaperType.A1:
                size = new PaperSizeF(594, 841);
                break;

            case PaperType.A2:
                size = new PaperSizeF(420, 594);
                break;

            case PaperType.A3:
                size = new PaperSizeF(297, 420);
                break;

            case PaperType.A4:
                size = new PaperSizeF(210, 297);
                break;

            case PaperType.A5:
                size = new PaperSizeF(148, 210);
                break;

            case PaperType.B1:
                size = new PaperSizeF(707, 1000);
                break;

            case PaperType.B2:
                size = new PaperSizeF(500, 707);
                break;

            case PaperType.B3:
                size = new PaperSizeF(353, 500);
                break;

            case PaperType.B4:
                size = new PaperSizeF(250, 353);
                break;

            case PaperType.B5:
                size = new PaperSizeF(176, 250);
                break;

            case PaperType.A0:
                size = new PaperSizeF(841, 1189);
                break;

            case PaperType.B0:
                size = new PaperSizeF(1000, 1414);
                break;

            case PaperType.B4JIS:
                size = new PaperSizeF(257, 364);
                break;

            case PaperType.B5JIS:
                size = new PaperSizeF(182, 257);
                break;

            default:      //默认A4
                size = new PaperSizeF(210, 297);
                break;
            }
            #endregion

            //横向调换
            if (setting.PaperOrientation == PaperOrientation.横向)
            {
                float tmp = size.Height;
                size.Height = size.Width;
                size.Width  = tmp;
            }

            return(size);
        }