//
        // ctor(s)
        //

        #region public PDFLayoutDocument(PDFDocument doc)

        /// <summary>
        /// Creates a new PDFLayoutDocument
        /// </summary>
        public PDFLayoutDocument(Document doc, IPDFLayoutEngine engine)
            : base(null, doc, engine, new Style())
        {
            AllPages               = new PDFLayoutPageCollection();
            CurrentPageIndex       = -1;
            this.DocumentComponent = doc;
            this._renderopts       = doc.RenderOptions;
            this.ValidateRenderOptions();
        }
 protected override PDFWriter DoGetInstance(Document forDoc, Stream stream, int generation, PDFDocumentRenderOptions options, PDFTraceLog log, PDFPerformanceMonitor monitor)
 {
     return(new PDFSecureWriter14(stream, log, monitor, this._enc));
 }
        //implementation methods

        protected override PDFWriter DoGetInstance(Document forDoc, Stream stream, int generation, PDFDocumentRenderOptions options, PDFTraceLog log)
        {
            if (null == forDoc.DocumentID)
            {
                forDoc.DocumentID = PDFDocumentID.Create();
            }

            PDFEncrypterFactory factory = this.GetEncrypterFactory();

            IDocumentPasswordSettings settings;
            string          path = forDoc.LoadedSource;
            SecureString    owner;
            SecureString    user;
            PermissionFlags protection;

            if (Options.SecurityOptions.TryGetPasswordSettings(path, out settings))
            {
                owner      = settings.OwnerPassword;
                user       = settings.UserPassword;
                protection = settings.DefaultPermissions;

                if (settings.AllowDocumentOverrides)
                {
                    if (null != this.OwnerPassword)
                    {
                        owner = this.OwnerPassword;
                    }
                    if (null != this.UserPassword)
                    {
                        user = this.UserPassword;
                    }
                    protection |= this.GetRestrictions();
                }
            }
            else
            {
                protection = this.GetRestrictions();
                owner      = this.OwnerPassword;
                user       = this.UserPassword;
            }

            PDFEncryter       enc    = factory.InitEncrypter(owner, user, forDoc.DocumentID, protection);
            PDFSecureWriter14 writer = new PDFSecureWriter14(stream, log, enc);

            return(writer);
        }
 protected abstract PDFWriter DoGetInstance(Document forDoc, System.IO.Stream stream, int generation, PDFDocumentRenderOptions options, PDFTraceLog log, PDFPerformanceMonitor monitor);
        public PDFWriter GetInstance(Document forDoc, System.IO.Stream stream, int generation, PDFDocumentRenderOptions options, PDFTraceLog log)
        {
            if (null == stream)
            {
                throw new ArgumentNullException("stream");
            }
            else if (null == options)
            {
                throw new ArgumentNullException("options");
            }
            else if (null == log)
            {
                throw new ArgumentNullException("log");
            }
            else if (_disposed)
            {
                throw new InvalidOperationException(Errors.DocumentHasBeenDisposed);
            }
            else
            {
                PDFPerformanceMonitor monitor;
                if (null == forDoc.PerformanceMonitor)
                {
                    monitor = new PDFPerformanceMonitor(false);
                }
                else
                {
                    monitor = forDoc.PerformanceMonitor;
                }

                return(DoGetInstance(forDoc, stream, generation, options, log, monitor));
            }
        }
        protected override PDFWriter DoGetInstance(Document forDoc, System.IO.Stream stream, int generation, PDFDocumentRenderOptions options, PDFTraceLog log, PDFPerformanceMonitor monitor)
        {
            Version vers = (string.IsNullOrEmpty(this.PDFVersion)) ? new Version(1, 4) : System.Version.Parse(this.PDFVersion);

            if (this.PooledStreams)
            {
                return(new PDFWriterPooled14(stream, generation, log, vers));
            }
            else
            {
                return(new PDFWriter14(stream, generation, log, vers));
            }
        }