0

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

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

这是我的 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>
4

1 回答 1

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);
于 2013-09-24T11:53:35.550 回答