Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed Mar 29, 2023 7:41 pm

Attempting to save an XLSX file that contains the U+1F9E9 (Jigsaw Puzzle Piece) character to PDF fails with exception:

Code: Select all
Exception in thread "main" java.lang.IllegalStateException: Requested a name string that is not present in the font.
   at com.spire.xls.packages.sprvvh.spr╸┠(Unknown Source)
   at com.spire.xls.packages.sprvvh.spr━┧(Unknown Source)
   at com.spire.xls.packages.sprvvh.spr┦┧(Unknown Source)
   at com.spire.xls.packages.sprvvh.spr⌺┠(Unknown Source)
   at com.spire.xls.packages.spryyh.spr├┠(Unknown Source)
   at com.spire.xls.packages.sprvvh.spr├┠(Unknown Source)
   at com.spire.xls.packages.sprvxj.spr㈭⃟╄(Unknown Source)
   at com.spire.xls.packages.sprdxj.spr⑉╅(Unknown Source)
   at com.spire.xls.packages.sprdxj.sprㆀ╄(Unknown Source)
   at com.spire.xls.packages.sprdxj.spr┿╅(Unknown Source)
   at com.spire.xls.packages.sprdxj.spr…╅(Unknown Source)
   at com.spire.xls.packages.sprdxj.spr⌮╅(Unknown Source)
   at com.spire.xls.packages.sprwak.spr⑉╃(Unknown Source)
   at com.spire.xls.packages.sprwak.spr–⌨(Unknown Source)
   at com.spire.xls.core.spreadsheet.XlsWorkbook.spr–⌨(Unknown Source)
   at com.spire.xls.Workbook.spr┗╖(Unknown Source)
   at com.spire.xls.Workbook.saveToStream(Unknown Source)
   at SpireProblem_20230329_emoji.main(SpireProblem_20230329_emoji.java:15)


Sample file and code to reproduce the problem are attached. Tested against Spire.XLS for Java v13.3.6.
Attachments
problem-2023-03-29-emoji.zip
Problem sample
(12.3 KiB) Downloaded 365 times

heikki.aitakangas
 
Posts: 2
Joined: Wed Mar 29, 2023 7:23 pm

Thu Mar 30, 2023 6:05 am

Hi,

Thanks for your message.
When converting an xlsx file to a pdf file, you need to ensure that the corresponding used font of the xlsx file is installed on your system. If you didn't install any font, the program may prompt that the font cannot be found. I used the following code to embed the font file("seguiemj.ttf"), the converted file displays as the below screenshot, is this the correct effect on your end? If so, you can test this way on your side and let us know your result.
Code: Select all
 
Workbook workbook = new Workbook();   
workbook.loadFromFile("unicode-0x1F9E9-bug.xlsx");   
workbook.setCustomFontFilePaths(new String[]{"seguiemj.ttf"});//add the font file   
try(FileOutputStream output = new FileOutputStream("spire.pdf"))   
 {     
    workbook.saveToStream(output,FileFormat.PDF);   
}


If you have any questions after the test, please feel free to contact.

Best Regards,
Herman
E-iceblue support team
Attachments
seguiemj.zip
(1.01 MiB) Downloaded 364 times
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Thu Mar 30, 2023 4:07 pm

Most of the files we work with do not originate from our own systems, but rather from clients. This means it is impossible to guarantee we have every font every Excel file uses, and further the exact same versions of those fonts as were in the system the file was created in.

Just failing the whole save operation when a character to glyph mapping is missing is not good behaviour. Better option would be for Spire.XLS to use the .notdef glyph for such characters.

heikki.aitakangas
 
Posts: 2
Joined: Wed Mar 29, 2023 7:23 pm

Fri Mar 31, 2023 9:11 am

Hi

Thanks for your message.
Even if my systems do not install the font(seguiemj), when converting your file, I also didn't reproduce the exception you encountered. It could be converted successfully. I have packaged my project as a JAR file. You can run it directly on your system. If your issue still occurs, please share us with your system information (E.g. Win10, 64 bit) and region setting (E.g. China, Chinese) for further testing.

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Return to Spire.XLS