印刷ドキュメントのチュートリアル

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronPrint (アイアンプリント)は、.NET C#開発者がアプリケーションに印刷機能を統合できるように設計された強力な印刷ライブラリです。 Windows、macOS、iOS、Androidの各プラットフォームにまたがる幅広い互換性により、アイアンプリントは多様なオペレーティングシステムで一貫して確実に機能します。 デスクトップ環境、AppleのmacOSエコシステム、またはiOSやAndroidのようなモバイルプラットフォーム用のアプリケーションを作成する場合でも、IronPrintは印刷機能の実装を簡素化し、.NET C#環境でのすべての印刷ニーズに対応する多用途でユーザーフレンドリーなソリューションを提供します。

目次

ドキュメントを印刷

サイレント印刷

印刷ダイアログを表示せずに文書をシームレスに印刷。 印刷設定はコード内で直接行うことができる。

:path=/static-assets/print/content-code-examples/tutorials/print-document-print-silently.cs
using IronPrint;

// Print the document
Printer.Print("newDoc.pdf");
Imports IronPrint

' Print the document
Printer.Print("newDoc.pdf")
VB   C#

ダイアログを使用して印刷

印刷設定ダイアログが表示された状態で印刷を開始する。 これにより、ユーザーはインタラクティブに印刷オプションをカスタマイズできる。

:path=/static-assets/print/content-code-examples/tutorials/print-document-print-with-dialog.cs
using IronPrint;

// Show print dialog
Printer.ShowPrintDialog("newDoc.pdf");
Imports IronPrint

' Show print dialog
Printer.ShowPrintDialog("newDoc.pdf")
VB   C#

印刷設定を適用

特定の要件を満たすために、印刷設定をプログラムで調整します。 このセクションでは、コードによって印刷設定を微調整する機能を提供します。

:path=/static-assets/print/content-code-examples/tutorials/print-document-apply-print-setting.cs
using IronPrint;

// Configure print setting
PrintSettings printSettings = new PrintSettings();
printSettings.Dpi = 150;
printSettings.NumberOfCopies = 2;
printSettings.PaperOrientation = PaperOrientation.Portrait;

// Print the document
Printer.Print("newDoc.pdf", printSettings);
Imports IronPrint

' Configure print setting
Private printSettings As New PrintSettings()
printSettings.Dpi = 150
printSettings.NumberOfCopies = 2
printSettings.PaperOrientation = PaperOrientation.Portrait

' Print the document
Printer.Print("newDoc.pdf", printSettings)
VB   C#

プリンター情報を取得する

プリンター名の取得

利用可能なすべてのプリンタのリストにアクセスします。 システムにインストールされているプリンターの名前を取得し、情報提供やアプリケーションでの動的なプリンター選択を行う。

:path=/static-assets/print/content-code-examples/tutorials/print-document-get-printer-names.cs
using IronPrint;
using System;
using System.Collections.Generic;

// Retrieve printers' name
List<string> printersName = Printer.GetPrinterNames();

foreach (var printer in printersName)
{
    Console.WriteLine(printer);
}
Imports IronPrint
Imports System
Imports System.Collections.Generic

' Retrieve printers' name
Private printersName As List(Of String) = Printer.GetPrinterNames()

For Each printer In printersName
	Console.WriteLine(printer)
Next printer
VB   C#