IRONPDFの使用

.NET MAUIでIronPDFを使用してPDFファイルを作成する

更新済み 9月 22, 2022
共有:

イントロダクション

.NETマルチプラットフォームアプリUI (.NET MAUI) は、C#とXAMLを使用してネイティブのモバイルおよびデスクトップアプリを作成するためのクロスプラットフォームフレームワークです。 .NET MAUI を使用して、単一のコードベースで Android、iOS、MacOS、および Windows 上で操作できます。 .NET MAUIはオープンソースであり、Xamarin Formsの改良版です。 UIコントロールは、パフォーマンスと拡張性を向上させるために一から書き直されました。 加えて、モバイルプラットフォームからデスクトップのユースケースまで拡大しました。 Xamarin Formsを使用してクロスプラットフォームのユーザーインターフェースを作成したことがあるなら、.NET MAUIフレームワークがそれと多くの共通点を持っていることに気付くでしょう。

しかし、いくつかの違いがあります。 単一のプロジェクトで.NET MAUIフレームワークを使用してマルチプラットフォームアプリを構築できますが、必要に応じてプラットフォーム固有のコードやリソースを追加することもできます。 .NET MAUIの主な目標の一つは、アプリのロジックやUIレイアウトを可能な限り単一のコードベースで記述できるようにすることです。 .NET MAUIはすべてのプラットフォームで利用可能となり、既存のMVVMおよびXAMLパターンをサポートします。

.NET MAUIは、開発者がモバイル開発やWindowsプラットフォームなど、さまざまなプラットフォームで作業することを可能にします。

IronPDFの機能

IronPDFは、ブラウザが処理できるほとんどすべてのタスクを処理できる強力なPDFコンバーターです。 .NETライブラリは、開発者がPDFファイルの作成、読み取り、および操作を簡単に行うことができるようにします。 IronPDFはHTMLをPDFファイルに変換するためにGoogle Chromeエンジンを使用します。 他のウェブ技術の中では、IronPDFはHTML、ASPXをサポートしています。 Razor Pages (レイザーページ), およびMVCビュー。 IronPDFはMicrosoft .NETアプリケーションをサポートします (ASP.NET Webアプリケーションと従来のWindowsアプリケーションの両方). IronPDFを使用して、魅力的なPDFドキュメントを作成することもできます。

IronPDFは HTMLファイルからPDFファイルを作成します。 JavaScript、CSS、画像ファイルを含む。

以下の内容を日本語に翻訳してください:

Not only can IronPDF convert HTML, ASPX, MVC, and images to PDF. It can also extract structured data from PDF documents, render existing PDFs, and apply security features like password protection. Additionally, IronOCR is capable of scanning and extracting text from various image formats, making it ideal for digitizing documents. These advanced features make IronPDF and IronOCR powerful tools for developers looking to handle various file types and enhance their document processing applications.


IronPDFはHTML、ASPX、MVC、画像をPDFに変換できるだけでなく、PDFドキュメントから構造化データを抽出し、既存のPDFをレンダリングし、パスワード保護のようなセキュリティ機能を適用することもできます。さらに、IronOCRはさまざまな画像形式からテキストをスキャンして抽出することができ、文書のデジタル化に最適です。これらの高度な機能により、IronPDFとIronOCRはさまざまなファイルタイプを処理し、文書処理アプリケーションを強化しようとする開発者にとって強力なツールとなります。 HTMLファイルをPDFに変換, しかし、以下の利用も可能です 画像ファイルをPDFに変換.

IronPDFは、インタラクティブなPDFドキュメントの作成に役立ちます。 インタラクティブフォームに入力し、送信する, PDFドキュメントの結合および分割, テキストと画像を抽出する PDFドキュメントからテキストを抽出、PDFドキュメント内のテキストを検索、PDFページを画像にラスタライズ、PDFをHTMLに変換、および PDF ドキュメントを印刷する.

IronPDFはURLからドキュメントを生成することができます。 HTMLの背後でのログイン用 ログインフォームまた、カスタムネットワークのログイン認証情報、ユーザーエージェント、プロキシ、クッキー、HTTPヘッダー、フォーム変数の使用も可能です。

