コード例 #1
0
        public WkHtmlToPdfConverter()
        {
            bool useX11 = false;

            try
            {
                useX11 = SysConvert.ToBoolean(ConfigurationManager.AppSettings["WkHtmlToXSharp.UseX11"]);
            }
            catch (Exception ex)
            {
                _Log.Error("Unable to parse 'WkHtmlToXSharp.UseX11' app. setting.", ex);
            }

            // Try to deploy native libraries bundles.
            WkHtmlToXLibrariesManager.InitializeNativeLibrary();

            var version = NativeCalls.WkHtmlToPdfVersion();

            if (NativeCalls.wkhtmltopdf_init(useX11 ? 1 : 0) == 0)
            {
                throw new InvalidOperationException(string.Format("wkhtmltopdf_init failed! (version: {0}, useX11 = {1})", version, useX11));
            }

            _Log.DebugFormat("Initialized new converter instance (Version: {0}, UseX11 = {1})", version, useX11);
        }