I am using Aspose Pdf library for converting HTML code to PDF Document in Dotnet. In Windows this is working perfectly but in docker image it is showing an error in the second line –
var options = new HtmlLoadOptions();
var pdfDocument = new Document(stream, options);
Here Document is using from Aspose and the steam is –
var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(HtmlData)
do I need any configuration for Aspose in the docker file?
2
Answers
We need to use "Aspose.pdf.drawing" for docker. Forum
You see the examples from here and here
Aspose.Words for .NET Core and .NET Standard uses
SkiaSharp
to deal with graphics, to make it work on Linux you have to add reference either to SkiaSharp.NativeAssets.Linux or to SkiaSharp.NativeAssets.Linux.NoDependenciesIf you add reference to
SkiaSharp.NativeAssets.Linux
, you should also installlibfontconfig1
in your system.SkiaSharp.NativeAssets.Linux
depends on this library. You can use the following command to install it:If you do not have rights to install packages, or other reasons not to install
libfontconfig1
, you can simply useSkiaSharp.NativeAssets.Linux.NoDependencies
, which does not require installation oflibfontconfig1
.For your reference here is simple working
Dokerfile
and.csproj
: