如何在 C# 中匯出 PDF/A、PDF/A-3 或 PDF/A-4 格式文件
IronPDF支援將 PDF 匯出為 PDF/A-3b 和 PDF/A-4標準。 PDF/A-3B 是 ISO PDF 規範的一個嚴格子集,用於建立文件的存檔版本,目的是使它們始終與儲存時完全相同。 PDF/A-4 是最新的合規標準,為數位簽章提供了更強大的支援。
第 508 條合規性
IronPDF回應了Google的倡議,旨在提高 PDF 歸檔和可訪問性,以符合第 508 條款的要求。 在進行HTML 轉換 PDF 轉換時,我們的渲染引擎會保留所有輔助功能。
2021年,我們改用GoogleChromium的HTML渲染引擎,從HTML渲染PDF檔。這使得我們的軟體能夠繼承Google已經實現的輔助功能。
為什麼符合第 508 條對 PDF/A 文件很重要?
第 508 條合規性確保殘疾人士可以使用螢幕閱讀器等輔助技術存取 PDF 文件。 符合第 508 條款標準的 PDF/A 文件保證內容在整個存檔生命週期內均可存取。 對於政府機構、教育機構以及為所有使用者提供平等資訊取得途徑的組織而言,遵守這項規定至關重要。
最簡工作流程(4 個步驟)
- Download C# Library for Creating PDF/A Documents
- 載入現有 PDF 或從 HTML/URL 渲染
- 根據存檔要求選擇 PDF/A 版本
- 轉換並儲存為符合 PDF/A 標準的文檔
IronPDF支援哪些 PDF/A 版本?
IronPDF支援 A 級和 B 級一致性。 "A"代表"可訪問","B"代表"基本"。這些等級適用於 PDF/A-1、PDF/A-2 和 PDF/A-3 標準。 以下資訊來自AdAdobe 關於 PDF/A 的文件。 預設情況下,透過IronPDF產生的 PDF 輸出為 PDF/A-3B (ISO 19005-3)。
- A 級符合所有規範要求,使輔助軟體能夠提高身體障礙使用者的可訪問性。
- B 級合規性較低,最低限度的合規性要求,重點在於長期保持視覺外觀。
PDF/A-1、PDF/A-2 和 PDF/A-3 之間有什麼區別?
PDF/A-1:基於原始 PDF 1.4 版本。
PDF/A-2:於 2011 年 7 月以 ISO 32001-1 發布,包含 PDF 版本 1.7 之前的所有功能以及新功能。 支援掃描文件的 JPEG2000 格式,並滿足對自訂 XMP 元資料的特定要求。 在處理PDF 元資料時, IronPDF可確保正確處理 XMP 元資料。
PDF/A-3:包含所有二級要求。 允許將其他文件格式(XML、CSV 和文字處理格式)嵌入到符合 PDF/A 標準的文件中。
PDF/A-4: PDF/A 合規標準的最新版本,於 2020 年發布。它基於 PDF 2.0,並引入了改進的功能,包括相比 PDF/A-3 更強大的數位簽章支援。此版本最適合涉及 3D 模型和其他複雜元素的工程文件和技術工作流程。
| 特徵 | PDF/A-3 | PDF/A-4 |
|---|---|---|
| 基礎 PDF 版本 | PDF 1.7 | PDF 2.0 |
| 嵌入式檔案附件 | 支援 | 不支援。 |
| 數位簽名 | 支援 | 增強支持 |
| 最佳用例 | 發票,XML資料嵌入 | 工程、3D模型、技術工作流程 |
IronPDF目前尚未支援將附有附件的 PDF 檔案轉換為 PDF/A-3B 格式。
轉換為最新的 PDF/A-4 標準
PDF/A-4 是 PDF/A 系列中的最新合規標準。 它被認為是各種文件類型的最佳存檔格式,尤其適用於涉及數位簽章的文件。 此格式不允許加密和多媒體元素,確保每個檔案都是完全獨立的。
將現有文件轉換為符合 PDF/A-4 標準的文件非常簡單。
:path=/static-assets/pdf/content-code-examples/how-to/sample-pdfa4.cs
using IronPdf;
// Load an existing PDF
PdfDocument pdf = PdfDocument.FromFile("input.pdf");
// Save as PDF/A-4 compliant document
pdf.SaveAsPdfA("pdfa4-output.pdf", PdfAVersions.PdfA4);
Imports IronPdf
' Load an existing PDF
Dim pdf As PdfDocument = PdfDocument.FromFile("input.pdf")
' Save as PDF/A-4 compliant document
pdf.SaveAsPdfA("pdfa4-output.pdf", PdfAVersions.PdfA4)
從現有 PDF 文件 (PDF/A-3B)
本範例使用 wikipedia.pdf,這是使用IronPDF產生的 PDF 檔案。 為獲得最佳效果,請確保在開始轉換之前已正確配置許可證密鑰。
下面的程式碼會將檔案載入並重新儲存為 PDF/A-3B 和 PDF/A-4 相容格式,以示範與這兩種標準的相容性。
轉換前的輸入PDF檔是什麼樣的?
什麼程式碼可以將現有的PDF檔案轉換為PDF/A格式?
:path=/static-assets/pdf/content-code-examples/how-to/pdfa-fromfile.cs
using IronPdf;
// Create a PdfDocument object or open any PDF File
PdfDocument pdf = PdfDocument.FromFile("wikipedia.pdf");
// Use the SaveAsPdfA method to save to file
pdf.SaveAsPdfA("pdf-a3-wikipedia.pdf", PdfAVersions.PdfA3b);
Imports IronPdf
' Create a PdfDocument object or open any PDF File
Private pdf As PdfDocument = PdfDocument.FromFile("wikipedia.pdf")
' Use the SaveAsPdfA method to save to file
pdf.SaveAsPdfA("pdf-a3-wikipedia.pdf", PdfAVersions.PdfA3b)
如何確認PDF/A轉換是否成功?
輸出檔符合PDF/A-3b標準:

