コード例 #1
0
        /// <summary>Removes paddings and rows heights.</summary>
        /// <param name="report">The source report</param>
        /// <returns>The report without spacing.</returns>
        public static Report RemoveSpacing(this Report report, TxtSettings settings)
        {
            var result = report;

            var lineHeight = $"{settings.FontSizePt.Height}pt";

            foreach (var reportComponent in report.Flat())
            {
                switch (reportComponent)
                {
                case TextBox textBox:
                    textBox.CanGrow = true;

                    var style = textBox.Style;
                    style.PaddingBottom   = "0pt";
                    style.PaddingTop      = "0pt";
                    style.ShrinkToFit     = "false";
                    style.MinCondenseRate = "100";

                    switch (settings.HorizontalPaddings)
                    {
                    case PaddingsType.Remove:
                        style.PaddingLeft  = "0pt";
                        style.PaddingRight = "0pt";
                        break;

                    case PaddingsType.Adjust:
                        style.PaddingLeft  = Adjust(style.PaddingLeft, settings.FontSizePt.Width);
                        style.PaddingRight = Adjust(style.PaddingRight, settings.FontSizePt.Width);
                        break;
                    }

                    break;

                case Tablix tablix:
                    foreach (var tablixRow in tablix.TablixBody.TablixRows)
                    {
                        tablixRow.Height = lineHeight;
                    }
                    break;

                case Table table:
                    foreach (var tableRow in table.GetRows())
                    {
                        tableRow.Height = lineHeight;
                    }
                    break;
                }
            }

            return(result);
        }
コード例 #2
0
        public static void Render(IReport report, TextWriter writer, TxtSettings settings)
        {
            if (report == null)
            {
                throw new ArgumentNullException(nameof(report));
            }

            var settingsFontSizeTwips = new Size(settings.FontSizePt.Width * 20, settings.FontSizePt.Height * 20);

            var metricsProvider = new TxtMetricsProvider(settingsFontSizeTwips);
            var targetDevice    = (ITargetDevice) new TargetDevice(TargetDeviceKind.Export, InteractivityType.None, null, false, true);
            var layoutTree      = GenerateLayoutTree(report, targetDevice, metricsProvider);

            var page = layoutTree.Pages.First();

            var canvas = new TxtDrawingCanvas(settingsFontSizeTwips, settings.LineEnding);

            var context = new GraphicsRenderContext(targetDevice, canvas, metricsProvider, RenderersFactory.Instance, null);

            Renderer.RenderPage(context, page);

            canvas.Write(writer);
        }
コード例 #3
0
 public static Report PrepareReport(Report report, TxtSettings settings) =>
 report.Clone().RemoveSpacing(settings);