作成日: 2026/03/25 最終更新日: 2026/03/25
文書種別
使用方法
詳細
Windowsフォームアプリケーション用のViewerコントロールの[印刷]ボタンやPrintメソッドを使用して印刷する場合、印刷設定をコード上であらかじめ設定することが可能です。
具体的な方法は以下をご確認ください。
ただし、Webアプリケーションでクライアントサイドのプリンタに印刷する場合は、この方法は適用できません。詳しくはこちらのナレッジをご参照ください。
セクションレポート
◆サンプルコード (C#)
var rpt = new SectionReport1();
rpt.Document.Printer.PrinterName = "プリンタ名";
// 印刷部数
rpt.Document.Printer.PrinterSettings.Copies = 5;
// 両面印刷
rpt.Document.Printer.PrinterSettings.Duplex = GrapeCity.ActiveReports.Printing.Duplex.Vertical;
// カラー印刷
rpt.Document.Printer.DefaultPageSettings.Color = true;
// 給紙トレイ(手差し)
rpt.PageSettings.DefaultPaperSource = false;
rpt.PageSettings.PaperSource = GrapeCity.ActiveReports.Printing.PaperSourceKind.Manual;
// プリンタ固有の名前で設定する場合
foreach (GrapeCity.ActiveReports.Printing.PaperSource ps in rpt.Document.Printer.PrinterSettings.PaperSources)
{
//「手差し」に設定します。
if (ps.SourceName == "手差し")
{
rpt.Document.Printer.DefaultPageSettings.PaperSource = ps;
break;
}
}
// Viewerに表示する場合
rpt.Run();
viewer1.Document = rpt.Document;
// 直接印刷する場合
rpt.Run();
rpt.Document.Print(false, false, false);◆サンプルコード (VB.NET)
Dim rpt As New SectionReport1
rpt.Document.Printer.PrinterName = "プリンタ名"
' 印刷部数
rpt.Document.Printer.PrinterSettings.Copies = 5
' 両面印刷
rpt.Document.Printer.PrinterSettings.Duplex = GrapeCity.ActiveReports.Printing.Duplex.Vertical
' カラー印刷
rpt.Document.Printer.DefaultPageSettings.Color = True
' 給紙トレイ(手差し)
rpt.PageSettings.DefaultPaperSource = False
rpt.PageSettings.PaperSource = GrapeCity.ActiveReports.Printing.PaperSourceKind.Manual
' プリンタ固有の名前で設定する場合
For Each ps As GrapeCity.ActiveReports.Printing.PaperSource In rpt.Document.Printer.PrinterSettings.PaperSources
If ps.SourceName = "手差し" Then
rpt.Document.Printer.DefaultPageSettings.PaperSource = ps
Exit For
End If
Next
// Viewerに表示する場合
rpt.Run()
viewer1.Document = rpt.Document
// 直接印刷する場合
rpt.Run()
rpt.Document.Print(False, False, False)
ページレポート/RDLレポート(Viewerコントロール)
◆サンプルコード (C#)
var file_name = "PageReport1.rdlx";
var rpt = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(file_name));
var doc = new GrapeCity.ActiveReports.Document.PageDocument(rpt);
doc.Printer.PrinterName = "プリンタ名";
// 印刷部数
doc.Printer.PrinterSettings.Copies = 5;
// 両面印刷
doc.Printer.PrinterSettings.Duplex = GrapeCity.ActiveReports.Printing.Duplex.Vertical;
// カラー印刷
doc.Printer.DefaultPageSettings.Color = true;
// 給紙トレイ
foreach (GrapeCity.ActiveReports.Printing.PaperSource ps in doc.Printer.PrinterSettings.PaperSources)
{
if (ps.SourceName == "手差し")
{
doc.Printer.DefaultPageSettings.PaperSource = ps;
break;
}
}
viewer1.LoadDocument(doc);◆サンプルコード (VB.NET)
Dim file_name As String = "PageReport1.rdlx"
Dim rpt As New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo(file_name))
Dim doc As New GrapeCity.ActiveReports.Document.PageDocument(rpt)
doc.Printer.PrinterName = "プリンタ名"
' 印刷部数
doc.Printer.PrinterSettings.Copies = 5
' 両面印刷
doc.Printer.PrinterSettings.Duplex = GrapeCity.ActiveReports.Printing.Duplex.Vertical
' カラー印刷
doc.Printer.DefaultPageSettings.Color = True
' 給紙トレイ
For Each ps As GrapeCity.ActiveReports.Printing.PaperSource In rpt.Document.Printer.PrinterSettings.PaperSources
If ps.SourceName = "手差し" Then
doc.Printer.DefaultPageSettings.PaperSource = ps
Exit For
End If
Next
Viewer1.LoadDocument(doc)
ページレポート/RDLレポート(Printメソッド)
◆サンプルコード (C#)
var file_name = "PageReport1.rdlx";
var rpt = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(file_name));
var doc = new GrapeCity.ActiveReports.Document.PageDocument(rpt);
// 印刷設定用オブジェクト
var settings = new GrapeCity.ActiveReports.PrinterSettings();
settings.Printer.PrinterName = "プリンタ名";
settings.ShowPrintDialog = false;
settings.ShowPrintProgressDialog = false;
settings.UsePrintingThread = false;
// 印刷部数
settings.Printer.PrinterSettings.Copies = 5;
// 両面印刷
settings.Printer.PrinterSettings.Duplex = System.Drawing.Printing.Duplex.Vertical;
// カラー印刷
settings.Printer.DefaultPageSettings.Color = true;
// 給紙トレイ
foreach (System.Drawing.Printing.PaperSource ps in settings.Printer.PrinterSettings.PaperSources)
{
if (ps.SourceName == "手差し")
{
settings.Printer.DefaultPageSettings.PaperSource = ps;
break;
}
}
doc.Print(settings);◆サンプルコード (VB.NET)
Dim file_name As String = "PageReport1.rdlx"
Dim rpt As New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo(file_name))
Dim doc As New GrapeCity.ActiveReports.Document.PageDocument(rpt)
' 印刷設定用オブジェクト
Dim settings As New GrapeCity.ActiveReports.PrinterSettings()
settings.Printer.PrinterName = "プリンタ名"
settings.ShowPrintDialog = False
settings.ShowPrintProgressDialog = False
settings.UsePrintingThread = False
' 印刷部数
settings.Printer.PrinterSettings.Copies = 5
' 両面印刷
settings.Printer.PrinterSettings.Duplex = System.Drawing.Printing.Duplex.Vertical
' カラー印刷
settings.Printer.DefaultPageSettings.Color = True
' 給紙トレイ
For Each ps As System.Drawing.Printing.PaperSource In settings.Printer.PrinterSettings.PaperSources
If ps.SourceName = "手差し" Then
settings.Printer.DefaultPageSettings.PaperSource = ps
Exit For
End If
Next
doc.Print(settings)