a goal here is to follow the wkhtmltopdf parameters where it makes sense, to ease people switching to/from wkhtmltopdf: http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html Properties without the [Option] declarations aren't accessible directly, but are more convenient when the order is being constructed from code instead of commandline arguments.
예제 #1
0
 public ConversionProgress(ConversionOrder conversionOrder)
 {
     _conversionOrder = conversionOrder;
     InitializeComponent();
     _progressBar.Maximum = 100;
     if (conversionOrder.NoUIMode)
     {
         this.WindowState   = FormWindowState.Minimized;
         this.ShowInTaskbar = false;
     }
     SetUpXulRunner();
 }
예제 #2
0
 public ConversionProgress(ConversionOrder conversionOrder)
 {
     _conversionOrder = conversionOrder;
     InitializeComponent();
     _progressBar.Maximum = 100;
     if (conversionOrder.NoUIMode)
     {
         this.WindowState = FormWindowState.Minimized;
         this.ShowInTaskbar = false;
     }
     SetUpXulRunner();
 }
        /// <summary>
        /// On the application event thread, work on creating the pdf. Will raise the StatusChanged and Finished events
        /// </summary>
        /// <param name="conversionOrder"></param>
        public void Start(ConversionOrder conversionOrder)
        {
            if (!Gecko.Xpcom.IsInitialized)
            {
                throw new ApplicationException("Developer: you must call Initialize(pathToXulRunnerFolder), or do your own Gecko.Xpcom.Initialize(), before calling Start()");
            }

            //without this, we get invisible (white?) text on some machines
            Gecko.GeckoPreferences.User["gfx.direct2d.disabled"] = true;

            if (conversionOrder.EnableGraphite)
            {
                GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;
            }

            // geckofx can sometimes cache stale data, at least on Windows.  These settings should prevent
            // any caching (which we don't need anyway) from happening.
            // See https://silbloom.myjetbrains.com/youtrack/issue/BL-5875 for details.
            GeckoPreferences.User["browser.cache.disk.enable"]    = false;
            GeckoPreferences.User["browser.cache.memory.enable"]  = false;
            GeckoPreferences.User["browser.cache.offline.enable"] = false;
            GeckoPreferences.User["dom.caches.enable"]            = false;

            _conversionOrder = conversionOrder;
            _browser         = new GeckoWebBrowser();
            this.components.Add(_browser);            //so it gets disposed when we are

            if (conversionOrder.Debug)
            {
                _browser.ConsoleMessage += OnBrowserConsoleMessage;
            }

            var tempFileName = Path.GetTempFileName();

            File.Delete(tempFileName);
            _pathToTempPdf = tempFileName + ".pdf";
            File.Delete(_conversionOrder.OutputPdfPath);
            _checkForBrowserNavigatedTimer.Enabled = true;
            Status = "Loading Html...";

            // Why set a size here? If we don't, images sometimes don't show up in the PDF. See BL-408.
            // A size of 500x500 was enough to fix the problem for the most reproducible case,
            // JohnH's version of Pame's Family Battles Maleria. The size used here is based
            // on an unproved hypothesis that it's important for at least one picture to be
            // visible in the imaginary browser window; thus, we've made it big enough for a
            // 16x11 big-book page at fairly high screen resolution of 120dpi.
            _browser.Size = new Size(1920, 1320);

            _browser.Navigate(_conversionOrder.InputHtmlPath);
        }
 public ConversionProgress(ConversionOrder conversionOrder)
 {
     _conversionOrder = conversionOrder;
     InitializeComponent();
     _progressBar.Maximum = 100;
     if (_conversionOrder.NoUIMode)
     {
         this.WindowState   = FormWindowState.Minimized;
         this.ShowInTaskbar = false;
         // Setting the WindowState doesn't suffice on Linux/Mono.  So we'll make the form
         // invisible as soon as it is shown.  (This isn't needed on Windows.)
         if (Environment.OSVersion.Platform == PlatformID.Unix)
         {
             this.Shown += ConversionProgress_Shown;
         }
     }
     SetUpXulRunner();
 }
        /// <summary>
        /// On the application event thread, work on creating the pdf. Will raise the StatusChanged and Finished events
        /// </summary>
        /// <param name="conversionOrder"></param>
        public void Start(ConversionOrder conversionOrder)
        {
            if (!Gecko.Xpcom.IsInitialized)
            {
                throw new ApplicationException("Developer: you must call Initialize(pathToXulRunnerFolder), or do your own Gecko.Xpcom.Initialize(), before calling Start()");
            }

            //without this, we get invisible (white?) text on some machines
            Gecko.GeckoPreferences.User["gfx.direct2d.disabled"] = true;

            if (conversionOrder.EnableGraphite)
                GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;

            _conversionOrder = conversionOrder;
            _browser = new GeckoWebBrowser();
            this.components.Add(_browser);//so it gets disposed when we are

            if (conversionOrder.Debug)
            {
                _browser.ConsoleMessage += OnBrowserConsoleMessage;
            }

            var tempFileName = Path.GetTempFileName();
            File.Delete(tempFileName);
            _pathToTempPdf = tempFileName + ".pdf";
            File.Delete(_conversionOrder.OutputPdfPath);
            _checkForBrowserNavigatedTimer.Enabled = true;
            Status = "Loading Html...";

            // Why set a size here? If we don't, images sometimes don't show up in the PDF. See BL-408.
            // A size of 500x500 was enough to fix the problem for the most reproducible case,
            // JohnH's version of Pame's Family Battles Maleria. The size used here is based
            // on an unproved hypothesis that it's important for at least one picture to be
            // visible in the imaginary browser window; thus, we've made it big enough for a
            // 16x11 big-book page at fairly high screen resolution of 120dpi.
            _browser.Size = new Size(1920, 1320);

            _browser.Navigate(_conversionOrder.InputHtmlPath);
        }