Aspose.PDF v20.11 - System.ArgumentException: Destination array was not long enough. Check destIndex and length, and the array's lower bounds

We got the following exception in our production environment, I have so far been unable to re-produce. I believe this issue may have been raised previously on other products, is this a known issue on Aspose.PDF?

System.ArgumentException: Destination array was not long enough. Check destIndex and length, and the array’s lower bounds.
at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
at System.Collections.Generic.Dictionary2.Resize(Int32 newSize, Boolean forceNewHashCodes) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)
at #=zvhGFYF4WvYmsypCRm15eZk7CZ5E_6tI8VH$NUBWVqEc6.#=zUyEVsg0=(String #=zC5_AWEg=, Int32 #=zeRsKxoE=)
at #=zvhGFYF4WvYmsypCRm15eZk7CZ5E_6tI8VH$NUBWVqEc6.#=zBB44TLZkhfZO()
at #=zvhGFYF4WvYmsypCRm15eZk7CZ5E_6tI8VH$NUBWVqEc6.#=zLosKcq_WNF7h(String #=zC5_AWEg=)
at #=z0LKTtCfNFYTWtiha0GmMxln8wBOzDvThgi1w5EbGM57sQomqf1cSdEvJW_rP.#=z8f$k_9b8dd_j()
at #=z0LKTtCfNFYTWtiha0GmMxln8wBOzDvThgi1w5EbGM57sQomqf1cSdEvJW_rP…ctor(#=zy5kkHc1qKVNKS3Of8QOdV_i$diDCTgCUZ3oh51BjeiVe #=zEwdrebQiHh07)
at #=z41PQwlAXVF3C4xYRZatHFahjkV7eYm9jvfhg9ws=.#=zfHGV4$t5x4JC(#=zy5kkHc1qKVNKS3Of8QOdV_i$diDCTgCUZ3oh51BjeiVe #=zehCqd7g=)
at #=zAVT_PM5qsUpKqNbRjkZoSl5BpIEfO7gzAZIrhSYF8Rj0.#=zVZly2ONTnIz1()
at #=zAVT_PM5qsUpKqNbRjkZoSl5BpIEfO7gzAZIrhSYF8Rj0.#=zniFlr7VlOWBf(#=z5PZXDILIiJUwWWTIRkN5Bi1XyPSobTeRkg== #=zrYeM6ZE=, #=zYZrGvjWFX94EKE8bYxXnUavxeas8WFlyOg==& #=zYFHtRiJGFCPq, #=zJ7mqFOeX8tyl7GEYBXHhttjtGa0h8bkY1g4TJ09HKNnI #=zxN23lyg=)
at #=zxCv6S2z7NdWmfwwqWneIpiTFowaZSuGh$mDdJbw=.#=zniFlr7VlOWBf(#=z5PZXDILIiJUwWWTIRkN5Bi1XyPSobTeRkg== #=zrYeM6ZE=, #=zYZrGvjWFX94EKE8bYxXnUavxeas8WFlyOg==& #=zYFHtRiJGFCPq, #=zJ7mqFOeX8tyl7GEYBXHhttjtGa0h8bkY1g4TJ09HKNnI #=zxN23lyg=)
at #=zAVT_PM5qsUpKqNbRjkZoSl5BpIEfO7gzAZIrhSYF8Rj0.#=zniFlr7VlOWBf(String #=zI4cVO$4=, #=zYZrGvjWFX94EKE8bYxXnUavxeas8WFlyOg==& #=zYFHtRiJGFCPq, #=zJ7mqFOeX8tyl7GEYBXHhttjtGa0h8bkY1g4TJ09HKNnI #=zxN23lyg=)
at #=z3ZQvZYuLvdVcKUYIa0iHLOKkPHN1BVnSt1RtDapUV5m9KK2x3dVln5F6h8BMV_V1nYdrXIE=.#=zilmy1EQ=(String #=zks6sutQ=, #=zkCgUhCeYfGyo$1Siop2gPIvDcte6IKOaGOH0pws= #=zHMCWp_8=, #=zBAxJlleIr5pNqZ7Vr4Trojjbrcoj$Mm7jTqG8vxcdxQVmpLsm3efn$4= #=zvs$lj2Sd1ace, Boolean #=zyLUH4T8=, Boolean #=z8vpfRto=, #=zYZrGvjWFX94EKE8bYxXnUavxeas8WFlyOg==& #=zrYeM6ZE=, #=zy5kkHc1qKVNKS3Of8QOdV_i$diDCTgCUZ3oh51BjeiVe& #=z30IwaBzzvKNT, String& #=zzBmo7NvGBi7_)
at #=zjr9I_kCMLB35JyqolpZ05U38q5KDjjkUsoLwrA47o4A82L8Cy3XDpCY=.#=zq$iwurA=(#=zVCpWUBUoqHMQ2zfntTiDaXJSLIQ7PBs4RvIC3LLiX3mLC$Yq92jsmjVKp9Lkaaf1lwWDbLFnwNdd$l2BJg==[] #=zF0U0m6JJxScXmt$kWRhXIPkaA10O, String #=zks6sutQ=, #=zkCgUhCeYfGyo$1Siop2gPIvDcte6IKOaGOH0pws= #=zHMCWp_8=, #=zBAxJlleIr5pNqZ7Vr4Trojjbrcoj$Mm7jTqG8vxcdxQVmpLsm3efn$4= #=zvs$lj2Sd1ace, Boolean #=zyLUH4T8=, Boolean #=z8vpfRto=, #=zYZrGvjWFX94EKE8bYxXnUavxeas8WFlyOg==& #=z3HIv6i0=, #=zy5kkHc1qKVNKS3Of8QOdV_i$diDCTgCUZ3oh51BjeiVe& #=z30IwaBzzvKNT, String& #=zzBmo7NvGBi7_)
at #=zjr9I_kCMLB35JyqolpZ05U38q5KDjjkUsoLwrA47o4A82L8Cy3XDpCY=.#=zJ03RuSo43VYo(#=zkCgUhCeYfGyo$1Siop2gPIvDcte6IKOaGOH0pws= #=zHMCWp_8=, Boolean #=zyLUH4T8=, Boolean #=z8vpfRto=, #=zy5kkHc1qKVNKS3Of8QOdV_i$diDCTgCUZ3oh51BjeiVe #=zd$DXUTN2aSX_, #=zi9kiu_gX4kkAM75xdusAuow= #=zPgphEwT5Q4f4, String #=zgCKF8IM=, #=zBAxJlleIr5pNqZ7Vr4Trojjbrcoj$Mm7jTqG8vxcdxQVmpLsm3efn$4= #=zvs$lj2Sd1ace, #=zYZrGvjWFX94EKE8bYxXnUavxeas8WFlyOg==& #=zrYeM6ZE=, String& #=zYDwsmX9GhZdl)
at #=z4Kb5d_Z3n4NtphJ1InWLNkr2PEzZ9Q1DjQWly6NtF4Vm3wxjklynFis=.#=zGLshXSO8lUiz(#=zi9kiu_gX4kkAM75xdusAuow= #=zpmYQp9Q=, Boolean #=zyLUH4T8=, Boolean #=z8vpfRto=, String #=zgCKF8IM=, #=zBAxJlleIr5pNqZ7Vr4Trojjbrcoj$Mm7jTqG8vxcdxQVmpLsm3efn$4= #=zvs$lj2Sd1ace, #=zy5kkHc1qKVNKS3Of8QOdV_i$diDCTgCUZ3oh51BjeiVe #=zwV5s08Xivk2I, Font #=zTP$5vRpoa26E, #=zy5kkHc1qKVNKS3Of8QOdV_i$diDCTgCUZ3oh51BjeiVe& #=zghxqlts=, String& #=zazdcWQ58FnJf, #=zYZrGvjWFX94EKE8bYxXnUavxeas8WFlyOg==& #=zSaa65u8=)
at #=z4Kb5d_Z3n4NtphJ1InWLNkr2PEzZ9Q1DjQWly6NtF4Vm3wxjklynFis=.#=zk4GynGonKycL(#=zi9kiu_gX4kkAM75xdusAuow= #=zpmYQp9Q=, Boolean #=zyLUH4T8=, Boolean #=z8vpfRto=, String #=zgCKF8IM=, #=zBAxJlleIr5pNqZ7Vr4Trojjbrcoj$Mm7jTqG8vxcdxQVmpLsm3efn$4= #=zvs$lj2Sd1ace, #=zy5kkHc1qKVNKS3Of8QOdV_i$diDCTgCUZ3oh51BjeiVe #=zwV5s08Xivk2I, Font #=zTP$5vRpoa26E, #=zYZrGvjWFX94EKE8bYxXnUavxeas8WFlyOg==& #=zrYeM6ZE=)
at #=z4Kb5d_Z3n4NtphJ1InWLNkr2PEzZ9Q1DjQWly6NtF4Vm3wxjklynFis=.#=zk4GynGonKycL(#=zi9kiu_gX4kkAM75xdusAuow= #=zpmYQp9Q=, Boolean #=zyLUH4T8=, Boolean #=z8vpfRto=, String #=zgCKF8IM=, #=zBAxJlleIr5pNqZ7Vr4Trojjbrcoj$Mm7jTqG8vxcdxQVmpLsm3efn$4= #=zvs$lj2Sd1ace, #=zy5kkHc1qKVNKS3Of8QOdV_i$diDCTgCUZ3oh51BjeiVe #=zwV5s08Xivk2I, Font #=zTP$5vRpoa26E)
at Aspose.Pdf.Text.TextState.set_Font(Font value)
at Aspose.Pdf.Text.TextState.#=zlEjLb72WCuFX(TextState #=ztiwfUso=, #=zwDke0qLP6_TZqOtxwhERJQiG0xtZz7Lhamc_Fo_rnXNP7XpFjA== #=zAjJzcTg=)
at Aspose.Pdf.Text.TextState.#=zeq_i79o=(#=z4Kb5d_Z3n4NtphJ1InWLNkr2PEzZ9Q1DjQWly6NtF4Vm3wxjklynFis= #=zdAwrF6FKP7uM)
at Aspose.Pdf.Text.TextSegment.#=zeq_i79o=(#=z4Kb5d_Z3n4NtphJ1InWLNkr2PEzZ9Q1DjQWly6NtF4Vm3wxjklynFis= #=zdAwrF6FKP7uM)
at Aspose.Pdf.Text.TextBuilder.#=ze4Emfq0=(TextFragment #=zNsOz3k8rnBDP, Int32 #=zBL3QmMI=, Boolean #=zEYxrwMupgSRe)
at Aspose.Pdf.Text.TextBuilder.#=z26oAqVC3Q_dO(TextParagraph #=z4DTUZAypDCHR, Int32 #=zBL3QmMI=)
at Aspose.Pdf.Text.TextBuilder.AppendParagraph(TextParagraph textParagraph)
at #=zvFiHOsTf_lfyT1zLUsQ93HY=.#=zfxuzJsESKqX4(BaseParagraph #=zRy4K60rP55eMjtMAeg==)
at #=zvFiHOsTf_lfyT1zLUsQ93HY=.#=zntu3$XA=()
at Aspose.Pdf.Cell.#=zfFA2IMY=(Table #=zEV9jSAs=, Page #=zWqCr9EQ=, Double #=z0Hra9_lLz8$i, Boolean #=zqfBQekDdyZNK)
at Aspose.Pdf.Row.#=zntu3$XA=(Table #=zEV9jSAs=, Double& #=zuivCJn4=, Double& #=zfGse8_E=, Boolean #=z9woOq53AB7dA, Double #=zvekwU5xjoo9S, Double #=ze7$uC4g=, Page #=zWqCr9EQ=, Int32& #=zPrFyRVZ6IEnq)
at Aspose.Pdf.Table.#=zntu3$XA=(Double& #=zfGse8_E=, Double& #=zuivCJn4=, Boolean #=z9woOq53AB7dA, Double #=zQqmfBaBlui68, Double #=ze7$uC4g=, Page #=zWqCr9EQ=, Boolean #=zggzW$NkjsQKT, List1 #=z$S44JmI=) at #=zvFiHOsTf_lfyT1zLUsQ93HY=.#=zntu3$XA=() at Aspose.Pdf.Page.#=zZIM2h$4=(Page #=zWqCr9EQ=) at Aspose.Pdf.Page.#=zXya8hQWO$pG_ZAAkxw==() at Aspose.Pdf.Document.ProcessParagraphs() at Aspose.Pdf.Document.#=zKw9RmlsEtPsj(Stream #=zeAiaYbI=, SaveOptions #=z2Tk5FOg$aPIm) at Aspose.Pdf.Document.Save(Stream output) at BerthR.DocumentManagement.Pdf.Aspose.AsposeExtensions.ToMemoryStream(Document document) in C:\agent\_work\4\s\BerthR\Main\Applications\ThirdParties\DocumentManagement\BerthR.DocumentManagement.Pdf.Aspose\AsposeExtensions.cs:line 306 at BerthR.Web.Services.TemplateBuilders.ContentBuilder.BuildStatementPdf(DateTime statementDate, List1 statementTransactions, Site site, Boolean includeAccountDetails, Customer customer, Nullable1 currency) in C:\agent\_work\4\s\BerthR\Main\Applications\BerthR.Web.Services\TemplateBuilders\ContentBuilder.cs:line 1758 at BerthR.Web.Services.TransactionService.BuildStatementPdf(Boolean showOutstandingOnly, Boolean includeHiddenDebt, Boolean includeFutureTransactions, DateTime statementDate, Customer customer, Nullable1 currency, Site site, Boolean includeAccountDetails) in C:\agent_work\4\s\BerthR\Main\Applications\BerthR.Web.Services\Services\TransactionService.cs:line 1259
at BerthR.Web.Api.Controllers.TransactionPdfController.GetCustomerStatementPdfStream(Int32 siteId, Int32 customerId, Boolean showOutstandingOnly, Boolean includeFutureTransactions, Boolean includeHiddenDebt, String timestamp, Nullable1 currency) in C:\agent\_work\4\s\BerthR\Main\Applications\BerthR.Web.Api\Controllers\TransactionsPdfsController.cs:line 601 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary2 arguments, CancellationToken cancellationToken)
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.d__1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.d__6.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Web.Http.Filters.ActionFilterAttribute.d__6.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.d__6.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Web.Http.Filters.ActionFilterAttribute.d__6.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.d__6.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Web.Http.Filters.ActionFilterAttribute.d__6.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.d__6.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Web.Http.Filters.ActionFilterAttribute.d__6.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.d__5.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.AuthorizationFilterAttribute.d__3.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.AuthorizationFilterAttribute.d__3.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.AuthenticationFilterResult.d__5.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ExceptionFilterResult.d__6.MoveNext()

