IRONPDFの使用 .NET MAUIでPDFを表示する方法(ステップバイステップ)チュートリアル Curtis Chau 更新日:7月 28, 2025 Download IronPDF NuGet Download テキストの検索と置換 テキストと画像のスタンプ Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article .NET MAUIは、開発者が単一のコードベースでクロスプラットフォームのデスクトップ、ウェブ、モバイルアプリを構築できる.NETの次世代です。これにはXamarin.Formsが含まれます。 .NET MAUIを使用すると、アプリケーションを一度作成し、Windows、macOS、iOS、Android、tvOSなどの複数のプラットフォームに同じプロジェクト名でデプロイできます。 .NET MAUIは、各プラットフォームの最新のUI機能を活用することも可能にします。例えば、macOS上のダークモードやタッチサポート、またはWindows 10上の音声認識などです。 この記事では、.NET MAUIアプリでIronPDFを使用して、多くの利点を持つPDFドキュメントを作成する方法を説明します。 class="hsg-featured-snippet"> .NET MAUIでのPDFファイルの表示方法 .NET MAUIでPDFファイルを表示するためにIronPDFをインストールする MAUIプロジェクトのフロントエンドデザインを設定する ローカルストレージにファイルを保存し、PDFを表示して処理する URL、HTML文字列、またはファイルのレンダリングメソッドを使用する ステップ3でカスタムハンドラーにレンダリング済みPDFを渡す IronPDF: C# PDFライブラリ IronPDFは、PDFファイルを生成および編集することができる.NETライブラリです。 それは.NET MAUIアプリケーションでの使用に最適であり、特定のニーズに合わせてカスタマイズできる幅広い機能を提供します。 使いやすいAPIを持つIronPDFは、PDF機能を.NET MAUIプロジェクトに統合するのを簡単にします。 前提条件 IronPDFを使用して.NET MAUIでPDFおよびPDFビューアーを作成するための前提条件があります: 最新バージョンのVisual Studio .NET Framework 6または7 Visual StudioにインストールされたMAUIパッケージ Visual Studioで実行される.NET MAUIアプリケーション ステップ 1: IronPDFをインストールする 新しいプロジェクトにIronPDFをインストールする最良の方法の一つは、Visual Studio内のNuGetパッケージマネージャーコンソールを使用することです。 この方法を使用してIronPDFをインストールするには、いくつかの利点があります。 簡単にでき、 最新バージョンのIronPDFを使用していることを確認できます。 IronPDFをインストールする手順 まず、ツール > NuGetパッケージマネージャー > パッケージマネージャーコンソールを選択して、パッケージマネージャーコンソールを開きます。 パッケージマネージャーコンソール 次に、以下のコマンドを入力します: Install-Package IronPdf これにより、パッケージとその依存関係(assetsフォルダーなど)がインストールされます。 IronPDFインストール これで、MAUIプロジェクトでIronPDFを使用し始めることができます。 ステップ 2: .NET MAUIでフロントエンドデザインを設定する まず、IronPDFの3つの機能のためのレイアウトを作成します。 URLをPDFに変換するレイアウト URLをPDFに変換するレイアウトには、.NET MAUIラベルコントロールを使用して、「PDFに変換するURLを入力する」というテキストを持つラベルを作成します。 その後、エントリーコントロールとボタンを横に並べるための水平スタックレイアウトを適用します。 次に、コントロールの後に行を入れて、次のセクションのコントロールを区切ります。 <Label Text="Enter URL to Convert PDF" SemanticProperties.HeadingLevel="Level1" FontSize="18" HorizontalOptions="Center" /> <HorizontalStackLayout HorizontalOptions="Center"> <Border Stroke="White" StrokeThickness="2" StrokeShape="RoundRectangle 5,5,5,5" HorizontalOptions="Center"> <Entry x:Name="URL" HeightRequest="50" WidthRequest="300" HorizontalOptions="Center" /> </Border> <Button x:Name="urlPDF" Text="Convert URL to PDF" Margin="30,0,0,0" Clicked="UrlToPdf" HorizontalOptions="Center" /> </HorizontalStackLayout> <Line Stroke="White" X2="1500" /> <Label Text="Enter URL to Convert PDF" SemanticProperties.HeadingLevel="Level1" FontSize="18" HorizontalOptions="Center" /> <HorizontalStackLayout HorizontalOptions="Center"> <Border Stroke="White" StrokeThickness="2" StrokeShape="RoundRectangle 5,5,5,5" HorizontalOptions="Center"> <Entry x:Name="URL" HeightRequest="50" WidthRequest="300" HorizontalOptions="Center" /> </Border> <Button x:Name="urlPDF" Text="Convert URL to PDF" Margin="30,0,0,0" Clicked="UrlToPdf" HorizontalOptions="Center" /> </HorizontalStackLayout> <Line Stroke="White" X2="1500" /> XML HTMLをPDFに変換するレイアウト HTMLをPDFに変換するセクションのレイアウトには、エディターコントロールとボタンを作成します。 エディターコントロールは、ユーザーからHTMLコンテンツの文字列を受け入れるために使用されます。 さらに、区切り線として線を追加します。 <Label Text="Enter HTML to Convert to PDF" SemanticProperties.HeadingLevel="Level2" FontSize="18" HorizontalOptions="Center" /> <Border Stroke="White" StrokeThickness="2" StrokeShape="RoundRectangle 5,5,5,5" HorizontalOptions="Center"> <Editor x:Name="HTML" HeightRequest="200" WidthRequest="300" HorizontalOptions="Center" /> </Border> <Button x:Name="htmlPDF" Text="Convert HTML to PDF" Clicked="HtmlToPdf" HorizontalOptions="Center" /> <Line Stroke="White" X2="1500" /> <Label Text="Enter HTML to Convert to PDF" SemanticProperties.HeadingLevel="Level2" FontSize="18" HorizontalOptions="Center" /> <Border Stroke="White" StrokeThickness="2" StrokeShape="RoundRectangle 5,5,5,5" HorizontalOptions="Center"> <Editor x:Name="HTML" HeightRequest="200" WidthRequest="300" HorizontalOptions="Center" /> </Border> <Button x:Name="htmlPDF" Text="Convert HTML to PDF" Clicked="HtmlToPdf" HorizontalOptions="Center" /> <Line Stroke="White" X2="1500" /> XML HTMLファイルをPDFに変換するレイアウト HTMLファイルをPDFに変換するには、ボタンを1つ追加するだけです。 そのボタンは、IronPDFを使用してHTMLファイルをPDFドキュメントに変換する役割を果たします。 <Label Text="Convert HTML file to PDF" SemanticProperties.HeadingLevel="Level2" FontSize="18" HorizontalOptions="Center" /> <Button x:Name="htmlFilePDF" Text="Convert HTML file to PDF" Clicked="FileToPdf" HorizontalOptions="Center" /> <Label Text="Convert HTML file to PDF" SemanticProperties.HeadingLevel="Level2" FontSize="18" HorizontalOptions="Center" /> <Button x:Name="htmlFilePDF" Text="Convert HTML file to PDF" Clicked="FileToPdf" HorizontalOptions="Center" /> XML 完全なUIコード 以下に.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="PDF_Viewer.MainPage"> <ScrollView> <VerticalStackLayout Spacing="25" Padding="30,0" VerticalOptions="Center"> <Label Text="Enter URL to Convert PDF" SemanticProperties.HeadingLevel="Level1" FontSize="18" HorizontalOptions="Center" /> <HorizontalStackLayout HorizontalOptions="Center"> <Border Stroke="White" StrokeThickness="2" StrokeShape="RoundRectangle 5,5,5,5" HorizontalOptions="Center"> <Entry x:Name="URL" HeightRequest="50" WidthRequest="300" HorizontalOptions="Center" /> </Border> <Button x:Name="urlPDF" Text="Convert URL to PDF" Margin="30,0,0,0" Clicked="UrlToPdf" HorizontalOptions="Center" /> </HorizontalStackLayout> <Line Stroke="White" X2="1500" /> <Label Text="Enter HTML to Convert to PDF" SemanticProperties.HeadingLevel="Level2" FontSize="18" HorizontalOptions="Center" /> <Border Stroke="White" StrokeThickness="2" StrokeShape="RoundRectangle 5,5,5,5" HorizontalOptions="Center"> <Editor x:Name="HTML" HeightRequest="200" WidthRequest="300" HorizontalOptions="Center" /> </Border> <Button x:Name="htmlPDF" Text="Convert HTML to PDF" Clicked="HtmlToPdf" HorizontalOptions="Center" /> <Line Stroke="White" X2="1500" /> <Label Text="Convert HTML file to PDF" SemanticProperties.HeadingLevel="Level2" FontSize="18" HorizontalOptions="Center" /> <Button x:Name="htmlFilePDF" Text="Convert HTML file to PDF" Clicked="FileToPdf" HorizontalOptions="Center" /> </VerticalStackLayout> </ScrollView> </ContentPage> <?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="PDF_Viewer.MainPage"> <ScrollView> <VerticalStackLayout Spacing="25" Padding="30,0" VerticalOptions="Center"> <Label Text="Enter URL to Convert PDF" SemanticProperties.HeadingLevel="Level1" FontSize="18" HorizontalOptions="Center" /> <HorizontalStackLayout HorizontalOptions="Center"> <Border Stroke="White" StrokeThickness="2" StrokeShape="RoundRectangle 5,5,5,5" HorizontalOptions="Center"> <Entry x:Name="URL" HeightRequest="50" WidthRequest="300" HorizontalOptions="Center" /> </Border> <Button x:Name="urlPDF" Text="Convert URL to PDF" Margin="30,0,0,0" Clicked="UrlToPdf" HorizontalOptions="Center" /> </HorizontalStackLayout> <Line Stroke="White" X2="1500" /> <Label Text="Enter HTML to Convert to PDF" SemanticProperties.HeadingLevel="Level2" FontSize="18" HorizontalOptions="Center" /> <Border Stroke="White" StrokeThickness="2" StrokeShape="RoundRectangle 5,5,5,5" HorizontalOptions="Center"> <Editor x:Name="HTML" HeightRequest="200" WidthRequest="300" HorizontalOptions="Center" /> </Border> <Button x:Name="htmlPDF" Text="Convert HTML to PDF" Clicked="HtmlToPdf" HorizontalOptions="Center" /> <Line Stroke="White" X2="1500" /> <Label Text="Convert HTML file to PDF" SemanticProperties.HeadingLevel="Level2" FontSize="18" HorizontalOptions="Center" /> <Button x:Name="htmlFilePDF" Text="Convert HTML file to PDF" Clicked="FileToPdf" HorizontalOptions="Center" /> </VerticalStackLayout> </ScrollView> </ContentPage> XML ステップ 3: PDFファイルを保存して表示するためのコード .NET MAUIにはローカルストレージにファイルを保存するための事前に構築された機能はありません。 したがって、自分でコードを書く必要があります。 保存および表示の機能を作成するため、SaveServiceという名前の部分クラスが作成され、ファイル名、ファイルのコンテンツタイプ、ファイルを書き込むメモリーストリームの3つのパラメータを持つSaveAndViewという名前の部分的なvoid関数が含まれています。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PDF_Viewer { public partial class SaveService { public partial void SaveAndView(string filename, string contentType, MemoryStream stream); } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PDF_Viewer { public partial class SaveService { public partial void SaveAndView(string filename, string contentType, MemoryStream stream); } } Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Text Imports System.Threading.Tasks Namespace PDF_Viewer Partial Public Class SaveService Public Partial Private Sub SaveAndView(ByVal filename As String, ByVal contentType As String, ByVal stream As MemoryStream) End Sub End Class End Namespace $vbLabelText $csharpLabel 保存および閲覧の機能は、サポートを意図している各プラットフォーム(例えば、Android、macOS、またはWindows)で実装する必要があります。 Windowsプラットフォームの場合、「SaveWindows.cs」というファイルを作成し、部分メソッドSaveAndViewを実装します。 using Windows.Storage; using Windows.Storage.Pickers; using Windows.Storage.Streams; using Windows.UI.Popups; namespace PDF_Viewer { public partial class SaveService { public async partial void SaveAndView(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 FileSavePicker(); 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 PDF_Viewer { public partial class SaveService { public async partial void SaveAndView(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 FileSavePicker(); 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 PDF_Viewer Partial Public Class SaveService Public Async Sub SaveAndView(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 $vbLabelText $csharpLabel AndroidおよびmacOSの場合、同様のSaveAndView実装を持つ別々のファイルを作成する必要があります。 作業例はこのMAUI PDF Viewer GitHubリポジトリから取得できます。 ステップ 4: PDF機能のコード それでは、PDF機能のコードを作成する時が来ました。 URLをPDFに変換する機能から始めましょう。 URLをPDFに変換する機能 URLからPDFに変換する機能のために、UrlToPdfという関数を作成します。 Inside the function, instantiate the ChromePdfRenderer object and use the RenderUrlAsPdf function to convert the URL to PDF documents. RenderUrlAsPdf関数は、ウェブサーバーからURLのデータを取得し、PDFドキュメントに変換するために処理します。 パラメータには、URLエントリーコントロールのテキストを渡し、SaveServiceクラスのオブジェクトを作成し、SaveAndView関数を利用します。 SaveAndView関数のパラメータには、生成されたPDFファイルのストリームを渡します。 SaveAndView関数は、ファイルを任意のカスタマイズされたパスに保存し、PDFファイルを表示するオプションを提供します。 最後に、PDFファイルの作成についての情報を持つアラートボックスを表示します。ユーザーが空のエントリコントロールでPDFファイルを作成しようとすると、エラーメッセージと警告を持つアラートボックスが表示されます。 private void UrlToPdf(object sender, EventArgs e) { if (!string.IsNullOrEmpty(URL.Text)) { var renderer = new IronPdf.ChromePdfRenderer(); var pdf = renderer.RenderUrlAsPdf(URL.Text.Trim()); SaveService saveService = new SaveService(); saveService.SaveAndView("URLtoPDF.pdf", "application/pdf", pdf.Stream); DisplayAlert("Success", "PDF from URL Created!", "OK"); } else { DisplayAlert("Error", "Field can't be empty! \nPlease enter URL!", "OK"); } } private void UrlToPdf(object sender, EventArgs e) { if (!string.IsNullOrEmpty(URL.Text)) { var renderer = new IronPdf.ChromePdfRenderer(); var pdf = renderer.RenderUrlAsPdf(URL.Text.Trim()); SaveService saveService = new SaveService(); saveService.SaveAndView("URLtoPDF.pdf", "application/pdf", pdf.Stream); DisplayAlert("Success", "PDF from URL Created!", "OK"); } else { DisplayAlert("Error", "Field can't be empty! \nPlease enter URL!", "OK"); } } Imports Microsoft.VisualBasic Private Sub UrlToPdf(ByVal sender As Object, ByVal e As EventArgs) If Not String.IsNullOrEmpty(URL.Text) Then Dim renderer = New IronPdf.ChromePdfRenderer() Dim pdf = renderer.RenderUrlAsPdf(URL.Text.Trim()) Dim saveService As New SaveService() saveService.SaveAndView("URLtoPDF.pdf", "application/pdf", pdf.Stream) DisplayAlert("Success", "PDF from URL Created!", "OK") Else DisplayAlert("Error", "Field can't be empty! " & vbLf & "Please enter URL!", "OK") End If End Sub $vbLabelText $csharpLabel HTMLをPDFに変換する機能 HTMLからPDFに変換する機能のためには、HtmlToPdf関数を作成し、RenderHtmlAsPdf関数を使用します。 エディターコントロールのテキストを使用し、RenderHtmlAsPdf関数のパラメータに渡します。 上記の関数と同様に、SaveAndView関数を使用して、PDFファイルを保存した後に閲覧できるように機能を有効にします。 private void HtmlToPdf(object sender, EventArgs e) { if (!string.IsNullOrEmpty(HTML.Text)) { var renderer = new IronPdf.ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf(HTML.Text); SaveService saveService = new SaveService(); saveService.SaveAndView("IronPDF HTML string.pdf", "application/pdf", pdf.Stream); DisplayAlert("Success", "PDF from HTML Created!", "OK"); } else { DisplayAlert("Error", "Field can't be empty! \nPlease enter valid HTML!", "OK"); } } private void HtmlToPdf(object sender, EventArgs e) { if (!string.IsNullOrEmpty(HTML.Text)) { var renderer = new IronPdf.ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf(HTML.Text); SaveService saveService = new SaveService(); saveService.SaveAndView("IronPDF HTML string.pdf", "application/pdf", pdf.Stream); DisplayAlert("Success", "PDF from HTML Created!", "OK"); } else { DisplayAlert("Error", "Field can't be empty! \nPlease enter valid HTML!", "OK"); } } Imports Microsoft.VisualBasic Private Sub HtmlToPdf(ByVal sender As Object, ByVal e As EventArgs) If Not String.IsNullOrEmpty(HTML.Text) Then Dim renderer = New IronPdf.ChromePdfRenderer() Dim pdf = renderer.RenderHtmlAsPdf(HTML.Text) Dim saveService As New SaveService() saveService.SaveAndView("IronPDF HTML string.pdf", "application/pdf", pdf.Stream) DisplayAlert("Success", "PDF from HTML Created!", "OK") Else DisplayAlert("Error", "Field can't be empty! " & vbLf & "Please enter valid HTML!", "OK") End If End Sub $vbLabelText $csharpLabel HTMLファイルをPDFに変換する機能 HTMLファイルからPDFファイルに変換するために、FileToPdf関数を作成します。 RenderHtmlFileAsPdf関数を使用し、HTMLファイルのパスをパラメータとして渡します。 すべてのHTMLコンテンツをPDFに変換し、出力ファイルを保存します。 private void FileToPdf(object sender, EventArgs e) { var renderer = new IronPdf.ChromePdfRenderer(); var pdf = renderer.RenderHtmlFileAsPdf(@"C:\Users\Administrator\Desktop\index.html"); SaveService saveService = new SaveService(); saveService.SaveAndView("HTML File to PDF.pdf", "application/pdf", pdf.Stream); DisplayAlert("Success", "PDF from File Created!", "OK"); } private void FileToPdf(object sender, EventArgs e) { var renderer = new IronPdf.ChromePdfRenderer(); var pdf = renderer.RenderHtmlFileAsPdf(@"C:\Users\Administrator\Desktop\index.html"); SaveService saveService = new SaveService(); saveService.SaveAndView("HTML File to PDF.pdf", "application/pdf", pdf.Stream); DisplayAlert("Success", "PDF from File Created!", "OK"); } Private Sub FileToPdf(ByVal sender As Object, ByVal e As EventArgs) Dim renderer = New IronPdf.ChromePdfRenderer() Dim pdf = renderer.RenderHtmlFileAsPdf("C:\Users\Administrator\Desktop\index.html") Dim saveService As New SaveService() saveService.SaveAndView("HTML File to PDF.pdf", "application/pdf", pdf.Stream) DisplayAlert("Success", "PDF from File Created!", "OK") End Sub $vbLabelText $csharpLabel 出力 プロジェクトを実行した後、出力は次のようになります。 出力 このセクションにMicrosoftのウェブサイトURLを入力して、ボタンをクリックします。 URLからPDFへ PDFファイルを作成した後、カスタマイズ可能な保存先にファイルを保存するためのダイアログボックスが表示されます。 ファイルの保存 ファイルを保存した後、このポップアップが表示され、PDFファイルを見るためのPDFビューアを選択するオプションが提供されます。 PDFビューアポップアップ IronPDFは、URLを素晴らしい形でPDFに変換します。 それは、すべての色と画像を元の形とフォーマットで保持します。 PDFビューアポップアップ 他のすべての機能でも同じ手順を行う必要があります。 IronPDFのBlazorでの動作を学ぶには、このIronPDFのBlazorブログをご覧ください。 「MAUIでXAMLをPDFに変換する方法」を訪れて、MAUIページをXAMLとしてPDFドキュメントに変換する方法を学びましょう。 まとめ このチュートリアルでは、.NET MAUIアプリでIronPDFを使用してPDFファイルとPDFビューアを作成しました。 .NET MAUIは、単一のコードベースでマルチプラットフォームアプリケーションを作成するための素晴らしいツールです。 IronPDFは、.NETアプリケーションでPDFファイルを簡単に作成およびカスタマイズするのに役立ちます。 IronPDFは、.NET MAUIプラットフォームと完全に互換性があります。 IronPDFは開発用に無料です。 無料トライアルキーを取得して、IronPDFを本番環境で試すことができます。 IronPDF公式ウェブサイトで、IronPDFとその機能についての更なる情報をぜひご覧ください。 よくある質問 .NET MAUIアプリケーションにPDFビューアーを統合する方法は? .NET MAUIアプリケーションにPDFビューアーを統合するには、IronPDFを使用してPDFファイルのレンダリングと表示を処理できます。IronPDFを使用すると、URL、HTML文字列、HTMLファイルからPDFをレンダリングでき、.NET MAUI内のさまざまなPDFビューアーツールを使用して保存および表示できます。 .NET MAUI用のIronPDFを設定するにはどのようなステップが含まれていますか? .NET MAUI用のIronPDFを設定するには、Visual StudioのNuGetパッケージマネージャーを介してIronPDFパッケージをインストールし、PDFレンダリングを処理するプロジェクトを構成し、HTML、URL、またはHTMLファイルをPDFドキュメントに変換するためにIronPDFのメソッドを使用します。 .NET MAUIでPDFのレイアウトをどのようにして維持することができますか? IronPDFは、.NET MAUIアプリケーションでのPDFレイアウトの維持に強力な機能を提供します。RenderHtmlAsPdf や RenderUrlAsPdf などのメソッドを使用することで、元のフォーマットとレイアウトを維持しながらコンテンツをPDFに変換できます。 .NET MAUIでPDFを表示する際の一般的な問題点は何ですか、それらをどのように解決できますか? .NET MAUIでPDFを表示する際の一般的な問題点には、プラットフォーム固有のレンダリングエラーやファイルアクセス権限があります。これらはIronPDFのクロスプラットフォーム機能を使用し、アプリのコードベースでファイル権限を適切に処理することで解決できます。 .NET MAUIアプリケーションでHTMLコンテンツをPDFに変換できますか? はい、IronPDFのRenderHtmlAsPdfメソッドを使用して、.NET MAUIアプリケーションでHTMLコンテンツをPDFに変換できます。これにより、HTML文字列を効率的に完全にフォーマットされたPDFドキュメントに変換できます。 .NET MAUIでファイルの保存と表示をどのように処理しますか? .NET MAUIでIronPDFを使用してPDFファイルを生成し、プラットフォーム固有のファイル処理APIを使用してファイルの保存と表示を実装できます。IronPDFは、ローカルストレージにPDFファイルを保存することをサポートしており、PDFビューアーで開くことができます。 IronPDFは.NET MAUIの全対象プラットフォームと互換性がありますか? はい、IronPDFは.NET MAUIが対象としているすべてのプラットフォーム(Windows、macOS、iOS、Android、tvOS)と互換性があり、これらのシステム間でシームレスなPDFの作成および表示を提供します。 .NET MAUIプロジェクトでIronPDFを本格的な導入前にテストするにはどうすればよいですか? 無料の開発ライセンスを使用して、.NET MAUIプロジェクトでIronPDFをテストできます。これにより、完全なプロダクションライセンスを購入する前に、アプリケーションにPDF機能を統合してテストできます。 IronPDF は .NET 10 をサポートしていますか? また、それによってどのような利点がありますか? はい、IronPDFは.NET 10を完全にサポートしています。MAUI、Web、デスクトップ、クラウドベースのアプリなど、.NET 10でアプリを構築する際に、特別な回避策を必要とせず、すぐに使用できます。.NET 10を使用することで、最新のプラットフォームの改善、パフォーマンスの向上、更新されたAPIを利用できます。 Curtis Chau 今すぐエンジニアリングチームとチャット テクニカルライター Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。 関連する記事 公開日 11月 13, 2025 C#で2つのPDFバイト配列をマージする方法 IronPDFを使用してC#で2つのPDFバイト配列をマージします。バイト配列、メモリストリーム、データベースから複数のPDFファイルを組み合わせる方法を簡単なコード例で学びましょう。 詳しく読む 公開日 11月 13, 2025 ASP.NET MVC PDFビューアを作成する方法 ASP.NET MVCアプリケーションのための強力なPDFビューアを構築します。PDFドキュメントを表示し、ビューをPDFに変換し、IronPDFを使用してインタラクティブな機能を追加します。 詳しく読む 公開日 11月 13, 2025 .NET HTMLからPDFへのコンバーターを構築する方法 IronPDFを使用して.NETでHTMLをPDFに変換する方法を学ぶ。 詳しく読む C#でExcelをPDFに変換する(ステップバイステップ)チュートリアルC#でIronPDFを使用したPDFium...
公開日 11月 13, 2025 C#で2つのPDFバイト配列をマージする方法 IronPDFを使用してC#で2つのPDFバイト配列をマージします。バイト配列、メモリストリーム、データベースから複数のPDFファイルを組み合わせる方法を簡単なコード例で学びましょう。 詳しく読む
公開日 11月 13, 2025 ASP.NET MVC PDFビューアを作成する方法 ASP.NET MVCアプリケーションのための強力なPDFビューアを構築します。PDFドキュメントを表示し、ビューをPDFに変換し、IronPDFを使用してインタラクティブな機能を追加します。 詳しく読む