Increase character spacing while replace text in PDF

<span style=“color: rgb(61, 61, 61); font-family: “Helvetica Neue”, Helvetica, Arial, “Lucida Grande”, sans-serif; font-size: 14px;”>while I try to replace text in pdf, the character spacing changed in the same line, I want to keep the same character spacing, any help ?

Hello mohamed,


Thanks for using our API’s.

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000; min-height: 14.0px} span.s1 {font-kerning: none}

I will appreciate if you please share your sample PDF document and code. It will help us to understand your issue exactly and address it accordingly.


We are sorry for the inconvenience.


Best Regards,

Dear Fahad,

Thanks for your replay
I attached the Sample pdf and there is the code

static void Main(string[] args)
{
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(“Aspose.Pdf.lic”);
// The path to the documents directory.
string dataDir = “D:\Production Softwares\Tasks\PDF Replace\”;

// Open document
Document pdfDocument = new Document(dataDir + “input.pdf”);

// Create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“xxxxxxxxxx”);
// Accept the absorber for all the pages
pdfDocument.Pages.Accept(textFragmentAbsorber);
// Get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
if (textFragmentCollection.Count > 0)
{
Console.WriteLine(“”);
// Get first occurance of text and replace
TextFragment textFragment = textFragmentCollection[1];
// Update text and other properties
textFragment.Text = “Published”;

dataDir = dataDir + “4801784_out.pdf”;
pdfDocument.Save(dataDir);

Console.WriteLine("\nText replaced successfully.\nFile saved at " + dataDir);
}
}

Hello Mohamed,


Thanks for sharing input file along with the sample code.

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial; -webkit-text-stroke: #000000} span.s1 {font-kerning: none}

I have tested the scenario and have managed to reproduce the problem that after replace text in PDF, the character spacing changed in the same line. I have logged it as PDFNET-42192 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction.


Please be patient and spare us little time. We are sorry for this inconvenience.


Best Regards,

Thanks, I’ll wait your reply

The issues you have found earlier (filed as PDFNET-42192) have been fixed in Aspose.PDF for .NET 19.8.