從 HTML 設計或 URL(PDF/A-3B)
本範例使用 HTML 設計檔案 design.html,透過IronPDF將 HTML 渲染為 PDF,並匯出為符合 PDF/A 標準的 PDF 檔案。 HTML檔案到 PDF 的轉換過程會保留所有樣式和格式。
以下程式碼將輸出儲存為符合 PDF/A-3B 標準的 PDF 檔案。
如何將HTML檔案轉換為PDF/A格式?
:path=/static-assets/pdf/content-code-examples/how-to/pdfa-fromhtml.cs
using IronPdf;
// Use the Chrome Renderer to make beautiful HTML designs
var chromeRenderer = new ChromePdfRenderer();
// Render an HTML design as a PdfDocument object using Chrome
PdfDocument pdf = chromeRenderer.RenderHtmlAsPdf("design.html");
// Use the SaveAsPdfA method to save to file
pdf.SaveAsPdfA("design-accessible.pdf", PdfAVersions.PdfA3b);
Imports IronPdf
' Use the Chrome Renderer to make beautiful HTML designs
Private chromeRenderer = New ChromePdfRenderer()
' Render an HTML design as a PdfDocument object using Chrome
Private pdf As PdfDocument = chromeRenderer.RenderHtmlAsPdf("design.html")
' Use the SaveAsPdfA method to save to file
pdf.SaveAsPdfA("design-accessible.pdf", PdfAVersions.PdfA3b)
輸出檔符合PDF/A-3B標準:

