Text boxes moved after text replacement in 18.3 and 19.5 but not in 7.7

Hello,

We have issues with one of our templates when some text is replaced in text boxes. Some text boxes are moved when they should stay in place. This does not happen with other templates.

In the output we got with Aspose.Pdf 19.5, the company name is even overwritten with the year, in addition to being moved.

This is happening with Aspose.Pdf 18.3 and 19.5 but not with 7.7.

Here is our template. ART-0xxxx_A_READER_PRODUCT_LABEL_TEMPLATE-V010-001_Generic.pdf (31.5 KB)

Here are the outputs generated (we have licenses for 7.7 and 18.3)
Outputs.zip (139.1 KB)

Here is the code that has been used.
AsposeSample.zip (801.9 KB)

Is there a new feature introduced after version 7.7 which is causing this?

How can we make sure that no text box is moved after text replacement?

Thanks for your help.

@pjcagnard

Would you please use DOM (Document object model) Approach in order to search and replace the text in PDF document. We have tested the scenario in our environment while using following code snippet and did not notice any issue. For your kind reference, an output generated with 19.5 version of the API is also attached.

Document doc = new Document(dataDir + "ART-0xxxx_A_READER_PRODUCT_LABEL_TEMPLATE-V010-001_Generic.pdf");
var jsonData = System.IO.File.ReadAllText(dataDir + "GENERIC-RESOURCES.json");
JObject values = JObject.Parse(jsonData);
NameValueCollection nvc = new NameValueCollection();
nvc.Add("_name_", values.GetValue("name").ToString());
nvc.Add("_prod_", values.GetValue("prod").ToString());
nvc.Add("_CRyear_", values.GetValue("CRyear").ToString());
nvc.Add("_made_in_", "France");
nvc.Add("_PN_", values.GetValue("PN").ToString());
nvc.Add("_VAS_", values.GetValue("VAS").ToString());
nvc.Add("_FCC_ID_", values.GetValue("FCC_ID").ToString());
nvc.Add("_IC_", values.GetValue("IC").ToString());
nvc.Add("_SN_", values.GetValue("SN").ToString());
nvc.Add("_guide_", values.GetValue("guide").ToString());
nvc.Add("_HWModel_", values.GetValue("HWModel").ToString());
nvc.Add("_ULModel_", values.GetValue("ULModel").ToString());
nvc.Add("_ICE_", "");
nvc.Add("_FMT_", "");
nvc.Add("_WS_", "0");

foreach(string s in nvc.AllKeys)
{
 string replaceword = nvc[s];
 TextFragmentAbsorber tfa = new TextFragmentAbsorber(s);
 tfa.TextReplaceOptions = new TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.None);
 doc.Pages[1].Accept(tfa);
 tfa.TextFragments[1].Text = replaceword;
}
doc.Save(dataDir + "output195.pdf");

output195.pdf (39.8 KB)

Hello,

Thanks for your answer. With version 19.5 I get the same output as yours. With version 18.3, the version we are currently using in production, I’m getting the same errors as before, and even one more: the company name is overwritten with the year. The corresponding file is attached.

Result-18.3-as-out.pdf (40.3 KB)

Do you have a solution for version 18.3?

Thanks.

@pjcagnard

Thanks for writing back.

Please note that support is provided on the basis of latest version of the API and it is always recommended to use latest version as it contains more fixes and improvements. Furthermore, Aspose.PDF for .NET 19.6 has just been rolled out as latest version and we request you to please use it on your side for better results. In case you face any issue with it, please let us know. We will further proceed to assist you accordingly.

Hello,

Thanks for your feedback. Note that we are experiencing these issues with this template, but not with others.

Could you tell us whether something is wrong or done badly inside the PDF itself, so we could try to generate it differently in order to avoid the issues?

Thanks.

@pjcagnard

We definitely understand your concerns but, we regret to share that we can only perform investigation or analysis against an issue if it is reproducible with latest version of the API. With every new release of the API, there are new classes and methods which are added to improve as well as fix previously reported bugs which is why it is always recommended to use latest version. In case you need any further assistance, please feel free to let us know.