.NET MAUI Blazor for (PDF,EXCEL,OCR,BARCODE,QR Code)
.NET Multi-platform App UI(.NET MAUI)包含 BlazorWebView 控件,可讓開發人員使用 Visual Studio 將 MAUI Blazor 伺服器應用程式整合至 .NET MAUI 專案中。 這些 Blazor 混合應用程式稱為 .NET MAUI Blazor 應用程式,可將 Blazor 混合應用程式與特定平台功能整合,並呈現網頁 UI(使用者介面)控制項。 這些 .NET MAUI Blazor 應用程式是跨平台應用程式,因為 .NET MAUI 是跨平台框架,不需要特定平台的程式碼。 我們可以在 Android 裝置/Android 模擬器、iOS、macOS、Mac Catalyst 和 Windows 作業系統機器上使用 .NET MAUI 應用程式。
BlazorWebView 控件可添加至 .NET MAUI 原生應用程式中的任何頁面,並指向 MAUI Blazor Web 應用程式的根。 之後,.NET MAUI Blazor Web 應用程式的 Razor 元件將在 .NET 程序中本機執行,並透過內嵌的 Web 視圖控制渲染 Web UI 元件。 MAUI Blazor 混合應用程式、桌面應用程式或 Windows 表單可在 .NET MAUI 支援的所有不同平台上使用,包括瀏覽器沙盒。
IronPDF:.NET PDF 函式庫

IronPDF
身為 C# 開發人員,您應該知道擁有適合工作的工具的重要性。 這就是 IronPdf 的用武之地。 這個功能強大的 .NET 類庫可讓您使用跨平台 API,輕鬆地以 .NET Core 和 .NET 技術建立 PDF 處理應用程式。IronPDF 使用 .NET Chromium 引擎將 HTML 頁面(代碼或 URL 形式)轉換為 PDF 檔案,省去了複雜的 API 和手動設計工作。 它支援 HTML、ASPX、JS、CSS 和圖片等標準網頁文件。
與 Blazor 和 .NET MAUI 相容。
IronPDF 可輕鬆整合至使用 Blazor 元件和 .NET MAUI 框架建立的應用程式中,為開發人員提供一系列建立和處理 PDF 文件的功能。 這些功能包括從 HTML、XML 和其他檔案格式產生 PDF 的能力,以及透過新增或修改文字、圖片和其他 .NET MAUI 工作量元素來編輯現有 PDF 的能力。
建立 .NET MAUI Blazor 應用程式的步驟
按照以下步驟在 Visual Studio 中建立 .NET MAUI 應用程式。
步驟 1:開啟 Visual Studio
開啟最新版本的 Visual Studio 並啟用開發者模式。 建議使用 Visual Studio 的最新版本。
步驟 2:搜尋 .NET Blazor
現在按"建立新專案"按鈕並搜尋 .NET MAUI Blazor 模板。 從搜尋結果中選擇".NET MAUI Blazor App",然後按"下一步"按鈕。

建立 Visual Studio .NET MAUI 應用程式
步驟 3:設定專案名稱
給予專案適當的名稱,然後按一下下一步按鈕。
步驟 4:.NET Framework
選擇 .NET 目標框架。 為使工作順利進行,建議使用最新的架構。 選擇框架後,按一下建立按鈕。
依照上述步驟,即可建立 .NET MAUI Blazor 應用程式。

