Hello, I am trying to replace a text in my pdf. But the text symbol is breaking.
My code:
var dest = @“C:\Users\BS216\Desktop\RFI\Eps Test\PdfOut\ILL-000335112_Check.pdf”;
var src = @“C:\Users\BS216\Desktop\RFI\Eps Test\XmlOut_PDF\ILL-000335112_translate.pdf”;
Document pdfDocument = new Document(src);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("Ignition switch");
pdfDocument.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
// Update text and other properties
textFragment.Text = "Switch de ignición";
//textFragment.TextState.Font = FontRepository.FindFont("Arial");
//textFragment.TextState.FontSize = 10;
//textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black);
}
pdfDocument.Save(dest);
pdfDocument.Dispose();
ILL-000335112_translate.pdf (24.7 KB)
ILL-000335112_replaced.pdf (60.0 KB)