IronPDFは、PDFドキュメントを読み取って記入することができ、ドキュメントから画像を抽出することも可能なライブラリです。 これにより、私たちは ヘッダーとフッターを追加テキスト、写真 ブックマーク, ドキュメントに透かしなどを追加します。 また、新しいドキュメントや既存のドキュメント内でページを結合および分割することもできます。 IronPDFは、Acrobatビューアを使用せずにドキュメントをPDFオブジェクトに変換することができます。 CSSファイルをPDFドキュメントに変換することも可能であり、CSSメディアタイプファイルをドキュメントに変換することもできます。

Visual Studioで新しいプロジェクトを作成

まず、Visual Studio Code と Visual Studio の両方を使用してプロジェクトを作成します。 Visual Studio Codeを使用する際には、コマンドラインツールを使用してプロジェクトタイプのテンプレートをインストールする必要があります。

Microsoft Visual Studioソフトウェアを開き、ファイルメニューに移動します。 「新規プロジェクト」を選択し、新しいプロジェクトウィンドウで「.NET MAUI App」を選択します。 この記事では、.NET MAUI Appを使用してPDFドキュメントを生成し、適切な場所に保存します。

.NET MAUIでIronPDFを使用してPDFファイルを作成する, 図1: Visual Studioで新しいプロジェクトを作成する

Visual Studio で新しいプロジェクトを作成する

プロジェクト名を入力し、適切なテキストボックスにファイルパスを選択してください。 次に、以下のスクリーンショットのようにCreateボタンをクリックします。

.NET MAUIでIronPDFを使用してPDFファイルを作成する、図2:プロジェクトの構成

プロジェクトの構成

Visual Studioプロジェクトは、選択したアプリケーションの構造を.NET MAUI Appプラットフォームに従って生成します。これで、アプリケーションのコードを追加してビルド/実行するためにMainPage.csファイルが開かれます。

.NET MAUIでIronPDFを使用してPDFファイルを作成するには、図3: MainPage.csファイルにコードを追加する

MainPage.csファイルにコードを追加する

次に、ライブラリをインストールしてコードをテストします。

IronPDFライブラリをインストールする

IronPDFライブラリは、4つの方法でダウンロードおよびインストールできます。

これらは:

  • Visual Studio を使用して。
  • Visual Studio コマンドラインの使用。
  • NuGetウェブサイトから直接ダウンロードします。
  • IronPDFのウェブサイトから直接ダウンロード。

Visual Studio を使用して

Visual Studioソフトウェアは、ソリューションにパッケージを直接インストールするためのNuGetパッケージマネージャーオプションを提供します。 以下のスクリーンショットは、NuGetパッケージマネージャーの開き方を示しています。

.NET MAUIでIronPDFを使用してPDFファイルを作成する, 図4: NuGetパッケージマネージャーUIに移動

NuGet パッケージ マネージャー UI に移動

これは、NuGetウェブサイトからパッケージのリストを表示するための検索ボックスを提供します。NuGetパッケージマネージャーで「IronPDF」というキーワードを検索してください。以下のスクリーンショットのように。

.NET MAUIでIronPDFを使用してPDFファイルを作成する、図5:NuGetパッケージマネージャーUIからIronPDFパッケージを選択

NuGetパッケージマネージャーUIからのIronPDFパッケージ

上記の画像では関連する検索項目がリストされています。ソリューションにパッケージをインストールするには、最初のオプションを選択してください。 .NET MAUIアプリケーションプラットフォーム、例えばAndroid、iOS、Windowsプラットフォームすべてにインストールされます。

Visual Studio コマンド ラインの使用

Visual Studioで、ツール > NuGetパッケージマネージャー > パッケージマネージャーコンソール に移動します

パッケージマネージャーコンソールタブに次の行を入力してください:

Install-Package IronPdf

現在、このパッケージは現在のプロジェクトの全ての.NET MAUIプラットフォームにダウンロード/インストールされ、使用可能な状態になります。

.NET MAUIでIronPDFを使用してPDFファイルを作成する、図6:パッケージマネージャーコンソールでパッケージをインストール

パッケージ マネージャー コンソールでパッケージをインストールする

NuGetウェブサイトから直接ダウンロード

第三の方法は、公式ウェブサイトからNuGetパッケージを直接ダウンロードすることです。これにアクセスして 「IronPDF」パッケージリンク NuGetのIronPDFリポジトリページに移動する。

  • 右側のメニューからダウンロードパッケージオプションを選択してください。
  • ダウンロードしたパッケージをダブルクリックしてください。 自動的にインストールされます。

  • ソリューションをリロードすると、パッケージはプロジェクトで使用可能になるはずです。

