Click or drag to resize
Pdf Library for .NET

PdfFileAttachmentElement Class

Represents a file attachment in a pdf document. The attachment can be purely document-level (file travels with the PDF, no visual indicator) or page-level (a clickable paperclip-style icon is placed at LinkRectangle). Four constructors are provided: two with a link rectangle (page-level, visible icon) and two without (document-level only), each in file-path and stream+name flavors.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfPageElement
    SelectPdf.UniversalPdfFileAttachmentElement

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public class PdfFileAttachmentElement : PdfPageElement

The PdfFileAttachmentElement type exposes the following members.

Constructors
 NameDescription
Public methodPdfFileAttachmentElement(String) Creates a file attachment without a link in the pdf page to the attachment. The file is attached at the document level only.
Public methodPdfFileAttachmentElement(RectangleF, String) Creates a file attachment and a link in the pdf page to the attachment.
Public methodPdfFileAttachmentElement(Stream, String) Creates a file attachment from a stream without a link in the pdf page to the attachment. The file is attached at the document level only.
Public methodPdfFileAttachmentElement(RectangleF, Stream, String) Creates a file attachment from a stream and a link in the pdf page to the attachment.
Top
Properties
 NameDescription
Public propertyActualText Gets or sets the exact text represented by this element (the structure element's /ActualText entry), used when the drawn glyphs do not map to readable text.
(Inherited from PdfPageElement)
Public propertyAlternateText Gets or sets the alternate text describing this element for assistive technology (the structure element's /Alt entry). Required on figures for PDF/UA conformance.
(Inherited from PdfPageElement)
Public propertyArtifact Gets or sets a value indicating whether this element is an artifact — decorative or layout content that carries no meaning and is excluded from the logical structure (backgrounds, rules, running headers). Takes precedence over TagType.
(Inherited from PdfPageElement)
Public propertyLinkRectangle Gets or sets the attachment link rectangle in the pdf page. When empty, no visual indicator is drawn — the file is available only via the PDF viewer's attachment panel.
Public propertyTagType Gets or sets the structure type used to tag this element in a tagged (accessible) document. Ignored unless the document's tagged mode (PdfDocument.Tagged) is enabled. Null (default) leaves the element untagged unless Artifact is set.
(Inherited from PdfPageElement)
Top
Example
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
PdfFileAttachmentElement attachment = new PdfFileAttachmentElement(
    new SelectPdf.Universal.Drawing.RectangleF(20, 20, 20, 20), "readme.txt");
page.Add(attachment);
document.Save("out.pdf");
document.Close();
See Also