ページ設定
PageSettings クラス
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
PageSettings クラスを使用して、ページの印刷方法を変更する設定を指定します。通常、PrintDocument.DefaultPageSettings プロパティを使用して、印刷するすべてのページに既定の設定を指定します。ページごとに設定を指定するには、PrintDocument.PrintPage イベントまたは PrintDocument.QueryPageSettings イベントを処理し、それぞれ PrintPageEventArgs または QueryPageSettingsEventArgs に含まれる PageSettings 引数を変更します。
PrintDocument イベント処理の詳細については、PrintDocument クラスのトピックの概要を参照してください。印刷の詳細については、System.Drawing.Printing 名前空間のトピックの概要を参照してください。
PrintDocument.DefaultPageSettings プロパティを使用して文書の既定の用紙方向を横に設定し、Print メソッドを使用して文書を印刷するコード例を次に示します。この例には、次の 3 つの必要条件があります。
この例では、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
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); } }
public: void Printing() { try { streamToPrint = gcnew StreamReader( filePath ); try { printFont = gcnew Font( "Arial",10 ); PrintDocument^ pd = gcnew PrintDocument; pd->PrintPage += gcnew 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 ); } }
public void Printing() { try { streamToPrint = new StreamReader(filePath); try { printFont = new Font("Arial", 10); PrintDocument pd = new PrintDocument(); pd.add_PrintPage(new PrintPageEventHandler(pd_PrintPage)); pd.get_PrinterSettings().set_PrinterName(printer); // Set the page orientation to landscape. pd.get_DefaultPageSettings().set_Landscape(true); pd.Print(); } finally { streamToPrint.Close(); } } catch (System.Exception ex) { MessageBox.Show(ex.get_Message()); } } //Printing
System.Drawing.Printing.PageSettings
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
PageSettings コンストラクタ ()
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
解説
既定のコンストラクタは、すべてのフィールドを既定値に初期化します。
通常、PageSettings のインスタンスは作成しません。PrintDocument.DefaultPageSettings を使用して、すべてのページに対する設定を指定します。
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
PageSettings コンストラクタ (PrinterSettings)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
PageSettings コンストラクタ
オーバーロードの一覧
名前 | 説明 |
---|---|
PageSettings () | 既定のプリンタを使用して、PageSettings クラスの新しいインスタンスを初期化します。 |
PageSettings (PrinterSettings) | プリンタを指定して、PageSettings クラスの新しいインスタンスを初期化します。 |
PageSettings プロパティ
パブリック プロパティ
名前 | 説明 | |
---|---|---|
Bounds | Landscape プロパティで指定した用紙方向が考慮された、ページのサイズを取得します。 | |
Color | ページを色付きで印刷するかどうかを示す値を取得または設定します。 | |
HardMarginX | ページの左側のハード マージンの x 座標 (1/100 インチ単位) を取得します。 | |
HardMarginY | ページの上部のハード マージンの y 座標 (1/100 インチ単位) を取得します。 | |
Landscape | ページの印刷時に用紙を横向きにするか縦向きにするかを示す値を取得または設定します。 | |
Margins | このページの余白を取得または設定します。 | |
PaperSize | ページの用紙サイズを取得または設定します。 | |
PaperSource | ページの給紙方法を取得または設定します (たとえば、プリンタの上段トレイ)。 | |
PrintableArea | プリンタのページの印刷可能領域の範囲を取得します。 | |
PrinterResolution | ページのプリンタ解像度を取得または設定します。 | |
PrinterSettings | ページに関連するプリンタ設定を取得または設定します。 |
PageSettings メソッド
パブリック メソッド
名前 | 説明 | |
---|---|---|
Clone | この PageSettings のコピーを作成します。 | |
CopyToHdevmode | 関連情報を PageSettings から指定した DEVMODE 構造体にコピーします。 | |
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) | |
SetHdevmode | 関連情報を、指定した DEVMODE 構造体から PageSettings にコピーします。 | |
ToString | オーバーライドされます。 PageSettings を文字列形式に変換します。 |
名前 | 説明 | |
---|---|---|
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
PageSettings メンバ
PageSettings データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
パブリック プロパティ
名前 | 説明 | |
---|---|---|
Bounds | Landscape プロパティで指定した用紙方向が考慮された、ページのサイズを取得します。 | |
Color | ページを色付きで印刷するかどうかを示す値を取得または設定します。 | |
HardMarginX | ページの左側のハード マージンの x 座標 (1/100 インチ単位) を取得します。 | |
HardMarginY | ページの上部のハード マージンの y 座標 (1/100 インチ単位) を取得します。 | |
Landscape | ページの印刷時に用紙を横向きにするか縦向きにするかを示す値を取得または設定します。 | |
Margins | このページの余白を取得または設定します。 | |
PaperSize | ページの用紙サイズを取得または設定します。 | |
PaperSource | ページの給紙方法を取得または設定します (たとえば、プリンタの上段トレイ)。 | |
PrintableArea | プリンタのページの印刷可能領域の範囲を取得します。 | |
PrinterResolution | ページのプリンタ解像度を取得または設定します。 | |
PrinterSettings | ページに関連するプリンタ設定を取得または設定します。 |
名前 | 説明 | |
---|---|---|
Clone | この PageSettings のコピーを作成します。 | |
CopyToHdevmode | 関連情報を PageSettings から指定した DEVMODE 構造体にコピーします。 | |
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) | |
SetHdevmode | 関連情報を、指定した DEVMODE 構造体から PageSettings にコピーします。 | |
ToString | オーバーライドされます。 PageSettings を文字列形式に変換します。 |
名前 | 説明 | |
---|---|---|
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
- PageSettingsのページへのリンク