IronPDFウェブサイトから直接ダウンロード

クリックしてください 最新のZIPファイルをダウンロードするリンク ウェブサイトから直接ダウンロードできます。ダウンロードが完了したら、以下の手順に従ってパッケージをプロジェクトに追加してください。

  • ソリューションウィンドウでプロジェクトのDependenciesオプションを右クリックします。
  • 特定のプラットフォームを選択し、次にオプションの参照を選択し、ダウンロードした参照の場所を参照します。

  • 参照を追加するには「OK」をクリックしてください。

    .NET MAUIがサポートするすべてのプラットフォームへの言及も追加する必要があります。

.NET MAUIアプリでIronPDFを使用してPDFを作成

プロジェクトが作成されると、自動生成されたファイル「MainPage.xaml」が作成されます。 これが .NET MAUI アプリケーションのユーザーインターフェースを配置する場所です。

以下のコードに従ってください。

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MAUI_PDF.MainPage"
            >

    <ScrollView>
        <VerticalStackLayout
            Spacing="25"
            Padding="30,0"
            VerticalOptions="Center">

            <Image
                Source="dotnet_bot.png"
                SemanticProperties.Description="Cute .NET bot waving hi to you!"
                HeightRequest="200"
                HorizontalOptions="Center" />

            <Label
                Text="Welcome to IronPDF!"
                SemanticProperties.HeadingLevel="Level1"
                FontSize="32"
                HorizontalOptions="Center" />

            <Button
                x:Name="PdfBtn"
                Text="Click me to generate PDF"
                SemanticProperties.Hint="Click button to generate PDF"
                Clicked="GeneratePDF"
                HorizontalOptions="Center" />
        </VerticalStackLayout>
    </ScrollView>

</ContentPage>
XML

上記のコードを MainPage.xaml ファイルに追加したら、MainPage.xaml.cs ファイルを開いて、以下のメソッドを MainPage クラス内に含めてください。

private void GeneratePDF(object sender, EventArgs e)
{
    ChromePdfRenderer renderer = new ChromePdfRenderer();
    var doc = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF!</h1> <p>I'm using IronPDF MAUI!</p>");

    //Saves the memory stream as file.
    SaveService saveService = new SaveService();
    saveService.SaveAndView("IronPDF HTML string.pdf", "application/pdf", doc.Stream);
}
private void GeneratePDF(object sender, EventArgs e)
{
    ChromePdfRenderer renderer = new ChromePdfRenderer();
    var doc = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF!</h1> <p>I'm using IronPDF MAUI!</p>");

    //Saves the memory stream as file.
    SaveService saveService = new SaveService();
    saveService.SaveAndView("IronPDF HTML string.pdf", "application/pdf", doc.Stream);
}
Private Sub GeneratePDF(ByVal sender As Object, ByVal e As EventArgs)
	Dim renderer As New ChromePdfRenderer()
	Dim doc = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF!</h1> <p>I'm using IronPDF MAUI!</p>")

	'Saves the memory stream as file.
	Dim saveService As New SaveService()
	saveService.SaveAndView("IronPDF HTML string.pdf", "application/pdf", doc.Stream)
End Sub
VB   C#

GeneratePDFメソッドは、"Hello, IronPDF"というテキストを含む新しいPDFドキュメントを生成します。!..."そして、指定された場所にあるユーザーのコンピューターに保存します。

上記のメソッドでは、新しい ChromePdfRenderer オブジェクトが作成され、呼び出します RenderHtmlAsPdf 新しいPDFドキュメントに「Hello IronPDF」という言葉を含む方法! ... "HTMLマークアップの文字列から”。 次に、ユーザーのデバイスにファイルを保存するタスクを別のクラス、SaveServiceに委任します。このクラスは次のステップで作成されます。

以下に完全な MainPage.xaml.cs ファイルを示します。 次のステップに進む前に、ファイルの内容が以下に表示されている内容と一致していることを確認してください:


// Change the namespace as desired, but make sure that all source files use this same namespace,
// or there will be errors!
namespace MAUI_IronPDF;    

// This namespace is required to make use of IronPDF functionality
using IronPdf;

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
    }

    private void GeneratePDF(object sender, EventArgs e)
    {
        ChromePdfRenderer renderer = new ChromePdfRenderer();
        var doc = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF!</h1> <p>I'm using IronPDF MAUI!</p>");
        //Saves the memory stream as file.
        SaveService saveService = new SaveService();
        saveService.SaveAndView("IronPDF HTML string.pdf", "application/pdf", doc.Stream);
    }
}