@matthew.house

There is no such known issue in Aspose.PDF for .NET. Please note that the API is multi-threaded safe as long as one thread is accessing one PDF at one time. In other words, one PDF document should only be accessed by one thread. Furthermore, it is really hard to determine the actual cause of the error without replicating it at our side. Could you please share some sample code snippet along with sample files with which we can try to replicate it at our end and address it accordingly?

PS: Please try using 21.7 version of the API as well before sharing the requested information.

@asad.ali I am also facing a similar issue.
Please refer my logs and code below.

Code:

    private static void TextReplacement( string searchText, object placeholderValue, string path)
    {
        using (var pdfDocument = new AsposePdf.Document(path))
        {
            string replacedText = string.Empty;
            int totalPages = pdfDocument.Pages.Count;
            
            foreach (var Page in pdfDocument.Pages)
            {
                AsposePdfText.TextFragmentAbsorber textFragmentAbsorber = new AsposePdfText.TextFragmentAbsorber(searchText);
                replacedText = getReplacementString(placeholderValue, Page.Number, searchText, totalPages);

                Page.Accept(textFragmentAbsorber);

                textFragmentAbsorber.TextSearchOptions.LimitToPageBounds = true;

                AsposePdfText.TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
                foreach (AsposePdfText.TextFragment textFragment in textFragmentCollection)
                {
                    // Update text only for current page, else will update all the consecutive pages
                    if (Page == textFragment.Page)
                    {
                        var rectangle = textFragment.Rectangle;
                        textFragment.Text = replacedText;

                        if (searchText == Placeholders.HPageLabelWithNumber || searchText == Placeholders.FPageLabelWithNumber)
                        {
                            textFragment.TextState.Font = AsposePdfText.FontRepository.FindFont("Arial");
                            textFragment.TextState.FontSize = searchText == Placeholders.FPageLabelWithNumber ? 6 : 10;
                            textFragment.TextState.FontStyle = AsposePdfText.FontStyles.Regular;
                            textFragment.TextState.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;

                            // to enable right alignment
                            double wordlength = textFragment.TextState.Font.MeasureString(textFragment.Text, textFragment.TextState.FontSize);

                            double textX = rectangle.URX - wordlength;
                            double textY = textFragment.Position.YIndent;
                            textFragment.Position = new Position(textX, textY);
                        }
                    }
                }
            }
            pdfDocument.Save(path);
        }
    }

