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

Free Support Forum - aspose.com

Texts disappear after overwriting TextSegment.Text before doc.Save();

Aspose.Pdf 19.6 .netcore 2.1

textNull.zip (2.7 MB)

I’d like to know the reason why the out.pdf lacks some texts(digits), which are supposed to be incrementaly replaced from the original text in in.pdf.
For example, “2014/11/19” on the top left corner in in.pdf should be “1234567891” in out.pdf, but there’s no “6”.
We can observe the object using debugger on Visual Studio to be null (\0)
As we read log.txt they are correctly replaced to the numbers right after the overwriting.

The code I used to reproduce this issue is as follows.
Thanks in advance.

using System;
using System.IO;
using Aspose.Pdf;
using Aspose.Pdf.Text;

namespace textNull
	class Program
		static void Main(string[] args)
			License license = new License();

			Console.WriteLine("Hello World!");
			ParagraphAbsorber pa = new ParagraphAbsorber();
			Document doc = new Document("in.pdf");
			int id = 0;
			File.WriteAllText("log.txt", "");
			int num = 0;
			foreach (PageMarkup markup in pa.PageMarkups)
				foreach (MarkupSection section in markup.Sections)
					foreach (MarkupParagraph paragraph in section.Paragraphs)
						foreach (TextFragment tf in paragraph.Fragments)
							foreach (TextSegment ts in tf.Segments)
								if (num == 9) num = 0;
								string replace_txt = (++num).ToString();
								string save_text = ts.Text.ToString();
								ts.Text = replace_txt.Substring(0, ts.Text.Length);
								Console.WriteLine(string.Format($"{id}\tts.Text=[{save_text}] replacement=[{replace_txt}] after ts.Text=[{ts.Text}]\n"));
								File.AppendAllText("log.txt", string.Format($"{id}\tts.Text=[{save_text}] replacement=[{replace_txt}] after ts.Text=[{ts.Text}]\n"));



Thanks for contacting support. We have tested this scenario in our environment and have been able to observe the issue that you have mentioned. We have logged issue in our issue tracking system.