PageCount using GroupDocs.Conversion

Hello,
we are using Converter.GetDocumentInfo().PagesCount for getting pageCount. we found issues for below scenerios

  • for PasswordProtected and broken it is giving 1 as result instead of exception

  • also,for >= 400mb file size getting OOM(out of memory exceptions) when trying to get pageCount

GroupDocs.Conversion – 23.1.0

@MeghanaVaitla

Could you please share the sample code and the problematic file(s)? We cannot reproduce these issues at our end.

For a password protected Word file, we are getting following exception:

Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'GroupDocs.Conversion.Contracts.PasswordProtectedDocumentInfo'

Code : image.png (8.8 KB)
PasswordprotectedDocument: 3d.pdf (2.3 MB) this is the pdf u can set any password using https://www.adobe.com/acrobat/online/password-protect-pdf.html
Broken Doucment: BROKEN.docx (8.6 KB)

@MeghanaVaitla

We could reproduce this issue using the provided code.
However, please take a look at this Get Document Info documentation article on how to get WordProcessing or PDF documents info (e.g. PagesCount).
If we use following code to get page counts for the password protected Word document, we get following exception:

const string source = "test.docx";
using (Converter converter = new Converter(() => new FileStream(source, FileMode.Open)))
{
     IDocumentInfo info = converter.GetDocumentInfo();
     if (info is PasswordProtectedDocumentInfo)
     {
          throw new Exception("Source document is password protected");
     }
     WordProcessingDocumentInfo docInfo = (WordProcessingDocumentInfo)info;
     Console.WriteLine("Pages count: {0}", docInfo.PagesCount); 
}

Exception:
Unhandled Exception: System.Exception: Source document is password protected

As far as broken document issue is concerned, we are investigating it. Your investigation ticket ID is CONVERSIONNET-6104.

@atir.tahir the code you provided is working for passsword protected but, do we have any similar fix for broken as well? Because, even it got fixed we can’t are unable to use the latest version

@MeghanaVaitla

We have already logged a ticket for this issue (CONVERSIONNET-6104). You’ll be notified in case of any update.

Could you please share subscription expiry date of your license?

The reason I said we are unable to upgrade latest version is due to .Net framework incompatible we are still at 4.6.1 version if we want to use the latest group docs we need to upgrade .NET version and that will take time

2024-01-10 is the expiry of subscription

@MeghanaVaitla

Thank you for your input. We’ll continue our investigation and notify you in case of any update.