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

时间:2022-09-30 07:07:17

I have a C#.NET reportviewer rdlc file that I want to print in legal size by default. No matter what I do the print dialog always has the paper size set to letter. Unless you change it to legal before printing the report is cut off.

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

Someone suggested setting the report size manually or changing units from cm to inches but it didn't seem to have an affect. Any ideas?

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

This is the contents of my rdlc file:

这是我的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 个解决方案

#1


0  

Try this in the form load where your report viewer is located ....

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


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);

#1


0  

Try this in the form load where your report viewer is located ....

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


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);