// Change the namespace as desired, but make sure that all source files use this same namespace,
// or there will be errors!
namespace MAUI_IronPDF;    

// This namespace is required to make use of IronPDF functionality
using IronPdf;

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
    }

    private void GeneratePDF(object sender, EventArgs e)
    {
        ChromePdfRenderer renderer = new ChromePdfRenderer();
        var doc = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF!</h1> <p>I'm using IronPDF MAUI!</p>");
        //Saves the memory stream as file.
        SaveService saveService = new SaveService();
        saveService.SaveAndView("IronPDF HTML string.pdf", "application/pdf", doc.Stream);
    }
}
Imports IronPdf

' Change the namespace as desired, but make sure that all source files use this same namespace,
' or there will be errors!
Namespace MAUI_IronPDF

	' This namespace is required to make use of IronPDF functionality

	Partial Public Class MainPage
		Inherits ContentPage

		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub GeneratePDF(ByVal sender As Object, ByVal e As EventArgs)
			Dim renderer As New ChromePdfRenderer()
			Dim doc = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF!</h1> <p>I'm using IronPDF MAUI!</p>")
			'Saves the memory stream as file.
			Dim saveService As New SaveService()
			saveService.SaveAndView("IronPDF HTML string.pdf", "application/pdf", doc.Stream)
		End Sub
	End Class
End Namespace
VB   C#

次に、プロジェクトのルートに SaveService.cs という新しいクラスファイルを作成し、以下のソースコードを追加してください。

// Change the namespace as desired, but make sure that all source files use this same namespace,
// or there will be errors!
namespace MAUI_IronPDF
{
    // SaveService partial class declaration ... this allows a layer of abstraction
    // as we implement the save file details specially for each platform on which this app will
    // operate! 
    public partial class SaveService
    {
        public void SaveAndView(string filename, string contentType, MemoryStream stream)
        {
            SaveFile(filename, contentType, stream);
        }

        // Additional partial files will provide implementations for this method specifically.
        partial void SaveFile(string filename, string contentType, MemoryStream stream);
    }
}
// Change the namespace as desired, but make sure that all source files use this same namespace,
// or there will be errors!
namespace MAUI_IronPDF
{
    // SaveService partial class declaration ... this allows a layer of abstraction
    // as we implement the save file details specially for each platform on which this app will
    // operate! 
    public partial class SaveService
    {
        public void SaveAndView(string filename, string contentType, MemoryStream stream)
        {
            SaveFile(filename, contentType, stream);
        }

        // Additional partial files will provide implementations for this method specifically.
        partial void SaveFile(string filename, string contentType, MemoryStream stream);
    }
}
' Change the namespace as desired, but make sure that all source files use this same namespace,
' or there will be errors!
Namespace MAUI_IronPDF
	' SaveService partial class declaration ... this allows a layer of abstraction
	' as we implement the save file details specially for each platform on which this app will
	' operate! 
	Partial Public Class SaveService
		Public Sub SaveAndView(ByVal filename As String, ByVal contentType As String, ByVal stream As MemoryStream)
			SaveFile(filename, contentType, stream)
		End Sub

		' Additional partial files will provide implementations for this method specifically.
		Partial Private Sub SaveFile(ByVal filename As String, ByVal contentType As String, ByVal stream As MemoryStream)
		End Sub
	End Class
End Namespace
VB   C#

ユーザーのデバイスにコンテンツを保存する実装の詳細は、プラットフォームごとに異なるため (ウィンドウズ、アンドロイド、マコス、など)アプリケーションが対応する各デバイスタイプに対して、プラットフォームに特化したコードを記述する必要があります。 これを可能にするために、SaveServiceを部分クラスとして定義します。 (抽象化の目的のために) SaveAndViewという部分メソッドを1つ含む。 以下に続いて、このメソッドの実装は、ソリューションエクスプローラーのプラットフォームフォルダー内の一つまたは複数のフォルダーにネストされた SaveService.cs 部分クラスで定義されます。 (下の画像を参照):

.NET MAUIでIronPDFを使用してPDFファイルを作成する方法、図7:クロスプラットフォームを実装するためのフォルダ構造

