How to Use IronWord on iOS

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

.NET MAUI (Multi-platform App UI) enables you to build native applications across Android, iOS, Windows, and macOS using a single .NET codebase. With IronWord, .NET developers can easily create, read, edit, and save Microsoft Word (.docx) documents — fully cross-platform and without requiring Microsoft Office.

IronWord works seamlessly on iOS via the shared .NET MAUI codebase using the standard IronWord NuGet package — there is no platform-specific version needed.

Install the IronWord NuGet Package

IronWord is available as a standard cross-platform NuGet package and supports all major .NET MAUI targets, including iOS.

Install-Package IronWord

Create a .NET MAUI Project

In Visual Studio:

  1. Go to File > New > Project.
  2. Under Multiplatform, select .NET MAUI App.
  3. Name your project (e.g., IronWordMauiIOS) and click Create.

Add IronWord to Your Project

You can add the package via NuGet Package Manager or by editing your .csproj file:

<ItemGroup>
  <PackageReference Include="IronWord" Version="2025.5.0" />
</ItemGroup>
<ItemGroup>
  <PackageReference Include="IronWord" Version="2025.5.0" />
</ItemGroup>
XML

You don’t need platform conditions — IronWord works across all targets automatically.

Create the App Interface in XAML

Add a simple UI to load, edit, and save Word documents. To do this, start by adding this code to the MainPage.xml code:

<?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="IronWordMauiIOS.MainPage"
             BackgroundColor="White">

    <VerticalStackLayout Padding="20"
                         Spacing="15"
                         VerticalOptions="Center">

        <!-- Header -->
        <Label Text="IronWord iOS Demo"
               FontSize="24"
               FontAttributes="Bold"
               HorizontalOptions="Center"
               TextColor="#222"/>

        <!-- Open .docx -->
        <Button Text=" Open Word Document"
                Clicked="OpenDocx"
                BackgroundColor="#007AFF"
                TextColor="White"
                CornerRadius="10"
                HeightRequest="50"/>

        <!-- Editable content -->
        <Editor x:Name="docEditor"
                Placeholder="Start editing..."
                AutoSize="TextChanges"
                HeightRequest="250"
                FontSize="16"
                TextColor="#333"
                BackgroundColor="#F9F9F9"
                CornerRadius="10"
                Margin="0,10,0,0"/>

        <!-- Save Button -->
        <Button Text=" Save as .docx"
                Clicked="SaveDocx"
                BackgroundColor="#34C759"
                TextColor="White"
                CornerRadius="10"
                HeightRequest="50"/>

        <!-- Status message -->
        <Label x:Name="statusLabel"
               FontSize="14"
               TextColor="Gray"
               HorizontalOptions="Center"/>
    </VerticalStackLayout>
</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="IronWordMauiIOS.MainPage"
             BackgroundColor="White">

    <VerticalStackLayout Padding="20"
                         Spacing="15"
                         VerticalOptions="Center">

        <!-- Header -->
        <Label Text="IronWord iOS Demo"
               FontSize="24"
               FontAttributes="Bold"
               HorizontalOptions="Center"
               TextColor="#222"/>

        <!-- Open .docx -->
        <Button Text=" Open Word Document"
                Clicked="OpenDocx"
                BackgroundColor="#007AFF"
                TextColor="White"
                CornerRadius="10"
                HeightRequest="50"/>

        <!-- Editable content -->
        <Editor x:Name="docEditor"
                Placeholder="Start editing..."
                AutoSize="TextChanges"
                HeightRequest="250"
                FontSize="16"
                TextColor="#333"
                BackgroundColor="#F9F9F9"
                CornerRadius="10"
                Margin="0,10,0,0"/>

        <!-- Save Button -->
        <Button Text=" Save as .docx"
                Clicked="SaveDocx"
                BackgroundColor="#34C759"
                TextColor="White"
                CornerRadius="10"
                HeightRequest="50"/>

        <!-- Status message -->
        <Label x:Name="statusLabel"
               FontSize="14"
               TextColor="Gray"
               HorizontalOptions="Center"/>
    </VerticalStackLayout>
</ContentPage>
XML

This creates buttons and an editor UI for loading/saving Word content.

Use IronWord in Shared Code

In your MainPage.xaml.cs, implement reading and writing DOCX documents using IronWord:

using IronWord;
using IronWord.Models;
using Microsoft.Maui.Storage;
using System.Text;

