public PDFWriter CreateWriter(Document forDoc, System.IO.Stream outputStream, int generation, PDFTraceLog log)
        {
            if (null == this.WriterFactory)
            {
                IDocumentPasswordSettings settings = null;
                if (forDoc.PasswordProvider != null && forDoc.PasswordProvider.IsSecure(forDoc.LoadedSource, out settings))
                {
                    this.WriterFactory = GetSecureWriter(forDoc, settings);
                }

                else if (forDoc.Permissions.HasRestrictions)
                {
                    if (forDoc.ConformanceMode == ParserConformanceMode.Lax)
                    {
                        forDoc.TraceLog.Add(TraceLevel.Error, "Writer", "No Password provider has been set on the document, so using a random password for this generation. As a minimum an owner password should be set.");
                        Guid pass  = Guid.NewGuid();
                        var  passS = pass.ToString().Substring(14);

                        forDoc.PasswordProvider = new Secure.DocumentPasswordProvider(passS);
                        forDoc.PasswordProvider.IsSecure(forDoc.LoadedSource, out settings);

                        this.WriterFactory = GetSecureWriter(forDoc, settings);
                    }
                    else
                    {
                        throw new System.Security.SecurityException("No Password provider has been set on the document, so restrictions cannot be applied. As a minimum an owner password should be set.");
                    }
                }
                else
                {
                    this.WriterFactory = GetStandardWriter(forDoc);
                }
            }
            return(this.WriterFactory.GetInstance(forDoc, outputStream, generation, this, log));
        }
        public PDFDocumentRenderOptions()
        {
            var config = ServiceProvider.GetService <IScryberConfigurationService>();
            var output = config.OutputOptions;
            var imging = config.ImagingOptions;


            this.Compression    = output.Compression;
            this.ComponentNames = output.NameOutput;
            //this.PDFVersion = section.PDFVersion;
            this.OuptputCompliance         = output.Compliance.ToString();
            this.StringOutput              = output.StringType;
            this.ImageCacheDurationMinutes = imging.ImageCacheDuration;
            this.AllowMissingImages        = imging.AllowMissingImages;
            //this.PooledStreams = true;
            this.WriterFactory = null;
        }