Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Small QoL improvements #37

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Wkhtmltopdf.NetCore.Test/SmokeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ public class SmokeTest
[SetUp]
public void SetRotativaPath()
{
#pragma warning disable 612
#pragma warning disable 618
WkhtmltopdfConfiguration.RotativaPath = AppDomain.CurrentDomain.BaseDirectory + "Rotativa";
#pragma warning restore 612
#pragma warning restore 618
}

[TearDown]
public void ClearRotativaPath()
{
#pragma warning disable 612
#pragma warning disable 618
WkhtmltopdfConfiguration.RotativaPath = null;
#pragma warning restore 612
#pragma warning restore 618
}

[Test]
Expand Down Expand Up @@ -55,9 +55,9 @@ public void LegacyResolutionWorks()
using var host = Host.CreateDefaultBuilder()
.ConfigureWebHostDefaults(webBuilder =>
{
#pragma warning disable 612
#pragma warning disable 618
webBuilder.ConfigureServices(services => services.AddWkhtmltopdf());
#pragma warning restore 612
#pragma warning restore 618
})
.Build();

Expand Down
2 changes: 1 addition & 1 deletion Wkhtmltopdf.NetCore/Configuration/ExactPathProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ExactPathProvider(string path = "wkhtmltopdf")
_path = path;
}

/* <inheritDoc /> */
/** <inheritDoc /> */
public string GetPath() => _path;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Wkhtmltopdf.NetCore
{
/// <summary>
/// Provides path to wkhtmltopdf.
/// </summary>
public interface IWkhtmltopdfPathProvider
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Wkhtmltopdf.NetCore/Configuration/LegacyPathProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class LegacyPathProvider : IWkhtmltopdfPathProvider
private readonly string _rotativaLocation;

/// <summary>
/// Constructs path from <see cref="AppDomain.CurrentDomain" />'s base directory, <see cref="wkhtmltopdfRelativePath" />,
/// Constructs path from <see cref="AppDomain.CurrentDomain" />'s base directory, <paramref name="wkhtmltopdfRelativePath"/> />,
/// <para />
/// OS dependent folder and executable name.
/// </summary>
Expand Down Expand Up @@ -45,7 +45,7 @@ public LegacyPathProvider(string wkhtmltopdfRelativePath = "Rotativa")
}
}

/* <inheritDoc /> */
/** <inheritDoc /> */
public string GetPath() => _rotativaLocation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ internal class RotativaPathAsPrefixPathProvider : IWkhtmltopdfPathProvider
/* <inheritDoc /> */
public string GetPath()
{
#pragma warning disable 612
#pragma warning disable 618
var wkhtmlPath = WkhtmltopdfConfiguration.RotativaPath;
#pragma warning restore 612
#pragma warning restore 618

string rotativaLocation;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Expand Down
9 changes: 7 additions & 2 deletions Wkhtmltopdf.NetCore/Configuration/WkhtmltopdfConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@

namespace Wkhtmltopdf.NetCore
{
/// <summary>
/// Extension methods for setting up Wkhtmltopdf.NetCore services.
/// </summary>
public static class WkhtmltopdfConfiguration
{
[Obsolete] public static string RotativaPath { get; set; }
[Obsolete("Use " + nameof(AddWkhtmltopdf) + " accepting " + nameof(IMvcBuilder)
+ " with suitable " + nameof(IWkhtmltopdfPathProvider) + ".")]
public static string RotativaPath { get; set; }

/// <summary>
/// Setup Rotativa library
Expand All @@ -20,7 +25,7 @@ public static class WkhtmltopdfConfiguration
/// Optional. Relative path to the directory containing wkhtmltopdf.
/// Default is "Rotativa". Download at https://wkhtmltopdf.org/downloads.html
/// </param>
[Obsolete]
[Obsolete("Use " + nameof(AddWkhtmltopdf) + " accepting " + nameof(IMvcBuilder) + ".")]
public static IServiceCollection AddWkhtmltopdf(this IServiceCollection services,
string wkhtmltopdfRelativePath = "Rotativa")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Wkhtmltopdf.NetCore
{
/// <summary>
/// Invokes the wkhtmltopdf.
/// </summary>
public interface IWkhtmlDriver
{
/// <summary>
Expand Down
10 changes: 8 additions & 2 deletions Wkhtmltopdf.NetCore/Implementation/WkhtmlDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@

namespace Wkhtmltopdf.NetCore
{
/// <summary>
/// Invokes the wkhtmltopdf.
/// </summary>
public class WkhtmlDriver : IWkhtmlDriver
{
private readonly IWkhtmltopdfPathProvider _pathProvider;

/// <summary>
/// Constructs new instance of <see cref="WkhtmlDriver"/>.
/// </summary>
public WkhtmlDriver(IWkhtmltopdfPathProvider pathProvider = null)
{
_pathProvider = pathProvider ?? RotativaPathAsPrefixPathProvider.Default;
}

/* <inheritDoc /> */
/** <inheritDoc /> */
public byte[] Convert(IConvertOptions options, string html) => Convert(_pathProvider, options.GetConvertOptions(), html);

/// <summary>
Expand All @@ -26,7 +32,7 @@ public WkhtmlDriver(IWkhtmltopdfPathProvider pathProvider = null)
/// <param name="switches">Switches that will be passed to wkhtmltopdf binary.</param>
/// <param name="html">String containing HTML code that should be converted to PDF.</param>
/// <returns>PDF as byte array.</returns>
[Obsolete]
[Obsolete("Use injected " + nameof(IWkhtmlDriver) + ".")]
public static byte[] Convert(string wkhtmlPath, string switches, string html)
{
string rotativaLocation;
Expand Down
6 changes: 6 additions & 0 deletions Wkhtmltopdf.NetCore/WkhtmlDriverException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

namespace Wkhtmltopdf.NetCore
{
/// <summary>
/// Custom Wkhtmltopdf.NetCore exception.
/// </summary>
[Serializable]
public class WkhtmlDriverException : Exception
{
/// <summary>
/// Constructs new instance of <see cref="WkhtmlDriverException"/>
/// </summary>
public WkhtmlDriverException(string message, Exception e) : base(message, e)
{
}
Expand Down
2 changes: 2 additions & 0 deletions Wkhtmltopdf.NetCore/Wkhtmltopdf.NetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<AssemblyVersion>3.0.2.0</AssemblyVersion>
<FileVersion>3.0.2.0</FileVersion>
<Version>3.0.2</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
<Description>This project implements the library wkhtmltopdf for asp net core and a view engine, working in windows, macos, linux and docker.

For more information about how to use it, go to https://github.com/fpanaccia/Wkhtmltopdf.NetCore.Example</Description>
Expand Down