We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Strict validation closes stream

Hi
I can use the same stream for both Document and PdfFileInfo, but not if I set UseStrictValidation=true, then the stream seems to be closed which was not expected.
By design or a bug? If by design I have to have two copies of the PDF in memory.

Thanks,
Jacob

@bleze

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input PDF.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Hi
I believe any PDF will cause crash, so not attaching any here.

The following code can be used to replicate the crash

            String filepath = "<path to some pdf>";
            using (MemoryStream stream = new MemoryStream(File.ReadAllBytes(filepath)))
            {
                    using (Document pdfDocument = new Document(stream))
                    {
                        using (var info = new Aspose.Pdf.Facades.PdfFileInfo(stream))
                        {
                            info.UseStrictValidation = true;
                            var v2 = info.IsPdfFile;            // causes the crash later on, but only when UseStrictValidation is true
                        }

                        for (int i = 1; i <= pdfDocument.Pages.Count; i++)
                        {
                            Page page = pdfDocument.Pages[i]; // Crash! System.ObjectDisposedException: 'Cannot access a closed Stream.'
                        }
                    }
                }
            }

@bleze

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFNET-51874. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.