Class AttachedFile

Class AttachedFile

Namespace: Aspose.Note
Assembly: Aspose.Note.dll (24.12.0)

Represents an attached file.

public class AttachedFile : Node, IPageChildNode, IOutlineElementChildNode, ITaggable, INode

Inheritance

objectNodeAttachedFile

Implements

IPageChildNode, IOutlineElementChildNode, ITaggable, INode

Inherited Members

Node.Accept(DocumentVisitor), Node.Document, Node.IsComposite, Node.NodeType, Node.ParentNode, Node.PreviousSibling, Node.NextSibling, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

Shows how to get content of an attached file.```csharp // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Attachments();

                                                    // Load the document into Aspose.Note.
                                                    Document oneFile = new Document(dataDir + "Sample1.one");

                                                    // Get a list of attached file nodes
                                                    IList<attachedfile> nodes = oneFile.GetChildNodes<attachedfile>();

                                                    // Iterate through all nodes
                                                    foreach (AttachedFile file in nodes)
                                                    {
                                                        // Load attached file to a stream object
                                                        using (Stream outputStream = new MemoryStream(file.Bytes))
                                                        {
                                                            // Create a local file
                                                            using (Stream fileStream = System.IO.File.OpenWrite(String.Format(dataDir + file.FileName)))
                                                            {
                                                                // Copy file stream
                                                                CopyStream(outputStream, fileStream);
                                                            }
                                                        }
                                                    }</attachedfile></attachedfile>

Shows how to add a file to a document by using filepath.```csharp
// The path to the documents directory.
                                                                   string dataDir = RunExamples.GetDataDir_Attachments();

                                                                   // Create an object of the Document class
                                                                   Document doc = new Document();

                                                                   // Initialize Page class object
                                                                   Aspose.Note.Page page = new Aspose.Note.Page(doc);

                                                                   // Initialize Outline class object
                                                                   Outline outline = new Outline(doc);

                                                                   // Initialize OutlineElement class object
                                                                   OutlineElement outlineElem = new OutlineElement(doc);

                                                                   // Initialize AttachedFile class object
                                                                   AttachedFile attachedFile = new AttachedFile(doc,  dataDir + "attachment.txt");

                                                                   // Add attached file
                                                                   outlineElem.AppendChildLast(attachedFile);

                                                                   // Add outline element node
                                                                   outline.AppendChildLast(outlineElem);

                                                                   // Add outline node
                                                                   page.AppendChildLast(outline);

                                                                   // Add page node
                                                                   doc.AppendChildLast(page);

                                                                   dataDir = dataDir + "AttachFileByPath_out.one";
                                                                   doc.Save(dataDir);

Shows how to add a file from a stream to a document.```csharp // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Attachments();

                                                           // Create an object of the Document class
                                                           Document doc = new Document();

                                                           // Initialize Page class object
                                                           Aspose.Note.Page page = new Aspose.Note.Page(doc);

                                                           // Initialize Outline class object
                                                           Outline outline = new Outline(doc);

                                                           // Initialize OutlineElement class object
                                                           OutlineElement outlineElem = new OutlineElement(doc);

                                                           using (var stream = File.OpenRead(dataDir + "icon.jpg"))
                                                           {
                                                               // Initialize AttachedFile class object and also pass its icon path
                                                               AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt", stream, ImageFormat.Jpeg);

                                                               // Add attached file
                                                               outlineElem.AppendChildLast(attachedFile);
                                                           }

                                                           // Add outline element node
                                                           outline.AppendChildLast(outlineElem);

                                                           // Add outline node
                                                           page.AppendChildLast(outline);

                                                           // Add page node
                                                           doc.AppendChildLast(page);

                                                           dataDir = dataDir + "AttachFileAndSetIcon_out.one";
                                                           doc.Save(dataDir);

## Constructors

### <a id="Aspose_Note_AttachedFile__ctor_System_String_"></a> AttachedFile\(string\)

Initializes a new instance of the Aspose.Note.AttachedFile class.

```csharp
public AttachedFile(string path)

Parameters

path string

A string that contains the path to the file from which to create the Aspose.Note.AttachedFile.

AttachedFile(string, Stream, ImageFormat)

Initializes a new instance of the Aspose.Note.AttachedFile class.

public AttachedFile(string path, Stream icon, ImageFormat iconFormat)

Parameters

path string

A string that contains the path to the file from which to create the Aspose.Note.AttachedFile.

icon Stream

An icon for the attached file.

iconFormat ImageFormat

A format of the attached file icon.

AttachedFile(string, Stream)

Initializes a new instance of the Aspose.Note.AttachedFile class.

