Esempio n. 1
0
        //public  int distinctTop;
        //public  int distinctButtom;
        //public  int distinctLeft;
        //public  int distinctRight;

        public ReportPrintDocument(ServerReport serverReport, int distinctLeft, int distinctRight, int distinctTop, int distinctButtom)

        {
            // Set the page settings to the default defined in the report
            ReportPageSettings reportPageSettings = serverReport.GetDefaultPageSettings();

            // The page settings object will use the default printer unless
            // PageSettings.PrinterSettings is changed.  This assumes there
            // is a default printer.
            m_pageSettings = new PageSettings();

            //m_pageSettings.PaperSize = reportPageSettings.PaperSize;
            m_pageSettings.PaperSize =
                new PaperSize("custom", reportPageSettings.PaperSize.Height, reportPageSettings.PaperSize.Width);

            //m_pageSettings.Margins = reportPageSettings.Margins;
            m_pageSettings.Margins = new Margins(distinctLeft, distinctRight, distinctTop, distinctButtom); //reportPageSettings.Margins;

            RenderAllServerReportPages(serverReport);
            // MessageBox.Show(distinctTop.ToString()+","+ distinctButtom.ToString()+","+distinctLeft.ToString()+","+distinctRight.ToString()+",");
        }
Esempio n. 2
0
        private static string PrepareAndGetDeviceInfo(this ServerReport report, ReportSettings settings)
        {
            var defaults = report.GetDefaultPageSettings();

            var marginTop    = settings.TopMargin.HasValue ? (settings.TopMargin * (1 / 2.54)) : defaults.Margins.Top / 100.0;
            var marginBottom = settings.BottomMargin.HasValue ? (settings.BottomMargin * (1 / 2.54)) : defaults.Margins.Bottom / 100.0;
            var marginLeft   = settings.LeftMargin.HasValue ? (settings.LeftMargin * (1 / 2.54)) : defaults.Margins.Left / 100.0;
            var marginRight  = settings.RightMargin.HasValue ? (settings.RightMargin * (1 / 2.54)) : defaults.Margins.Right / 100.0;

            settings.EndPage = settings.EndPage ?? settings.StartPage;

            //The DeviceInfo settings should be changed based on the reportType
            // http://msdn2.microsoft.com/en-us/library/ms155397.aspx
            // http://msdn.microsoft.com/en-us/library/hh231593.aspx
            string deviceInfo =
                "<DeviceInfo>" +
                ((settings.DpiX > 0) ? "  <DpiX>" + settings.DpiX + "</DpiX>" : "") +
                ((settings.DpiY > 0) ? "  <DpiY>" + settings.DpiY + "</DpiY>" : "") +
                "  <OutputFormat>" + settings.OutputType + "</OutputFormat>" +
                "  <PageWidth>" + (defaults.IsLandscape ? defaults.PaperSize.Height : defaults.PaperSize.Width) / 100.0 + "in</PageWidth>" +
                "  <PageHeight>" + (defaults.IsLandscape ? defaults.PaperSize.Width : defaults.PaperSize.Height) / 100.0 + "in</PageHeight>" +
                "  <MarginTop>" + marginTop + "in</MarginTop>" +
                "  <MarginLeft>" + marginLeft + "in</MarginLeft>" +
                "  <MarginRight>" + marginRight + "in</MarginRight>" +
                "  <MarginBottom>" + marginBottom + "in</MarginBottom>" +
                "  <StartPage>" + (settings.StartPage ?? 0) + "</StartPage>" +
                "  <EndPage>" + (settings.EndPage ?? 0) + "</EndPage>" +
                "  <PageBreaksMode>OnEachPage</PageBreaksMode>" +
                "  <HumanReadablePDF>" + settings.HumanReadablePdf.ToString() + "</HumanReadablePDF>";

            if (!settings.EmbedFontsInPdf)
            {
                deviceInfo += "  <EmbedFonts>None</EmbedFonts>";
            }

            deviceInfo += "</DeviceInfo>";

            return(deviceInfo);
        }