diff --git a/RaceLapTimer/PDFExporter/PDFExporter.csproj b/RaceLapTimer/PDFExporter/PDFExporter.csproj index 4cd92a4..f0c0816 100644 --- a/RaceLapTimer/PDFExporter/PDFExporter.csproj +++ b/RaceLapTimer/PDFExporter/PDFExporter.csproj @@ -44,6 +44,7 @@ + diff --git a/RaceLapTimer/PDFExporter/PdfExporter.cs b/RaceLapTimer/PDFExporter/PdfExporter.cs index 6871e67..d0361c4 100644 --- a/RaceLapTimer/PDFExporter/PdfExporter.cs +++ b/RaceLapTimer/PDFExporter/PdfExporter.cs @@ -3,6 +3,7 @@ using System.Threading; using Interfaces; using Syncfusion.HtmlConverter; using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; namespace PDFExporter { @@ -28,11 +29,44 @@ namespace PDFExporter void DoExport(string fileContent, string baseUrl) { - var pdfExporter = new HtmlToPdfConverter(); + //var pdfExporter = new HtmlToPdfConverter(); + //var settings2 = new IEConverterSettings(); + //settings2.AdditionalDelay = 2000; + //pdfExporter.ConverterSettings = settings2; + //PdfDocument doc = pdfExporter.Convert(fileContent, baseUrl); + + + var conv = new HtmlToPdfConverter(); + + PdfDocument document = new PdfDocument(); + //Set page margins and dimensions. + + PdfUnitConvertor convertor = new PdfUnitConvertor(); + + float width = convertor.ConvertToPixels(document.PageSettings.Width, PdfGraphicsUnit.Point); + float height = convertor.ConvertToPixels(document.PageSettings.Height, PdfGraphicsUnit.Point); + var settings = new IEConverterSettings(); - settings.AdditionalDelay = 2000; - pdfExporter.ConverterSettings = settings; - PdfDocument doc = pdfExporter.Convert(fileContent, baseUrl); + + settings.EnableHyperLink = true; + settings.EnableJavaScript = true; + settings.SplitImages = false; + settings.SplitTextLines = false; + + settings.Margin.All = 20.0f; + + settings.PdfPageSize = PdfPageSize.A4; + + conv.ConverterSettings = settings; + + //Convert the URL/HTML string by providing the required width and height. + var doc = conv.Convert(@"http://www.bbc.co.uk", width, height, AspectRatio.KeepWidth); + doc.PageSettings.Size = PdfPageSize.A4; + doc.PageSettings.SetMargins((float)20.0f); + + doc.Save("c:\\zzz\\test3.pdf"); + //doc.Close(true); + MemoryStream ms = new MemoryStream(); doc.Save(ms); doc.Close(true); diff --git a/RaceLapTimer/RaceLapTimer/AuthenticationBootstrapper.cs b/RaceLapTimer/RaceLapTimer/AuthenticationBootstrapper.cs index da73ca1..bb0a7bf 100644 --- a/RaceLapTimer/RaceLapTimer/AuthenticationBootstrapper.cs +++ b/RaceLapTimer/RaceLapTimer/AuthenticationBootstrapper.cs @@ -58,7 +58,7 @@ namespace RaceLapTimer // id.Close(); // id.Dispose(); // fs.Flush(true); - // fs.Close(); + // fs.Close(); //this still isnt saving the file.. :( //} } diff --git a/RaceLapTimer/RaceLapTimer/Extensions/PluginLocator.cs b/RaceLapTimer/RaceLapTimer/Extensions/PluginLocator.cs index 951bee7..e0688f5 100644 --- a/RaceLapTimer/RaceLapTimer/Extensions/PluginLocator.cs +++ b/RaceLapTimer/RaceLapTimer/Extensions/PluginLocator.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; @@ -40,9 +41,18 @@ namespace RaceLapTimer.Extensions if (!IsAssembly(ext)) continue; var assembly = Assembly.ReflectionOnlyLoadFrom(file); - var pluginTypes = (from t in assembly.GetExportedTypes() - where t.GetInterfaces().Any(x => x.Name == typeof(T).Name) - select t).ToList(); + var pluginTypes = new List(); + try + { + pluginTypes.AddRange((from t in assembly.GetExportedTypes() + where t.GetInterfaces().Any(x => x.Name == typeof(T).Name) + select t).ToList()); + } + catch (FileLoadException flex) + { + _logger.Error(flex); + } + if (pluginTypes.Any()) { discoveryList.Add(new DiscoveredPlugin diff --git a/RaceLapTimer/RaceLapTimerHost/App.config b/RaceLapTimer/RaceLapTimerHost/App.config index 7dd592e..e770a52 100644 --- a/RaceLapTimer/RaceLapTimerHost/App.config +++ b/RaceLapTimer/RaceLapTimerHost/App.config @@ -32,6 +32,9 @@ + + + \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimerHost/RaceLapTimerHost.csproj b/RaceLapTimer/RaceLapTimerHost/RaceLapTimerHost.csproj index f832b65..37cb8ae 100644 --- a/RaceLapTimer/RaceLapTimerHost/RaceLapTimerHost.csproj +++ b/RaceLapTimer/RaceLapTimerHost/RaceLapTimerHost.csproj @@ -96,10 +96,10 @@ copy /B /Y "$(TargetDir)NLogConfig.xml" "$(TargetDir)Configs\NLogConfig.xml" copy /B /Y "$(SolutionDir)RaceLapTimer\$(OutDir)Ninject.Extensions.Xml.dll" "$(TargetDir)Ninject.Extensions.Xml.dll" copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)PDFExporter.dll" "$(TargetDir)Plugins\PDFExporter.dll" copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir).dll" "$(TargetDir)Plugins\PDFExporter.dll" -copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.HtmlConverter.Base.dll" "$(TargetDir)Syncfusion.HtmlConverter.Base.dll" -copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.Pdf.Base.dll" "$(TargetDir)Syncfusion.Pdf.Base.dll" -copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.Compression.Base.dll" "$(TargetDir)Syncfusion.Compression.Base.dll" -copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Microsoft.mshtml.dll" "$(TargetDir)Microsoft.mshtml.dll" +copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.HtmlConverter.Base.dll" "$(TargetDir)Plugins\Syncfusion.HtmlConverter.Base.dll" +copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.Pdf.Base.dll" "$(TargetDir)Plugins\Syncfusion.Pdf.Base.dll" +copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Syncfusion.Compression.Base.dll" "$(TargetDir)Plugins\Syncfusion.Compression.Base.dll" +copy /B /Y "$(SolutionDir)PDFExporter\$(OutDir)Microsoft.mshtml.dll" "$(TargetDir)Plugins\Microsoft.mshtml.dll"