public AttachedFile(string fileName, Stream attachedFileStream)

Parameters

fileName string

A name of the attached file.

attachedFileStream Stream

A stream which contains the attached file bytes.

AttachedFile(string, Stream, Stream, ImageFormat)

Initializes a new instance of the Aspose.Note.AttachedFile class.

public AttachedFile(string fileName, Stream attachedFileStream, Stream icon, ImageFormat iconFormat)

Parameters

fileName string

A name of the attached file.

attachedFileStream Stream

A stream which contains the attached file bytes.

icon Stream

An icon for the attached file.

iconFormat ImageFormat

A format of the attached file icon.

AttachedFile()

Initializes a new instance of the Aspose.Note.AttachedFile class.

public AttachedFile()

Properties

Alignment

Gets or sets the alignment.

public HorizontalAlignment Alignment { get; set; }

Property Value

HorizontalAlignment

AlternativeTextDescription

Gets or sets a body an alternative text for the icon of the attached file.

public string AlternativeTextDescription { get; set; }

Property Value

string

AlternativeTextTitle

Gets or sets a title of alternative text for the icon of the attached file.

public string AlternativeTextTitle { get; set; }

Property Value

string

Bytes

Gets the binary data for an embedded file.

public byte[] Bytes { get; }

Property Value

byte[]

Examples

Shows how to get content of an attached file.```csharp // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Attachments();

                                                    // Load the document into Aspose.Note.
                                                    Document oneFile = new Document(dataDir + "Sample1.one");

                                                    // Get a list of attached file nodes
                                                    IList<attachedfile> nodes = oneFile.GetChildNodes<attachedfile>();

                                                    // Iterate through all nodes
                                                    foreach (AttachedFile file in nodes)
                                                    {
                                                        // Load attached file to a stream object
                                                        using (Stream outputStream = new MemoryStream(file.Bytes))
                                                        {
                                                            // Create a local file
                                                            using (Stream fileStream = System.IO.File.OpenWrite(String.Format(dataDir + file.FileName)))
                                                            {
                                                                // Copy file stream
                                                                CopyStream(outputStream, fileStream);
                                                            }
                                                        }
                                                    }</attachedfile></attachedfile>

### <a id="Aspose_Note_AttachedFile_Extension"></a> Extension

Gets the extension of an embedded file.

```csharp
public string Extension { get; }

Property Value

string

FileName

Gets the name of the embedded file.

public string FileName { get; }

Property Value

string

FilePath

Gets the path to the original file.

public string FilePath { get; }

Property Value

string

Height

Gets the original height of the embedded file icon.

public float Height { get; }

Property Value

float

HorizontalOffset

Gets or sets the horizontal offset.

public float HorizontalOffset { get; set; }

Property Value

float

Icon

Gets the binary data for the icon that is associated with the embedded file.

public byte[] Icon { get; }

Property Value

byte[]

IconExtension

Gets the extension of the icon.

public string IconExtension { get; }

Property Value

string

IsPrintout

Gets or sets a value indicating whether the view of the file is printout.

public bool IsPrintout { get; set; }

Property Value

bool

IsSizeSetByUser

Gets or sets a value indicating whether the value of the size of the icon was explicitly updated by the user.

public bool IsSizeSetByUser { get; set; }

Property Value

bool

LastModifiedTime

Gets or sets the last modified time.

public DateTime LastModifiedTime { get; set; }

Property Value

DateTime

MaxHeight

Gets or sets the maximum height to display the embedded file icon.

public float MaxHeight { get; set; }

Property Value

float

MaxWidth

Gets or sets the maximum width to display the embedded file icon.

public float MaxWidth { get; set; }

Property Value

float

ParsingErrorInfo

Gets the data about error that occurred while accessing the file.

public ParsingErrorInfo ParsingErrorInfo { get; }

Property Value

ParsingErrorInfo

Tags

Gets the list of all tags of a paragraph.

public List<itag> Tags { get; }

Property Value

List<ITag&gt;

Text

Gets or sets the text representation of the embedded file. The string MUST NOT contain any characters of the value 10 (line feed) or 13 (carriage return).

public string Text { get; set; }

Property Value

string

VerticalOffset

Gets or sets the vertical offset.

public float VerticalOffset { get; set; }

Property Value

float

Width

Gets the original width of the embedded file icon.

public float Width { get; }

Property Value

float

Methods

Accept(DocumentVisitor)

Accepts the visitor of the node.

public override void Accept(DocumentVisitor visitor)

Parameters

visitor DocumentVisitor

The object of a class derived from the Aspose.Note.DocumentVisitor.