diff --git a/MarkdownToRW/MarkdownConverter/DragonConverter/Converter.cs b/MarkdownToRW/MarkdownConverter/DragonConverter/Converter.cs index 72b9ea1..ce3dc02 100644 --- a/MarkdownToRW/MarkdownConverter/DragonConverter/Converter.cs +++ b/MarkdownToRW/MarkdownConverter/DragonConverter/Converter.cs @@ -24,15 +24,16 @@ public static string ConvertMarkdownStringToHtml(string markdown, ConverterOptio string output = Markdown.ToHtml(markdown, pipeline); //Console.WriteLine(output); - - // HTML readability improvements & RW specific changes // Code - output = output.Replace("
", "\r\n");
+ if (!prepareForPreview)
+ {
+ output = output.Replace("
", "\r\n");
+ }
// Add attributes
AddClassToImages(ref output, options.FirstImageIsAlignedRight, rootPath);
@@ -68,7 +69,6 @@ public static string ConvertMarkdownStringToHtml(string markdown, ConverterOptio
// Spoiler
ConvertSpoilers(ref output);
-
if (options.ReplaceImageWithAltWithCaption)
{
ConvertImagesWithAltToCaptions(ref output);
diff --git a/MarkdownToRW/MarkdownConverter/DragonConverter/PdfConverter.cs b/MarkdownToRW/MarkdownConverter/DragonConverter/PdfConverter.cs
index 6909dbb..2d8ca59 100644
--- a/MarkdownToRW/MarkdownConverter/DragonConverter/PdfConverter.cs
+++ b/MarkdownToRW/MarkdownConverter/DragonConverter/PdfConverter.cs
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Text;
using DinkToPdf;
using DinkToPdf.EventDefinitions;
+using DragonMarkdown.Utility;
namespace DragonMarkdown.DragonConverter
{
@@ -22,7 +24,6 @@ public static void ConvertToPdf(string html, string ouputPath)
ColorMode = ColorMode.Color,
Orientation = Orientation.Portrait,
PaperSize = PaperKind.A4Plus,
- Out = ouputPath,
},
Objects = {
new ObjectSettings() {
@@ -30,11 +31,19 @@ public static void ConvertToPdf(string html, string ouputPath)
HtmlContent = html,
WebSettings = { DefaultEncoding = "utf-8" },
HeaderSettings = { FontSize = 9, Left = "My Amazing Title", Right = "Page [page] of [toPage]", Line = true, Spacing = 2.812 },
+ FooterSettings = { FontSize = 9, Left = "My Amazing Title", Right = "Page [page] of [toPage]", Line = true, Spacing = 2.812 },
}
}
};
- converter.Convert(doc);
+ Console.WriteLine("Saving PDF to " + ouputPath);
+
+ byte[] pdf = converter.Convert(doc);
+
+ using (FileStream stream = new FileStream(ouputPath, FileMode.Create))
+ {
+ stream.Write(pdf, 0, pdf.Length);
+ }
}
private static void ConverterOnProgressChanged(object sender, ProgressChangedArgs progressChangedArgs)
diff --git a/MarkdownToRW/MarkdownConverter/DragonMarkdown.csproj b/MarkdownToRW/MarkdownConverter/DragonMarkdown.csproj
index 8410326..7fee758 100644
--- a/MarkdownToRW/MarkdownConverter/DragonMarkdown.csproj
+++ b/MarkdownToRW/MarkdownConverter/DragonMarkdown.csproj
@@ -39,6 +39,15 @@