Free Support Forum - aspose.com

Write Line using Accented Characters

Hello,

We are using Aspose version 3.3.0.0 to stamp documents with various information, including the name of the person responsible for the stamping. There is currently an issue we are seeing that when the text includes an accented character (for example é), then we get some gibberish instead of the letter.

Here is the code we are using:

            memStreamOriginal = new MemoryStream(memStreamOutput.ToArray());
            memStreamOutput.Close();
            memStreamOutput = new MemoryStream();
            top = top - 14;
            headerStamp.BindLogo(new FormattedText(name, new FontColor((byte)0, (byte)0, (byte)0), FontStyle.TimesRoman, EncodingType.Winansi, false, 10.0f));
            headerStamp.Pages = new int[] { 1 }; // stamping first page
            headerStamp.Rotation = 0;
            headerStamp.SetOrigin(left, top); // top mid
            pdfFileStamper = new PdfFileStamp(memStreamOriginal, memStreamOutput);
            pdfFileStamper.AddStamp(headerStamp);
            pdfFileStamper.Close();

I have tried a few things in testing, for example adding this:

//string lowerAccentE = "#$UNICODE(233)";
string lowerAccentE = "&#233";
var formattedName = new FormattedText(name.Replace("é", lowerAccentE),
                                                       new FontColor((byte)0, (byte)0, (byte)0),
                                                       FontStyle.TimesRoman,
                                                       EncodingType.Winansi,
                                                       false,
                                                       10.0f);

However, those didn’t encode the é and just stamped the string onto the page.

I also tried changing the encoding to Identity_h, but that didn’t work either.

I did find that there is an option to html encode strings in a Text object, but BindLogo doesn’t take in a Text object, and I have no idea how I could use one to stamp the PDF document.

Do you know of a way to properly stamp the é letter onto the PDF?

@cwgsccca

You are using legacy and outdated version of the API so please upgrade to latest version of the API which includes more features and bug fixes. Moreover, support is provided based on latest available version of the API. You can add text stamp on a PDF document as explained over Adding Text Stamp in the PDF File.

In case of any problem, please feel free to contact us and we will be more than happy to assist you.