private static void TiffRenderingSettings_BeforeRenderPage(BeforeRenderPageEventArgs args)
        {
            // skip all pages expect first two
            if (args.PageIndex > 1)
            {
                args.IsPageSkipped = true;
                return;
            }

            // force the portrait mode for all pages if needed
            if (args.DesiredHeight < args.DesiredWidth)
            {
                args.RenderingSettings.RotationAngle = RotationAngle.Rotate270;
            }

            // crop from the all sides by cutting out existing margins
            double margin = 40;

            args.CropBox = new Rectangle(margin, margin, args.DesiredWidth - margin, args.DesiredHeight - margin);
        }
Пример #2
0
        private static void Settings_BeforeRenderPage(BeforeRenderPageEventArgs args)
        {
            // Change rotation every time
            switch (currentRotate)
            {
            case RotationAngle.Rotate0:
                currentRotate = RotationAngle.Rotate90;
                break;

            case RotationAngle.Rotate90:
                currentRotate = RotationAngle.Rotate180;
                break;

            case RotationAngle.Rotate180:
                currentRotate = RotationAngle.Rotate270;
                break;

            case RotationAngle.Rotate270:
                currentRotate = RotationAngle.Rotate0;
                break;
            }
            args.RenderingSettings.RotationAngle = currentRotate;

            // Change resolution every time
            if (currentResolution.DpiX == 72)
            {
                currentResolution = new Resolution(300, 300);
            }
            else
            {
                currentResolution  = new Resolution(72, 72);
                args.DesiredWidth  = args.DesiredWidth * 5;
                args.DesiredHeight = args.DesiredHeight * 5;
            }
            args.Resolution = currentResolution;

            // Set crop box
            args.CropBox = new Rectangle(400, 600, args.DesiredWidth - 400, args.DesiredHeight - 600);
        }