Esempio n. 1
0
        public void ExportPdf()
        {
            string text = this.Filename;

            if (string.IsNullOrEmpty(text))
            {
                text = this.Title;
            }
            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                Filter           = this.SavePdfFileTypes,
                FileName         = System.IO.Path.GetFileNameWithoutExtension(text),
                RestoreDirectory = true
            };
            bool?  flag     = saveFileDialog.ShowDialog();
            string fileName = saveFileDialog.FileName;

            if (!flag.Value || string.IsNullOrEmpty(fileName))
            {
                return;
            }
            EditorRenderer._logger.Trace("Exporting PDF document: " + fileName);
            HtmlTemplate htmlTemplate = this.HtmlTemplate;

            htmlTemplate.UseBaseRelativeImageWorkaround = true;
            string      content     = htmlTemplate.GenerateHtmlTemplate(false);
            PdfExporter pdfExporter = new PdfExporter(fileName, content)
            {
                IncludeCssBackground    = this._settings.IO_Pdf_IncludeBackground,
                EnableOutlineGeneration = this._settings.IO_Pdf_EnableOutlineGeneration
            };

            pdfExporter.ExportPdf();
        }
Esempio n. 2
0
        public void LoadHtml()
        {
            EditorRenderer._logger.Trace("Loading base HTML into renderer");
            this.IsLoadCompletedCompleted = false;
            HtmlTemplate htmlTemplate = new HtmlTemplate
            {
                BodyContent       = string.Empty,
                CssFilePath       = this.CssFileLocation,
                CustomHeadContent = this._settings.Renderer_CustomHtmlHeadContent,
                Filename          = this.Filename,
                MarkdownProcessor = this._settings.Markdown_MarkdownProcessor
            };
            string html = htmlTemplate.GenerateHtmlTemplate(true);

            this.Renderer.LoadHTML(html);
        }
Esempio n. 3
0
        public void PreviewMarkdownInBrowser()
        {
            string       str          = string.Format("{0}.{1}", "MarkdownPadPreview", "html");
            string       text         = System.IO.Path.GetTempPath() + str;
            HtmlTemplate htmlTemplate = this.HtmlTemplate;

            htmlTemplate.UseBaseRelativeImageWorkaround = true;
            string contents = htmlTemplate.GenerateHtmlTemplate(false);

            try
            {
                System.IO.File.WriteAllText(text, contents);
            }
            catch (System.Exception exception)
            {
                MessageBoxHelper.ShowErrorMessageBox(LocalizationProvider.GetLocalizedString("Error_MarkdownBrowserPreviewMessage", false, "MarkdownPadStrings"), LocalizationProvider.GetLocalizedString("Error_MarkdownBrowserPreviewTitle", false, "MarkdownPadStrings"), exception, "");
            }
            if (System.IO.File.Exists(text))
            {
                text.TryStartDefaultProcess();
            }
        }