クロスプラットフォームを実装するためのフォルダ構造

簡単のために、このチュートリアルでは、前述の部分ファイルをWindowsプラットフォーム専用に定義します。 Windowsプラットフォームフォルダの下に、新しい SaveService.cs ファイルを作成し、以下のコードを含めます:

using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.Storage.Streams;
using Windows.UI.Popups;

namespace MAUI_IronPDF;

public partial class SaveService
{
    async partial void SaveFile(string filename, string contentType, MemoryStream stream)
    {
        StorageFile stFile;
        string extension = Path.GetExtension(filename);
        //Gets process windows handle to open the dialog in application process.
        IntPtr windowHandle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
        if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
        {
            //Creates file save picker to save a file.
            FileSavePicker savePicker = new();
            savePicker.DefaultFileExtension = ".pdf";
            savePicker.SuggestedFileName = filename;
            //Saves the file as PDF file.
            savePicker.FileTypeChoices.Add("PDF", new List<string>() { ".pdf" });

            WinRT.Interop.InitializeWithWindow.Initialize(savePicker, windowHandle);
            stFile = await savePicker.PickSaveFileAsync();
        }
        else
        {
            StorageFolder local = ApplicationData.Current.LocalFolder;
            stFile = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
        }
        if (stFile != null)
        {
            using (IRandomAccessStream zipStream = await stFile.OpenAsync(FileAccessMode.ReadWrite))
            {
                //Writes compressed data from memory to file.
                using Stream outstream = zipStream.AsStreamForWrite();
                outstream.SetLength(0);
                //Saves the stream as file.
                byte [] buffer = stream.ToArray();
                outstream.Write(buffer, 0, buffer.Length);
                outstream.Flush();
            }
            //Create message dialog box.
            MessageDialog msgDialog = new("Do you want to view the document?", "File has been created successfully");
            UICommand yesCmd = new("Yes");
            msgDialog.Commands.Add(yesCmd);
            UICommand noCmd = new("No");
            msgDialog.Commands.Add(noCmd);

            WinRT.Interop.InitializeWithWindow.Initialize(msgDialog, windowHandle);

            //Showing a dialog box.
            IUICommand cmd = await msgDialog.ShowAsync();
            if (cmd.Label == yesCmd.Label)
            {
                //Launch the saved file.
                await Windows.System.Launcher.LaunchFileAsync(stFile);
            }
        }
    }
}
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.Storage.Streams;
using Windows.UI.Popups;

namespace MAUI_IronPDF;

public partial class SaveService
{
    async partial void SaveFile(string filename, string contentType, MemoryStream stream)
    {
        StorageFile stFile;
        string extension = Path.GetExtension(filename);
        //Gets process windows handle to open the dialog in application process.
        IntPtr windowHandle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
        if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
        {
            //Creates file save picker to save a file.
            FileSavePicker savePicker = new();
            savePicker.DefaultFileExtension = ".pdf";
            savePicker.SuggestedFileName = filename;
            //Saves the file as PDF file.
            savePicker.FileTypeChoices.Add("PDF", new List<string>() { ".pdf" });

            WinRT.Interop.InitializeWithWindow.Initialize(savePicker, windowHandle);
            stFile = await savePicker.PickSaveFileAsync();
        }
        else
        {
            StorageFolder local = ApplicationData.Current.LocalFolder;
            stFile = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
        }
        if (stFile != null)
        {
            using (IRandomAccessStream zipStream = await stFile.OpenAsync(FileAccessMode.ReadWrite))
            {
                //Writes compressed data from memory to file.
                using Stream outstream = zipStream.AsStreamForWrite();
                outstream.SetLength(0);
                //Saves the stream as file.
                byte [] buffer = stream.ToArray();
                outstream.Write(buffer, 0, buffer.Length);
                outstream.Flush();
            }
            //Create message dialog box.
            MessageDialog msgDialog = new("Do you want to view the document?", "File has been created successfully");
            UICommand yesCmd = new("Yes");
            msgDialog.Commands.Add(yesCmd);
            UICommand noCmd = new("No");
            msgDialog.Commands.Add(noCmd);

            WinRT.Interop.InitializeWithWindow.Initialize(msgDialog, windowHandle);

            //Showing a dialog box.
            IUICommand cmd = await msgDialog.ShowAsync();
            if (cmd.Label == yesCmd.Label)
            {
                //Launch the saved file.
                await Windows.System.Launcher.LaunchFileAsync(stFile);
            }
        }
    }
}
Imports Windows.Storage
Imports Windows.Storage.Pickers
Imports Windows.Storage.Streams
Imports Windows.UI.Popups