namespace IronWordMauiIOS;

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        License.LicenseKey = "YOUR-LICENSE-KEY"; 
    }

    private async void OpenDocx(object sender, EventArgs e)
    {
        try
        {
            var file = await FilePicker.PickAsync();
            if (file == null) return;

            var path = Path.Combine(FileSystem.CacheDirectory, file.FileName);
            using (var source = await file.OpenReadAsync())
            using (var target = File.Create(path))
                await source.CopyToAsync(target);

            var doc = new WordDocument(path);
            docEditor.Text = ExtractText(doc);
            statusLabel.Text = "Document loaded successfully.";
        }
        catch (Exception ex)
        {
            statusLabel.Text = $"Error: {ex.Message}";
        }
    }

    private async void SaveDocx(object sender, EventArgs e)
    {
        try
        {
            var document = new WordDocument();
            var paragraph = new Paragraph();
            paragraph.Texts.Add(new TextContent(docEditor.Text));
            document.Paragraphs.Add(paragraph);

            var fileName = $"ExportedDoc_{DateTime.Now:yyyyMMddHHmmss}.docx";
            var path = Path.Combine(FileSystem.AppDataDirectory, fileName);
            document.SaveAs(path);

            statusLabel.Text = $"Saved to: {fileName}";
        }
        catch (Exception ex)
        {
            statusLabel.Text = $"Save error: {ex.Message}";
        }
    }

    private string ExtractText(WordDocument doc)
    {
        var sb = new StringBuilder();
        foreach (var para in doc.Paragraphs)
        {
            foreach (var element in para.Texts)
            {
                if (element is TextContent text)
                    sb.AppendLine(text.Text);
            }
        }
        return sb.ToString();
    }
}
using IronWord;
using IronWord.Models;
using Microsoft.Maui.Storage;
using System.Text;

namespace IronWordMauiIOS;

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        License.LicenseKey = "YOUR-LICENSE-KEY"; 
    }

    private async void OpenDocx(object sender, EventArgs e)
    {
        try
        {
            var file = await FilePicker.PickAsync();
            if (file == null) return;

            var path = Path.Combine(FileSystem.CacheDirectory, file.FileName);
            using (var source = await file.OpenReadAsync())
            using (var target = File.Create(path))
                await source.CopyToAsync(target);

            var doc = new WordDocument(path);
            docEditor.Text = ExtractText(doc);
            statusLabel.Text = "Document loaded successfully.";
        }
        catch (Exception ex)
        {
            statusLabel.Text = $"Error: {ex.Message}";
        }
    }

    private async void SaveDocx(object sender, EventArgs e)
    {
        try
        {
            var document = new WordDocument();
            var paragraph = new Paragraph();
            paragraph.Texts.Add(new TextContent(docEditor.Text));
            document.Paragraphs.Add(paragraph);

            var fileName = $"ExportedDoc_{DateTime.Now:yyyyMMddHHmmss}.docx";
            var path = Path.Combine(FileSystem.AppDataDirectory, fileName);
            document.SaveAs(path);

            statusLabel.Text = $"Saved to: {fileName}";
        }
        catch (Exception ex)
        {
            statusLabel.Text = $"Save error: {ex.Message}";
        }
    }

    private string ExtractText(WordDocument doc)
    {
        var sb = new StringBuilder();
        foreach (var para in doc.Paragraphs)
        {
            foreach (var element in para.Texts)
            {
                if (element is TextContent text)
                    sb.AppendLine(text.Text);
            }
        }
        return sb.ToString();
    }
}
Imports IronWord
Imports IronWord.Models
Imports Microsoft.Maui.Storage
Imports System.Text

