System.ArgumentOutOfRangeException when new Aspose.Pdf.Document object

Hi:

In my application, i need to extract the pdf content, but when i new the Aspose.pdf.document object, it throws the System.ArgumentOutOfRangeException, either the contractor with a pdf file path string or the pdf file stream.
My code is as below:

Stream pdf = System.IO.File.OpenRead(fileFullPath);
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(pdf);
Aspose.Pdf.Text.TextAbsorber textAbsorber = new Aspose.Pdf.Text.TextAbsorber();
pdfDoc.Pages.Accept(textAbsorber);
textContent = textAbsorber.Text;

the exception throws when reach the second line of the above code snippet, the stack trace as below:

<pre style=“font-family: Consolas, “Lucida Console”, monospace; font-size: 11pt; margin-top: 0px; margin-bottom: 0px; padding: 0.5em; line-height: 14pt; background-color: rgb(255, 255, 204);”>[ArgumentOutOfRangeException: required an none negative value.
Parameter name: value]
System.IO.UnmanagedMemoryStream.set_Position(Int64 value) +11743765
​ .(Int32 ) +1856
​ .(Int32 ) +91
.() +37
​ …cctor() +29

[TypeInitializationException: “​ ”的类型初始值设定项引发异常。]
.(Stream , Boolean , Boolean ) +66
.(Stream , Boolean ) +29
…ctor(Stream , String , Boolean ) +106
…ctor(Stream ) +29
.(Stream ) +39
…ctor(Stream ) +34
.(Stream ) +39
. (Stream ) +40
…ctor(Stream ) +36
Aspose.Pdf.Document.(Stream , String ) +148
Aspose.Pdf.Document…ctor(Stream input) +106
Web.Controllers.AttachmentController.GenerateHtmlFileOutPutPlainText(String fileName, String fileExt, String fileFullPath, Int32 folderNamePrefix, String folderNameId, String& textContent, String& errorMsg) in E:\project\Corpline (Old)\Trunk\Web\Controllers\AttachmentController.cs:7119
Web.Controllers.AttachmentController.CreateNewAttachmentForWikiArticle(VM_CreateArticleFileAttachment vm) in E:\project\Corpline (Old)\Trunk\Web\Controllers\AttachmentController.cs:1842
lambda_method(Closure , ControllerBase , Object[] ) +103
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +30
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +197 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +46
System.Web.Mvc.Async.ActionInvocation.InvokeSynchronousActionMethod() +37
System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +24
System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +43 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +68
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.AsyncInvocationWithFilters.b__3d() +69
System.Web.Mvc.Async.<>c__DisplayClass46.b__3f() +230
System.Web.Mvc.Async.<>c__DisplayClass33.b__32(IAsyncResult asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +27 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +68
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.b__1c() +42
System.Web.Mvc.Async.<>c__DisplayClass21.b__1e(IAsyncResult asyncResult) +124
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +27 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +27
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +48 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +32
System.Web.Mvc.Controller.b__15(IAsyncResult asyncResult, Controller controller) +26
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +40 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +24
System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +27
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +48 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +29
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +23
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9644037
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Hi Chris,


Thanks for contacting support.

Can you please share the resource file, so that we can test the scenario in our environment. We are sorry for this inconvenience.

Hi there:

Thanks for the reply. it actually happens in any of the pdf files in my pc, but i attached my .cs file and the two of the pdf file anyway.
I don’t know how you can debugging on this issue without my full solution to run. if needed we can arrange a time for your technician to do a remote debugging by using teamview or any other way in your convenient.
p.s. in my AttachmentController.cs file, the exception throws when hit the line 7119

Regards,

Chris Wu

Hi Chris,

Thanks for sharing the resource file.

I have tested the scenario using Aspose.Pdf for .NET 11.7.0 in Visual Studio 2010 project with .NE Framework 4.0 running over Windows 7 (x64) where I have used following simple code to extract contents from vim_user_manual_603.0.pdf file and I am unable to notice any issue. As per my observations, the PDF file contents are properly being extracted. For your reference, I have also attached the output generated over my end.

Furthermore, the 2016 new products.pdf do not contain any text as its comprised of images and graphics objects, so no contents are extracted from this document. Can you please share which version of API you are using and also please share some details regarding your working environment. i.e. Operating System, .NET Framework version etc.

[C#]

Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(@"C:\pdftest\code\code\2016 new products.pdf");

Aspose.Pdf.Text.TextAbsorber textAbsorber = new Aspose.Pdf.Text.TextAbsorber();

pdfDoc.Pages.Accept(textAbsorber);

// create a writer and open the file
TextWriter tw = new StreamWriter(@"C:\pdftest\code\code\2016 new products-extracted-text.txt");

// write a line of text to the file
tw.WriteLine(textAbsorber.Text);

// close the stream
tw.Close();