如何將網頁轉換為PDF/A格式?
此範例使用IronPDF將 URL 中的 https://www.microsoft.com 內容渲染為 PDF 文件,並匯出為符合 PDF/A 標準的 PDF 文件。 URL轉 PDF功能可確保所有網頁內容(包括JavaScript和 CSS)都能正確渲染。
以下程式碼將輸出儲存為符合 PDF/A-3B 標準的 PDF 檔案。
:path=/static-assets/pdf/content-code-examples/how-to/pdfa-fromurl.cs
using IronPdf;
// Use the Chrome Renderer to make beautiful HTML designs from URLs
var chromeRenderer = new ChromePdfRenderer();
// Render a Website as a PdfDocument object using Chrome
PdfDocument pdf = chromeRenderer.RenderUrlAsPdf("https://www.microsoft.com");
// Use the SaveAsPdfA method to save to file
pdf.SaveAsPdfA("website-accessible.pdf", PdfAVersions.PdfA3b);
Imports IronPdf
' Use the Chrome Renderer to make beautiful HTML designs from URLs
Private chromeRenderer = New ChromePdfRenderer()
' Render a Website as a PdfDocument object using Chrome
Private pdf As PdfDocument = chromeRenderer.RenderUrlAsPdf("https://www.microsoft.com")
' Use the SaveAsPdfA method to save to file
pdf.SaveAsPdfA("website-accessible.pdf", PdfAVersions.PdfA3b)
輸出檔符合PDF/A-3B標準:

