we were using licensed Aspose.Words version 18, this is not supporting the font and image of doc file to pdf conversion in Linux.
Is there any way to get actual font and image on word to PDF conversion.
Here is my sample code:-
Document document = new Document(source);
using (MemoryStream stream = new MemoryStream())
{
document.Save(stream, GetSaveFileFormat(fileName));
return stream.GetBuffer();
}
When we’re running this code on a Windows system, everything works great. When we try to run the code in Linux we are facing font and image related issue.
Please help us to find the solutions.
Thank you.
@Alok_Nidhi_Gupta
Images
Most likely .NET Standard version of Aspose.Words is used on Linux. Aspose.Words for .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.NoDependencies
If you add reference to SkiaSharp.NativeAssets.Linux, you should also install libfontconfig1
in your system. SkiaSharp.NativeAssets.Linux depends on this library. You can use the following command to install it:
apt-get update && apt-get install -y libfontconfig1
If you do not have rights to install packages, or other reasons not to install libfontconfig1
, you can simply use SkiaSharp.NativeAssets.Linux.NoDependencies, which does not require installation of libfontconfig1
.
Fonts
The problem might occur because the fonts used in your input document are not available on the machine where document is converted to PDF. If Aspose.Words cannot find the font used in the document, the font is substituted. This might lead into fonts mismatch and document layout differences due to the different fonts metrics. You can implement IWarningCallback to get notifications when font substitution is performed.
Please see our documentation to learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/
Hi @alexey.noskov
We tried you suggestion but for version Aspose.Words version 18.8.0, its not working for us.
if we use SkiaSharp.NativeAssets.Linux or SkiaSharp.NativeAssets.Linux.NoDependencies
we are getting error at document.Save(stream, GetSaveFileFormat(fileName))
as
Object reference not set to an instance of an object.
@Alok_Nidhi_Gupta Aspose.Words 18.8 uses old version of SkiaSharp 1.60.1. SkiaSharp.NativeAssets.Linux package is provided starting from 1.68.0 version. 1.60.1 and 1.68.0 versions of SkiaSharp are incompatible. So I would suggest you to update your version of Aspose.Words at least to 19.2.0 version, which uses SkiaSharp 1.68.0. Or better update to the latest version of Aspose.Words and to SkiaSharp 2.80.3.
Hi Himadri
Please advise
Best regards,
Alok Nidhi Gupta+91 9620666066
@Alok_Nidhi_Gupta Yes, I would advice you to update to the latest version of Aspose.Words and to SkiaSharp 2.80.3.
Unfortunately, I cannot find SkiaSharp native assets for Linux for old version of SkiaSharp.