Beispiel #1
0
        protected virtual void OnPhaseChanged(IntPtr converter)
        {
            int    phaseNumber      = PechkinStatic.GetPhaseNumber(converter);
            string phaseDescription = PechkinStatic.GetPhaseDescription(converter, phaseNumber);

            Tracer.Trace(string.Format("T:{0} Conversion Phase Changed: #{1} {2}", Thread.CurrentThread.Name, phaseNumber, phaseDescription));

            PhaseChangedEventHandler handler = this.PhaseChanged;

            try
            {
                if (handler != null)
                {
                    handler(this, phaseNumber, phaseDescription);
                }
            }
            catch (Exception e)
            {
                Tracer.Warn(string.Format("T:{0} Exception in PhaseChange event handler", Thread.CurrentThread.Name), e);
            }
        }
Beispiel #2
0
        public static void ApplySettings(IntPtr config, object settings, bool global = false)
        {
            if (settings == null)
            {
                return;
            }

            var bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

            foreach (var property in settings.GetType().GetProperties(bindingFlags))
            {
                var attributes = property.GetCustomAttributes(true);

                if (attributes.Length == 0 || !(attributes[0] is WkhtmltopdfSettingAttribute))
                {
                    continue;
                }

                var attribute = attributes[0] as WkhtmltopdfSettingAttribute;
                var rawValue  = property.GetValue(settings, null);

                if (rawValue == null)
                {
                    continue;
                }

                var value = GetStringValue(property, rawValue);

                if (global)
                {
                    PechkinStatic.SetGlobalSetting(config, attribute.SettingName, value);
                }
                else
                {
                    PechkinStatic.SetObjectSetting(config, attribute.SettingName, value);
                }
            }
        }
Beispiel #3
0
        internal void ApplyToConverter(out IntPtr converter)
        {
            converter = IntPtr.Zero;

            var config = PechkinStatic.CreateGlobalSetting();

            SettingApplicator.ApplySettings(config, this.global, true);

            converter = PechkinStatic.CreateConverter(config);

            //if (this.TableOfContents != null)
            //{
            //    this.TableOfContents.ApplyToConverter(converter);
            //}

            foreach (var setting in this.Objects)
            {
                if (setting != null)
                {
                    setting.ApplyToConverter(converter);
                }
            }
        }