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

Free Support Forum - aspose.com

Aspose PDF text breaking

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)

@ferdous0905

The symbol can be missing because of fonts. I request you to try a compatible font and then share your feedback.

1 Like

Thanks for the reply. It is working now :slight_smile:

@ferdous0905

It’s good to know that it is working on your end.