建立 Visual Studio .NET MAUI 應用程式
讓我們來看看如何使用這個 IronPDF 的根 Blazor 元件專案。
將 Blazor 內容匯出至 PDF.
我們可以使用下列程式碼,非常輕鬆地將 Blazor 內容轉換為 PDF。
首先,開啟 Index.razor 檔案,並將程式碼更換為下列程式碼:
@page "/"
<!-- Input to take HTML content and button to trigger PDF generation -->
<input @bind="InputValue" placeholder="Enter HTML content" />
<button @onclick="SubmitHTML">Render HTML</button>
@code {
// Property to bind input value
private string InputValue { get; set; }
// Async method to render HTML as PDF and save
private async Task SubmitHTML()
{
// Create an instance of ChromePdfRenderer
var renderer = new IronPdf.ChromePdfRenderer();
// Render the HTML input value as a PDF document
var doc = renderer.RenderHtmlAsPdf(InputValue);
// Save the document as 'Test.pdf' on the local file system
doc.SaveAs("Test.pdf");
}
}@page "/"
<!-- Input to take HTML content and button to trigger PDF generation -->
<input @bind="InputValue" placeholder="Enter HTML content" />
<button @onclick="SubmitHTML">Render HTML</button>
@code {
// Property to bind input value
private string InputValue { get; set; }
// Async method to render HTML as PDF and save
private async Task SubmitHTML()
{
// Create an instance of ChromePdfRenderer
var renderer = new IronPdf.ChromePdfRenderer();
// Render the HTML input value as a PDF document
var doc = renderer.RenderHtmlAsPdf(InputValue);
// Save the document as 'Test.pdf' on the local file system
doc.SaveAs("Test.pdf");
}
}'INSTANT VB TODO TASK: The following line could not be converted:
page "/" <!-- Input [to] take HTML content [and] button [to] trigger PDF generation -- > <input bind="InputValue" placeholder="Enter HTML content" /> <button onclick="SubmitHTML"> Render HTML</button> code
If True Then
' Property to bind input value
private String InputValue {get;set;}
' Async method to render HTML as PDF and save
'INSTANT VB TODO TASK: Local functions are not converted by Instant VB:
' private async Task SubmitHTML()
' {
' ' Create an instance of ChromePdfRenderer
' var renderer = New IronPdf.ChromePdfRenderer();
'
' ' Render the HTML input value as a PDF document
' var doc = renderer.RenderHtmlAsPdf(InputValue);
'
' ' Save the document as 'Test.pdf' on the local file system
' doc.SaveAs("Test.pdf");
' }
End If此代碼有助於在本機上下載生成的 PDF 檔案。這就是我們如何使用 IronPDF 將 Blazor 內容轉換為 PDF 檔案,而無需使用任何外部函式庫。

使用 .NET MAUI Blazor 生成 PDF
我們將在文字方塊中輸入以下 HTML:
<!DOCTYPE html>
<html>
<head>
<link href='https://fonts.googleapis.com/css2?family=Popin&display=swap' rel='stylesheet'>
<style>
/* Add CSS styles for the invoice here */
body{
font-family: 'Popin', cursive;
}
.invoice {
width: 80%;
margin: 0 auto;
border: 1px solid #ccc;
padding: 20px;
background-color: #f5f5f5;
color: #333;
}
.invoice h1 {
text-align: center;
}
.invoice .invoice-info {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
}
.invoice .invoice-info div {
width: 45%;
}
.invoice table {
width: 100%;
border-collapse: collapse;
}
.invoice table th, .invoice table td {
border: 1px solid #ccc;
padding: 10px;
}
.invoice table th {
text-align: left;
background-color: #f5f5f5;
}
.invoice table td {
text-align: right;
}
.invoice table td.total {
font-weight: bold;
}
</style>
</head>
<body>
<div class="invoice">
<h1>Invoice</h1>
<div class="invoice-info">
<div>
<p><strong>From:</strong></p>
<p>Your Company Name</p>
<p>123 Main St</p>
<p>City, State ZIP</p>
</div>
<div>
<p><strong>To:</strong></p>
<p>Customer Name</p>
<p>456 Park Ave</p>
<p>City, State ZIP</p>
</div>
</div>
<table>
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>Product 1</td>
<td>1</td>
<td>$10.00</td>
<td>$10.00</td>
</tr>
<tr>
<td>Product 2</td>
<td>2</td>
<td>$5.00</td>
<td>$10.00</td>
</tr>
<tr>
<td colspan="3" class="total">Total:</td>
<td class="total">$20.00</td>
</tr>
</tbody>
</table>
</div>
</body>
</html><!DOCTYPE html>
<html>
<head>
<link href='https://fonts.googleapis.com/css2?family=Popin&display=swap' rel='stylesheet'>
<style>
/* Add CSS styles for the invoice here */
body{
font-family: 'Popin', cursive;
}
.invoice {
width: 80%;
margin: 0 auto;
border: 1px solid #ccc;
padding: 20px;
background-color: #f5f5f5;
color: #333;
}
.invoice h1 {
text-align: center;
}
.invoice .invoice-info {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
}
.invoice .invoice-info div {
width: 45%;
}
.invoice table {
width: 100%;
border-collapse: collapse;
}
.invoice table th, .invoice table td {
border: 1px solid #ccc;
padding: 10px;
}
.invoice table th {
text-align: left;
background-color: #f5f5f5;
}
.invoice table td {
text-align: right;
}
.invoice table td.total {
font-weight: bold;
}
</style>
</head>
<body>
<div class="invoice">
<h1>Invoice</h1>
<div class="invoice-info">
<div>
<p><strong>From:</strong></p>
<p>Your Company Name</p>
<p>123 Main St</p>
<p>City, State ZIP</p>
</div>
<div>
<p><strong>To:</strong></p>
<p>Customer Name</p>
<p>456 Park Ave</p>
<p>City, State ZIP</p>
</div>
</div>
<table>
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>Product 1</td>
<td>1</td>
<td>$10.00</td>
<td>$10.00</td>
</tr>
<tr>
<td>Product 2</td>
<td>2</td>
<td>$5.00</td>
<td>$10.00</td>
</tr>
<tr>
<td colspan="3" class="total">Total:</td>
<td class="total">$20.00</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>MAUI Blazor 應用程式會產生如下所示的輸出。

