2013-08-23 67 views
0

我有一個C#.NET reportviewer rdlc文件,我想默認情況下以合法的大小打印。無論我做什麼,打印對話框始終將紙張尺寸設置爲字母。除非您在打印前將其更改爲合法,否則報告將被切斷。如何在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> 

回答

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); 
相關問題