cognidox / OfficeToPDF

A command line tool to convert Microsoft Office documents to PDFs
https://www.cognidox.com/
Other
609 stars 137 forks source link

Run on .NET Core #71

Closed iamkeyur closed 3 years ago

iamkeyur commented 3 years ago

Thank you for the work. @vittala Would it be possible to port this to .Net Core? If yes, what would be main hurdles? I can work on this port.

vittala commented 3 years ago

Hi @iamkeyur

No, it wouldn't be possible to port to .Net core because it relies on the Office interops. The main body of the code will port to .Net core, but it'll never be cross platform because of the requirement for the interops. See https://github.com/dotnet/core/issues/402

The only way around this would be to stop using the interops and use a commercial .net package for the document handling (e.g. Aspose https://products.aspose.com/total). The downside is you'd need a commercial license for this and rendering of documents probably wouldn't be as accurate as it is using the native Office code.

iamkeyur commented 3 years ago

Thanks. I know that it won't be cross-platform. I just wanted it to port to .NET Core to make it more modern.

DaveMcD56 commented 2 years ago

It is possible to use COM interop using .NET Core, .NET 5, or .NET 6. Just set the target framework correctly to include -windows. Example:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net5.0-windows</TargetFramework>