Free Support Forum - aspose.com

XLS to PDF not getting converted correctly

Hi,
Please check the attached xls and corresponding pdf file which got generated. The formatting in the pdf file is not at all appropriate, Can you please advice something.

Thanks,
Saumil

Hi,

Thanks for your reporting.

I have found that latest version is working fine. Please see the code below and the output pdf file.

Please download the latest version: Aspose.Cells
for Java v2.5.4.16


Java


String path=“F:\Shak-Data-RW\Downloads\samplexls1.xls”;


Workbook workbook = new Workbook();

workbook.open(path);


workbook.save(path + “.out.pdf”, FileFormatType.PDF);

Thanks,
I tried with the new jar, and it still has some formatting issue, not sure whether it is because I am on linux or due to the watermarking on the top.

Hi,

Please make sure, you have all the additional java libraries needed for Aspose.Cells for Java.

You can download them from this link: additional libraries

I have added all the required libraries.

Hi,

Were you able to get the desired results? If not, then please let me know your System Environment.

Hi,

FYI: To make the generated pdf be same with what shown in excel, you need to specify the correct font path in which we can find the same font definition used by Ms-Excel to render content to pdf.

Please make sure you have the same font files in your Linux Enviornment and have specified the correct path e.g such as by calling SaveOptions.setFontPath(String[])

I am still facing the problem.

I guess its the font setting issue, as I am getting the same problem with the ppt files as well. I will have to figure it out how to add all the fonts on my system.

Below are the fonts available

I got the below result when I called GraphicsEnvironment.getLocalGraphicsEnvironment();

Bitstream Charter
Bitstream Vera Sans
Bitstream Vera Sans Mono
Bitstream Vera Serif
Century Schoolbook L
Courier
Courier 10 Pitch
Cursor
DejaVu LGC Sans
DejaVu LGC Sans Condensed
DejaVu LGC Sans Light
DejaVu LGC Sans Mono
DejaVu LGC Serif
DejaVu LGC Serif Condensed
Dialog
DialogInput
Dingbats
Hershey
Liberation Mono
Liberation Sans
Liberation Serif
Lucida Bright
Lucida Sans
Lucida Sans Typewriter
Luxi Mono
Luxi Sans
Luxi Serif
Monospaced
Nimbus Mono L
Nimbus Roman No9 L
Nimbus Sans L
Nimbus Sans L Condensed
SansSerif
Serif
Standard Symbols L
URW Bookman L
URW Chancery L
URW Gothic L
URW Palladio L
Utopia

Am I missing any font in particular?

<span style=“font-size:10.0pt;font-family:“Tahoma”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;color:black;mso-ansi-language:EN-US;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>

<span style=“font-size:10.0pt;font-family:“Tahoma”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;color:black;mso-ansi-language:EN-US;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>Hi,
<span style=“font-size:10.0pt;font-family:“Tahoma”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;color:black;mso-ansi-language:EN-US;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>

Well, when rendering your template file to PDF, such as, the cell B9, its font is
Calibri with size 12, we need to read the font definition file of
Calibri, in Windows, i.e…, full path name is C:\WINDOWS\Fonts\CALIBRI.TTF. In Linux,
because it doesn’t have this font file, we need copy this file to Linux, and call SaveOptions.setFontPath(String[])
in the program.
<span style=“font-size:10.0pt;font-family:“Tahoma”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;color:black;mso-ansi-language:EN-US;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>
<span style=“font-size:10.0pt;font-family:“Tahoma”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;color:black;mso-ansi-language:EN-US;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>Thank you

Hi,
I copied the calibri.ttf file on my linux system and gave the path to the Saveoptions, but still it doesnot seem to work, I am also confused that if the font is not present on my system how can openoffice display the font correctly?

Hi,

Firstly, for OpenOffice, I guess maybe it maintains additional font repository.

Secondly, I have tested this case at Ubuntu 10.04:

copy calibri.ttf to /home/aspose/share/IFonts

Please see the code below and the output file attached.

Java


workbook.open("/home/aspose/share/test/issue/samplexls1.xls");

SaveOptions saveop = workbook.getSaveOptions();

saveop.setFontPath(new String[]{"/home/aspose/share/IFonts"});

workbook.save("/home/aspose/share/test/issue/samplexls1.xls.pdf", FileFormatType.PDF);



And, here is the output file (attached).


Thank you.