使用 .NET MAUI Blazor 生成 PDF
透過Blazor PDF 創作教學和.NET MAUI 應用程式取得更多關於 IronPDF 的資訊。
IronXL。

IronXL
IronXL 是一個 .NET 函式庫,可讓開發人員在 C# 中讀取、編輯和建立 Excel 試算表。 它不需要安裝 Microsoft Excel,並支援所有平台,包括 Android、iOS、macOS、Windows 機器和 Azure。 它提供了一系列功能,例如從各種格式載入和編輯資料、儲存和匯出至各種格式,以及處理 System.Data 物件、處理公式、排序資料和設定儲存格的樣式。 此外,它可以 NuGet 套件的形式提供,並在其網站和 GitHub 套件庫中提供說明文件和範例。
IronXL for .NET 支援 .NET MAUI 和 Blazor,讓使用者能夠從一系列來源存取或取得資料,包括 Excel 試算表、Web 或 Azure 服務以及其他應用程式。 有了 IronXL for .NET MAUI 和 Blazor 的支援,開發人員就能獲得最強大的工具,在 iOS、macOS 和 Windows、Android 裝置上開發引人入勝的使用者介面。
讓我們來看看 IronXL 的範例程式碼:
using IronXL;
using IronXL.Formatting;
using IronXL.Formatting.Enums;
using IronXL.Styles;
// Load an existing Excel workbook
WorkBook workbook = WorkBook.Load("test.xlsx");
WorkSheet sheet = workbook.DefaultWorkSheet;
// Create a specific conditional formatting rule for cells with values less than 8
ConditionalFormattingRule rule = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.LessThan, "8");
// Set different style options for the rule
rule.FontFormatting.IsBold = true; // Bold text
rule.FontFormatting.FontColor = "#123456"; // Custom font color
rule.BorderFormatting.RightBorderColor = "#ffffff"; // Right border color
rule.BorderFormatting.RightBorderType = BorderType.Thick; // Right border thickness
rule.PatternFormatting.BackgroundColor = "#54bdd9"; // Background color
rule.PatternFormatting.FillPattern = FillPattern.Diamonds; // Fill pattern
// Add the formatting rule to the specified cell range
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A8", rule);
// Create another conditional formatting rule for values between 7 and 10
ConditionalFormattingRule rule1 = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.Between, "7", "10");
// Set additional style options for the new rule
rule1.FontFormatting.IsItalic = true; // Italic text
rule1.FontFormatting.UnderlineType = FontUnderlineType.Single; // Single underline
// Add this formatting rule to a different range of cells
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A9", rule1);
// Save the workbook with the applied conditional formatting
workbook.SaveAs("ApplyConditionalFormatting.xlsx");using IronXL;
using IronXL.Formatting;
using IronXL.Formatting.Enums;
using IronXL.Styles;
// Load an existing Excel workbook
WorkBook workbook = WorkBook.Load("test.xlsx");
WorkSheet sheet = workbook.DefaultWorkSheet;
// Create a specific conditional formatting rule for cells with values less than 8
ConditionalFormattingRule rule = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.LessThan, "8");
// Set different style options for the rule
rule.FontFormatting.IsBold = true; // Bold text
rule.FontFormatting.FontColor = "#123456"; // Custom font color
rule.BorderFormatting.RightBorderColor = "#ffffff"; // Right border color
rule.BorderFormatting.RightBorderType = BorderType.Thick; // Right border thickness
rule.PatternFormatting.BackgroundColor = "#54bdd9"; // Background color
rule.PatternFormatting.FillPattern = FillPattern.Diamonds; // Fill pattern
// Add the formatting rule to the specified cell range
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A8", rule);
// Create another conditional formatting rule for values between 7 and 10
ConditionalFormattingRule rule1 = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.Between, "7", "10");
// Set additional style options for the new rule
rule1.FontFormatting.IsItalic = true; // Italic text
rule1.FontFormatting.UnderlineType = FontUnderlineType.Single; // Single underline
// Add this formatting rule to a different range of cells
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A9", rule1);
// Save the workbook with the applied conditional formatting
workbook.SaveAs("ApplyConditionalFormatting.xlsx");Imports IronXL
Imports IronXL.Formatting
Imports IronXL.Formatting.Enums
Imports IronXL.Styles
' Load an existing Excel workbook
Private workbook As WorkBook = WorkBook.Load("test.xlsx")
Private sheet As WorkSheet = workbook.DefaultWorkSheet
' Create a specific conditional formatting rule for cells with values less than 8
Private rule As ConditionalFormattingRule = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.LessThan, "8")
' Set different style options for the rule
rule.FontFormatting.IsBold = True ' Bold text
rule.FontFormatting.FontColor = "#123456" ' Custom font color
rule.BorderFormatting.RightBorderColor = "#ffffff" ' Right border color
rule.BorderFormatting.RightBorderType = BorderType.Thick ' Right border thickness
rule.PatternFormatting.BackgroundColor = "#54bdd9" ' Background color
rule.PatternFormatting.FillPattern = FillPattern.Diamonds ' Fill pattern
' Add the formatting rule to the specified cell range
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A8", rule)
' Create another conditional formatting rule for values between 7 and 10
Dim rule1 As ConditionalFormattingRule = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.Between, "7", "10")
' Set additional style options for the new rule
rule1.FontFormatting.IsItalic = True ' Italic text
rule1.FontFormatting.UnderlineType = FontUnderlineType.Single ' Single underline
' Add this formatting rule to a different range of cells
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A9", rule1)
' Save the workbook with the applied conditional formatting
workbook.SaveAs("ApplyConditionalFormatting.xlsx")上述程式碼可協助您開啟已存在的 Excel 檔案,並在不同的儲存格範圍套用條件格式化。 使用以下Excel 條件格式化教學獲取更多關於 IronXL 的教學。
IronOCR。