Namespace MAUI_IronPDF

	Partial Public Class SaveService
		Private Async Sub SaveFile(ByVal filename As String, ByVal contentType As String, ByVal stream As MemoryStream)
			Dim stFile As StorageFile
			Dim extension As String = Path.GetExtension(filename)
			'Gets process windows handle to open the dialog in application process.
			Dim windowHandle As IntPtr = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle
			If Not Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons") Then
				'Creates file save picker to save a file.
				Dim savePicker As New FileSavePicker()
				savePicker.DefaultFileExtension = ".pdf"
				savePicker.SuggestedFileName = filename
				'Saves the file as PDF file.
				savePicker.FileTypeChoices.Add("PDF", New List(Of String)() From {".pdf"})

				WinRT.Interop.InitializeWithWindow.Initialize(savePicker, windowHandle)
				stFile = Await savePicker.PickSaveFileAsync()
			Else
				Dim local As StorageFolder = ApplicationData.Current.LocalFolder
				stFile = Await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting)
			End If
			If stFile IsNot Nothing Then
				Using zipStream As IRandomAccessStream = Await stFile.OpenAsync(FileAccessMode.ReadWrite)
					'Writes compressed data from memory to file.
					Using outstream As Stream = zipStream.AsStreamForWrite()
						outstream.SetLength(0)
						'Saves the stream as file.
						Dim buffer() As Byte = stream.ToArray()
						outstream.Write(buffer, 0, buffer.Length)
						outstream.Flush()
					End Using
				End Using
				'Create message dialog box.
				Dim msgDialog As New MessageDialog("Do you want to view the document?", "File has been created successfully")
				Dim yesCmd As New UICommand("Yes")
				msgDialog.Commands.Add(yesCmd)
				Dim noCmd As New UICommand("No")
				msgDialog.Commands.Add(noCmd)

				WinRT.Interop.InitializeWithWindow.Initialize(msgDialog, windowHandle)

				'Showing a dialog box.
				Dim cmd As IUICommand = Await msgDialog.ShowAsync()
				If cmd.Label = yesCmd.Label Then
					'Launch the saved file.
					Await Windows.System.Launcher.LaunchFileAsync(stFile)
				End If
			End If
		End Sub
	End Class
End Namespace
VB   C#

MAUIアプリケーションをビルドして実行します。 以下に示すインターフェースを含むウィンドウが表示されます。

.NET MAUIでIronPDFを使用してPDFファイルを作成する, 図8: MAUIアプリのUI

MAUIアプリのUI

「Generate PDF」ボタンをクリックしてください。 数秒後に、生成されたPDFファイルの保存場所を選択するポップアップが表示されます。

.NET MAUIでIronPDFを使用してPDFファイルを作成する,図9:PDFファイルを保存する場所を選択

PDFファイルを保存する場所を選択してください

結論

IronPDFは、PDFを生成、読み取り、編集、フォーマットすることができる、最も一般的に使用されているPDF変換ライブラリの1つです。 IronPDFライブラリは、指定されたURLをPDFファイルに変換するためのブラウザエンジンを提供し、HTML文字列にCSSを追加してPDFファイルに変換することができ、さらにPDFフォームに入力することもできるなど、多くの利点と機能を提供します。 IronPDFのすべての機能が1つのライブラリに含まれています。

IronPDFは、さまざまな価格構造があります。 IronPDFの基本価格は$749から始まります。 製品サポートとアップデートは、1年間の料金で利用可能です。 ロイヤリティフリーの再配布カバレッジも追加オプションとして購入できます。

要約すると、IronPDFは優れたパフォーマンスと多くの機能を提供しており、PDFを扱う開発者に推奨されます。 .NET MAUIなどのユニバーサルプラットフォームをサポートしています。 それは、IronPDFライブラリの広範な機能とその多くの特徴を完全に活用するための優れたサポートとドキュメントも付属しています。

< 以前
BlazorチュートリアルでPDFファイルを作成
次へ >
C#で画像をPDFに変換する方法 [コード例チュートリアル]

準備はできましたか? バージョン: 2024.9 新発売

無料のNuGetダウンロード 総ダウンロード数: 10,659,073 View Licenses >