com.ironsoftware.ironpdf.attachment.AttachmentManager Maven / Gradle / Ivy
package com.ironsoftware.ironpdf.attachment;
import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.internal.staticapi.Attachment_Api;
import com.ironsoftware.ironpdf.internal.staticapi.InternalPdfDocument;
import java.util.List;
/**
* Class used to edit attachment to a {@link com.ironsoftware.ironpdf.PdfDocument}.
* See: {@link com.ironsoftware.ironpdf.PdfDocument#getAttachment()}
*/
public class AttachmentManager {
private final InternalPdfDocument internalPdfDocument;
/**
* Please get AttachmentManager by {@link PdfDocument#getAttachment()} instead.
*
* @param internalPdfDocument the internal pdf document
*/
public AttachmentManager(InternalPdfDocument internalPdfDocument) {
this.internalPdfDocument = internalPdfDocument;
}
/**
* A Collection of file attachment names (keys) contained within this PdfDocument.
*/
public final List getAttachments() {
return Attachment_Api.getPdfAttachmentCollection(
this.internalPdfDocument);
}
/**
* Add a new attachment.
*
* @param name attachment name
* @param attachmentData attachment data
*/
public final void addAttachment(String name, byte[] attachmentData) {
Attachment_Api.addPdfAttachment(this.internalPdfDocument, name, attachmentData);
}
/**
* Remove an attachment by attachment name
*
* @param name attachment name
*/
public final void removeAttachment(String name) {
Attachment_Api.removePdfAttachment(this.internalPdfDocument, name);
}
/**
* Gets attachment data from attachment name
*
* @param name Attachment name
*/
public final byte[] getAttachmentData(String name) {
return Attachment_Api.getPdfAttachmentData(this.internalPdfDocument, name);
}
}