Logs :
ERROR Destination array was not long enough. Check destIndex and length, and the array’s lower bounds. System.ArgumentException: Destination array was not long enough. Check destIndex and length, and the array’s lower bounds.

at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)


at #=zN0rxLZ0nC$n7nts4RfcoB3EEHIMDWP5WESEp169l4igdv3afSWTwGzHeZrWD…ctor(Page #=zuJ_P5xg=, TextSearchOptions #=zhKGdn8O8FUG5)

at Aspose.Pdf.Text.TextFragmentAbsorber.Visit(Page page)

at Aspose.Pdf.Page.Accept(TextFragmentAbsorber visitor)


We are using Aspose v21.1 ; and this issue occurs intermittently.

Q1) Does this aspose library create multiple temp files ?
Q2) Can you assure that the issue would get resolved in v21.7 or latest as we would need to purchase licence for this ?
Q3) Issue could not be replicated in local environments and we dont know the cause of issue in production. So do you have any workaround fix for the same ?

@AshishSah

No, Aspose.PDF does not create multiple temp files.

You can please evaluate the latest version yourself in order to check if the issue is occurring with it or not. You can please use a 30-days temporary license to evaluate the 21.8 version of the API which is latest one for now.

It is quite hard to comment on the situation and determine the cause of the error without noticing and replicating it on our end. Can you please share a sample application along with the steps to reproduce the issue in our environment if it still occurs with latest version on your side? We will test the case and address it accordingly.

