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

Free Support Forum - aspose.com

Aspose.Words.Document.PageCount throws ArgumentOutOfRangeException

Hi to everybody of the support team,

the attached word document causes problems.

Aspose.Words Version 9.7.0

Example code

private static void Test_SaveAsPng(string strSourceFile)
{
string strDestFile = Path.ChangeExtension(strSourceFile, “png”);

if (File.Exists(strDestFile))
{
File.Delete(strDestFile);
}

// Loading document causes exception …
LoadOptions lOpt = new LoadOptions(LoadFormat.Doc, null, null);
Aspose.Words.Document currDoc = new Aspose.Words.Document(strSourceFile, lOpt);

currDoc.ShadeFormData = false;

ImageSaveOptions imageSaveOpt = (ImageSaveOptions)Aspose.Words.Saving.SaveOptions.CreateSaveOptions(Aspose.Words.SaveFormat.Png);
imageSaveOpt.PageCount = 1;
imageSaveOpt.PageIndex = 0;
imageSaveOpt.Resolution = 100;
imageSaveOpt.SaveFormat = Aspose.Words.SaveFormat.Png;

if (currDoc.PageCount > 0)
{
SaveOutputParameters savedOutput = currDoc.Save(strDestFile, imageSaveOpt);
}
}

internal bugid#4046

Same exception occurs, when document is converted to pdf.

Example code:

private static void Test_SaveAsPdf(string strSourceFile)
{
string strDestFile = Path.ChangeExtension(strSourceFile, “pdf”);

if (File.Exists(strDestFile))
{
File.Delete(strDestFile);
}

// Loading document causes exception …
LoadOptions lOpt = new LoadOptions(LoadFormat.Doc, null, null);
Aspose.Words.Document currDoc = new Aspose.Words.Document(strSourceFile, lOpt);

currDoc.ShadeFormData = false;

PdfSaveOptions pdfSaveOpt = (PdfSaveOptions)Aspose.Words.Saving.SaveOptions.CreateSaveOptions(Aspose.Words.SaveFormat.Pdf);
pdfSaveOpt.Compliance = PdfCompliance.Pdf15;
pdfSaveOpt.BookmarksOutlineLevel = 3;
pdfSaveOpt.HeadingsOutlineLevels = 3;
pdfSaveOpt.SaveFormat = Aspose.Words.SaveFormat.Pdf;

SaveOutputParameters savedOutput = currDoc.Save(strDestFile, pdfSaveOpt);
}

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for reporting this problem to us. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.

It seems the reason of the problem is the following construction inside the footer of the document {IF {PAGE} <> {NUMPAGES} …}. As a workaround, you should change this construction like this {IF {PAGE} <> {NUMPAGES} "..."}

Best regards,

The error still exists with Aspose.Words 9.8.0.0. When the method PageCount is called the following exception is thrown.

- e {“Der Index und die Länge müssen sich auf eine Position in der Zeichenfolge beziehen.\r\nParametername: length”} System.Exception {System.ArgumentOutOfRangeException}
+ [System.ArgumentOutOfRangeException] {“Der Index und die Länge müssen sich auf eine Position in der Zeichenfolge beziehen.\r\nParametername: length”} System.ArgumentOutOfRangeException
+ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
HelpLink null string
+ InnerException null System.Exception
Message “Der Index und die Länge müssen sich auf eine Position in der Zeichenfolge beziehen.\r\nParametername: length” string
Source “mscorlib” string
StackTrace " bei System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)\r\n bei Aspose.Words.Run.x4ede2f7ca43a1460(Int32 xd4f974c06ffa392b, Int32 x961016a387451f05, Boolean x1e2b473fecc8c6b6)\r\n bei x28925c9b27b37a46.xb56968f92e308c8a.x64ae56857b252b27(xe83a6b069ec8efc2 xcbf24c118ac8aa0b, Boolean xdd2a9ff3a1da2f60)\r\n bei x28925c9b27b37a46.x0a28863c804404d7.xb3491b205d3b163a()\r\n bei x28925c9b27b37a46.x0a28863c804404d7.x452863527147987d()\r\n bei x28925c9b27b37a46.x0a28863c804404d7.OnChildNode()\r\n bei x28925c9b27b37a46.xce798d32ec270dda.x267efc5f6ada2866()\r\n bei x28925c9b27b37a46.x0a28863c804404d7.x775521112ede5e6f(x7e263f21a73a027a x5f36ad26e64b91c3, Node x98cacf1c34b53cca, xe83a6b069ec8efc2 xcbf24c118ac8aa0b)\r\n bei xfbd1009a0cbb9842.x54b0ce4be209efe2.ApplyResultCore()\r\n bei xfbd1009a0cbb9842.xf83652aff352c801.x7d44c41f397d72e0()\r\n bei xfbd1009a0cbb9842.xca592a476766b11a.xb333e1e6c01c2be2()\r\n bei Aspose.Words.Fields.Field.x295cb4a1df7a5add(x5e36356bc92c609b x0f7b23d1c393aed9)\r\n bei Aspose.Words.Fields.Field.xda55dc11084967d0(xdac068096ca09318 xb4edacb3d605f604)\r\n bei x4adf554d20d941a6.x5c28fdcd27dee7d9.x295cb4a1df7a5add(Field xe01ae93d9fe5a880)\r\n bei x4adf554d20d941a6.x5c28fdcd27dee7d9.x295cb4a1df7a5add()\r\n bei x59d6a4fc5007b7a4.xcde671c53995c411.x836cc4d43484aecd(xac6c82c74ce247fb x2612f62f94df47de)\r\n bei x59d6a4fc5007b7a4.xcde671c53995c411.x84448f134fcddce5(x398b3bd0acd94b61 xd7e5673853e47af4, Hashtable x9883c720593ff2cd)\r\n bei x59d6a4fc5007b7a4.xcde671c53995c411.x17e48e42e094d16c(xeefdffd909e695da xc3f0a044e1e9f77f)\r\n bei x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98(Document x3664041d21d73fdc, xdeb77ea37ad74c56 xdfde339da46db651)\r\n bei Aspose.Words.Document.UpdatePageLayout()\r\n bei Aspose.Words.Document.x410db0f4a89a6ef1(Boolean x24af0daafcd8fb8c)\r\n bei Aspose.Words.Document.get_xcde671c53995c411()\r\n bei Aspose.Words.Document.get_PageCount()\r\n bei de.egov.AsposeDcs.Wrapper.WordDocumentWrapper.SaveAsGraphic(DocumentWrapper objDestDoc) in C:\CVSHOME\ccDcs2\ccDcsDll\wrapper\WordWrapper.cs:Zeile 254." string
+ TargetSite {System.String InternalSubStringWithChecks(Int32, Int32, Boolean)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
+ Statische Member
+ Nicht öffentliche Member




Hi Martin,

Thanks for your request. Unfortunately, the issue is still unresolved. We will keep you informed regarding status of this issue and let you know once it is resolved.

Best regards,

The issues you have found earlier (filed as 24315) have been fixed in this .NET update and in this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.