Comments (75)
Hi,
Debian 10 x64 on .NET 5 - would error out with Current platform is not supported
What fixed it for me:
a) Went to https://wkhtmltopdf.org/downloads.html and downloaded the .deb package for Debian x64
b) Installed it via: dpkg -i debpackagename.deb
c) Typed: apt --fix-broken install
to force dependency installation
Now the PDF generation works without changing anything on C# side.
Thanks.
from wkhtmltopdf-dotnet.
hi @HakanL after some digging I've found this article than following the steps I've installed the parent library manually. on install this yelled the following "The following packages have unmet dependencies: wkhtmltox : Depends: libpng12-0 but it is not installable" A bit into google I've found that "libpng12-0" is not supported since version 16.10, look here. After you get the package then install it as the guide says I was able to install the parent library to Linux 18.04 wohoo. I've run the test command wkhtmltopdf http://google.com google.pdf
and a pdf was generated. In the code same error is generated.
Things to mention:
- I've installed also the .netcore 2.0.9 runtime thinking that is a problem so now installed are Microsoft.AspNetCore.All 2.2.8, Microsoft.AspNetCore.App 2.2.8, Microsoft.AspNetCore.App 3.1.9, Microsoft.NETCore.App 2.0.9, Microsoft.NETCore.App 2.2.8, Microsoft.NETCore.App 3.1.9.
- My app runs on .netcore 3.1
- The library works as expected on my windows 10 desktop and I am able to generate the pdf through the app.
Do you have any ideas?
from wkhtmltopdf-dotnet.
@daniel-van-niekerk So I tried to build my test project and just run it in Ubuntu 18.04, worked fine. But when I published I got the error when running it from the publish directory. I ran
ldd libwkthmltopdf
to see if there were any missing libraries and on my machine I was missing libjpeg62. Once I installed that I was able to run it successfully. I don't know/understand why I can run it fine in just the release folder (not publish), but not when published without this library. Maybe there's a difference in how things are loaded dynamically. But try ldd on the library and see if that gives you any insight.
Installing libjpeg62 on Ubuntu 20.04 got this working for me. Thanks
from wkhtmltopdf-dotnet.
Most likely you're missing some dependencies that you have to install via your docker file. Try to add the libjpeg62 as suggested.
from wkhtmltopdf-dotnet.
@HakanL
apologies for the delay. I tested it again on another Server on Ubuntu 18.04 and it had the same errors. lack of libjpeg62
and Current platform is not supported.
Even installing libjpeg62
it didn't show resolution
I downloaded the SO File from https://wkhtmltopdf.org/downloads.html and declared SO as in the above comment.
ldconfig -p | grep 'libwkhtml' /usr/local/lib/runtimes/libwkhtmltox.so libwkhtmltox.so
After declaring the SO, it worked perfectly
Edited:
I tested in version 1.5.71 as you requested
from wkhtmltopdf-dotnet.
@rmalca So you shouldn't actually install the native library, it's already part of this wrapper, I was just suggesting it as a way to determine which dependencies are required. It may work but your image will be larger than necessary.
from wkhtmltopdf-dotnet.
Are you getting this error in Windows, or Ubuntu? Are the examples in this project working?
from wkhtmltopdf-dotnet.
The error occures on windows.
If you mean this "Lorem Ipsum" examples.. Yes they are working..
Edit: But this is funny: if I do this inside the example project.. it works.. (there is IMHO nothing different with my solution..)
HtmlContent = File.ReadAllText("path\to\file.html")
from wkhtmltopdf-dotnet.
I'm not sure I understand what you mean, if you add File.ReadAllText to your project, or which project? What .NET platform is your project using? Can you share it?
from wkhtmltopdf-dotnet.
Ok,
I try to explain it: I have a .netstandard2.0 lib (inside of a .netcore3.1 webapi app) which loads a template .docx, searching template strings and replace them with real data. This is working as it should be (but not part of this project here). (On windows and Ubuntu)
Now I want to support some export possibilities like PDF or HTML. The PDF is generated (at this point) with libreoffice cli on ubuntu. In near future I want to get rid of this dependency and use a full ".net way" to convert to PDF.
I use DocumentFormat.OpenXML for the .docx and openXML-Power-Tools to convert to HTML.
But here is the problem: I can load the HTML into this lib, but on this line "converter.Convert(doc);" the error happens.
I cannot tell more, because I have no more details, unfortunately..
PS: what I want to tell in the comment above: The HTML is definitly valid (and therefore the bug is not in the HTML)
And: I cannot share this project, because there are a bunch of internal dependencies and you would not be able to compile anyways.
from wkhtmltopdf-dotnet.
Ok, you probably need to create a simple project that runs in the same platform, etc as your main project and see if you can reproduce it. Windows 10 x64 is definitely supported, I use it myself in a project (ASP.Net Core 3.1 hosted in Azure)
from wkhtmltopdf-dotnet.
Facing the same issue in Ubuntu 20.04. Do I need to install additional libraries or this nuget package is enough?
from wkhtmltopdf-dotnet.
Hmm, the NuGet package should be enough, but I've only tested this on Docker (where it works fine). Can you share more details about your project? Have you tried with a simple command line project? Which .NET version?
from wkhtmltopdf-dotnet.
I gave it a trial run using a simple console application.
Project File
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Haukcode.WkHtmlToPdfDotNet" Version="1.3.0" />
</ItemGroup>
</Project>
Program.cs
public class Program
{
public static void Main(string[] args)
{
var converter = new BasicConverter(new PdfTools());
converter.PhaseChanged += Converter_PhaseChanged;
converter.ProgressChanged += Converter_ProgressChanged;
converter.Finished += Converter_Finished;
converter.Warning += Converter_Warning;
converter.Error += Converter_Error;
var doc = new HtmlToPdfDocument()
{
GlobalSettings = {
ColorMode = ColorMode.Color,
Orientation = Orientation.Landscape,
PaperSize = PaperKind.A4,
},
Objects = {
new ObjectSettings() {
PagesCount = true,
HtmlContent = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur mauris eget ultrices iaculis. Ut et odio viverra, molestie lectus nec, venenatis turpis. Nulla quis euismod nisl. Duis scelerisque eros nec dui facilisis, sit amet porta odio varius. Praesent vitae sollicitudin leo. Sed vitae quam in massa eleifend porta. Aliquam pulvinar orci dapibus porta laoreet. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed commodo tortor eget dolor hendrerit dapibus.
Vivamus lorem diam, vulputate at ultrices quis, tristique eu nunc. Sed bibendum hendrerit leo. Nulla nec risus turpis. Vivamus at tortor felis. Donec eget posuere libero. Pellentesque erat nunc, molestie eget gravida vitae, eleifend a eros. Integer in tortor sed elit aliquam vehicula eget a erat. Vivamus nisi augue, venenatis ut commodo vel, congue id neque. Curabitur convallis dictum semper. Nulla accumsan urna aliquet, mattis dolor molestie, fermentum metus. Quisque at nisi non augue tempor commodo et pretium orci.
Quisque blandit libero ut laoreet venenatis. Morbi sit amet quam varius, euismod dui et, volutpat felis. Sed nec ante vel est convallis placerat. Morbi mollis pretium tempor. Aliquam luctus eu justo vitae tristique. Sed in elit et elit sagittis pharetra sed vitae velit. Proin eget mi facilisis, scelerisque justo in, ornare urna. Aenean auctor ante ex, eget mattis neque pretium id. Aliquam ut risus leo. Vivamus ullamcorper et mauris in vehicula. Maecenas tristique interdum tempus. Etiam mattis lorem eget odio faucibus, in rhoncus nisi ultrices. Etiam at convallis nibh. Suspendisse tincidunt velit arcu, a volutpat nulla euismod sed.
Aliquam mollis placerat blandit. Morbi in nibh urna. Donec nisl enim, tristique id tincidunt sed, pharetra non mi. Morbi viverra arcu vulputate risus dignissim efficitur. Vivamus dolor eros, finibus et porttitor a, pellentesque a lectus. Integer pellentesque maximus velit sit amet sollicitudin. Nulla a elit eget augue pretium luctus quis eu metus. Aenean nec dui id nibh tempor dapibus. Pellentesque dignissim ullamcorper mauris, vitae pharetra turpis sodales sit amet. Etiam et bibendum neque.
Nulla gravida sit amet velit eu aliquet. Etiam sit amet elit leo. Sed nec arcu tincidunt, placerat turpis quis, laoreet nulla. Aenean neque est, fringilla non nulla in, laoreet vehicula nunc. Etiam vel nisl sit amet lectus pellentesque eleifend. Etiam sed nisi dolor. Mauris quis tincidunt ex. Aliquam porta mattis tempor. Maecenas fringilla bibendum elementum. Vestibulum quis tempus libero, vitae cursus neque. Suspendisse lectus risus, lacinia consectetur enim quis, ullamcorper porta tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
WebSettings = { DefaultEncoding = "utf-8" },
HeaderSettings = { FontSize = 9, Right = "Page [page] of [toPage]", Line = true },
FooterSettings = { FontSize = 9, Right = "Page [page] of [toPage]" }
}
}
};
byte[] pdf = converter.Convert(doc);
if (!Directory.Exists("Files"))
{
Directory.CreateDirectory("Files");
}
using (var stream = new FileStream(Path.Combine("Files", DateTime.UtcNow.Ticks.ToString() + ".pdf"), FileMode.Create))
{
stream.Write(pdf, 0, pdf.Length);
}
}
private static void Converter_Error(object sender, WkHtmlToPdfDotNet.EventDefinitions.ErrorArgs e)
{
Console.WriteLine("[ERROR] {0}", e.Message);
}
private static void Converter_Warning(object sender, WkHtmlToPdfDotNet.EventDefinitions.WarningArgs e)
{
Console.WriteLine("[WARN] {0}", e.Message);
}
private static void Converter_Finished(object sender, WkHtmlToPdfDotNet.EventDefinitions.FinishedArgs e)
{
Console.WriteLine("Conversion {0} ", e.Success ? "successful" : "unsucessful");
}
private static void Converter_ProgressChanged(object sender, WkHtmlToPdfDotNet.EventDefinitions.ProgressChangedArgs e)
{
Console.WriteLine("Progress changed {0}", e.Description);
}
private static void Converter_PhaseChanged(object sender, WkHtmlToPdfDotNet.EventDefinitions.PhaseChangedArgs e)
{
Console.WriteLine("Phase changed {0} - {1}", e.CurrentPhase, e.Description);
}
}
from wkhtmltopdf-dotnet.
I created the above console app. Then I published it to a file folder (in Visual Studio on Windows 64). Then I ran it successfully under WSL2 in Ubuntu 18 and 20, both in 64-bit mode. I just added the default Ubuntu image from Microsoft Store, nothing else was installed in them.
from wkhtmltopdf-dotnet.
I am getting this error as well on Windows.
Both local on Windows 10 and on Server Windows 2012.
from wkhtmltopdf-dotnet.
I am getting this error as well on Windows.
Both local on Windows 10 and on Server Windows 2012.
I added the binaries for my test app here, see if you can run this (with .NET Core 3.1 runtime installed): https://github.com/HakanL/WkHtmlToPdf-DotNet/releases/tag/testapp
from wkhtmltopdf-dotnet.
@HakanL Your program worked (I think, I cant find where you saved the file, but looking at the screen, it seemed to be OK )
But how does that help me solve my problem on my server that is running on 4.7.2
Here is my very simple code:
Dim doc As New HtmlToPdfDocument
Dim g As New GlobalSettings
g.ColorMode = ColorMode.Grayscale
g.PaperSize = PaperKind.A4
g.Orientation = Orientation.Portrait
g.Out = "C:\Users\yoni\Downloads\RX_654321.pdf"
doc.GlobalSettings = g
doc.Objects.Add(New ObjectSettings With {.Page = "https://www.google.com"})
Dim converter As New BasicConverter(New PdfTools)
converter.Convert(doc)
from wkhtmltopdf-dotnet.
There should be a subfolder called Files that has the generated PDF. Ok, that's good. You never said you wanted to run this under FW 4.7.2, let me see if that works here, never tried that, I'm all .NET Core nowadays.
from wkhtmltopdf-dotnet.
from wkhtmltopdf-dotnet.
So it seems that when you add a .NET Standard NuGet package to .NET FW 4.7.2 then the runtimes files aren't included. I don't know how to fix that, may need some research, but you should be able to manually add the runtimes folder, see if that works.
from wkhtmltopdf-dotnet.
Pardon my inexperience, but which folders specifically should I be addin and where do I add them? (To my bin folder)
from wkhtmltopdf-dotnet.
All folders/files in the runtimes
folder that you can copy from the .NET Core build (on another machine). But it's not a full solution, just for testing. Yes, into the same folder where your exe lives. Compare to the .NET Core build I sent you, the files have to be in the same place for .NET Framework, it's just that for some reason the build process for .NET Framework (4.7.2) doesn't add them automatically. That's the part that I need to look into how to fix.
from wkhtmltopdf-dotnet.
Hi, I'm also running into this problem, but running under docker with Linux as the target OS. If I run the project not under docker then it generates the pdf just fine. It's a very simple implementation and not much I can see I'm doing wrong.
This is the document.
return new HtmlToPdfDocument { GlobalSettings = { ColorMode = ColorMode.Color, Orientation = Orientation.Landscape, PaperSize = PaperKind.A4Plus }, Objects = { new ObjectSettings { PagesCount = true, HtmlContent = htmlString, WebSettings = { DefaultEncoding = "utf-8" }, HeaderSettings = { FontSize = 9, Right = "Page [page] of [toPage]", Line = true, Spacing = 2.812 } } } };
This is the service registration services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));
It's called from an async controller that returns a file.
This is the output:
Exception thrown: 'System.DllNotFoundException' in WkHtmlToPdfDotNet.dll Exception thrown: 'System.DllNotFoundException' in WkHtmlToPdfDotNet.dll Exception thrown: 'System.DllNotFoundException' in WkHtmlToPdfDotNet.dll Exception thrown: 'System.NotSupportedException' in WkHtmlToPdfDotNet.dll Exception thrown: 'System.NotSupportedException' in System.Private.CoreLib.dll Exception thrown: 'System.AggregateException' in WkHtmlToPdfDotNet.dll
from wkhtmltopdf-dotnet.
@josh-core Can you try the docker example in the repo instead? Also verify that the native DLLs are in your docker image.
from wkhtmltopdf-dotnet.
Ahh, ok, so I did notice that the project TestConsoleAppDocker had the following within the docker file
# Install dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends \ zlib1g \ libgdiplus \ libc6-dev \ ca-certificates \ fontconfig \ fontconfig-config \ fonts-dejavu-core \ libbsd0 \ libexpat1 \ libfontconfig1 \ libfontenc1 \ libfreetype6 \ libjpeg62-turbo \ libpng16-16 \ libssl1.1 \ libx11-6 \ libx11-data \ libxau6 \ libxcb1 \ libxdmcp6 \ libxext6 \ libxrender1 \ ucf \ x11-common \ xfonts-75dpi \ xfonts-base \ xfonts-encodings \ xfonts-utils \ && rm -rf /var/lib/apt/lists/*
Are these what's required for it to work? Yep, just added them and it works! Thanks.
from wkhtmltopdf-dotnet.
@josh-core Well, there are dependencies of the parent/native wkhtmltopdf, and the bare-bones docker images don't have those, so yes you need to make sure those dependencies are met. You can test it by running the wkhtmltopdf binaries in a container and see if that works, this .NET project is just a wrapper around the native wkhtmltopdf, so anything the native library requires is required.
from wkhtmltopdf-dotnet.
Hi @HakanL, I believe I have a similar issue but with a different platform. I was using the library with no issues with .net core 2.2 on both Windows and Linux (18). After updating the entire project to .net 5.0, the error from the issue title occurs.
Example app ("dotnet new web") with installed package ("dotnet add package Haukcode.WkHtmlToPdfDotNet.") and sample convert produces the error.
from wkhtmltopdf-dotnet.
@BorisPetelj I haven't tested this with .NET5, feel free to see if you can figure out what has changed.
from wkhtmltopdf-dotnet.
I didn't have much time to commit to the Linux issue, but I can confirm that on Windows (7 and 10) it's working.
As far as Linux (Ubuntu 20.04), the "Current platform is not supported" occurs as the library cannot be located inside ModuleFactory.GetModule()
from wkhtmltopdf-dotnet.
I'm getting the same error on ubuntu 18.04. I've installed the packages from the above but the issue is the same platform not supported in ModuleFactory.GetModule(). My machine is an azure machine if this helps, also I'm using it in conjunction with .netcore 3.1. I'm thinking that this project is using .netstandard 2.0 that may not be installed on my vm
from wkhtmltopdf-dotnet.
@radupopabac It's most likely missing libraries. Try to download the parent/native wkhtmltopdf project and see if that runs, this wrapper only calls the native library, if that library is missing something then there's nothing this C# wrapper can do, and you get the above error.
from wkhtmltopdf-dotnet.
@radupopabac It looks like you've done a thorough job in trying to get it to work. Unfortunately I don't have a lot more details to give you, I have an Ubuntu 20.04 instance (WSL2) and I just installed .NET Core 3.1 and created a new console app (.NET Core 3.1) which I then built and executed on the Ubuntu instance. It generates the files just fine (there are no dependencies on anything in .NET Core 2). I also tested it successfully on Ubuntu 18.04 (also under WSL2). Both x64.
from wkhtmltopdf-dotnet.
@HakanL how did you got the .so file? how did you build it to get it? Are you using 0.12.6 libraries or 0.12.5 it got me a bit confused as in commits I see .6 and on release the name is .5 :P
from wkhtmltopdf-dotnet.
@radupopabac I install the wkhtmltopdf binaries from their site using their installers. Then I grab the so file from the file system.
from wkhtmltopdf-dotnet.
Hi , my project is runing on net core 3.1 in WSL2
I found the same exceptions !
The Errors
thanks
from wkhtmltopdf-dotnet.
@lic0914 Can you try to run the parent wkhtmltopdf project and see if that runs in your instance? The issue is most likely that Linux fails to load the SO due to missing dependencies, unfortunately those details don't bubble up to the C# code, all it gets is that the native library can't be loaded.
from wkhtmltopdf-dotnet.
@HakanL I think I know what is the problem. You have a Linux on version 20.04 and my vm on azure was on 18.04 it seems that the .so files that you put inside the library are not compatible with the 18.04 version. Maybe not compatible with a different version of architecture if you run on arm64 they may not be compatible with amd64 and for sure with x86 architectures. As I can't use the library I've found this library which lets each developer to import it's own executable for windows, linux and mac. Hope this helps to solve this problem
from wkhtmltopdf-dotnet.
@radupopabac I've tested it in both 18 and 20, it worked fine here (granted WSL, but still). But maybe we need to figure out a way to have different binaries based on the distribution, hopefully it's not required. This project/wrapper does not currently support ARM64, so if you're testing on that then it won't work.
The purpose of this library is so you don't have to manually add the binaries.
from wkhtmltopdf-dotnet.
Publishing to linux-x64 self-contained also doesn't copy over the runtimes folder. Manually copying the runtimes folder still produced the same error on Centos 7. Project is dotnetcore 3.1
I installed Wkhtmltopdf on that Centos 7 and called it directly from the command line to convert from html to a pdf and it worked fine. Just this nuget package that can't seem to find the linux-64 find the libwkhtmltox file.
from wkhtmltopdf-dotnet.
Publishing to linux-x64 self-contained also doesn't copy over the runtimes folder. Manually copying the runtimes folder still produced the same error on Centos 7. Project is dotnetcore 3.1
I installed Wkhtmltopdf on that Centos 7 and called it directly from the command line to convert from html to a pdf and it worked fine. Just this nuget package that can't seem to find the linux-64 find the libwkhtmltox file.
What steps do you take to publish to linux-x64 that doesn't copy the runtimes folder? When I build it in VS it puts the runtimes folder there with all the binaries. Can you share your project?
from wkhtmltopdf-dotnet.
What steps do you take to publish to linux-x64 that doesn't copy the runtimes folder? When I build it in VS it puts the runtimes folder there with all the binaries. Can you share your project?
Right-click the project -> Publish -> Folder -> netcoreapp3.1/linux-x64
The project config is:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Haukcode.WkHtmlToPdfDotNet" Version="1.3.0" />
</ItemGroup>
<ItemGroup>
<None Update="templateOne.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
templateOne.html is just the file I read to to pass as the HtmlContent.
The only other code is:
string DATA = File.ReadAllText("templateOne.html");
var converter = new SynchronizedConverter(new PdfTools());
var doc = new HtmlToPdfDocument()
{
GlobalSettings = {
ColorMode = ColorMode.Color,
Orientation = Orientation.Portrait,
PaperSize = PaperKind.A4,
},
Objects = {
new ObjectSettings() {
PagesCount = true,
HtmlContent = DATA,
WebSettings = { DefaultEncoding = "utf-8" }
}
}
};
byte[] pdf = converter.Convert(doc);
Debugging this in Windows works fine.
from wkhtmltopdf-dotnet.
@daniel-van-niekerk So I tried to build my test project and just run it in Ubuntu 18.04, worked fine. But when I published I got the error when running it from the publish directory. I ran ldd libwkthmltopdf
to see if there were any missing libraries and on my machine I was missing libjpeg62. Once I installed that I was able to run it successfully. I don't know/understand why I can run it fine in just the release folder (not publish), but not when published without this library. Maybe there's a difference in how things are loaded dynamically. But try ldd on the library and see if that gives you any insight.
from wkhtmltopdf-dotnet.
I'm also getting this on Win 10 x64 .Net Core (3.1 I think).
If I clone your repo and try to run the unit tests I get the same error. If I update the DLL name (add ".dll") the unit tests (mostly) work.
ModuleFactory.cs
from this
[DllImport(@"runtimes\win-x64\native\wkhtmltox", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, EntryPoint = "wkhtmltopdf_version")]
to this
[DllImport(@"runtimes\win-x64\native\wkhtmltox.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, EntryPoint = "wkhtmltopdf_version")]
FYI RepeatTableOfContents
fails with this message (I added FluentAssertions).
Expected pdf.Length to be greater than 20000, but found 13098.
from wkhtmltopdf-dotnet.
@nyash Thanks for the details. Yeah, the issue isn't necessarily that the platform isn't supported, it basically is that the native library can't be loaded, and in the .NET environment there are no further details to tell us if it's due to a missing dependency, or if the platform itself isn't supported. We could of course change the error message to include that, but does anybody has a suggestion for a better solution then I'm all open ears.
from wkhtmltopdf-dotnet.
hi @HakanL , getting below error after deployment in docker. Im using .Net 5.
have added below line of code in docker file too.
RUN apt-get update -qq && apt-get -y install libgdiplus libc6-dev
One or more errors occurred. (Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.) Unable to load native library. The platform may be missing native dependencies (Ji libjpeg62, etc). Or the current platform is not supported.
from wkhtmltopdf-dotnet.
Hi @HakanL , how can I convert generated PDF into document? Is it possible to generate document with this?
from wkhtmltopdf-dotnet.
Hi @HakanL , how can I convert generated PDF into document? Is it possible to generate document with this?
@svnaidu41 This library is to convert from HTML to PDF. Also this question is not related to issue 28.
from wkhtmltopdf-dotnet.
Hi,
Debian 10 x64 on .NET 5 - would error out with
Current platform is not supported
What fixed it for me:
a) Went to https://wkhtmltopdf.org/downloads.html and downloaded the .deb package for Debian x64
b) Installed it via:dpkg -i debpackagename.deb
c) Typed:apt --fix-broken install
to force dependency installationNow the PDF generation works without changing anything on C# side.
Thanks.
Great stuff, thanks for this. Did the same on Ubuntu 16.04 by downloading the amd64 package and PDF generation now works.
WkHtmlToPdfDotNet version i am using is 1.5.8
from wkhtmltopdf-dotnet.
Most likely it's the jpeg library that was missing, installing the deb file will provide all the dependencies, something the .NET wrapper unfortunately can't.
from wkhtmltopdf-dotnet.
Install dependencies RUN apt-get update libgdiplus
from wkhtmltopdf-dotnet.
Closing this as the issue is most likely related to missing native libraries in the OS.
from wkhtmltopdf-dotnet.
Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.
Hey I got this error when hosted on Linux server . It works fine on my windows machine but when I host to linux serve I get above error help please
from wkhtmltopdf-dotnet.
@ramson12 Have you checked if you have all the dependencies installed?
from wkhtmltopdf-dotnet.
Can you please help me how I can install dependencies
Thank you
from wkhtmltopdf-dotnet.
@ramson12 The easiest is to install the wkhtmltopdf package, the WkHtmlToPdf-DotNet is just a wrapper around the native library.
from wkhtmltopdf-dotnet.
@HakanL i have only added Haukcode.WkHtmlToPdfDotNet from Nuget manager.
from wkhtmltopdf-dotnet.
@ramson12 I understand that, but this is just a wrapper for the native library wkhtmltopdf, you need to make sure your platform has all the necessary dependencies for the wkhtmltopdf library, this NuGet package can't do that for you.
from wkhtmltopdf-dotnet.
it worked for me after registering the runtimes.
after 5 hours of debugging and testing, I checked, and during the installation, it didn't register the Runtimes. I added the following command in Docker and it worked 100%
ldconfig -p | grep 'libwkhtml' /usr/local/lib/runtimes/libwkhtmltox.so libwkhtmltox.so
after that it worked normally
from wkhtmltopdf-dotnet.
@DanielBruch I wonder if that just bypassed the logic that tries to find the runtime, it shouldn't be necessary to do that step, so it's more of a workaround. I wonder if this may be related to #72, maybe you can try the new 1.5.71 NuGet package, maybe that fix helps this scenario as well?
from wkhtmltopdf-dotnet.
Thanks for testing Daniel, I haven't heard of anyone else having to register the native library. You don't happen to have this testable in a docker container do you? Without that it's hard to know if it's something related to your Ubuntu instance.
from wkhtmltopdf-dotnet.
Hi I am using .NET core Azure functions app getting the error mentioned above.
"One or more errors occurred. (Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.)". See the function execution logs for additional details.". See the function execution logs for additional details."
(Inner Exception #0) System.NotSupportedException: Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.
[2022-05-06T17:08:27.778Z] at WkHtmlToPdfDotNet.ModuleFactory.GetModule()
[2022-05-06T17:08:27.781Z] at WkHtmlToPdfDotNet.PdfTools.Load()
[2022-05-06T17:08:27.784Z] at WkHtmlToPdfDotNet.BasicConverter.Convert(IDocument document)
[2022-05-06T17:08:27.788Z] at WkHtmlToPdfDotNet.SynchronizedConverter.<>c__DisplayClass4_0.b__0()
[2022-05-06T17:08:27.792Z] at System.Threading.Tasks.Task`1.InnerInvoke()
[2022-05-06T17:08:27.795Z] at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
[2022-05-06T17:08:27.802Z] at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
[2022-05-06T17:08:27.806Z] --- End of stack trace from previous location where exception was thrown ---
Which solutions actualy solves this problem ? Can you please guide step by step.
This in local environment, but the same issue occures in the server as well.
from wkhtmltopdf-dotnet.
@saumyeN Most likely you're missing some native dependency, try to install the native library and see what it installs. Could also be that it doesn't work with native libraries in Azure consumption plan.
from wkhtmltopdf-dotnet.
Can you suggest where I can get the native library ? And how to install it ?
from wkhtmltopdf-dotnet.
Can you suggest where I can get the native library ? And how to install it ?
You'll find all the details on their project page: https://wkhtmltopdf.org/
from wkhtmltopdf-dotnet.
In my case that I was using AWS and Centos 7 I had to follow this steps
1- install: libgdiplus-2.10-10.el7.x86_64
2- Add the files libwkhtmltox (with extensions .dll, .dylib, .so) and set their Compile Action as Content and Copy directory as: Always
With that everything wired up now is working perfectly.
from wkhtmltopdf-dotnet.
You shouldn't have to add the native binaries manually, they should be added during the build.
from wkhtmltopdf-dotnet.
I'm having trouble implementing this library on Amazon Linux 2. I always get this message and I don't know what might be missing:
"Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported."
FROM public.ecr.aws/lambda/dotnet:7
WORKDIR /var/task
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install -y \
fontconfig \
wget \
libX11 \
libXext \
libXrender \
libjpeg \
openssl \
xorg-x11-fonts-75dpi \
xorg-x11-fonts-Type1 \
libgdiplus \
ca-certificates \
zlib-devel
RUN rpm -Uvh https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm
RUN mkdir /opt/lib
RUN ln -s /usr/local/lib/libwkhtmltox.so /usr/lib/libwkhtmltox.so
RUN ln -s /usr/local/lib/libwkhtmltox.so /opt/lib/libwkhtmltox.so
COPY "bin/Release/lambda-publish" .
from wkhtmltopdf-dotnet.
You're missing some native dependencies. Try to install/load the native library wkhtmltopdf and once you got that working this wrapper should be fine.
from wkhtmltopdf-dotnet.
For anyone using AWS Toolkit for Visual Studio and having the same problem, I noticed that for some reason the "libwkhtmltox.so" binary is not copied to "runtimes/linux-x64/native/" so basically you have to create a COPY once installed.
FROM public.ecr.aws/lambda/dotnet:7
WORKDIR /var/task
RUN yum install -y \
libX11 \
libXext \
libXrender \
libjpeg \
openssl \
xorg-x11-fonts-75dpi \
xorg-x11-fonts-Type1 \
&& rpm -U https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm \
&& mkdir -p ./runtimes/linux-x64/native \
&& cp /usr/local/lib/libwkhtmltox.so ./runtimes/linux-x64/native/libwkhtmltox.so \
&& rpm -e wkhtmltox-0.12.6-1.amazonlinux2.x86_64
COPY "bin/Release/lambda-publish" .
from wkhtmltopdf-dotnet.
@rmalca So you shouldn't actually install the native library, it's already part of this wrapper, I was just suggesting it as a way to determine which dependencies are required. It may work but your image will be larger than necessary.
Got it, I made a change to my Dockerfile reducing the image size by 79MB. I must include the native library installation as the "libwkhtmltox.so" file is not being copied at publish time via the AWS Toolkit.
from wkhtmltopdf-dotnet.
@rmalca - are you able to fix the issue. is it working now?
I am also facing same error when deployed in aws lambda as image.
I noticed that file libwkhtmltox in ./runtimes/linux-x64/native is not being picked by code and throwing the similar error.
I have added x86 path also. then it worked.
Added below lines in docker
RUN mkdir -p ./runtimes/linux-x86/native
&& cp /usr/local/lib/libwkhtmltox.so ./runtimes/linux-x86/native/libwkhtmltox.so
I am not sure whether this is the right way to do it or not. but it worked.
from wkhtmltopdf-dotnet.
The publish should copy the native files, if not then that part should be troubleshooted. Copying the file is a workaround, which may be okay until the publish has been figured out.
from wkhtmltopdf-dotnet.
Can we please provide the docker command for installing native library and copying them at runtime via docker? Trying for almost a day, but couldn't figure it out. @HakanL
from wkhtmltopdf-dotnet.
@SaiGaneshKrishnan Not sure what you mean, perhaps you can use the docker example in this repo and go from there.
from wkhtmltopdf-dotnet.
Related Issues (20)
- Not reading settings on alpine HOT 2
- HTML tags removed HOT 3
- Reporting a vulnerability HOT 1
- In Linux CentOS 7, there was an error: Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported. HOT 3
- Memory overflow HOT 2
- The wkhtmltopdf project that is used, is no longer maintained HOT 3
- Display flex is not working HOT 1
- Unable to load native library - Windows 10/11 HOT 16
- How to directly pass parameters to wkhtmltopdf without using objects HOT 1
- You can only download the pdf once HOT 2
- How can I include CSS like Bootstrap in my HTML so that I can observe the applied styles when generating a PDF? HOT 6
- Unable to load native library on .NET8 HOT 29
- n/a
- GlobalSettings not respected on debian 11 HOT 3
- With Multiple requests fails HOT 15
- Not working on Azure Web App 32 bits HOT 7
- add cover command HOT 2
- PdfTools.GetConversionResult doesn't frees memory HOT 3
- HTML字符串转换为PDF报错System.ExecutionEngineException HOT 1
- 将HTML字符串转换为PDF文件,抛出异常System.ExecutionEngineException(重复,需要删除) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wkhtmltopdf-dotnet.