Hello,
we use Aspose.Words.Shaping.HarfBuzz.dll and we have the problem that the required harfbuzz.dll is found in most cases, but not on some clients and environments. How can we ensure that this DLL is always available? Is there a NuGet?
There are also differences between 32-bit and 64-bit programs that include Aspose.Words.Shaping.HarfBuzz.dll.
Kind Regards,
Andy
@AStelzner Could you please provide more information about the environments where Aspose.Words.Shaping.HarfBuzz is missing. Usually we determine which lib we need to use x86 or x64. Currently, the HarfBuzz plugin is not compatible with macOS on ARM processors. Here’s Nuget - NuGet Gallery | Aspose.Words.Shaping.HarfBuzz 25.6.0.
Not Aspose.Words.Shaping.HarfBuzz.dll is missing but the native harfbuzz.dll, referenced by Aspose.Words.Shaping.HarfBuzz.dll. See
We have an isolated portable version of our application, and this is where the problems occur. You can unpack and start this at any location.
@AStelzner Unfortunatly, it’s hart to tell what the problem is it. Nuget package contains two native harfbuzz.dll
compiled for x86 and x64 platforms and special MSBuild
script.
Depending on project’s target platform, the MSBuild
script chooses necessary native harfbuzz.dll
(x86 or x64) and copies them to TargetDir
of the project. This MSBuild
script detects project’s target platform using {PlatformTarget}
and {Prefer32Bit}
parameters of the project.
Also, some times harfbuzz.dll stays blocked until the process which utilized the shaping feature will be stopped. You can try to use Aspose.Words.Shaping.HarfBuzz.HarfBuzzTextShaperFactory.UnloadNativeLibrary()
to unload this library.
Aspose.Words.Shaping.Harfbuzz uses P/Invoke technology for invoking unmanaged functions from HarfBuzz.
For Windows platforms no additional efforts are required for installing HarfBuzz because Aspose.Words.Shaping.Harfbuzz already includes compiled HarfBuzz library.
For other systems, Aspose.Words.Shaping.Harfbuzz relies on already installed HarfBuzz library. For instance, many Linux-based systems have HarfBuzz installed system-wide by default. If not, there is usually a package available for installing via package manager.
You may need to install harfbuzz.dll if this is Linux: RUN apt-get update && apt-get install -y libharfbuzz-dev
.
Or you can try using this approach to solve your problems UpdatePageLayout/UpdateFields not working correctly - #13
Thanks.
I will check it and report back if necessary. Unfortunately, the link doesn’t work 
@AStelzner Okay, this is a private topic. It may not apply to your case, but I copied the answer here:
Could you please try loading harfbuzz.dll
manually in the code for testing.
NOTE: change the paths in the code according to your project files structure.
// I put the Aspose.Words.Shaping.HarfBuzz package into /files folder
HarfBuzzHelper.LoadNativeLibrary(Server.MapPath("/Files"));
doc.LayoutOptions.TextShaperFactory = Aspose.Words.Shaping.HarfBuzz.HarfBuzzTextShaperFactory.Instance;
public static class HarfBuzzHelper
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr LoadLibrary(string libname);
public static void LoadNativeLibrary(string root)
{
var harfBuzzPath = Path.Combine(root, "Aspose.Words.Shaping.HarfBuzz.22.5.0\\runtimes",
(IntPtr.Size == 4 ? "win-x86" : "win-x64"), "native\\harfbuzz.dll");
// for .net core
// var lib = System.Runtime.InteropServices.NativeLibrary.Load(harfBuzzPath);
// for .net framework
var lib = LoadLibrary(harfBuzzPath);
}
}
This works fine for me, thanks 
1 Like
we have a similar problem, our solution is deployed in a linux container and the organization has restricted installing any packages, hence we are not able to install libharfbuzz-dev, is there a way to handle this?
@PramodMn You can manually copy harfbuzz.dll
into a container and use it in your application.
In bin , runtimes folder , i found libHarfBuzzSharp.so under linux-x65 native and harfbuzz.dll under win-x64 native folder. modified the above code to load the package,
public static void LoadNativeLibrary(string root)
{
string libPath;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
libPath = Path.Combine(root, "runtimes", "linux-x64", "native", "libHarfBuzzSharp.so");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
libPath = Path.Combine(root, "runtimes", "win-x64", "native", "harfbuzz.dll");
}
else
{
throw new PlatformNotSupportedException("Unsupported OS");
}
// Load the native library
IntPtr handle = NativeLibrary.Load(libPath);
if (handle == IntPtr.Zero)
throw new Exception("Failed to load native HarfBuzz library.");
}
Unfortunately, that didn’t make any impact
@PramodMn Could you please rename libHarfBuzzSharp.so
to libharfbuzz.so
and try it again.
Aspose.Words.Shaping.HarfBuzz.HarfBuzzTextShaperFactory.UnloadNativeLibrary()
I don’t see this method??? I installed the latest via nuget and it’s not available. Please advise. We’re having file lock issues as well.
@AStelzner The method is not implemented yet.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-27598
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.