1234567891011121314151617181920212223242526272829303132333435 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using Microsoft.Reporting.WebForms;
- using System.Globalization;
- namespace EmisTerminal
- {
- public class ReportPrintHelper
- {
- public static string CreateEMFDeviceInfo(Report report)
- {
- var pageSettings = report.GetDefaultPageSettings();
- // The device info string defines the page range to print as well as the size of the page.
- // A start and end page of 0 means generate all pages.
- return string.Format(
- CultureInfo.InvariantCulture,
- "<DeviceInfo><OutputFormat>emf</OutputFormat><StartPage>0</StartPage><EndPage>0</EndPage><MarginTop>{0}</MarginTop><MarginLeft>{1}</MarginLeft><MarginRight>{2}</MarginRight><MarginBottom>{3}</MarginBottom><PageHeight>{4}</PageHeight><PageWidth>{5}</PageWidth></DeviceInfo>",
- ToInches(pageSettings.Margins.Top + 20),
- ToInches(pageSettings.Margins.Left),
- ToInches(pageSettings.Margins.Right),
- ToInches(pageSettings.Margins.Bottom),
- ToInches(pageSettings.PaperSize.Height),
- ToInches(pageSettings.PaperSize.Width));
- }
- private static string ToInches(int hundrethsOfInch)
- {
- double inches = hundrethsOfInch / 100.0;
- return inches.ToString(CultureInfo.InvariantCulture) + "in";
- }
- }
- }
|