[Aspose Cells 24.7 and 25.1] Issue with text encoding while creating PDF from .xlsb file

Hi,

i’m are facing a strange behavior since migration from aspose 18 to 24 with characters with accents like “è,é,î…ê…ô” which are not well handled; They are generated in my output pdf file but it seems like the font/or encoding is incorrect and nothing is display when editing/reading pdf with online tool like “we-pdf.com” ( it works fine with aspose cells 18)

Code:

  public static void main(String[] args) {
        String inputPath = "...MytestBook.xlsx";  /// a simple excel file with single sheet and a range/cells named  "customText"
        String outputPath = "...testPdfAccentSimple.pdf"; // out pdf file     
        Workbook wb = new Workbook(inputPath);
        wb.getSettings().setRegion(CountryCode.FRANCE);
        wb.getSettings().setLocale(Locale.FRANCE);
        wb.getWorksheets().getRangeByName("customText").setValue("Comptabilité Prénom é à è î ");  
        //  initializing named range customText
        wb.calculateFormula(true);
        PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
        pdfSaveOptions.setCompliance(0);
        pdfSaveOptions.setOptimizationType(1);
        // saving 
        wb.save(outputPath, pdfSaveOptions);
}

@fournierl,

Could you please zip and attach the template Excel file and output PDF file. We will check your issue soon.

@fournierl
Please install used fonts on the server :

Hi @amjad.sahi,

thanks for your answer! here attached the template file
template.zip (15.0 KB)

Hi @simon.zhao
all fonts are installed (TrueType : /usr/openwin/lib/X11/fonts/TrueType)

@fournierl,

Thanks for the template Excel file and output PDF file by Aspose.Cells for Java v25.1. Could you please also provide your expected PDF file. We will look into your issue soon.

@fournierl
In addition, if the text does not match the expected font, it may be that the program cannot find the installed fonts. You can add the following example code to set a custom font folder before loading the sample file.

// add this line to set a custom font folder
FontConfigs.setFontFolder("/usr/openwin/lib/X11/fonts/TrueType/", true);

String inputPath = "...MytestBook.xlsx";  /// a simple excel file with single sheet and a range/cells named  "customText"
String outputPath = "...testPdfAccentSimple.pdf"; // out pdf file     
Workbook wb = new Workbook(inputPath);
wb.getSettings().setRegion(CountryCode.FRANCE);
wb.getSettings().setLocale(Locale.FRANCE);
wb.getWorksheets().getRangeByName("customText").setValue("Comptabilité Prénom é à è î ");  
//  initializing named range customText
wb.calculateFormula(true);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setCompliance(0);
pdfSaveOptions.setOptimizationType(1);
// saving 
wb.save(outputPath, pdfSaveOptions);

You can also refer to the following document on how to set a custom font folder.

@amjad.sahi
attached 2 files to compare (aspose cells 18 Vs aspose cells 24 → same behavior as aspose cells 25)

current_generated_with_Aspose24.pdf (14.2 KB)
expected_generated_with_aspose18.pdf (2.6 KB)

@fournierl,

Thanks for the PDF files.

Could you please try to add the following line to set the custom fonts folder at the start of your program/code snippet if it makes any difference?

// add this line to set a custom font folder, please set/adjust the font folder path accordingly
FontConfigs.setFontFolder("/usr/openwin/lib/X11/fonts/TrueType/", true); 

Let us know if you still find the issue.

i just run it on my local windows laptop where fonts are located in C:/Windows/Fonts with option suggested just to make sure my remote solaris server is not missing somthing under his fonts folder (/usr/openwin/lib/X11/fonts/TrueType/)

FontConfigs.setFontFolder("C:/Windows/Fonts", true);

attached new file generated (put still not able to decode/read accent )

current_file_with_aspose24_with_issue_and_FontSet.pdf (14.2 KB)

@fournierl,

Thanks for the PDF file and further details.

We require thorough evaluation and investigation of your issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-46249

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@fournierl,

This is to inform you that your issue (logged earlier as “CELLSJAVA-46249”) has been resolved on priority basis. By default, the fix/enhancement will be included in the next release (Aspose.Cells v25.3) scheduled for release first half of March (next month).

The issues you have found earlier (filed as CELLSJAVA-46249) have been fixed in Aspose.Cells for Java 25.3.