AdaskoTheBeAsT.WkHtmlToX
7.0.0
See the version list below for details.
dotnet add package AdaskoTheBeAsT.WkHtmlToX --version 7.0.0
NuGet\Install-Package AdaskoTheBeAsT.WkHtmlToX -Version 7.0.0
<PackageReference Include="AdaskoTheBeAsT.WkHtmlToX" Version="7.0.0" />
paket add AdaskoTheBeAsT.WkHtmlToX --version 7.0.0
#r "nuget: AdaskoTheBeAsT.WkHtmlToX, 7.0.0"
// Install AdaskoTheBeAsT.WkHtmlToX as a Cake Addin #addin nuget:?package=AdaskoTheBeAsT.WkHtmlToX&version=7.0.0 // Install AdaskoTheBeAsT.WkHtmlToX as a Cake Tool #tool nuget:?package=AdaskoTheBeAsT.WkHtmlToX&version=7.0.0
WkHtmlToX
C# wrapper for wkhtmltopdf.org Html to Pdf and Image library.
Badges
Usage
In web api (in combination with SimpleInjector) registration should be as follows:
// for simplicity only version for win here
var configuration = new WkHtmlToXConfiguration((int)Environment.OSVersion.Platform, null);
_container.RegisterInstance(configuration);
_container.RegisterSingleton<IWkHtmlToXEngine, WkHtmlToXEngine>();
_container.RegisterSingleton<IPdfConverter, PdfConverter>();
_container.RegisterInitializer<IWkHtmlToXEngine>(e => e.Initialize());
In command line application:
// for simplicity only version for win here
var configuration = new WkHtmlToXConfiguration((int)Environment.OSVersion.Platform, null);
using (var engine = new WkHtmlToXEngine(configuration))
{
engine.Initialize();
var converter = new PdfConverter(engine);
}
Method for conversion to pdf takes 3 parameters. First is settings object in which there is possibility to pass html content to be converted. In second parameter you need to pass func which based on length will create stream. In third you need to pass CancellationToken.
Second parameter is tricky but such construction allows to use for example Microsoft.IO.RecyclableMemoryStream to reuse block of memories. Then whole conversion can look like this
// doc settings object created earlier
Stream? stream = null;
var converted = await _pdfConverter.ConvertAsync(
doc,
length =>
{
stream = _recyclableMemoryStreamManager.GetStream(
Guid.NewGuid(),
"wkhtmltox",
length);
return stream;
},
_httpContextAccessor.HttpContext?.RequestAborted ?? CancellationToken.None);
stream!.Position = 0;
if (converted)
{
var result = new FileStreamResult(stream, "application/pdf")
{
FileDownloadName = "sample.pdf",
};
return result;
}
WkHtmlToX native lib comes with support for following operation system flavours:
- WinX64,
- WinX86,
- OsxX64,
- AmazonLinux2,
- Centos6,
- Centos7,
- Centos8,
- Debian9X64,
- Debian9X86,
- Debian10X64,
- Debian10X86,
- OpenSuseLeap15,
- Ubuntu1404X64,
- Ubuntu1404X86,
- Ubuntu1604X64,
- Ubuntu1604X86,
- Ubuntu1804X64,
- Ubuntu1804X86,
- Ubuntu2004X64,
For linux you can set it using second parameter in config.
var configuration = new WkHtmlToXConfiguration((int)PlatformID.Unix, WkHtmlToXRuntimeIdentifier.Ubuntu2004X64);
Influencers
Library is based on wrapper (DinkToPdf)[https://github.com/rdvojmoc/DinkToPdf]. Interoperability was totally reworked and now it is under tests to see if leaking memory can be avoided.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
7.1.0 | 601 | 12/27/2023 |
7.0.0 | 160 | 12/5/2023 |
6.0.0 | 477 | 11/13/2022 |
5.0.0 | 464 | 2/23/2021 |
4.0.3 | 442 | 1/16/2021 |
4.0.1 | 447 | 12/3/2020 |
4.0.0 | 482 | 7/8/2020 |
3.0.3 | 522 | 4/22/2020 |
3.0.2 | 504 | 4/19/2020 |
3.0.1 | 478 | 4/19/2020 |
3.0.0 | 528 | 3/29/2020 |
2.0.0 | 533 | 3/28/2020 |
1.1.0 | 616 | 12/15/2019 |
1.0.0 | 537 | 12/8/2019 |