EmbeddedFile

Represents a PDF document's EmbeddedFile(attachment) entry.

public class EmbeddedFile
Public Class EmbeddedFile

Inheritance: ObjectEmbeddedFile

Licensing Info

This class is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples

This example shows how to embed files(attachments) in to a document.
Imports System
Imports System.IO
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
     
Module MyModule
     
    Sub Main()
     
        ' Create a PDF Document
        Dim MyDocument As Document = New Document 
     
        ' FileStreams used for creating the instance of EmbeddedFile
        Dim fileStream1 As FileStream = New FileStream("C:\DocumentA.pdf",FileMode.Open,FileAccess.Read,FileShare.ReadWrite)
        Dim fileStream2 As FileStream  = New FileStream("C:\DocumentB.pdf",FileMode.Open,FileAccess.Read,FileShare.ReadWrite)
    		
        ' byte array of the file by reading the file.
        Dim  filebyte(fileStream2.Length) As  byte 
        fileStream2.Read(filebyte, 0, filebyte.Length )
    		
        ' Created 3 instances of EmbeddedFile using all the available constructors.
        Dim  embeddedFile1 As EmbeddedFile  = New EmbeddedFile("C:\DocumentC.pdf")
        Dim embeddedFile2 As EmbeddedFile  = New EmbeddedFile( fileStream1, "DocumentA.pdf", DateTime.Now )
        Dim embeddedFile3 As  EmbeddedFile  = New EmbeddedFile( filebyte, "DocumentB.pdf", DateTime.Now )
    		
        ' Added the embeddedFiles to the EmbeddedFileList of the document class.
        MyDocument.EmbeddedFiles.Add( embeddedFile1 )
        MyDocument.EmbeddedFiles.Add( embeddedFile2 )
        MyDocument.EmbeddedFiles.Add( embeddedFile3 )
    		
        ' Set the PageMode to the ShowAttachments
        MyDocument.InitialPageMode = PageMode.ShowAttachments
     
        ' Create a Page and add it to the document
        Dim MyPage As Page = New Page
        MyDocument.Pages.Add(MyPage)
     
        ' Add a label to the page
        MyPage.Elements.Add(New Label("My PDF Document", 0, 0, 512, 40, Font.Helvetica, 30, TextAlign.Center))
     
        ' Save the PDF document
        MyDocument.Draw("C:\MyDocument.pdf")
     
    End Sub
End Module
using System;
using System.IO;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class Example
{
    public static void CreatePDF(string outputPath, string inputPathPdfA, string inputPathPdfB, string inputPathPdfC)
    {
        // Create a PDF Document
        Document document = new Document();

        // FileStreams used for creating the instance of EmbeddedFile
        FileStream fileStream1 = new FileStream(inputPathPdfA, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
        FileStream fileStream2 = new FileStream(inputPathPdfB, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

        // byte array of the file by reading the file.
        byte[] filebyte = new byte[fileStream2.Length];
        fileStream2.Read(filebyte, 0, filebyte.Length);

        // Created 3 instances of EmbeddedFile using all the available constructors.
        EmbeddedFile embeddedFile1 = new EmbeddedFile(inputPathPdfC);
        EmbeddedFile embeddedFile2 = new EmbeddedFile(fileStream1, "DocumentA.pdf", DateTime.Now);
        EmbeddedFile embeddedFile3 = new EmbeddedFile(filebyte, "DocumentB.pdf", DateTime.Now);

        // Added the embeddedFiles to the EmbeddedFileList of the document class.
        document.EmbeddedFiles.Add(embeddedFile1);
        document.EmbeddedFiles.Add(embeddedFile2);
        document.EmbeddedFiles.Add(embeddedFile3);

        // Set the PageMode to the ShowAttachments
        document.InitialPageMode = PageMode.ShowAttachments;

        // Create a Page and add it to the document
        Page page = new Page();
        document.Pages.Add(page);

        // Add a label to the page 
        page.Elements.Add(new Label("My PDF Document", 0, 0, 512, 40, Font.Helvetica, 30, TextAlign.Center));

        // Save the PDF document
        document.Draw(outputPath);
    } 
}

Constructors

EmbeddedFile(Byte[], String, DateTime)Initializes a new instance of the EmbeddedFile class.
EmbeddedFile(FileStream, String, DateTime)Initializes a new instance of the EmbeddedFile class.
EmbeddedFile(String)Initializes a new instance of the EmbeddedFile class.

Properties

DescriptionGets and Sets the description of the embedded file.
FileNameGets and Sets the FileName of the EmbeddedFile.
MimeTypeGets and Sets the mime type of the embedded file.
RelationGets or Sets the embedded file relation.

Methods

DrawReference(DocumentWriter)Draws a reference to the EmbeddedFile indirect object.
Equals(Object)Determines whether the specified Object is equal to the current Object .
(Inherited from Object)
GetHashCode()Serves as a hash function for a particular type.
(Inherited from Object)
GetType()Gets the Type of the current instance.
(Inherited from Object)
ToString()Returns a String that represents the current Object .
(Inherited from Object)

See Also

ceTe.DynamicPDF

In this topic