Hello team.
we are using Spire.Officefor.NETStandard 8.4.1 instead Spire.Office because our code run behind NET 7 on linux system.
We tried to use Spire.Office with a bad result (Check log below)
---> System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
---> System.PlatformNotSupportedException:
System.Drawing.Common is not supported on non-Windows platforms. See aka.ms/systemdrawingnonwindows for more information.
at System.Drawing.LibraryResolver.EnsureRegistered()
at System.Drawing.SafeNativeMethods.Gdip.PlatformInitialize()
at System.Drawing.SafeNativeMethods.Gdip..cctor()
--- End of inner exception stack trace ---
at System.Drawing.SafeNativeMethods.Gdip.GdipLoadImageFromDelegate_linux(StreamGetHeaderDelegate getHeader, StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, IntPtr& image)
at System.Drawing.Image.InitializeFromStream(Stream stream)
at System.Drawing.Image.LoadFromStream(Stream stream, Boolean keepAlive)
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at sprꡫ.귟(Byte[] A_0)
at sprꡫ..ctor(PointF A_0, SizeF A_1, Byte[] A_2, spr䁁 A_3)
at spr爊.권(sprꓱ A_0, sprꦷ A_1)
at spr爊.㚔(spr煤 A_0)
at spr猃.권(spr湹 A_0, SizeF A_1, RectangleF A_2, spr걏 A_3)
at spr猃.귟(XmlDocument A_0, SizeF A_1, RectangleF A_2, spr걏 A_3)
this is our code that we are using to convert word to pdf.
- Code: Select all
byte[] content = <miss code >
using MemoryStream readMs = new(content);
using MemoryStream writeMs = new();
Document document = new();
document.LoadFromStream(readMs, FileFormat.Auto);
if (document.IsContainMacro)
{
document.ClearMacros();
}
ToPdfParameterList pdfParameterList = new()
{
IsEmbeddedAllFonts = true,
DisableLink = true
};
document.SaveToStream(writeMs, pdfParameterList);
return writeMs.ToArray();