using System; using System.Collections.Generic; using System.Text; using System.IO; using iTextSharp.text.xml.xmp; using System.Drawing; using Spring.Objects; using Spring.Core.IO; namespace Sleis.Pdf { public class SignatureDisplay { public IResource Background { get; set; } public Point Location { get; set; } public Size Size { get; set; } public void Init() { if (Background == null || !Background.File.Exists) { throw new FileNotFoundException(Background.File.FullName); } if (Size == null) { throw new ArgumentNullException("Size"); } if (Location == null) { Location = new Point(0, 0); } } } public class PdfSignatureArgs { public string Author { get; set; } public string Title { get; set; } public string Subject { get; set; } public string Keywords { get; set; } public string Producer { get; set; } public string Creator { get; set; } public string Reason { get; set; } public string Contact { get; set; } public string Locality { get; set; } public SignatureDisplay Display { get; set; } public Dictionary Other { get; set; } public void Init() { if (Display == null) { throw new ArgumentNullException("Display"); } Display.Init(); if (String.IsNullOrEmpty(Author)) { throw new ArgumentNullException("Author"); } if (String.IsNullOrEmpty(Title)) { throw new ArgumentNullException("Title"); } if (String.IsNullOrEmpty(Subject)) { throw new ArgumentNullException("Subject"); } if (String.IsNullOrEmpty(Keywords)) { Keywords = String.Empty; } if (String.IsNullOrEmpty(Producer)) { throw new ArgumentNullException("Producer"); } if (String.IsNullOrEmpty(Creator)) { throw new ArgumentNullException("Creator"); } if (String.IsNullOrEmpty(Reason)) { throw new ArgumentNullException("Reason"); } if (String.IsNullOrEmpty(Contact)) { throw new ArgumentNullException("Contact"); } if (String.IsNullOrEmpty(Locality)) { throw new ArgumentNullException("Locality"); } } public Dictionary GetAllArgs() { Dictionary allArgs = new Dictionary(Other); allArgs.Add("Author", Author); allArgs.Add("Title", Title); allArgs.Add("Subject", Subject); allArgs.Add("Keywords", Keywords); allArgs.Add("Producer", Producer); allArgs.Add("Creator", Creator); return allArgs; } public byte[] GetStreamedArgs() { MemoryStream os = new System.IO.MemoryStream(); XmpWriter xmp = new XmpWriter(os, GetAllArgs()); xmp.Close(); return os.ToArray(); } } }