ページの印刷時に用紙を横向きにするか縦向きにするかを示す値を取得または設定します。
Public Property Landscape As Boolean
[C#]
public bool Landscape {get; set;}
[C++]
public: __property bool get_Landscape();public: __property void set_Landscape(bool);
[JScript]
public function get Landscape() : Boolean;public function set Landscape(Boolean);
プロパティ値
ページを横向きで印刷する場合は true 。それ以外の場合は false 。既定値はプリンタによって決定されます。
例外
例外の種類 | 条件 |
---|---|
InvalidPrinterException | PrinterSettings.PrinterName プロパティで指定されたプリンタが存在しません。 |
解説
PrinterSettings.LandscapeAngle プロパティを使用して、縦向きの用紙を回転して横向きにする場合の角度 (°) を判断できます。
使用例
[Visual Basic, C#, C++] PrintDocument.DefaultPageSettings プロパティを使用して文書の既定の用紙方向を横向きに設定し、文書を印刷する例を次に示します。この例は、次の 3 つのことを前提にしています。変数 filePath
が印刷するファイルのパスに設定されていること、 PrintPage イベントを処理するメソッド pd_PrintPage
が定義されていること、変数 printer
がプリンタ名に設定されていることです。
[Visual Basic, C#, C++] この例では、 System.Drawing 、 System.Drawing.Printing 、および System.IO の各名前空間を使用します。
Public Sub Printing()
Try
streamToPrint = New StreamReader(filePath)
Try
printFont = New Font("Arial", 10)
Dim pd As New PrintDocument()
AddHandler pd.PrintPage, AddressOf pd_PrintPage
pd.PrinterSettings.PrinterName = printer
' Set the page orientation to landscape.
pd.DefaultPageSettings.Landscape = True
pd.Print()
Finally
streamToPrint.Close()
End Try
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
[C#]
public void Printing() {
try {
streamToPrint = new StreamReader (filePath);
try {
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.PrinterSettings.PrinterName = printer;
// Set the page orientation to landscape.
pd.DefaultPageSettings.Landscape = true;
pd.Print();
}
finally {
streamToPrint.Close() ;
}
}
catch(Exception ex) {
MessageBox.Show(ex.Message);
}
}
[C++]
public:
void Printing() {
try {
streamToPrint = new StreamReader (filePath);
try {
printFont = new Font(S"Arial", 10);
PrintDocument* pd = new PrintDocument();
pd->PrintPage += new PrintPageEventHandler(this, &Sample::pd_PrintPage);
pd->PrinterSettings->PrinterName = printer;
// Set the page orientation to landscape.
pd->DefaultPageSettings->Landscape = true;
pd->Print();
}
__finally {
streamToPrint->Close() ;
}
}
catch(Exception* ex) {
MessageBox::Show(ex->Message);
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
PageSettings クラス | PageSettings メンバ | System.Drawing.Printing 名前空間 | PrintDocument | PrintDocument.PrintPage | PrinterSettings.LandscapeAngle