Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Apr 15, 2025 8:12 am

I have the following code to convert Xls fils to PDF in my .net 8.0 project. My code is as follows;

Code: Select all
private byte[] ConvertWithSpire()
{
    // Original Windows Spire-based implementation
    using (var excelStream = new MemoryStream(_package))
    {
        var workbook = new Workbook();
   
       
        workbook.LoadFromStream(excelStream);

        var sheet = workbook.Worksheets[0];
        sheet.PageSetup.FitToPagesWide = 1;
        sheet.PageSetup.FitToPagesTall = 0;

        using (var pdfStream = new MemoryStream())
        {
            workbook.SaveToStream(pdfStream, FileFormat.PDF);
            return pdfStream.ToArray();
        }
    }
}


This works locally on my Windows dev environment, but when I publish to my `Linux` container in production. Which is running `Debian 12 Bullseye`, I get the following exception;

[08:03:27 ERR] [ExcelService] The type initializer for 'Spire.Xls.Core.Spreadsheet.XlsPageSetupBase' threw an exception.


digging down deeper the inner exception is;

---> System.InvalidOperationException: The version of the native libSkiaSharp library (119.0) is incompatible with this version of SkiaSharp. Supported versions of the native libSkiaSharp library are in the range [88.1, 89.0).


To clarify I have;

1. ensure the msfonts are installed on the docker container.
2. followed the various forum posts I have found to enable this to work on linux.

The following packages are installed to the class library;

Code: Select all
FreeSpire.XLS @ 14.2.0
SkiaSharp @ 2.88.0
SkiaSharp.NativeAssets.Linux.NoDependencies @  3.116.1
Spire.Officefor.NETStandard @ 10.2.0
System.Buffers @ 4.6.1
System.Memory @ 4.6.3
System.Runtime.CompilerServices.Unsafe @ 6.1.2
System.Text.Encoding.CodePages @ 9.0.4


Can anyone direct me how I can fix this issue?

mflynn2025
 
Posts: 2
Joined: Tue Apr 15, 2025 7:22 am

Tue Apr 15, 2025 9:17 am

Hello,

Thanks for your inquiry.
Since our current Spire.Xls depends on SkiaSharp.NativeAssets.Linux.NoDependencies, but does not support version 3.xx yet. Please downgrade this dependency version to 2.88.0 and retest. Looking forward to your test results.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 757
Joined: Mon Dec 27, 2021 2:23 am

Tue Apr 15, 2025 11:01 am

Thank you for your response. I managed to get this working but for now requrie to use only the Freespire.xls until production is full.

I get the error;

[12:00:37 ERR] [ExcelService] Error trying to generate PDF agreement : System.TypeInitializationException: The type initializer for 'Spire.Xls.Core.Spreadsheet.XlsPageSetupBase' threw an exception.
---> System.TypeInitializationException: The type initializer for 'spr?' threw an exception.
---> System.MissingMethodException: Method not found: 'SkiaSharp.SKPathVerb Iterator.Next(SkiaSharp.SKPoint[], Boolean, Boolean)'.
at spr?.?(Boolean A_0, Boolean A_1)
at spr?.?()
at spr?.?(RectangleF A_0)
at spr?..ctor()
at spr?..ctor(spr? A_0)
at spr?.?(spr? A_0)
at spr?..cctor()
--- End of inner exception stack trace ---
at Spire.Xls.Core.Spreadsheet.XlsPageSetupBase.PaperSizeEntry..ctor(Double width, Double height, MeasureUnits units)
at Spire.Xls.Core.Spreadsheet.XlsPageSetupBase..cctor()
--- End of inner exception stack trace ---
at Spire.Xls.Core.Spreadsheet.XlsPageSetupBase..ctor(Object A_0)
at Spire.Xls.Core.Spreadsheet.XlsPageSetup..ctor(Object A_0)
at Spire.Xls.PageSetup..ctor(Object A_0)
at Spire.Xls.Core.Spreadsheet.XlsWorksheet.InitializeCollections()
at Spire.Xls.Core.Spreadsheet.XlsWorksheetBase..ctor(Object A_0)
at Spire.Xls.Core.Spreadsheet.XlsWorksheet..ctor(Object A_0)
at Spire.Xls.Worksheet..ctor(Object A_0)
at Spire.Xls.Core.Spreadsheet.Collections.XlsWorksheetsCollection.Add(String sheetName)
at Spire.Xls.Core.Spreadsheet.XlsWorkbook.?(Int32 A_0)
at Spire.Xls.Core.Spreadsheet.XlsWorkbook..ctor(Object A_0)
at Spire.Xls.Workbook..ctor()


Code: Select all
  <ItemGroup>
    <PackageReference Include="EPPlus" Version="7.2.2" />
    <PackageReference Include="FreeSpire.XLS" Version="14.2.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
    <PackageReference Include="SkiaSharp" Version="3.116.1" />
    <PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.116.1" />
    <PackageReference Include="System.Buffers" Version="4.6.1" />
    <PackageReference Include="System.Linq.Dynamic.Core" Version="1.6.0.2" />
    <PackageReference Include="System.Memory" Version="4.6.3" />
    <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.2" />
    <PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.4" />
    <PackageReference Include="Z.Expressions.Eval" Version="6.2.9" />
  </ItemGroup>

mflynn2025
 
Posts: 2
Joined: Tue Apr 15, 2025 7:22 am

Wed Apr 16, 2025 4:00 am

Hello,

Thanks for your reply.
I noticed that your SkiaSharp and SkiaSharp.NativeAssets.Linux.NoDependencies are still at a higher version. As I said above, we have not yet adapted to version 3.xx. Please downgrade them all to 2.88.0 and retest.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 757
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF

cron