cete.dynamicpdf.embeddedfile
EmbeddedFile
- Namespace: ceTe.DynamicPDF
- Assemblies: ceTe.DynamicPDF.40.dll
Represents a PDF document's EmbeddedFile entry.
public class EmbeddedFile
Public Class EmbeddedFile
Inheritance: Object → EmbeddedFile
Licensing
This class is a DynamicPDF Generator Enterprise Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Generator for .NET Enterprise Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF ReportWriter for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Examples
This example shows how to Embedded files 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;
class MyClass
{
static void Main()
{
// Create a PDF Document
Document document = new Document();
// FileStreams used for creating the instance of EmbeddedFile
FileStream fileStream1 = new FileStream(@"C:\DocumentA.pdf",FileMode.Open,FileAccess.Read,FileShare.ReadWrite); FileStream fileStream2 = new FileStream(@"C:\DocumentB.pdf",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(@"C:\DocumentC.pdf");
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( @"C:\MyDocument.pdf" );
}
}
Constructors
EmbeddedFile(Byte[], String, DateTime)
Initializes a new instance of the EmbeddedFile class.
public EmbeddedFile(Byte[] file, string fileName, DateTime modifiedDate)
Public Sub New (file As Byte(), fileName As String, modifiedDate As Date)
Parameters
- file: Byte[]
The byte array of the file need to be Embedded
- fileName: String
Name of the File Embedded
- modifiedDate: DateTime
Last modifieddate of the file
EmbeddedFile(FileStream, String, DateTime)
Initializes a new instance of the EmbeddedFile class.
public EmbeddedFile(FileStream file, string fileName, DateTime modifiedDate)
Public Sub New (file As FileStream, fileName As String, modifiedDate As Date)
Parameters
- file: FileStream
The FileStream of the file need to be Embedded
- fileName: String
Name of the File Embedded
- modifiedDate: DateTime
Last modifieddate of the file
EmbeddedFile(String)
Initializes a new instance of the EmbeddedFile class.
public EmbeddedFile(string filePath)
Public Sub New (filePath As String)
Parameters
- filePath: String
The physical path to the file need to be Embedded
Properties
Description
Gets and Sets the Description of the EmbeddedFile.
public string Description { get; set; }
Public Property Description As String
Property Value
FileName
Gets and Sets the FileName of the EmbeddedFile.
public string FileName { get; set; }
Public Property FileName As String
Property Value
Methods
DrawReference(DocumentWriter)
Draws a reference to the EmbeddedFile indirect object.
public void DrawReference(DocumentWriter writer)
Sub DrawReference(writer As DocumentWriter)
Parameters
- writer: DocumentWriter
DocumentWriter object to receive the EmbeddedFile indirect object.
Equals(Object)
Determines whether the specified Object is equal to the current Object . (Inherited from Object)
public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean
Parameters
- obj: Object
The Object to compare with the current Object .
Returns
true if the specified Object is equal to the current Object ; otherwise, false.
GetHashCode()
Serves as a hash function for a particular type. (Inherited from Object)
public int GetHashCode()
Function GetHashCode() As Integer
Returns
A hash code for the current Object .
GetType()
Gets the Type of the current instance. (Inherited from Object)
public Type GetType()
Function GetType() As Type
Returns
The Type instance that represents the exact runtime type of the current instance.
ToString()
Returns a String that represents the current Object . (Inherited from Object)
public string ToString()
Function ToString() As String
Returns
A String that represents the current Object .