Namespace IronWordMauiIOS

	Partial Public Class MainPage
		Inherits ContentPage

		Public Sub New()
			InitializeComponent()
			License.LicenseKey = "YOUR-LICENSE-KEY"
		End Sub

		Private Async Sub OpenDocx(ByVal sender As Object, ByVal e As EventArgs)
			Try
				Dim file = Await FilePicker.PickAsync()
				If file Is Nothing Then
					Return
				End If

				Dim path As System.String = System.IO.Path.Combine(FileSystem.CacheDirectory, file.FileName)
				Using source = Await file.OpenReadAsync()
				Using target = System.IO.File.Create(path)
					Await source.CopyToAsync(target)
				End Using
				End Using

				Dim doc = New WordDocument(path)
				docEditor.Text = ExtractText(doc)
				statusLabel.Text = "Document loaded successfully."
			Catch ex As Exception
				statusLabel.Text = $"Error: {ex.Message}"
			End Try
		End Sub

		Private Async Sub SaveDocx(ByVal sender As Object, ByVal e As EventArgs)
			Try
				Dim document = New WordDocument()
				Dim paragraph As New Paragraph()
				paragraph.Texts.Add(New TextContent(docEditor.Text))
				document.Paragraphs.Add(paragraph)

				Dim fileName = $"ExportedDoc_{DateTime.Now:yyyyMMddHHmmss}.docx"
				Dim path As System.String = System.IO.Path.Combine(FileSystem.AppDataDirectory, fileName)
				document.SaveAs(path)

				statusLabel.Text = $"Saved to: {fileName}"
			Catch ex As Exception
				statusLabel.Text = $"Save error: {ex.Message}"
			End Try
		End Sub

		Private Function ExtractText(ByVal doc As WordDocument) As String
			Dim sb = New StringBuilder()
			For Each para In doc.Paragraphs
				For Each element In para.Texts
					Dim tempVar As Boolean = TypeOf element Is TextContent
					Dim text As TextContent = If(tempVar, CType(element, TextContent), Nothing)
					If tempVar Then
						sb.AppendLine(text.Text)
					End If
				Next element
			Next para
			Return sb.ToString()
		End Function
	End Class
End Namespace
$vbLabelText   $csharpLabel

Project File Overview

Your project structure should now include:

IronWordMauiIOS/
│
├── MainPage.xaml              ← UI Layout
├── MainPage.xaml.cs          ← Logic for UI (Word document actions)
├── IronWordMauiIOS.csproj     ← References IronWord NuGet package
├── Platforms/ios/             ← iOS-specific config (no changes needed here)
└── ...

Run the Project

  1. Set the target to iOS Simulator.
  2. Press Run.
  3. Test reading and writing .docx documents directly on your simulated iOS device.

Final Notes

  • Fully cross-platform (iOS, Android, Windows, macOS)
  • No need for Microsoft Office or Interop
  • 100% C# / .NET MAUI-native
  • Works offline
  • Excellent for building editors, resume builders, document viewers

常見問題解答

IronWord是什麼?如何在iOS上使用?

IronWord 是一個功能強大的程式庫,專為在 .NET 應用程式(包括 iOS)中處理 Word 文件而設計。它允許開發人員在其行動應用程式中無縫建立、操作和轉換 Word 文件。

如何將 IronWord 整合到我的 iOS 專案中?

要將 IronWord 整合到您的 iOS 專案中,您需要將 IronWord 程式庫新增至您的 .NET 解決方案中,配置您的專案以引用它,並使用提供的 API 來管理 Word 文件。

在 iOS 系統上使用 IronWord 需要哪些系統設定?

IronWord 需要 iOS 開發環境中相容的 .NET 元件。請確保您的開發環境已更新並支援必要的框架,以實現無縫整合。

IronWord能否在iOS上將Word文件轉換為其他格式?

是的,IronWord 可以將 Word 文件轉換為各種格式,例如 PDF,以便在 iOS 應用程式中使用,從而實現靈活的文件處理和共用。

IronWord是否支援在iOS上進行文件操作?

當然,IronWord 支援多種文件操作,包括直接在 iOS 應用程式中編輯文字、插入圖像和管理文件屬性。

是否可以使用 iOS 上的 IronWord 從頭開始建立 Word 文件?

是的,IronWord 允許您在 iOS 上從頭開始建立新的 Word 文件,並提供一套全面的工具,以程式設計方式添加內容、格式和樣式。

IronWord 如何處理 iOS 應用程式中 Word 文件的安全性問題?

IronWord 包含管理文件安全的功能,例如密碼保護和加密,確保您的 Word 文件在 iOS 應用程式上保持安全。

是否有可在 iOS 上使用 IronWord 的範例項目?

是的,Iron Software 提供範例專案和文檔,幫助開發者快速上手 iOS 上的 IronWord,展示各種功能和用例。

IronWord在iOS部署方面是否需要額外的許可?

IronWord 需要有效的授權才能部署到生產環境,包括 iOS 應用程式。請務必查看許可條款,以遵守使用指南。

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'name'

Filename: sections/author_component.php

Line Number: 18

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 18
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/get-started/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Getstarted.php
Line: 25
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'title'

Filename: sections/author_component.php

Line Number: 38

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 38
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/get-started/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Getstarted.php
Line: 25
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'comment'

Filename: sections/author_component.php

Line Number: 48

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 48
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/get-started/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Getstarted.php
Line: 25
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

準備好開始了嗎?
Nuget 下載 25,807 | 版本: 2025.11 剛剛發布