如何在rdlc文件中将legal设置为默认打印大小?

时间:2013-08-23 18:54:06

标签: c# reportviewer rdlc

我有一个C#.NET reportviewer rdlc文件,我想默认以合法大小打印。无论我做什么,打印对话框始终将纸张大小设置为字母。除非您在打印前将其更改为合法,否则报告将被切断。

有人建议手动设置报告大小或将单位从cm更改为英寸,但似乎没有影响。有什么想法吗?

这是我的rdlc文件的内容:

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
  <Body>
    <ReportItems>
      <Subreport Name="LoadoutReport">
        <ReportName>LoadoutReport</ReportName>
        <Parameters>
          <Parameter Name="GroupingProperty">
            <Value>Grouping</Value>
          </Parameter>
          <Parameter Name="GroupingValue">
            <Value>1</Value>
          </Parameter>
        </Parameters>
        <Height>6.67396cm</Height>
        <Width>7.5cm</Width>
        <Style>
          <Border>
            <Style>Solid</Style>
          </Border>
          <RightBorder>
            <Color>Black</Color>
          </RightBorder>
        </Style>
      </Subreport>
      <Subreport Name="LoadoutReport2">
        <ReportName>LoadoutReport</ReportName>
        <Parameters>
          <Parameter Name="GroupingProperty">
            <Value>Grouping</Value>
          </Parameter>
          <Parameter Name="GroupingValue">
            <Value>1</Value>
          </Parameter>
        </Parameters>
        <Left>7.60583cm</Left>
        <Height>6.67396cm</Height>
        <Width>7.5cm</Width>
        <ZIndex>1</ZIndex>
        <Style>
          <Border>
            <Style>Solid</Style>
          </Border>
          <LeftBorder>
            <Color>Black</Color>
          </LeftBorder>
          <RightBorder>
            <Color>Black</Color>
          </RightBorder>
        </Style>
      </Subreport>
      <Subreport Name="LoadoutReport3">
        <ReportName>LoadoutReport</ReportName>
        <Parameters>
          <Parameter Name="GroupingProperty">
            <Value>Grouping</Value>
          </Parameter>
          <Parameter Name="GroupingValue">
            <Value>1</Value>
          </Parameter>
        </Parameters>
        <Left>15.21167cm</Left>
        <Height>6.67396cm</Height>
        <Width>7.5cm</Width>
        <ZIndex>2</ZIndex>
        <Style>
          <Border>
            <Style>Solid</Style>
          </Border>
          <LeftBorder>
            <Color>Black</Color>
          </LeftBorder>
        </Style>
      </Subreport>
    </ReportItems>
    <Height>2.62754in</Height>
    <Style />
  </Body>
  <Width>8.9416in</Width>
  <Page>
    <PageHeight>8.5in</PageHeight>
    <PageWidth>14in</PageWidth>
    <LeftMargin>0.5in</LeftMargin>
    <RightMargin>0.3937in</RightMargin>
    <TopMargin>1in</TopMargin>
    <BottomMargin>0.7874in</BottomMargin>
    <ColumnSpacing>0.05118in</ColumnSpacing>
    <Style />
  </Page>
  <rd:ReportID>f154f70e-de6e-4320-82c8-44d60995e61a</rd:ReportID>
  <rd:ReportUnitType>Inch</rd:ReportUnitType>
</Report>

1 个答案:

答案 0 :(得分:0)

在报表查看器所在的表单加载中尝试此操作....


using System.Drawing.Printing;

...

PageSettings ps = new PageSettings(); //Declare a new PageSettings for printing
ps.Landscape = false; //Set True for landscape, False for Portrait
ps.Margins = new Margins(0, 0, 0, 0); //Set margins
//Choose paper size from the paper sizes defined in ur printer.
//Here we use Linq to quickly choose by name
ps.PaperSize =
    (from PaperSize p
    in ps.PrinterSettings.PaperSizes
    where p.PaperName == "Legal" select p).First();
//Alternatively you can set the paper size as custom
//ps.PaperSize = new PaperSize("MyPaperSize", 100, 100);

reportViewer1.SetPageSettings(ps);