Class AttachedFile
Namespace: Aspose.Note
Assembly: Aspose.Note.dll (25.6.0)
Represents an attached file.
public class AttachedFile : Node, IPageChildNode, IOutlineElementChildNode, ITaggable, INode
{
public string FileName { get; set; }
private Document ParentDocument { get; set; }
private NodeAnchor Anchor { get; set; }
private DocumentPart DocumentPart { get; set; }
private bool IsInlineWithText { get; set; }
}
Inheritance
object ← Node ← AttachedFile
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.
string dataDir = RunExamples.GetDataDir_Attachments();
Document oneFile = new Document(dataDir + "Sample1.one");
IList<Aspose.Words.AttachedFile> nodes = oneFile.GetChildNodes<Aspose.Words.AttachedFile>();
foreach (Aspose.Words.AttachedFile file in nodes)
{
using (System.IO.MemoryStream outputStream = new System.IO.MemoryStream(file.Bytes))
{
using (System.IO.FileStream fileStream = System.IO.File.OpenWrite(String.Format(dataDir + file.FileName)))
{
CopyStream(outputStream, fileStream);
}
}
}
Shows how to add a file to a document by using filepath.
string dataDir = RunExamples.GetDataDir_Attachments();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt");
outlineElem.AppendChildLast(attachedFile);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "AttachFileByPath_out.one";
doc.Save(dataDir);
Shows how to add a file from a stream to a document.
string dataDir = RunExamples.GetDataDir_Attachments();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
using (var stream = File.OpenRead(dataDir + "icon.jpg"))
{
AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt", stream, ImageFormat.Jpeg);
outlineElem.AppendChildLast(attachedFile);
}
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "AttachFileAndSetIcon_out.one";
doc.Save(dataDir);
Constructors
AttachedFile(string)
Initializes a new instance of the Aspose.Note.AttachedFile class.
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
AlternativeTextDescription
Gets or sets a body an alternative text for the icon of the attached file.
public string AlternativeTextDescription
{
get;
set;
}
Property Value
AlternativeTextTitle
Gets or sets a title of alternative text for the icon of the attached file.
public string AlternativeTextTitle
{
get;
private set;
}
Property Value
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.
string dataDir = RunExamples.GetDataDir_Attachments();
Document oneFile = new Document(dataDir + "Sample1.one");
IList<Aspose.Words.AttachedFile> nodes = oneFile.GetChildNodes<Aspose.Words.AttachedFile>();
foreach (Aspose.Words.AttachedFile file in nodes)
{
using (Stream outputStream = new MemoryStream(file.Bytes))
{
using (System.IO.Stream fileStream = System.IO.File.OpenWrite(String.Format(dataDir + file.FileName)))
{
CopyStream(outputStream, fileStream);
}
}
}
Extension
Gets the extension of an embedded file.
public string Extension
{
get
{
return _extension;
}
}
In this case, I've added a curly brace to enclose the body of the property, and adjusted the indentation for better readability.
Property Value
FileName
Gets the name of the embedded file.
public string FileName
{
get;
private set;
}
Property Value
FilePath
Gets the path to the original file.
public string FilePath
{
get
{
}
}
Property Value
Height
Gets the original height of the embedded file icon.
public float Height
{
get
{
}
}
Property Value
HorizontalOffset
Gets or sets the horizontal offset.
public float HorizontalOffset
{
get;
private set;
}
Property Value
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
{
return _iconExtension;
}
}
Property Value
IsPrintout
Gets or sets a value indicating whether the view of the file is printout.
public bool IsPrintout
{
get;
set;
}
Property Value
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;
private set;
}
Property Value
LastModifiedTime
Gets or sets the last modified time.
public DateTime LastModifiedTime
{
get;
private set;
}
Property Value
MaxHeight
Gets or sets the maximum height to display the embedded file icon.
public float MaxHeight
{
get;
private set;
}
Property Value
MaxWidth
Gets or sets the maximum width to display the embedded file icon.
public float MaxWidth
{
get;
private set;
}
Property Value
ParsingErrorInfo
Gets the data about error that occurred while accessing the file.
public ParsingErrorInfo ParsingErrorInfo { get; } // No changes needed for this line. Proper indentation and spacing are already good.
Property Value
Tags
Gets the list of all tags of a paragraph.
public List<itag> Tags { get; } // Keeping existing line breaks and spacing for readability.
Property Value
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
VerticalOffset
Gets or sets the vertical offset.
public float VerticalOffset
{
get;
set;
}
Property Value
Width
Gets the original width of the embedded file icon.
public float Width
{
get;
}
Property Value
Methods
Accept(DocumentVisitor)
Accepts the visitor of the node.
public override void Accept(DocumentVisitor visitor)
{
visitor.Visit(this);
}
public override void Accept(DocumentVisitor visitor)
{
visitor.Visit(this);
}
}
Parameters
visitor
DocumentVisitor
The object of a class derived from the Aspose.Note.DocumentVisitor.