FileSpecification Constructor

 

   

Syntax
 

[C#]
FileSpecification(ObjectSoup soup)
FileSpecification(ObjectSoup soup, string path)

[Visual Basic]
Sub New(soup As ObjectSoup)
Sub New(soup As ObjectSoup, path As String)

 

   

Params
 
Name Description
soup The ObjectSoup to contain the newly created FileSpecification.
path A file to embed within the file specification.

 

   

Notes
 

Create a FileSpecification.

This constructor which takes a path to a file will embed and compress the file data using using the CompressFlate function. It will also insert appropriate metadata using the EmbeddedFileUpdateMetadata function.

The constructor which takes an array of data will similarly embed and compress the data. However since there is no file path metadata will not be assigned.

 

   

Example
 

The example below shows how to combine a set of PDF documents into a portfolio. See the Catalog.GetEmbeddedFiles function for how to extract files from a portfolio.

 

string[] files = {   "SignedDocument.pdf",   "spaceshuttle.pdf",   "Authorization.pdf",   "Portfolio1.pdf", }; using (Doc doc = new Doc()) {   List<Tuple<string, FileSpecification>> fileSpecs = new List<Tuple<string, FileSpecification>>();   foreach (string file in files) {     byte[] data = null;     using (Doc subDoc = new Doc()) {       subDoc.Read(Server.MapPath(file));       data = subDoc.GetData();     }     EmbeddedFile embedFile = new EmbeddedFile(doc.ObjectSoup, data);     embedFile.CompressFlate();     FileSpecification fileSpec = new FileSpecification(doc.ObjectSoup);     fileSpec.EmbeddedFile = embedFile;     fileSpec.Uri = file;     string name = Path.GetFileName(file);     fileSpecs.Add(new Tuple<string, FileSpecification>(name, fileSpec));   }   fileSpecs.Sort((a, b) => a.Item1.CompareTo(b.Item1));   // we do not really need to delete existing files but we do so as an example   doc.SetInfo(doc.Root, "/Names*/EmbeddedFiles*/Names:Del", "");   foreach (Tuple<string, FileSpecification> fileSpec in fileSpecs) {     doc.SetInfo(doc.Root, "/Names*/EmbeddedFiles*/Names*[]:Text", fileSpec.Item1);     doc.SetInfo(doc.Root, "/Names*/EmbeddedFiles*/Names*[]:Ref", fileSpec.Item2.ID);   }   doc.SetInfo(doc.Root, "/Names*/EmbeddedFiles*/Limits*[]:Ref", fileSpecs[0].Item1);   doc.SetInfo(doc.Root, "/Names*/EmbeddedFiles*/Limits*[]:Ref", fileSpecs[fileSpecs.Count - 1].Item1);   doc.SetInfo(doc.Root, "/Collection*/D:Text", files[0]);   doc.Save(Server.MapPath("createportfolio.pdf")); }