ReportPrintHelper.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using Microsoft.Reporting.WebForms;
  6. using System.Globalization;
  7. namespace EmisTerminal
  8. {
  9. public class ReportPrintHelper
  10. {
  11. public static string CreateEMFDeviceInfo(Report report)
  12. {
  13. var pageSettings = report.GetDefaultPageSettings();
  14. // The device info string defines the page range to print as well as the size of the page.
  15. // A start and end page of 0 means generate all pages.
  16. return string.Format(
  17. CultureInfo.InvariantCulture,
  18. "<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>",
  19. ToInches(pageSettings.Margins.Top + 20),
  20. ToInches(pageSettings.Margins.Left),
  21. ToInches(pageSettings.Margins.Right),
  22. ToInches(pageSettings.Margins.Bottom),
  23. ToInches(pageSettings.PaperSize.Height),
  24. ToInches(pageSettings.PaperSize.Width));
  25. }
  26. private static string ToInches(int hundrethsOfInch)
  27. {
  28. double inches = hundrethsOfInch / 100.0;
  29. return inches.ToString(CultureInfo.InvariantCulture) + "in";
  30. }
  31. }
  32. }