Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Jul 08, 2019 2:03 pm

I have issues with adding German special characters to a pdf.

Attached is the output im getting with the wrong values.

I have verified that the special characters are actually correct before adding them to the pdf..

The code im using for adding the values are
var lst = new PdfGridCellContentList();
lst.List.Add(AddCellLine("Customer", 10, true, false));
lst.List.Add(AddCellLine(customer.Name, 10, false, true));
lst.List.Add(AddCellLine(customer.Address, 10, false, true));

var line = $"{customer.Zip} {customer.City}";
lst.List.Add(AddCellLine(line, 10, false, true));

if (!string.IsNullOrEmpty(customer.Phone))
{
lst.List.Add(AddCellLine($"Phone {customer.Phone}", 10, false, true));
}

row.Cells[0].Value = lst;
}

private static PdfGridCellContent AddCellLine(string text, int fontSize, bool fontBold, bool newLine)
{
var font = RegularFont(fontSize);
if (fontBold) font = BoldFont(fontSize);
if (newLine)
{
text = "\n" + text;
}

var result = new PdfGridCellContent
{
Text = text,
Font = font,
StringFormat = new PdfStringFormat
{
WordWrap = PdfWordWrapType.WordOnly
}
};

return result;
}

gwinnem01
 
Posts: 6
Joined: Wed Jul 03, 2019 4:32 am

Tue Jul 09, 2019 6:56 am

Hello,

Thanks for your inquiry.
I simulated your scenario and tested with our latest Spire.PDF Pack Version:5.7, but I didn't reproduce your issue. Thus, I prefer to recommend that you try again with the latest version. If your issue still occurs after trying. Please provide the following more information to help us further look into it.
1. The string content of your special German characters for customer.Address and customer.City.
2. The details about you defined two fonts (RegularFont(), BoldFont()).
3. Your system information (E.g. Windows 7, 64 bit) and the region setting (E.g. Germany, German).

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Tue Jul 09, 2019 7:15 am

Hi Lisa.
I am using Spire.PDF 5.7.0

Germany has the following special characters you can test with:
Ä ä
Ö ö
Ü ü
ẞ ß


Test strings you can use:
1. Gerätebestätigung
2. Pömmelter Straße 2
3. 39218 Schönebeck, Deutschland
4. Gerät schaltet selbständig ab

The code for them two functions are:
private static PdfTrueTypeFont RegularFont(float size)
=> new PdfTrueTypeFont(new Font("Arial", size, FontStyle.Regular));

private static PdfTrueTypeFont BoldFont(float size)
=> new PdfTrueTypeFont(new Font("Arial", size, FontStyle.Bold));

My development environment is
Windows 10, but this will run in production on Windows Server 2012

My regional settings are
German (Austria), This will also be the case for the production environment.

The system will later also be using Norwegian and Danish special letters to. And i hope i will not have the same issue with them.

Anyway I am giving you some examples for those to test with to.

Norwegian / Danish test strings:
æ ø å
Æ Ø Å

1. som også opplevde svømmekonkurransen
2. han er godt vant til å være i vann


Regards
Geirr

gwinnem01
 
Posts: 6
Joined: Wed Jul 03, 2019 4:32 am

Tue Jul 09, 2019 8:42 am

Hello,

Thanks for your more information.
When defining the fonts, please add the parameter (bool unicode= true) like the following modified code and then test your case again. Look forward to your testing result.
Code: Select all
private static PdfTrueTypeFont RegularFont(float size)
=> new PdfTrueTypeFont(new Font("Arial", size, FontStyle.Regular), true);

private static PdfTrueTypeFont BoldFont(float size)
=> new PdfTrueTypeFont(new Font("Arial", size, FontStyle.Bold), true);

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Tue Jul 09, 2019 1:43 pm

Thank you so much Lisa.
That solved my issue :D

gwinnem01
 
Posts: 6
Joined: Wed Jul 03, 2019 4:32 am

Wed Jul 10, 2019 1:19 am

Hello,

Glad to hear that! If you encounter any issue related to our products in the future, just feel free to contact us.
Wish you all the best!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF

cron