facebooktwittermenuarrow-up

GemBox Support Forum

Print PDF on Worker Services

I’m trying to print in a .NET Core 3.1 Worker Service application, but I get an exception that the ReachFramework assembly could not be loaded.

Is it possible to print in a .NET Core 3.1 application or do I need to target a .NET Framework?

Hi Jochen,

GemBox.Pdf uses WPF (more specifically the System.Printing namespace) for printing PDF files, see this related .NET Core section.

So, in order to print on .NET Core 3.1, you’ll need to enable WPF.
For example, something like this:

<Project Sdk="Microsoft.NET.Sdk.Worker">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UserSecretsId>dotnet-WorkerService1-ABCD-1234-EFGH-5678</UserSecretsId>
  </PropertyGroup>
  
  <ItemGroup>
    <FrameworkReference Include="Microsoft.WindowsDesktop.App" />
  </ItemGroup>
  
  <ItemGroup>
    <PackageReference Include="GemBox.Pdf" Version="*" />
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.4" />
  </ItemGroup>
  
</Project>

I hope this helps.

Regards,
Mario

Hi Mario,

In the documentation, I was looking at Print PDF files, because I did not need the creation.

With your sample, I was able to get it working, but I also had to add the following:

<ItemGroup>
    <UseWPF>true</UseWPF>
</ItemGroup>

Thx,
Regards,

Jochen