GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / EmbedFile Method / EmbedFile(String,String) Method
The file path of the file to embed. Any kind of file, and any numbers of files, can be embedded into a PDF file.
The verbal description of this attachment, for example, a purpose of embedding this file.
Example





In This Topic
EmbedFile(String,String) Method
In This Topic
Embeds (attaches) a file specified by its file path into the currently loaded PDF document. You can also add a verbal description of this attachment. The specified file 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 FilePath As String, _
   ByVal Description As String _
) As GdPictureStatus
public GdPictureStatus EmbedFile( 
   string FilePath,
   string Description
)
public function EmbedFile( 
    FilePath: String;
    Description: String
): GdPictureStatus; 
public function EmbedFile( 
   FilePath : String,
   Description : String
) : GdPictureStatus;
public: GdPictureStatus EmbedFile( 
   string* FilePath,
   string* Description
) 
public:
GdPictureStatus EmbedFile( 
   String^ FilePath,
   String^ Description
) 

Parameters

FilePath
The file path of the file to embed. Any kind of file, and any numbers of files, can be embedded into a PDF file.
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.

Remarks
This method is only allowed for use with non-encrypted documents.

The file title for the embedded file is set to the file name of this embedded file without the file extension.

You also need to be aware that embedded files are forbidden in PDF/A-1. But PDF/A-2 allows embedding of PDF/A files, facilitating the archiving of sets of PDF/A documents in a single file. PDF/A-3 allows embedding of any file format such as XML, CAD and others into PDF/A documents.

Example
Embedding a text file into the PDF document.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
{
    gdpicturePDF.LoadFromFile("document.pdf", True)
    gdpicturePDF.EmbedFile("textfile.txt", "Text Attachment")
    gdpicturePDF.SaveToFile("document.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    gdpicturePDF.LoadFromFile("document.pdf", true);
    gdpicturePDF.EmbedFile("textfile.txt", "Text Attachment");
    gdpicturePDF.SaveToFile("document.pdf");
}
See Also