We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ASPOSE CELLS : Save as PDF : Font size differences

Hi,

I'm using Aspose Cells for Java 8.3.0.1.

On an Excel file, font size was smaller when i saved the file as PDF with Aspose rather than save as PDF with Excel.

According to this post :

https://forum.aspose.com/t/80459

I changed my code :

1- change the default font of the workbook in Excel

2- set the font directory with CellsHelper.setFontDir

3- save the file in PDF format using

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();

pdfSaveOptions.setCalculateFormula(true);

wb.save(repertoire + File.separator + filename, pdfSaveOptions);

And now font size in pdf file saved with Aspose is little bit bigger than font size in pdf file saved with Excel.

For example :

Font size of cells N10 and S15 (file Template.xlsx) are correct the generated pdf with Excel (Template_SAVEAS_EXCEL.pdf).

But fonts are little bit bigger in generated pdf file with Aspose (Template_SAVEAS_ASPOSE.pdf)

Another example, cell D8:9 is down truncated in Aspose generated pdf file (Template2.xlsx, Template2_SAVEAS_EXCEL.pdf, Template2_SAVEAS_ASPOSE.pdf)

thx,

Eric HAMEL

Developpment Software Engineer

Sopra/Steria Group

Hi Eric,


Thank you for contacting Aspose support.

We have evaluated your both presented scenarios against the latest version of Aspose.Cells for Java 8.3.0.1. However, we are able to replicate only one of the problems. The text size for the cells N10 & S15 seems to have enlarged when spreadsheet template.xlsx is converted to PDF format with Aspose.Cells API. We have logged this incident in our bug tracking system under the ticket CELLSJAVA-41115 for further investigation. We were unable to replicate the problem related to the sample template2.xlsx as the text in the cells D8:9 is not getting truncated from the bottom when we generated the PDF on our end. The sample PDF attached to your post that shows this problem was generated with Aspose.Cells for Java 7.3.1.6 (see attached snapshot) so we would suggest you to reevaluate the case with latest revision of Aspose.Cells for Java API.

Hi Eric,


We have investigated your both presented scenarios further, and here are our investigation results for your reference.

  1. In reference to the sample spreadsheet template.xlsx, our generated PDF is more like the Excel’s normal view with zoom level 100% (please see highlighted parts in the attached screenshot). While converting the spreadsheet to PDF format, Excel does scaling to the font size according to some unknown factors. At moment we can not do exactly the same as Excel does so we will thoroughly analyze the case in future and will let you when we have some updates.
  2. The problem regarding the Cell D8 in template2.xlsx is caused due to the unavailability of the required font. You’ll find the font name of cell D8 is “Small Fonts”. This is not an installed font name, and in such situations Aspose.Cells APIs fetch proper installed font (the first choice is the workbook’s default font–Calibri, but it seems Calibri is not available in your environment) to show the cell text in PDF. If you load your provided PDF and ours in Adobe Acrobat to check the fonts, you’ll find the font of cell D8 in the your PDF is Arial Unicode Ms, but Calibri in ours.

Hi Babar,

I don't understand the matter becaus, first thig we do is to est font dir with cellsHelper.setFontDir to local font dir with is a copy of Windows font directory which contains "Small Font" font.

Soory, we don't have Adobe Acrobat Pro to analyse fonts.

Thx,

Eric HAMEL

Hi Eric,


Thank you for writing back.

I guess you have misunderstood our justification for the point 2) from our previous response. Please note, you need Calibri font family to avoid the aforesaid situation. If you have copy pasted the fonts from a windows environment then please double check that you have the TTF files for the Calibri font family at the specified location. Alternatively, you can extract the TTF files from the attached archive to your font repository and re-evaluate this scenario. Please provide us a copy of the newly generated PDF (after placing the Calibri TTF files) for our review.

Hi Eric,



soprasteria:

I don't understand the matter becaus, first thig we do is to est font dir with cellsHelper.setFontDir to local font dir with is a copy of Windows font directory which contains "Small Font" font.

Please share the “Small Font” from your repository of windows fonts for our local testing. Moreover, please check if the aforesaid font is “Small Font” or “Small Fonts” that is set in Cell D8 of your shared sample spreadsheet “template2.xlsx”.


soprasteria:

Soory, we don't have Adobe Acrobat Pro to analyse fonts.

You should have any tool that could return the Font family name and the font face size for a particular text in a given PDF in order to thoroughly analyze such cases as discussed in this thread.

Hi Babar,

my loca font directory ( D:\prime-local\travail\Editions\Fonts) is a copy of windows font directory (C:\Windows\Fonts) which contains calibri family and Small Font family (see hard copy in joined LocalFontsDir.docx)

Font directory is seted with CellsHelper.setFontDir before opening the workbook.

And result PDF still Template2_SAVEAS_ASPOSE.pdf (joined).

I don't unsderstand why.

Eric HAMEL

PS : we are waiting for Adobe Acrobat Writer Pro installation ...

Hi Eric,


Thank you for sharing the more details.

The first thing we noticed from your provided snapshot is that the font files for “Small Font” are in “.fon” format whereas Aspose.Cells APIs currently support only TTC & TTF font format. In order to use the same fonts with Aspose.Cells APIs, you have to change the format of these fonts to TTC or TTF using any available tool.

Moreover, you have probably changed the default font of the spreadsheet, and set it to Arial Unicode MS therefore for the cell D8, the font in your generated PDF is different as compared to the one in our generated PDF.

Hi Babar,

it's a good thing to know that Aspose.Cells API only support TTF and TTC font format.

It's a good argument to make our client changes font of his spreadsheets.

You are right, I changed the default font of the spreadsheet according to this this thread :

https://forum.aspose.com/t/80459

As default font was "Small Font", then not TTC font format Aspose changed it in Arial which is the "default font" in Aspose.Cells, if i well understood.

We are going to propose Calibri by default. I'll come back to you when it's done.

Eric HAMEL

Hi Eric,


Thank you for writing back.

I believe you are able to avoid the said problem by changing the default font of the spreadsheet. For future reference, Aspose.Cells APIs do not change the default font of a given spreadsheet, however, if default font is not available in TTC or TTF formats, the Aspose.Cells APIs use the Arial as default font and calculates the cell height & width accordingly to render the spreadsheets in PDF and/or image formats.

Please feel free to get in touch if you have any further inquiries.