支援嵌入附件(PDF/A-3B)
IronPDF支援在 PDF/A 轉換過程中使用文件路徑、位元組數組或流將文件嵌入 PDF 文件中。 此功能可建立包含所有必要支援材料的獨立存檔文件。 如需了解更多進階 PDF 操作功能,請查看我們的PDF 編輯教學。
嵌入檔案路徑
使用檔案路徑嵌入檔案。 提供了一系列文件路徑,這些文件在 PDF/A 轉換過程中作為附件包含在內。
:path=/static-assets/pdf/content-code-examples/how-to/pdfa-attachment-path.cs
using IronPdf;
using System.Collections.Generic;
PdfDocument pdf = new PdfDocument("Google.pdf");
// Initialize collection of embed file as string of path
IEnumerable<string> embedPaths = new[] { "File1.xml", "File2.png" };
// Convert to Pdf/A-3B with embeded files
pdf.ConvertToPdfA(embedPaths);
Imports IronPdf
Imports System.Collections.Generic
Private pdf As New PdfDocument("Google.pdf")
' Initialize collection of embed file as string of path
Private embedPaths As IEnumerable(Of String) = { "File1.xml", "File2.png" }
' Convert to Pdf/A-3B with embeded files
pdf.ConvertToPdfA(embedPaths)
如何使用位元組數組嵌入文件?
透過將文件內容以位元組數組的形式提供並包含相應的文件類型來嵌入文件。當文件已載入到記憶體中時,此方法非常有用。
:path=/static-assets/pdf/content-code-examples/how-to/pdfa-attachment-byte.cs
using IronPdf;
using System.Collections.Generic;
using System.IO;
PdfDocument pdf = new PdfDocument("Google.pdf");
// Initialize collection of embed file as Bytes and their file type
byte[] fileData1 = File.ReadAllBytes("File1.png");
byte[] fileData2 = File.ReadAllBytes("File2.xml");
var embedFileConfig1 = new EmbedFileConfiguration(EmbedFileType.png);
embedFileConfig1.EmbedFileName = "logo.png";
var embedFileConfig2 = new EmbedFileConfiguration(EmbedFileType.xml)
{
EmbedFileName = "supportSystem.xml",
AFDesc = "Internal system",
ConformanceLevel = ConformanceLevel.XRECHNUNG,
SchemaNamespace = SchemaNamespace.Zugferd1,
SchemaPrefix = SchemaPrefix.rsm,
PropertyVersion = PropertyVersion.v1p0,
AFRelationship = AFRelationship.Supplement,
};
IEnumerable<EmbedFileByte> embedBytes = new[]
{
new EmbedFileByte(fileData1, embedFileConfig1),
new EmbedFileByte(fileData2, embedFileConfig2)
};
// Convert to Pdf/A-3B with embeded files
pdf.ConvertToPdfA(embedBytes).SaveAs("PdfACompliance.pdf");
Imports IronPdf
Imports System.Collections.Generic
Imports System.IO
Private pdf As New PdfDocument("Google.pdf")
' Initialize collection of embed file as Bytes and their file type
Private fileData1() As Byte = File.ReadAllBytes("File1.png")
Private fileData2() As Byte = File.ReadAllBytes("File2.xml")
Private embedFileConfig1 = New EmbedFileConfiguration(EmbedFileType.png)
embedFileConfig1.EmbedFileName = "logo.png"
Dim embedFileConfig2 = New EmbedFileConfiguration(EmbedFileType.xml) With {
.EmbedFileName = "supportSystem.xml",
.AFDesc = "Internal system",
.ConformanceLevel = ConformanceLevel.XRECHNUNG,
.SchemaNamespace = SchemaNamespace.Zugferd1,
.SchemaPrefix = SchemaPrefix.rsm,
.PropertyVersion = PropertyVersion.v1p0,
.AFRelationship = AFRelationship.Supplement
}
Dim embedBytes As IEnumerable(Of EmbedFileByte) = {
New EmbedFileByte(fileData1, embedFileConfig1),
New EmbedFileByte(fileData2, embedFileConfig2)
}
' Convert to Pdf/A-3B with embeded files
pdf.ConvertToPdfA(embedBytes).SaveAs("PdfACompliance.pdf")
如何使用流嵌入檔案?
使用流來嵌入文件,並包含文件類型資訊。當文件資料以流的形式處理時,這種方法非常理想。
:path=/static-assets/pdf/content-code-examples/how-to/pdfa-attachment-stream.cs
using IronPdf;
using System.Collections.Generic;
using System.IO;
PdfDocument pdf = new PdfDocument("Google.pdf");
// Initialize collection of embed file as Stream and their file type
Stream stream1 = new MemoryStream(File.ReadAllBytes("File1.png"));
Stream stream2 = new MemoryStream(File.ReadAllBytes("File2.xml"));
var embedFileConfig1 = new EmbedFileConfiguration(EmbedFileType.png);
embedFileConfig1.EmbedFileName = "logo.png";
var embedFileConfig2 = new EmbedFileConfiguration(EmbedFileType.xml)
{
EmbedFileName = "supportSystem.xml",
AFDesc = "Internal system",
ConformanceLevel = ConformanceLevel.XRECHNUNG,
SchemaNamespace = SchemaNamespace.Zugferd1,
SchemaPrefix = SchemaPrefix.rsm,
PropertyVersion = PropertyVersion.v1p0,
AFRelationship = AFRelationship.Supplement,
};
IEnumerable<EmbedFileStream> embedStreams = new[]
{
new EmbedFileStream(stream1, embedFileConfig1),
new EmbedFileStream(stream2, embedFileConfig2)
};
// Convert to Pdf/A-3B with embeded files
pdf.ConvertToPdfA(embedStreams).SaveAs("PdfACompliance.pdf");
Imports IronPdf
Imports System.Collections.Generic
Imports System.IO
Private pdf As New PdfDocument("Google.pdf")
' Initialize collection of embed file as Stream and their file type
Private stream1 As Stream = New MemoryStream(File.ReadAllBytes("File1.png"))
Private stream2 As Stream = New MemoryStream(File.ReadAllBytes("File2.xml"))
Private embedFileConfig1 = New EmbedFileConfiguration(EmbedFileType.png)
embedFileConfig1.EmbedFileName = "logo.png"
Dim embedFileConfig2 = New EmbedFileConfiguration(EmbedFileType.xml) With {
.EmbedFileName = "supportSystem.xml",
.AFDesc = "Internal system",
.ConformanceLevel = ConformanceLevel.XRECHNUNG,
.SchemaNamespace = SchemaNamespace.Zugferd1,
.SchemaPrefix = SchemaPrefix.rsm,
.PropertyVersion = PropertyVersion.v1p0,
.AFRelationship = AFRelationship.Supplement
}
Dim embedStreams As IEnumerable(Of EmbedFileStream) = {
New EmbedFileStream(stream1, embedFileConfig1),
New EmbedFileStream(stream2, embedFileConfig2)
}
' Convert to Pdf/A-3B with embeded files
pdf.ConvertToPdfA(embedStreams).SaveAs("PdfACompliance.pdf")
如何使用 EmbedFileConfiguration 配置嵌入檔案屬性?
將 PdfDocument 轉換為嵌入檔案的 PDF/A-3 格式時,設定參數,例如 EmbedFileByte 或 EmbedFileStream,以指定檔案類型、資料名稱和自訂資料。
正確的配置可確保嵌入內容得到有效組織,並符合 PDF/A-3 標準。 自訂 XMP 元資料可以提供有關嵌入文件的其他信息,從而增強文件的可用性和可訪問性。 使用 EmbedFileConfiguration 類,開發人員可以輕鬆自訂文件的值和格式。
var config = new EmbedFileConfiguration
{
EmbedFileName = "Attachment.xml",
AFDesc = "Associated File Description",
ConformanceLevel = ConformanceLevel.EN16931,
SchemaNamespace = SchemaNamespace.facturX,
SchemaPrefix = SchemaPrefix.fx,
PropertyVersion = PropertyVersion.v1,
AFRelationship = AFRelationship.Alternative
};
// Load a PDF document
var document = PdfDocument.FromFile("wikipedia.pdf");
// Configure embedded file parameters
document.EmbedFileFromFilePath("path/to/attachment", config);
// Save the document as PDF/A-3b
document.SaveAsPdfA3B("output-with-configured-attachment.pdf");
var config = new EmbedFileConfiguration
{
EmbedFileName = "Attachment.xml",
AFDesc = "Associated File Description",
ConformanceLevel = ConformanceLevel.EN16931,
SchemaNamespace = SchemaNamespace.facturX,
SchemaPrefix = SchemaPrefix.fx,
PropertyVersion = PropertyVersion.v1,
AFRelationship = AFRelationship.Alternative
};
// Load a PDF document
var document = PdfDocument.FromFile("wikipedia.pdf");
// Configure embedded file parameters
document.EmbedFileFromFilePath("path/to/attachment", config);
// Save the document as PDF/A-3b
document.SaveAsPdfA3B("output-with-configured-attachment.pdf");
Option Strict On
Dim config As New EmbedFileConfiguration With {
.EmbedFileName = "Attachment.xml",
.AFDesc = "Associated File Description",
.ConformanceLevel = ConformanceLevel.EN16931,
.SchemaNamespace = SchemaNamespace.facturX,
.SchemaPrefix = SchemaPrefix.fx,
.PropertyVersion = PropertyVersion.v1,
.AFRelationship = AFRelationship.Alternative
}
' Load a PDF document
Dim document = PdfDocument.FromFile("wikipedia.pdf")
' Configure embedded file parameters
document.EmbedFileFromFilePath("path/to/attachment", config)
' Save the document as PDF/A-3b
document.SaveAsPdfA3B("output-with-configured-attachment.pdf")
EmbedFileName: 表示 PDF/A 文件中嵌入檔案名稱的string屬性。 預設值為空字串。AFDesc: 表示嵌入檔案的關聯檔案所描述的string屬性。預設值為空字串。ConformanceLevel: 套用於 PDF/A 文件 XMP 元資料的嵌入 XML 檔案的一致性等級。 預設值為ConformanceLevel.EN16931。 IronPDF透過ConformanceLevel枚舉提供不同的值。SchemaNamespace: PDF/A Schema NamespaceURI 嵌入 XML 檔案並套用於 PDF/A 文件的 XMP 元資料。 預設值為SchemaNamespace.facturX,枚舉中提供了各種選項SchemaNamespace。SchemaPrefix: 用於嵌入 XML 檔案的 PDF/A 模式前綴,適用於 PDF/A 文件的 XMP 元資料。 預設值為SchemaPrefix.fx,枚舉類型為SchemaPrefix,還有幾個選項。PropertyVersion: 套用於 PDF/A 文件 XMP 元資料的嵌入 XML 檔案的屬性版本。 預設值為PropertyVersion.v1,枚舉類型為PropertyVersion,有多個選項。AFRelationship: 關聯文件(嵌入文件)與 PDF/A 文件的關係。AFRelationship枚舉中有多個選項。
什麼原因會導致 PDF/A 中的字元顯示問題?
PDF/A 要求文件中的所有字元都對應到視覺上和語義上正確的字體。 並非所有字體都必須嵌入,但所用字體必須支援所需的字形。如果使用錯誤或不完整的字體,某些字元可能會顯示不完整、缺失或渲染錯誤—尤其是在使用特殊文字或符號的語言中。 為了優化檔案大小,請參考我們的PDF 壓縮指南,以平衡字體嵌入和檔案大小。
為什麼PDF/A文件中有些字元顯示不完整?
例如,在下面的問題中,上面的範例使用了正確的字體並正確顯示字符,而下面的範例由於字體不匹配而無法正確渲染字符。