@asad.ali Thank you for your information.

I have already shared the exact code which we are using in scenario when the issue occurs (along with the logs). Business wont allow me to share more data.

However, I can give you an idea on what we doing here.
The issue occurs when we try to generate a pdf report. This particular function is responsible for replacing values(here page numbers) in placeholder per page.

As pointed out earlier too, that though the issue is intermittent, it happens every once in a while.
We also observed that cleaning temp files, reduced the occurrence of this issue.
Though we are not sure if this is the root cause, since we have observed this problem across different servers.
Further we have also tried to downgrade the API to v19.11 in few servers and issue has reduced there too.

We will check with v21.8, with temporary license; but from business point we need confirmation if the issue is resolved in latest versions.

If neither of these things work out, I am afraid they will cancel the existing Aspose license, since reports are the core of our application.

@AshishSah

Thanks for further elaborations.

The issue you are mentioning is not known issue in the API and we are not certain about the root cause of the issue since we did not reproduce it in our environment. Furthermore, we cannot make a statement about issue with the latest version of the API due to same reasons. We really hope that you would understand it.

However, we do and keep improving the API in every release which is why we recommend using the latest version every time as it contains more enhancements and improvements. Please feel free to evaluate the latest version and if issue still persists, we will try to perform some more investigation against it and share our feedback with you.

