GroupDocsMergerException: Failed to detect file type when using a stream as input

Hi, I’m using GroupDocs.Merger and I’m getting this error:
GroupDocsMergerException: Failed to detect file type.

My C# code looks like this…

var tocStream = new MemoryStream();
// tocStream contains an ASCII encoded byte array of HTML
using (Merger merger = new Merger(tocStream)) // error on this line...
{
merger.Join(filePath)
...add more documents to the Merger object
}

This used to work in an older version of GroupDocs.Merger that I used on .NET5.
I have recently upgraded our codebase to .NET6 and updated our GroupDocs.Merger to Version 22.1 and now we get this error.

Can you give me any advice on what I need to do to make this work properly again?

Thank you.

@alfredbr

We are investigating this issue with ticket ID MERGERNET-1204. You’ll be notified in case of any update.

Hi!

Any update on this? I’ve tried a few approaches but nothing works.

-AlfredBr

@alfredbr

This issue is still under investigation. We’ll inform you in case of any update.

I’m using VS2022 and .NET6.0.3

I’ve done some more experimentation and I now when I call:

merger.Save(filename);

I get this error:

Could not load file or assembly ‘Aspose.PDF, Version=20.6.0.0, Culture=neutral, PublicKeyToken=f0262d67fe233d63’. General Exception (0x80131500)

This is my PackageReference from my .csproj:

<PackageReference Include="GroupDocs.Merger" Version="22.1" />
<PackageReference Include="GroupDocs.Conversion" Version="22.2.0" />

Based on the text of the error:

Could not load file or assembly ‘Aspose.PDF, Version=20.6.0.0, Culture=neutral, PublicKeyToken=f0262d67fe233d63’. General Exception (0x80131500)

I decided to try to download Aspose.PDF from Nuget. Now my code runs without error, but it only renders three pages in the PDF output (when I expected dozens of pages.)

@alfredbr

We are also investigating this issue with ticket ID MERGERNET-1205.

Do you get evaluation watermark in the output document? Did you apply Aspose.PDF license as well?

No, I do not get the evaluation watermark in the output document.

I don’t have a license for Aspose.PDF. I purchased GroupDocs.Merger and it appears to be asking for Aspose.PDF. I only downloaded Aspose.PDF because GroupDocs.Merger seems to be asking about it (and I am desparate to get this working.)

I could not get the Merger() constructor to work with a stream, so I switched to a file.

using (Merger merger = new Merger(filename) {
...merge additional files in a loop...
merger.Save(mergedFileName);
}

But I’ve noticed that the handle to the file that I pass to the constructor is not closed after exiting the using() context. This causes an error the next time I try to merge that file into another PDF.

@alfredbr

This scenario is under investigation.

Could you please share the sample application with the source/problematic file(s)?

I don’t think your library works under .net6.
I’ve reverted back to .net5 and it works as before.

We are investigating the possibility to add .NET 6 support. Your investigation ticket ID is MERGERNET-1207. Meanwhile, you can continue with .NET 5.

Please try to get .net6 support working soon. .net5 support runs out soon (i.e. May 8, 2022)

Yes, we will investigate this scenario. You’ll be notified in case of any update.

A post was split to a new topic: Failed to detect file type when using a stream as input