從現有 PDF 文件 (PDF/A-4)
本範例使用"ENV-2026-1847-Assessment-Report.pdf",這是一份 8 頁的市政環境影響評估文件。 該報告證明 PDF/A-4 適合用於存檔需要長期保存的官方政府文件——環境研究、監管文件和機構必須保留數十年的合規記錄。
PDF/A-4 格式非常適合這些文檔,因為它保證文件在一段時間內保持視覺效果,嵌入所有字體和資源,並支援官方認證所需的增強型數位簽章功能。
輸入檔:"ENV-2026-1847-Assessment-Report.pdf"
程式碼
:path=/static-assets/pdf/content-code-examples/how-to/save-as-pdfa4.cs
using IronPdf;
// Load the environmental impact assessment document
PdfDocument pdf = PdfDocument.FromFile("ENV-2026-1847-Assessment-Report.pdf");
// Save as PDF/A-4 compliant document for long-term archival
pdf.SaveAsPdfA("ENV-2026-1847-Report-PDFA4Compliant.pdf", PdfAVersions.PdfA4);
Imports IronPdf
' Load the environmental impact assessment document
Dim pdf As PdfDocument = PdfDocument.FromFile("ENV-2026-1847-Assessment-Report.pdf")
' Save as PDF/A-4 compliant document for long-term archival
pdf.SaveAsPdfA("ENV-2026-1847-Report-PDFA4Compliant.pdf", PdfAVersions.PdfA4)
輸出
輸出檔符合PDF/A-4標準:

準備好要看看你還能做什麼了嗎? 請造訪我們的教學頁面:建立 PDF
常見問題解答
如何使用 C# 將標準 PDF 轉換為 PDF/A-3b 格式?
使用 IronPDF,您只需使用兩行程式碼即可將任何標準 PDF 轉換為 PDF/A-3b 格式。只需使用 PdfDocument.FromFile() 載入您的 PDF,然後調用 SaveAsPdfA() 將其匯出為符合要求的 PDF/A-3b 文件,以便長期存檔。
什麼是 PDF/A-3b,為什麼它對文件歸檔很重要?
PDF/A-3b 是 ISO PDF 規格的嚴格子集,專為長期文件保存而設計。IronPDF 支援 PDF/A-3b 匯出,以確保您的文件永遠呈現與儲存時一模一樣的效果,因此非常適合對文件完整性要求極高的法律、政府和歸檔用途。
PDF/A 轉換是否支援 Section 508 可存取性規範?
是的,IronPDF 通過使用 Google Chromium 的渲染引擎來確保符合 Section 508 的規定,該引擎繼承了 Google 的無障礙功能。這意味著使用螢幕閱讀器等輔助技術的殘障使用者可以存取您的 PDF/A 文件。
我可以直接將 HTML 內容轉換成 PDF/A 格式嗎?
絕對可以IronPDF 可讓您直接將 HTML 內容或 URL 轉換為 PDF/A-3b 格式。Google Chromium 渲染引擎會在 HTML 轉換為 PDF 的過程中保留所有可存取性功能,確保您所產生的 PDF/A 文件完全符合規範。
與標準 PDF 格式相比,使用 PDF/A-3b 的主要優點是什麼?
IronPDF 的 PDF/A-3b 匯出功能可確保長期保存、在所有檢視器上提供一致的呈現、符合 Section 508 可訪問性規定,並遵守 ISO 存檔標準。這使得它非常適合法律文件、政府記錄以及任何需要永久存檔的內容。