Hi @asad.ali, we have downgraded the aspose to v19.11, and the issue mentioned earlier seems to have reduced.

However we are seeing a different issue, leading to very high CPU usage (>90%) during the replace function in the above code segment.
We have a report of over 500 pages and we are trying to replace 4-5 fragments in them. This is causing a huge surge in CPU usage.
Could you please clarify what exactly is being done in the replacement function ? Or like how are you replacing values in each page?

@AshishSah

Please note that it is never recommended to downgrade the API version. We always recommend you use the latest available version of the API as it contains maximum fixes and improvements.

Regarding text searching and replacement functionality, we improve text handling engine/component of the API in every release in order to make if more efficient in terms of memory consumption. We cannot really explain or share how it is replacing the text internally in the API. However, as we requested you earlier, please try to use the latest available version of the API and share some sample files with us in case you are noticing any issues.

Downgrade of API is temporary.

Regarding the replacement function, could you please provide any technical details as to how its been handled internally. As we could see huge surge in CPU usage every time the function call is made.
The sample code provided earlier is what is being used by us, so you may refer to that.
Somewhere when we are trying to use textfragment or absorber, it causes huge memory consumption. So any insight on how its handled in Aspose would be helpful to modify our code.

@AshishSah

We have logged an investigation ticket as PDFNET-50515 in our issue tracking system in order to analyze this whole scenario. We will gather related details after investigating it and share our feedback with you as soon as the ticket is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

@asad.ali
Thank you creating ticket.

While checking performance issues, we also observed that while setting the properties of Aspose like fontSize, Alignment, FontFamily, Position etc., it takes lot of time. This adds up for each placeholder within one page.
Setting of each property takes ~ 0.8s to 1.5s, during the peak usage.

It also looks like the Generic Dictionary used within Aspose takes lot of memory.
This we observed even with a report of 8 pages( a pdf file of ~1MB).

Q: Is there any way Aspose can handle the position of texts directly? In our current sample code we have to consider length of texts while placing it in our rdl.

@AshishSah

Have you made these observations using Aspose.PDF for .NET 21.1? However, we have recorded these concerns along with the ticket as well and we will keep them in view while investigating the ticket. We will let you know as soon as the ticket is resolved. Please give us some time.