from ironpdf import * # Instantiate the Renderer and create PdfDocument from HTML renderer = ChromePdfRenderer() my_pdf = renderer.RenderHtmlFileAsPdf("my-content.html") # Open PDF document to be attached pdf = PdfDocument.FromFile("new_sample.pdf") # Here we can add an attachment with a name and a byte[] attachment1 = my_pdf.Attachments.AddAttachment("attachment_1", pdf.BinaryData) # And here is an example of removing an attachment my_pdf.Attachments.RemoveAttachment(attachment1) my_pdf.SaveAs("my-content.pdf")
添加附件