IronOCR
IronOCR 是 C# 開發人員廣泛使用的 OCR 工具,提供直接的 API,可將 OCR 功能整合至 C# 應用程式。 它可以有效地從掃描文件、PDF 和影像等各種來源中擷取文字,使用先進的機器學習演算法,即使是扭曲或難以閱讀的文字也能精確辨識。 IronOCR 為 C# 開發人員提供一系列自訂選項,包括調整辨識文字的語言、字型和字元集、預測集合,以及預先處理影像以提高 OCR 精確度。 這些客製化功能可讓開發人員優化 IronOCR 的效能,以符合他們的特定需求。
IronOCR 是一個功能強大的 OCR 識別函式庫,支援 .NET MAUI 和 Blazor。 有了 IronOCR,開發人員可以在任何平台上快速建立應用程式,而不必擔心掃描、讀取和寫入大量文字資料的複雜性。 沒有其他 OCR 軟體能讓使用者以如此簡單的整合方式存取如此多的開發工具。
請看一下 IronOCR 的範例,它展示了我們如何使用 IronOCR 從 PDF 檔案中擷取文字。
using IronOcr;
var ocrTesseract = new IronTesseract();
using (var ocrInput = new OcrInput())
{
// OCR the entire document
ocrInput.AddPdf("example.pdf", "password");
// Alternatively OCR selected page numbers
ocrInput.AddPdfPages("example.pdf", new[] { 1, 2, 3 }, "password");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
}using IronOcr;
var ocrTesseract = new IronTesseract();
using (var ocrInput = new OcrInput())
{
// OCR the entire document
ocrInput.AddPdf("example.pdf", "password");
// Alternatively OCR selected page numbers
ocrInput.AddPdfPages("example.pdf", new[] { 1, 2, 3 }, "password");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
}Imports IronOcr
Private ocrTesseract = New IronTesseract()
Using ocrInput As New OcrInput()
' OCR the entire document
ocrInput.AddPdf("example.pdf", "password")
' Alternatively OCR selected page numbers
ocrInput.AddPdfPages("example.pdf", { 1, 2, 3 }, "password")
Dim ocrResult = ocrTesseract.Read(ocrInput)
Console.WriteLine(ocrResult.Text)
End Using閱讀更多關於如何在 .NET Maui 中使用 IronOCR 的教學,請造訪此 OCR in .NET MAUI 教學。
使用以下PDF OCR 教學獲取更多關於 IronOCR 的教學。
IronBarcode。

