public void PDFGeneratorSettingsConstructorTest() { Type literaltype = typeof(Scryber.Components.TextLiteral); Type templategenerator = typeof(Scryber.Data.ParsableTemplateGenerator); Type templateinstance = typeof(Scryber.Data.TemplateInstance); PDFReferenceResolver resolver = new PDFReferenceResolver(this.ShimResolver); ParserConformanceMode conformance = ParserConformanceMode.Lax; ParserLoadType loadtype = ParserLoadType.ReflectiveParser; PDFTraceLog log = new Scryber.Logging.DoNothingTraceLog(TraceRecordLevel.Off); PDFPerformanceMonitor mon = new PDFPerformanceMonitor(true); Mocks.MockControllerClass controller = new Mocks.MockControllerClass(); PDFGeneratorSettings target = new PDFGeneratorSettings(literaltype, templategenerator, templateinstance, resolver, conformance, loadtype, log, mon, controller); Assert.IsNotNull(target); Assert.AreSame(literaltype, target.TextLiteralType); Assert.AreSame(templategenerator, target.TempateGeneratorType); Assert.AreSame(resolver, target.Resolver); Assert.AreEqual(conformance, target.ConformanceMode); Assert.AreEqual(loadtype, target.LoadType); Assert.AreSame(log, target.TraceLog); Assert.AreSame(mon, target.PerformanceMonitor); Assert.AreSame(controller, target.Controller); Assert.AreEqual(controller.GetType(), target.ControllerType); }
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)); } }
/// <summary> /// Creates a new PDFSecureWriter14 that will write to the provded stream and encrypt output using the PDFEncrypter (cannot be null). /// </summary> /// <param name="stream">The stream to ultimately write the data to.</param> /// <param name="generation">The current generation of the PDF docucment.</param> /// <param name="log">The log to write messages to.</param> /// <param name="security">The PDFEncrypter to use.</param> internal PDFSecureWriter14(Stream stream, int generation, PDFTraceLog log, PDFPerformanceMonitor monitor, Version vers, PDFEncryter security) : base(stream, generation, log, vers) { if (null == security) { throw new ArgumentNullException("security"); } _security = security; _monitor = monitor; _encrypters = new Stack <PDFObjectEncryptionStream>(); }
// //You can use the following additional attributes as you write your tests: // //Use ClassInitialize to run code before running the first test in the class //[ClassInitialize()] //public static void MyClassInitialize(TestContext testContext) //{ //} // //Use ClassCleanup to run code after all tests in a class have run //[ClassCleanup()] //public static void MyClassCleanup() //{ //} // //Use TestInitialize to run code before running each test //[TestInitialize()] //public void MyTestInitialize() //{ //} // //Use TestCleanup to run code after each test has run //[TestCleanup()] //public void MyTestCleanup() //{ //} // #endregion // // support methods // private PDFGeneratorSettings GetSettings() { Type literaltype = typeof(Scryber.Components.TextLiteral); Type templategenerator = typeof(Scryber.Data.ParsableTemplateGenerator); Type templateinstance = typeof(Scryber.Data.TemplateInstance); PDFReferenceResolver resolver = new PDFReferenceResolver(this.ShimResolver); ParserConformanceMode conformance = ParserConformanceMode.Lax; ParserLoadType loadtype = ParserLoadType.ReflectiveParser; PDFTraceLog log = new Scryber.Logging.DoNothingTraceLog(TraceRecordLevel.Off); PDFPerformanceMonitor perfmon = new PDFPerformanceMonitor(true); PDFGeneratorSettings settings = new PDFGeneratorSettings(literaltype, templategenerator, templateinstance, resolver, conformance, loadtype, log, perfmon, null); return(settings); }
public void ConformanceModeTest() { Type literaltype = typeof(Scryber.Components.TextLiteral); Type templategenerator = typeof(Scryber.Data.ParsableTemplateGenerator); Type templateinstance = typeof(Scryber.Data.TemplateInstance); PDFReferenceResolver resolver = new PDFReferenceResolver(this.ShimResolver); ParserConformanceMode conformance = ParserConformanceMode.Lax; ParserLoadType loadtype = ParserLoadType.ReflectiveParser; PDFTraceLog log = new Scryber.Logging.DoNothingTraceLog(TraceRecordLevel.Off); PDFPerformanceMonitor mon = new PDFPerformanceMonitor(true); PDFGeneratorSettings target = new PDFGeneratorSettings(literaltype, templategenerator, templateinstance, resolver, conformance, loadtype, log, mon, null); Assert.AreEqual(conformance, target.ConformanceMode); ParserConformanceMode expected = ParserConformanceMode.Strict; ParserConformanceMode actual; target.ConformanceMode = expected; actual = target.ConformanceMode; Assert.AreEqual(expected, actual); }
public PDFGeneratorSettings(Type literaltype, Type templategenerator, Type templateinstance, PDFReferenceResolver resolver, ParserConformanceMode conformance, ParserLoadType loadtype, PDFTraceLog log, PDFPerformanceMonitor perfmon, object controllerInstance) { this._textLiteralType = literaltype; this._tempateGenType = templategenerator; this._templateinstanceType = templateinstance; this._resolver = resolver; this._conformance = conformance; this._loadtype = loadtype; this._log = log; this._perfmon = perfmon; this._controllerInstance = controllerInstance; this._controllerType = (null == controllerInstance) ? null : controllerInstance.GetType(); //Get the default culture from the config - can be overridden in the processing instructions, or at generation time in code var config = ServiceProvider.GetService <IScryberConfigurationService>(); var parserOptions = config.ParsingOptions; this.MissingReferenceAction = parserOptions.MissingReferenceAction; this.SpecificCulture = parserOptions.GetDefaultCulture(); }
protected override PDFWriter DoGetInstance(Document forDoc, Stream stream, int generation, PDFDocumentRenderOptions options, PDFTraceLog log, PDFPerformanceMonitor monitor) { return(new PDFSecureWriter14(stream, log, monitor, this._enc)); }
internal PDFEncryter InitEncrypter(string ownerpassword, string userpassword, PDFDocumentID documentid, PermissionFlags protection, PDFPerformanceMonitor monitor) { IDisposable dur = null; if (string.IsNullOrEmpty(ownerpassword)) { throw new ArgumentNullException("ownerpassword", "As a minimum the owner password is required"); } byte[] owner = null; byte[] user = null; PDFEncryter info; try { if (null != monitor) { dur = monitor.Record(PerformanceMonitorType.Encrypting_Streams, "Key creation"); } owner = ConvertToPaddedBytes(ownerpassword); user = ConvertToPaddedBytes(userpassword); info = this.InitEncrypter(owner, user, documentid, protection); } catch (Exception ex) { throw new PDFSecurityException("Could not create the encrypter information", ex); } finally { if (null != owner) { ZeroArray(owner); } if (null != user) { ZeroArray(user); } if (null != dur) { dur.Dispose(); } } return(info); }
protected abstract PDFWriter DoGetInstance(Document forDoc, System.IO.Stream stream, int generation, PDFDocumentRenderOptions options, PDFTraceLog log, PDFPerformanceMonitor 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)); } }