如何在 C# 中匯出 PDF UA 格式文檔

How to Export PDF/UA Format Documents in C#

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

IronPDF允許您將PDF導出為PDF/UA標準,確保殘障人士的可訪問性。 PDF/UA遵循特定準則,包括支援像螢幕閱讀器這樣的輔助技術。 通過遵循PDF/UA,您的PDF文檔滿足《康復法案》第508條的可訪問性要求。

除了可訪問性,PDF/UA還提供諸如小屏幕上的文本重排、改進的導航選項、自定義文本外觀、增強的搜尋引擎功能、以及高效文本選擇和複製等優勢。

快速入門:生成符合PDF/UA的文檔

只需幾行代碼,便可使用IronPDF輕鬆創建符合PDF/UA的文檔。 匯入現有的PDF並快速將其轉換為PDF/UA格式,以確保所有使用者的可訪問性。 這份快速指南展示了如何有效地利用IronPDF庫來滿足可訪問性標準。

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. Copy and run this code snippet.

    var pdf = IronPdf.PdfDocument.FromFile("input.pdf");
    pdf.SaveAsPdfUA("output_pdfua.pdf");
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer
class="hsg-featured-snippet">

最少流程(5步驟)

  1. 下載IronPDF C#庫以符合PDF/UA
  2. 匯入要轉換的現有PDF文檔
  3. 根據需要編輯PDF文檔
  4. 使用SaveAsPdfUA方法導出PDF/UA文檔
  5. 使用veraPDF合規檢查軟體驗證文檔是否符合標準


導出PDF/UA文檔示例

要導出符合PDF/UA規範的PDF文檔,您可以使用SaveAsPdfUA方法。 只需匯入PDF文檔並使用該方法將其導出為PDF/UA文件。您可以填充naturalLanguages參數來指定PDF文檔的自然語言。 請查看下方顯示的PDF文檔。 您可以使用隨附代碼將其導出為PDF/UA文件。默認情況下,IronPDF將PDF/UA輸出PDF文件生成為PDF/UA-1。

輸入文件:"wikipedia.pdf"

代码

:path=/static-assets/pdf/content-code-examples/how-to/pdfua-fromfile.cs
using IronPdf;

// Open PDF File
PdfDocument pdf = PdfDocument.FromFile("wikipedia.pdf");

// Export as PDF/UA compliance PDF
pdf.SaveAsPdfUA("pdf-ua-wikipedia.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

輸出

輸出文件符合PDF/UA標準:

class="content-img-align-center">
class="center-image-wrapper"> PDF/UA compliant

輸出PDF:

將HTML呈現為PDF/UA標準

除了將文件導出為PDF/UA標準外,我們還可以利用RenderHtmlAsPdfUA方法直接將HTML輸入直接呈現為PDF/UA標準。

這裡是一個使用該方法的簡短代碼示例。

代码

:path=/static-assets/pdf/content-code-examples/how-to/pdfua-render-html-to-pdfua.cs
using IronPdf;

ChromePdfRenderer renderer = new ChromePdfRenderer();

// html is a large stright above of a full html page with <html><head><style><body> etc...
var pdf = renderer.RenderHtmlAsPdfUA(@"
    <!DOCTYPE html>
    <html>
    <head>
        <title>Document</title>
    </head>
    <body>
        <h1>Heading 1</h1>
        <h2>Heading 2</h2>
        <p>Paragraph text</p>
    </body>
    </html>");

pdf.MetaData.Title = "v2025.1";

pdf.SaveAs("html-string-ua-ironpdf.pdf");
Imports IronPdf

Private renderer As New ChromePdfRenderer()

' html is a large stright above of a full html page with <html><head><style><body> etc...
Private pdf = renderer.RenderHtmlAsPdfUA("
    <!DOCTYPE html>
    <html>
    <head>
        <title>Document</title>
    </head>
    <body>
        <h1>Heading 1</h1>
        <h2>Heading 2</h2>
        <p>Paragraph text</p>
    </body>
    </html>")

pdf.MetaData.Title = "v2025.1"

pdf.SaveAs("html-string-ua-ironpdf.pdf")
$vbLabelText   $csharpLabel

輸出

輸出文件符合PDF/UA標準:

class="content-img-align-center">
class="center-image-wrapper"> PDF/UA compliant

常見問題解答

如何使用 C# 建立符合 PDF/UA 標準的文件?

您可以使用 IronPDF 匯入現有的 PDF 文件,然後使用SaveAsPdfUA方法將其匯出為 PDF/UA 格式,從而建立符合 PDF/UA 標準的文件。

使用PDF/UA標準有哪些好處?

PDF/UA 標準確保殘障人士能夠訪問,支援螢幕閱讀器,並提供諸如小螢幕上的文字重排、改進的導航、可自訂的文字外觀和增強的搜尋功能等特性。

如何驗證PDF/UA文件是否符合規範?

您可以使用 veraPDF 合規性檢查器來驗證 PDF/UA 文件的合規性,可確保文件符合必要的標準。

我可以在將 PDF 文件匯出為 PDF/UA 格式之前對其進行編輯嗎?

是的,您可以根據需要編輯 PDF 文檔,例如添加註釋或修改內容,然後再使用SaveAsPdfUA方法匯出。

是否可以將 HTML 字串轉換為 PDF/UA 文件?

目前,IronPDF 不支援直接從 HTML 字串、文件或 Web URL 匯出新渲染的 PDF 到 PDF/UA 格式。

在 C# 中匯出 PDF/UA 文件涉及哪些步驟?

若要匯出 PDF/UA 文檔,請下載 IronPDF 庫,匯入現有 PDF,(可選)對其進行編輯,指定自然語言,然後使用SaveAsPdfUA方法。

IronPDF 中的 SaveAsPdfUA 方法是如何運作的?

IronPDF 中的SaveAsPdfUA方法用於將現有的 PDF 文件匯出為符合 PDF/UA 標準的格式,確保其符合無障礙標準。

在 PDF/UA 文件中指定自然語言的目的是什麼?

在 PDF/UA 文件中指定自然語言有助於螢幕閱讀器和其他輔助技術更好地為殘障使用者解釋文字內容。

IronPDF 在匯出為 PDF/UA 時是否相容於 .NET 10?

是的,IronPDF 與 .NET 10 完全相容,您可以在 .NET 10 專案中使用它,透過SaveAsPdfUA方法將 PDF 文件匯出為 PDF/UA 標準,而無需任何特殊配置。

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/how-to/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/Howto.php
Line: 31
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/how-to/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/Howto.php
Line: 31
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/how-to/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/Howto.php
Line: 31
Function: render_products_view

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

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