Aspose.Pdf TextFragment Issues

When will Parallel.ForEach be supported? Using foreach is too slow when there are many elements in a PDF document. I would like to fill the text of TextFragments in the following way, but it throws an exception. Are there any other ways to speed up the processing?

private void Test01(List TextFragments, string text)
{
Parallel.ForEach(TextFragments, item =>
{
item.Text = text;
});
}

throws an exception
System.ArgumentOutOfRangeException:“Index was out of range. Must be non-negative and less than the size of the collection. Arg_ParamName_Name”
System.ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessException()
System.Collections.Generic.List`1.set_Item(Int32 index, T value)
#=zoZbZ78XusXM_nzRHEWgXZatF0xtlVTkWxg==.Add(#=zeIjt0LvMFrfNhR6gYJ9DRKbUYl53uWYgCw== #=zTIHcZV4=)
#=zz1_AR3XyRdQea33qYDW$CR3YMsiM.#=zTxrKbLk=(#=zxjoLlYWrye9pLs2KKWuwWEOjUQ0h21aVUg== #=zDDY0LrZ2KJpe)
#=z8Zx2Kam9l1Eg7OVBOp3KCLiITj_ZStBlsw==…ctor(#=z_H43cpRw2aRq4Ue$BEHRgP7EjQ7c4bv7ZOLxT40NDM2a #=zBOD6M2RWYwzN, Int32 #=zcIxR$Kg=, Int32 #=zC8PeMC0=, #=zpq6IshAFdAEoO4cXrGUc3Z_$oj3hOaNF4Q== #=zTIHcZV4=)
#=zjCY$mxk5M2MsTqpLq9nU83WG_oI8znGxmSH6KtA=.#=ziPfNCQtX5$Kw(#=z_H43cpRw2aRq4Ue$BEHRgP7EjQ7c4bv7ZOLxT40NDM2a #=zKpO3dOn81IZ6CkvvLw==, Int32 #=zzzMthmo=, Int32 #=zC8PeMC0=, #=zpq6IshAFdAEoO4cXrGUc3Z_$oj3hOaNF4Q== #=zTIHcZV4=)
#=z8YwyAFpXu4Vn5VQFGpzWPlAas5iBxd$A2OEfNfX3nY$7XLZDhQ==.#=zbjwPSy0=(Byte[] #=zAUwlRBo=)
#=z8YwyAFpXu4Vn5VQFGpzWPlAas5iBxd$A2OEfNfX3nY$7XLZDhQ==.#=zmhPoIAol$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1$eXz8=(String #=zUAt1SKM=, #=zQCcci$P9KO6aruY_AVdW2rYfKwBqWPKUuzIrjG8= #=zpA$fkFY=, #=zDfrLeQu7MCbAmnqNqqTFh4dHwD8Bnb_oiK1p89G7d3Gy2nxYe1EtKHk= #=z9vEC8sFMa$Wx, Boolean #=zM8Z9sBE=, Boolean #=zAopRzi8=, #=z9NdmLyH8aQe_9no61g$aGjSqMCBFrzhx4A==& #=zV$vOXXU=, #=ztYWYwnALNhuNwST_2qf1gVsyoxW9eiXHbU__MyPU2vN1& #=zCduLOskwTWke, String& #=zPPm$XBk42nQ7)
#=z3NJn0rgKZdfKwcCHUdmeHHRQ8$eVipejZ9FEpyF4rqRrpnUVUwQt7Ms=.#=zFF702i0=(#=zG8Zz8FMbPtEJPeK3qqFEujZ9ag0YfjT90tvYvRDYiVOnQtixnmhkaYYqAXDSPuYorF4cSpUhf5auPdsHdQ==[] #=zkd2QKsHZsj$WZmtbJPaL8CJdzr4A, String #=zUAt1SKM=, #=zQCcci$P9KO6aruY_AVdW2rYfKwBqWPKUuzIrjG8= #=zpA$fkFY=, #=zDfrLeQu7MCbAmnqNqqTFh4dHwD8Bnb_oiK1p89G7d3Gy2nxYe1EtKHk= #=z9vEC8sFMa$Wx, Boolean #=zM8Z9sBE=, Boolean #=zAopRzi8=, #=z9NdmLyH8aQe_9no61g$aGjSqMCBFrzhx4A==& #=zlwBrQwg=, #=ztYWYwnALNhuNwST_2qf1gVsyoxW9eiXHbU__MyPU2vN1& #=zCduLOskwTWke, String& #=zPPm$XBk42nQ7)
#=z3NJn0rgKZdfKwcCHUdmeHHRQ8$eVipejZ9FEpyF4rqRrpnUVUwQt7Ms=.#=zPe442wgIr8xo(#=zQCcci$P9KO6aruY_AVdW2rYfKwBqWPKUuzIrjG8= #=zpA$fkFY=, Boolean #=zM8Z9sBE=, Boolean #=zAopRzi8=, #=ztYWYwnALNhuNwST_2qf1gVsyoxW9eiXHbU__MyPU2vN1 #=zepepLXmWHmJO, #=zqGYn$DYhKsOgb2VkctEgHN8= #=zGsiXU4UfaKE6, String #=zAUQTw4U=, #=zDfrLeQu7MCbAmnqNqqTFh4dHwD8Bnb_oiK1p89G7d3Gy2nxYe1EtKHk= #=z9vEC8sFMa$Wx, #=z9NdmLyH8aQe_9no61g$aGjSqMCBFrzhx4A==& #=zV$vOXXU=, String& #=znEsRDHi07KgN)
#=zDgETdhojm66Tp3V5SzwzmPbf9Jf$Tl3G2T95shqVVLjUZWuNx1qkce8=.#=z5O6v8e_V0xwt(#=zqGYn$DYhKsOgb2VkctEgHN8= #=z9HSz1QY=, Boolean #=zM8Z9sBE=, Boolean #=zAopRzi8=, String #=zAUQTw4U=, #=zDfrLeQu7MCbAmnqNqqTFh4dHwD8Bnb_oiK1p89G7d3Gy2nxYe1EtKHk= #=z9vEC8sFMa$Wx, #=ztYWYwnALNhuNwST_2qf1gVsyoxW9eiXHbU__MyPU2vN1 #=zCgfezn3XNf4o, Font #=z7xab0SVxWTcq, #=ztYWYwnALNhuNwST_2qf1gVsyoxW9eiXHbU__MyPU2vN1& #=zdSh_YEE=, String& #=z9ld$1tbp4Yex, #=z9NdmLyH8aQe_9no61g$aGjSqMCBFrzhx4A==& #=z$fRqFAI=)
#=zDgETdhojm66Tp3V5SzwzmPbf9Jf$Tl3G2T95shqVVLjUZWuNx1qkce8=.#=zWjcUDKU7cy9b(#=zqGYn$DYhKsOgb2VkctEgHN8= #=z9HSz1QY=, Boolean #=zM8Z9sBE=, Boolean #=zAopRzi8=, String #=zAUQTw4U=, #=zDfrLeQu7MCbAmnqNqqTFh4dHwD8Bnb_oiK1p89G7d3Gy2nxYe1EtKHk= #=z9vEC8sFMa$Wx, #=ztYWYwnALNhuNwST_2qf1gVsyoxW9eiXHbU__MyPU2vN1 #=zCgfezn3XNf4o, Font #=z7xab0SVxWTcq, #=z9NdmLyH8aQe_9no61g$aGjSqMCBFrzhx4A==& #=zV$vOXXU=)
#=zDgETdhojm66Tp3V5SzwzmPbf9Jf$Tl3G2T95shqVVLjUZWuNx1qkce8=.#=zWjcUDKU7cy9b(#=zqGYn$DYhKsOgb2VkctEgHN8= #=z9HSz1QY=, Boolean #=zM8Z9sBE=, Boolean #=zAopRzi8=, String #=zAUQTw4U=, #=zDfrLeQu7MCbAmnqNqqTFh4dHwD8Bnb_oiK1p89G7d3Gy2nxYe1EtKHk= #=z9vEC8sFMa$Wx, #=ztYWYwnALNhuNwST_2qf1gVsyoxW9eiXHbU__MyPU2vN1 #=zCgfezn3XNf4o, Font #=z7xab0SVxWTcq)
Aspose.Pdf.Text.TextState.set_Font(Font value)
Aspose.Pdf.Text.TextFragmentState.set_Font(Font value)

@christy8074
At the moment, the library has a limitation that parallelism is not possible when working with one document.
The development team has the task of adding the ability to work in parallel with one document.
But it is impossible to say when this will be implemented.
Regarding this particular fragment, you can use for instead of foreach - but this is unlikely to significantly change performance.
Moreover, the main time expenditure must be spent on working out the Visit method, and going through already found fragments should not take much time.
I will create a task for the development team to add the ability to parallel search for text fragments in a document.

@christy8074
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-56443

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.