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.

Thu Jun 16, 2022 3:30 am

I am try to convert file excel to pdf, my problem is file pdf no data 0kb, i checked log no exception
My code:
Workbook workbook = new Workbook();
workbook.loadFromFile("path_file_excel.xlsx");

Worksheet worksheet = workbook.getWorksheets().get(0);

PageSetup pageSetup = worksheet.getPageSetup();
pageSetup.setPaperSize(PaperSizeType.PaperA4);
pageSetup.setOrientation(PageOrientationType.Landscape);
pageSetup.setFitToPagesWide(1);
//Save to PDF file
worksheet.saveToPdf("path_file_pdf.pdf");

i am used version:
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls.free</artifactId>
<version>5.1.0</version>
</dependency>

help me pls

dongneverdie
 
Posts: 5
Joined: Thu Jun 16, 2022 3:22 am

Thu Jun 16, 2022 6:34 am

Hello,

Thanks for your inquiry.

As we maintain the free version less frequently, there may be some issues that were fixed in the commercial version but the fixes are not added to the free version. Therefore, please update to the latest commercial version and test it first. If the problem persists, please send us your excel file. You can upload it here or send it to us by mail (support@e-iceblue.com). Thanks in advance.

commercial version:
Code: Select all
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls</artifactId>
<version12.6.0</version>
</dependency>
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Thu Jun 16, 2022 7:22 am

Andy.Zhou wrote:Hello,

Thanks for your inquiry.

As we maintain the free version less frequently, there may be some issues that were fixed in the commercial version but the fixes are not added to the free version. Therefore, please update to the latest commercial version and test it first. If the problem persists, please send us your excel file. You can upload it here or send it to us by mail (support@e-iceblue.com). Thanks in advance.

commercial version:
Code: Select all
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls</artifactId>
<version12.6.0</version>
</dependency>


Hi,

When i update to version 12.6.0, there is log:
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
And no file pdf which should be generated!

dongneverdie
 
Posts: 5
Joined: Thu Jun 16, 2022 3:22 am

Thu Jun 16, 2022 8:51 am

Hi,

To reproduce the issue, could you please share the excel file to us? Thanks in advance.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Thu Jun 16, 2022 9:04 am

Andy.Zhou wrote:Hi,

To reproduce the issue, could you please share the excel file to us? Thanks in advance.



Hi

i send the file. there is important note: it convert well in local( window) and error when run in centos
Attachments
bbds_detail_tmp_1655263325588.rar
(12.52 KiB) Downloaded 77 times

dongneverdie
 
Posts: 5
Joined: Thu Jun 16, 2022 3:22 am

Thu Jun 16, 2022 10:06 am

Hi,

As you described, I tested this file in centos7. But the PDF was generated successfully and opened normally. Are the fonts(times new roman and Calibri) required by this file installed in your centos system? If not, please install and test again. I suggest that you copy and install all the fonts in Windows into centos. Maybe the fonts caused this issue.
B5C43728-5AE0-4773-AE2C-77437795F72E.png
B5C43728-5AE0-4773-AE2C-77437795F72E.png (15.41 KiB) Viewed 823 times
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Thu Jun 16, 2022 11:35 am

Andy.Zhou wrote:Hi,

As you described, I tested this file in centos7. But the PDF was generated successfully and opened normally. Are the fonts(times new roman and Calibri) required by this file installed in your centos system? If not, please install and test again. I suggest that you copy and install all the fonts in Windows into centos. Maybe the fonts caused this issue.
The attachment B5C43728-5AE0-4773-AE2C-77437795F72E.png is no longer available


Hi,

I just edit my excel file have only font time new roman. And use custom font in java

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
InputStream is = new ClassPathResource("font/TimesNewRoman.ttf").getInputStream();
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, is));

It still no data in file pdf.
Attachments
chi_tiet_bbds_thang_1655375616540.rar
(101 Bytes) Downloaded 82 times
bbds_detail_tmp_1655263325588.rar
(12.52 KiB) Downloaded 82 times

dongneverdie
 
Posts: 5
Joined: Thu Jun 16, 2022 3:22 am

Fri Jun 17, 2022 10:27 am

Hi,

Please download my test jar and test in your system to see if the issue still exists. You can download it from the link below.

https://www.e-iceblue.com/downloads/demo/test.zip
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Mon Jun 20, 2022 2:58 am

Andy.Zhou wrote:Hi,

Please download my test jar and test in your system to see if the issue still exists. You can download it from the link below.

https://www.e-iceblue.com/downloads/demo/test.zip


HI,

There is error when run in my server:
java.lang.IllegalStateException: Cannot found font[SansSerif] installed on the system.
at com.spire.xls.packages.sprafr.spr⌭®—(Unknown Source)
at com.spire.xls.packages.sprhar.spr▧©—(Unknown Source)
at com.spire.xls.packages.sprhar.spr┑⌧(Unknown Source)
at com.spire.xls.packages.sprwqe.spr┑⌧(Unknown Source)

I don't know why it required SansSerif.

and another question: Can i embed font when convert excel to pdf?

dongneverdie
 
Posts: 5
Joined: Thu Jun 16, 2022 3:22 am

Mon Jun 20, 2022 10:09 am

Hi,

Please try to install the font "SansSerif" and test again. Or you can just embed it by calling workbook.setCustomFontFilePaths(). Here is the sample code.

Code: Select all
        String []embedFonts={"./fonts/xxxx.ttf","./fonts/yyyy.ttf"};
        workbook.setCustomFontFilePaths(embedFonts);
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.XLS