IRONSOFTWAREHOME
新增附件
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
Dim renderer As New ChromePdfRenderer()
Dim myPdf = renderer.RenderHtmlFileAsPdf("my-content.html")

' Load your own attachment
Dim attachment As Byte() = File.ReadAllBytes("path/to/attachment")

' Here we can add an attachment with a name and a byte()
Dim 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")
NuGet Download
Install-Package IronPdf
新增附件

新增附件

在 GitHub 上查看

準備開始了嗎?

Nuget Downloads 20,389,208版本:2026.7剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰

bullet_checked無需信用卡或建立帳號
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
預訂您的免費現場演示
Booking Badge related to IronPDF Product Demo

受到全球數百萬工程師的信任

Iron Software的客戶標誌
獲取您的無義務諮詢
填寫以下表格或電子郵件sales@ironsoftware.com
您的詳細資訊將始終保密
受到全球數百萬工程師的信任
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立