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
Add Attachments
IronPDF supports adding and removing attachments to your PDF documents.
For more information, you can explore the IronPDF Documentation where detailed guides and resources are available. Additionally, learn about more features and capabilities on the Iron Software Website.
Related Docs Links
Ready to get started? Version: 2024.12 just released