EmbedFile(Stream,String,String) Method
In This Topic
Embeds (attaches) a file data from a previously instantiated Stream object into the currently loaded PDF document under the provided file title.
You can also add a verbal description of this attachment. The file data is embedded (attached) into the source PDF file and can be displayed in a special viewer panel in most PDF viewers.
Syntax
'Declaration
Public Overloads Function EmbedFile( _
ByVal As Stream, _
ByVal As String, _
ByVal As String _
) As GdPictureStatus
public GdPictureStatus EmbedFile(
Stream ,
string ,
string
)
public function EmbedFile(
: Stream;
: String;
: String
): GdPictureStatus;
public function EmbedFile(
: Stream,
: String,
: String
) : GdPictureStatus;
public: GdPictureStatus EmbedFile(
Stream* ,
string* ,
string*
)
public:
GdPictureStatus EmbedFile(
Stream^ ,
String^ ,
String^
)
Parameters
- Stream
- The stream that contains file data to embed. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Any kind of file data, and any numbers of files, can be embedded into a PDF file.
- FileTitle
- The file title to use for the embedded file data.
- Description
- The verbal description of this attachment, for example, a purpose of embedding this file.
Return Value
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Example
Embedding a text file into the PDF document using stream.
Using (gdpicturePDF As GdPicturePDF = New GdPicturePDF())
gdpicturePDF.LoadFromFile("document.pdf", True)
FileStream attachment = new FileStream("textfile.txt", FileMode.Open)
gdpicturePDF.EmbedFile(attachment, "textfile.txt", "Text Attachment")
gdpicturePDF.SaveToFile("document.pdf")
attachment.Close()
attachment.Dispose()
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("document.pdf", true);
FileStream attachment = new FileStream("textfile.txt", FileMode.Open);
gdpicturePDF.EmbedFile(attachment, "textfile.txt", "Text Attachment");
gdpicturePDF.SaveToFile("document.pdf");
attachment.Close();
attachment.Dispose();
}
Example
Embedding a text file into the PDF document using stream.
Using (gdpicturePDF As GdPicturePDF = New GdPicturePDF())
gdpicturePDF.LoadFromFile("document.pdf", True)
FileStream attachment = new FileStream("textfile.txt", FileMode.Open)
gdpicturePDF.EmbedFile(attachment, "textfile.txt", "Text Attachment")
gdpicturePDF.SaveToFile("document.pdf")
attachment.Close()
attachment.Dispose()
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("document.pdf", true);
FileStream attachment = new FileStream("textfile.txt", FileMode.Open);
gdpicturePDF.EmbedFile(attachment, "textfile.txt", "Text Attachment");
gdpicturePDF.SaveToFile("document.pdf");
attachment.Close();
attachment.Dispose();
}
See Also