新增附件
IronPDF 支援在 PDF 文件中新增及移除附件。
如需更多資訊,您可以瀏覽 IronPDF 文件,其中提供詳細的指南與資源。 此外,您可前往 Iron Software 網站進一步了解更多功能與特性。
準備開始了嗎?
Nuget 下載 19,014,616 | 版本: 2026.5 just released
using IronPdf;
using System.IO;
// Instantiate the Renderer and create PdfDocument from HTML
var renderer = new ChromePdfRenderer();
var myPdf = renderer.RenderHtmlFileAsPdf("my-content.html");
// Load your own attachment
byte[] attachment = File.ReadAllBytes("path/to/attachment");
// Here we can add an attachment with a name and a byte[]
PdfAttachment exampleAttachment = myPdf.Attachments.AddAttachment("exampleAttachment", attachment);
// And here is an example of removing an attachment
myPdf.Attachments.RemoveAttachment(exampleAttachment);
myPdf.SaveAs("my-content.pdf");
Imports IronPdf
Imports System.IO
' Instantiate the Renderer and create PdfDocument from HTML
Private renderer = New ChromePdfRenderer()
Private myPdf = renderer.RenderHtmlFileAsPdf("my-content.html")
' Load your own attachment
Private attachment() As Byte = File.ReadAllBytes("path/to/attachment")
' Here we can add an attachment with a name and a byte[]
Private exampleAttachment As PdfAttachment = myPdf.Attachments.AddAttachment("exampleAttachment", attachment)
' And here is an example of removing an attachment
myPdf.Attachments.RemoveAttachment(exampleAttachment)
myPdf.SaveAs("my-content.pdf")
Install-Package IronPdf
IronPDF 支援在 PDF 文件中新增及移除附件。
如需更多資訊,您可以瀏覽 IronPDF 文件,其中提供詳細的指南與資源。 此外,您可前往 Iron Software 網站進一步了解更多功能與特性。