IronBarcode
如何在 .NET Maui 中建立 BarCode 掃描器
- 下載 C# 函式庫以在 Maui 中建立 BarCode 掃描器
- 利用
Read方法掃描 PDF 和影像中的 BarCode - 支援多種條碼格式,包括 QR 碼、Code 39、Code 128 等等
- 將 C# 函式庫輕鬆整合至現有的 .NET MAUI 與 Blazor 專案中
- 對不完美的影像進行預處理
IronBarcode 是一個 C# 函式庫,可讓開發人員輕鬆地在其 C# 應用程式中加入條碼讀寫功能。 對於那些從事涉及掃描或產生 BarCode 的專案(例如庫存管理系統或銷售點系統)的人來說,這個資料庫尤其有用。 IronBarcode 的主要功能之一是能夠讀寫多種條碼格式,包括 QR 代碼、Code 39、Code 128 以及許多其他格式。 這表示開發人員可以根據專案的需求,使用它來處理各種不同的 BarCode 類型。
IronBarcode 支援 .NET MAUI 和 Blazor,這是開發人員用來建立現代化、跨平台應用程式的兩個常用框架。 這對開發人員來說是有益的,因為這可以讓他們輕鬆地將 IronBarcode 強大的條碼生成和掃描功能整合到他們的 .NET MAUI 和 Blazor 項目中。
以下程式碼範例說明如何使用 IronBarcode 讀取多種類型的條碼。 這是一個非常簡單易懂的過程。
using IronBarCode;
using IronSoftware.Drawing;
// Reading a barcode is easy with IronBarcode.
// Read from a File, Bitmap, Image, or Stream:
var resultFromFile = BarcodeReader.Read(@"file/barcode.png"); // From a file
var resultFromBitMap = BarcodeReader.Read(new Bitmap("barcode.bmp")); // From a bitmap
var resultFromAnyBitmap = BarcodeReader.Read(new AnyBitmap("barcode.bmp")); // From AnyBitmap
var resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg")); // From an image
var resultFromStream = BarcodeReader.Read(myStream); // From a stream
// PDFs are more intricate and must be read using ReadPdf:
var resultFromPdf = BarcodeReader.ReadPdf(@"file/mydocument.pdf");using IronBarCode;
using IronSoftware.Drawing;
// Reading a barcode is easy with IronBarcode.
// Read from a File, Bitmap, Image, or Stream:
var resultFromFile = BarcodeReader.Read(@"file/barcode.png"); // From a file
var resultFromBitMap = BarcodeReader.Read(new Bitmap("barcode.bmp")); // From a bitmap
var resultFromAnyBitmap = BarcodeReader.Read(new AnyBitmap("barcode.bmp")); // From AnyBitmap
var resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg")); // From an image
var resultFromStream = BarcodeReader.Read(myStream); // From a stream
// PDFs are more intricate and must be read using ReadPdf:
var resultFromPdf = BarcodeReader.ReadPdf(@"file/mydocument.pdf");Imports IronBarCode
Imports IronSoftware.Drawing
' Reading a barcode is easy with IronBarcode.
' Read from a File, Bitmap, Image, or Stream:
Private resultFromFile = BarcodeReader.Read("file/barcode.png") ' From a file
Private resultFromBitMap = BarcodeReader.Read(New Bitmap("barcode.bmp")) ' From a bitmap
Private resultFromAnyBitmap = BarcodeReader.Read(New AnyBitmap("barcode.bmp")) ' From AnyBitmap
Private resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg")) ' From an image
Private resultFromStream = BarcodeReader.Read(myStream) ' From a stream
' PDFs are more intricate and must be read using ReadPdf:
Private resultFromPdf = BarcodeReader.ReadPdf("file/mydocument.pdf")請瀏覽此 Barcode Scanner in .NET MAUI 教學,閱讀更多關於如何在 .NET Maui 中使用 IronBarcode 的教學。
使用以下條碼掃描器閱讀器教程獲取更多 IronBarcode 的使用案例和教程。
IronDrawing。

IronDrawing
IronDrawing 是一個免費、開放原始碼的函式庫,為需要建立使用圖形、影像和字型的跨平台應用程式的 .NET 開發人員提供解決方案。 它是不同圖形庫之間的橋梁,讓開發人員在程式碼中使用單一、一致的格式,同時仍能使用他們所選擇的底層圖形庫。IronDrawing 與 .NET Framework 4.6.2 及更新版本相容,包括 .NET 5、6 和 7。
IronDrawing 由 Iron Software 開發和維護,Iron Software 是一個由經驗豐富的 .NET 開發人員組成的團隊,致力於 dot NET 的成長和成功。 他們創建 IronDrawing 的目的是讓類庫和 NuGet 開發更容易,並幫助 NuGet 生態系統蓬勃發展。
開發 IronDrawing 的原因
IronDrawing 是針對微軟宣佈的一項突破性變更而開發的,在該變更中,System.Drawing.Common將僅支援 Windows 平台。 這項變更對維護使用 System.Drawing.Common 的跨平台函式庫的開發人員造成問題,因為這需要他們重新建立函式庫,以支援 Android、iOS 等非 Windows 使用者。 IronDrawing 被創建為一種中介格式,可在不同的圖形庫之間進行轉換,使開發人員在新的圖形標準出現時更容易過渡到新的圖形標準。
IronDrawing。 的特點
IronDrawing 提供了多種功能來協助開發人員的工作,其中包括 AnyBitmap 這個普遍相容的 Bitmap 類別,它可以投射到其他各種 Bitmap 實作; Color,一個普遍相容的 Color 類別; CropRectangle,一個普遍相容的 Rectangle 類別; 以及 AnyFont 這個普遍相容的 Font 類別。 它也提供了這些類別與不同圖形庫中對應類別之間的隱含轉換,讓它們之間的轉換變得容易。 您可以從 NuGet 網站取得。
IronDrawing 支持几乎所有的 .NET 模板,包括 .NET MAUI 和 Blazor。 其不受平台限制的特性使其容易用於各種應用程式,從 Windows 桌面到行動或網頁型專案。
開放原始碼的好處
IronDrawing 是一個開放原始碼的函式庫。 任何人都可以從 GitHub 套件庫存取程式碼,因此比以往更容易自訂和修改程式庫,以更符合個別專案和需求。 不僅如此,公開源代碼還能鼓勵開發人員之間的合作,因為他們可以分享並建立彼此的想法。 有了 IronDrawing C# 庫,您將擁有無限可能 - 因此,請前往 GitHub 並開始探索!
讓我們來看看 IronDrawing 從多種檔案格式產生 AnyBitmap 的程式碼範例。
using IronSoftware.Drawing;
AnyBitmap bitmap;
// Generate AnyBitmap using filepath
bitmap = AnyBitmap.FromFile(@"FILE_PATH");
bitmap.SaveAs("output.bmp");
// Generate AnyBitmap from bytes
byte[] bytes = File.ReadAllBytes(@"FILE_PATH");
bitmap = AnyBitmap.FromBytes(bytes);
bitmap.SaveAs("result.bmp");
// Generate AnyBitmap from memory stream
byte[] bytes = File.ReadAllBytes(@"FILE_PATH");
MemoryStream ms = new MemoryStream(bytes);
bitmap = AnyBitmap.FromStream(ms);
bitmap.SaveAs("output.bmp");
// Generate AnyBitmap from Uri
Uri uri = new Uri("URI_PATH");
bitmap = AnyBitmap.FromUri(uri);
bitmap.SaveAs("uriImage.bmp");
// Generate AnyBitmap file from SVG file
bitmap = AnyBitmap.FromFile(@"FILE_PATH.svg");
bitmap.SaveAs("result.bmp"); using IronSoftware.Drawing;
AnyBitmap bitmap;
// Generate AnyBitmap using filepath
bitmap = AnyBitmap.FromFile(@"FILE_PATH");
bitmap.SaveAs("output.bmp");
// Generate AnyBitmap from bytes
byte[] bytes = File.ReadAllBytes(@"FILE_PATH");
bitmap = AnyBitmap.FromBytes(bytes);
bitmap.SaveAs("result.bmp");
// Generate AnyBitmap from memory stream
byte[] bytes = File.ReadAllBytes(@"FILE_PATH");
MemoryStream ms = new MemoryStream(bytes);
bitmap = AnyBitmap.FromStream(ms);
bitmap.SaveAs("output.bmp");
// Generate AnyBitmap from Uri
Uri uri = new Uri("URI_PATH");
bitmap = AnyBitmap.FromUri(uri);
bitmap.SaveAs("uriImage.bmp");
// Generate AnyBitmap file from SVG file
bitmap = AnyBitmap.FromFile(@"FILE_PATH.svg");
bitmap.SaveAs("result.bmp"); Imports IronSoftware.Drawing
Private bitmap As AnyBitmap
' Generate AnyBitmap using filepath
bitmap = AnyBitmap.FromFile("FILE_PATH")
bitmap.SaveAs("output.bmp")
' Generate AnyBitmap from bytes
Dim bytes() As Byte = File.ReadAllBytes("FILE_PATH")
bitmap = AnyBitmap.FromBytes(bytes)
bitmap.SaveAs("result.bmp")
' Generate AnyBitmap from memory stream
Dim bytes() As Byte = File.ReadAllBytes("FILE_PATH")
Dim ms As New MemoryStream(bytes)
bitmap = AnyBitmap.FromStream(ms)
bitmap.SaveAs("output.bmp")
' Generate AnyBitmap from Uri
Dim uri As New Uri("URI_PATH")
bitmap = AnyBitmap.FromUri(uri)
bitmap.SaveAs("uriImage.bmp")
' Generate AnyBitmap file from SVG file
bitmap = AnyBitmap.FromFile("FILE_PATH.svg")
bitmap.SaveAs("result.bmp")IronDrawing 使用多種方法將檔案從路徑轉換成位圖。您可以看到 IronDrawing 使用記憶體串流將檔案轉換為 BMP,這對於以伺服器為基礎的應用程式非常有幫助。 同樣地,您也可以使用 SVG 檔案產生 BMP。

由 IronDrawing 開源函式庫產生的位圖檔案
定價
Iron Software 提供一套五種軟體產品,稱為 Iron Suite。該套件包括 IronPDF、IronXL、IronOCR、IronWebscraper 和 IronBarcode,這些工具都是分別用來與 PDF、試算表、影像、網頁搜刮和條碼互動的工具。
這些產品的單獨定價為每個授權 $799 起,但 Iron Software 提供整套產品的優惠捆綁價,起價為 1498 美元。Iron Suite 對於需要處理多種檔案類型,並需要自動化轉換、分析和操作這些檔案類型的人來說,是一個很好的解決方案。
結論
總而言之,.NET MAUI 是一個建立跨平台桌面和行動應用程式的框架。 在文章中,我們討論了多個函式庫,例如 IronPDF、IronXL、IronBarcode、IronOCR 和 IronDrawing,這些函式庫提供了各種功能,可用於建立和處理 PDF 文件、讀取和寫入 Excel 檔案、產生和掃描條碼、光學字元辨識,以及繪製和處理圖形。
在這些函式庫中,IronDrawing 脫穎而出,成為開發人員在 .NET 應用程式中建立和編輯向量圖形的強大工具。 它提供了廣泛的功能,而且易於使用,使其成為 .NET MAUI Framework 的重要補充。 總而言之,.NET MAUI 與這些函式庫的結合,為開發人員提供了一個多功能的工具包,讓他們可以在各種平台上建立現代化且功能豐富的應用程式。
常見問題解答
如何將 PDF 功能整合到 .NET MAUI 應用程式中?
您可以使用 IronPDF 來整合 PDF 功能,它允許您使用 .NET Chromium 引擎將 HTML 轉換為 PDF。此整合支援在您的 .NET MAUI 應用程式中建立與操作 PDF 文件。
在 .NET MAUI 專案中使用 Excel 函式庫有哪些優點?
在您的 .NET MAUI 專案中使用 IronXL,可讓您在不需要安裝 Microsoft Excel 的情況下操作 Excel 試算表。它支援跨平台(如 Android、iOS、macOS 和 Windows)閱讀、編輯和建立試算表。
IronOCR 如何增強 .NET MAUI 應用程式中的文字擷取功能?
IronOCR 在 .NET MAUI 應用程式中提供先進的 OCR 功能,可從掃描的文件、PDF 和影像中準確擷取文字。它使用機器學習演算法,並提供語言和字型的客製化功能。
在 .NET MAUI 和 Blazor 應用程式中可以實作哪些條碼功能?
IronBarcode 可以整合到 .NET MAUI 和 Blazor 應用程式中,以增加條碼讀寫功能。它支援多種條碼格式,包括 QR 碼和 Code 128,適用於庫存管理等應用程式。
IronDrawing 如何有益於跨平台圖形開發?
IronDrawing 是一個免費的開放原始碼程式庫,用於在 .NET 中建立跨平台的圖形應用程式。它提供了一致的圖形格式,填補了 Microsoft 對 System.Drawing.Common 支援變更所留下的缺口。
BlazorWebView 在 .NET MAUI 應用程式中扮演什麼角色?
BlazorWebView 是 .NET MAUI 中的一個控制項,可讓開發人員將 MAUI Blazor 伺服器應用程式整合至 .NET MAUI 專案中。它透過在原生應用程式中渲染網頁 UI 控件,促進跨平台應用程式的建立。
如何使用 .NET MAUI 實現跨平台開發?
使用 .NET MAUI 進行跨平台開發,可利用其框架建立可在 Android、iOS、macOS 和 Windows 上執行的應用程式。透過與 BlazorWebView 的整合,可使用網頁 UI 控制項,進一步增強此功能。
適用於現代應用程式開發的 .NET MAUI 有哪些主要功能?
.NET MAUI 提供了一個框架,用來建立具有原生效能的跨平台應用程式。主要功能包括整合 BlazorWebView 的網頁 UI 控件,以及相容於 IronPDF、IronXL、IronOCR、IronBarcode 和 IronDrawing 等函式庫以增強功能。







