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

Free Support Forum - aspose.com

Font size is small in PDF and PPT

Hi,
While trying to convert xls to PDF/PPT, the font sizes are not same and in most cases smaller than the XLS font size. Kindly help with this issue.

Thanks.

Hi,

Thanks for your posting and using Aspose.Cells.

Please download and use the latest version:
Aspose.Cells for Java v8.7.1.4 and see if it makes any difference and resolves your issue.

If your issue still persists, then please provide us sample code, input files and output files. You can also provide us expected output files which you can create manually using their tools like MS-Excel, MS-PowerPoint, Adobe Acrobat. Also some screenshots highlighting your issues will be helpful for us. Thanks for your cooperation in this regard. Have a good day.

Hi Team,

I have tried generating PDF/PPT with latest version of ASPOSE Cells for Java v8.7.1.4 and it doesnt make a difference.

I have attached the PDF generated using the latest jar with this reply.

Can you please help us in resolving this issue.

Thanks,
Preethi.

Hi Preethi,


Thank you for sharing the resultant PDF, however, we also require the input spreadsheet for thorough investigation. That said, I believe you have reported a similar problem here as well, which was caused due to the Worksheet’s zoom set to a smaller scale (65%). In order to fix the problem of reduced font size in resultant PDF, please set the Worksheet’s zoom to 100% using the PageSetup.Zoom property. Please check the following piece of code and give it a try on your end against your sample spreadsheet. In case the problem persists, please share the input spreadsheet for our testing along with the resultant PDF generated on your side.

Java

Workbook book = new Workbook(dir + “sample.xlsx”);
for(int i = 0; i < book.getWorksheets().getCount(); i++)
{
Worksheet sheet = book.getWorksheets().get(i);
sheet.getPageSetup().setZoom(100);
}
book.save(dir + “output “+CellsHelper.getVersion()+”.pdf”);

Hi Team,

We are getting the same results even when we set the zoom size in spreadsheet to 100%.

We have attached the spreadsheet for your reference.

Please look into it and provide us solution.

Thanks in advance.

Hi again,


Thank you for the sample.

We have evaluated the presented scenario while using the latest version of Aspose.Cells for Java 8.7.1.4 and we are not able to replicate the said issue by setting the Worksheet’s zoom scale to 100%. Attached to this post are two PDF files along with snapshots showing the font size in Adobe Acrobat Pro application. You will notice that the font size of the title is 11.6 in PDF which was generated without setting the Worksheet’s zoom whereas same text has font size as 18 in PDF generated after setting the Worksheet’s zoom scale to 100%, which is the correct size as specified in the input spreadsheet.

Please note, I have performed tests on Windows 7 & Windows 10 against JDK 1.7.0_65 & 1.8.0_66 respectively whereas the code snippet to set the zoom scale is as follow.

Java

Workbook book = new Workbook(dir + “rep19+spreadsheet.xlsx”);
for(int i = 0; i < book.getWorksheets().getCount(); i++)
{
Worksheet sheet = book.getWorksheets().get(i);
sheet.getPageSetup().setZoom(100);
}
book.save(dir + “rep19+spreadsheet (with setting zoom).pdf”);

Hi Team,

We are not able to get the desired results for PDF/PPT when it is integrated with web application which runs on UNIX server.

As a standalone application it is working fine.

I have attached the code piece with this reply.

public void exportPPTX(OutputStream outputStream)
throws Exception
{
Worksheet worksheet = getWorkbookDesigner().getWorkbook().getWorksheets().get(SHEET_NAME_CHART);
worksheet.freezePanes(2,2,41,31);
setOleExcelEndRow(42);
setOleExcelEndColumn(31);
setPptHorizontalResolution(300);
setPptVerticalResolution(300);
super.exportPPTX(outputStream);
}

Thanks in advance.

Hi Prabu,


As mentioned here, we were trying to replicate the issue on Windows based platform as per your provided environment details. You have never mentioned that the said problem is reproducible in Unix environment only. Please note, on non-Windows based platforms you have to set the folder location containing the TTF/TTC fonts used in the spreadsheet in order to get the best results. If you do not set the font directory or API is not able to find the required fonts then the API will not be able to correctly calculate the glyph dimensions, as a consequence the row height and column widths may change. Please go through these articles for better understanding on how Aspose.Cells for Java API uses the TrueType fonts.

Coming back to the original problem, I humbly request to you please provide the following details for investigation. Please note, we are asking these details again because we were under the assumption that you are performing all tests on Windows based platform. Moreover, your provided code snippet is not complete and we cannot inject the missing parts due to the complexity of the Aspose.Cells APIs.

We need the following information/artifacts to reproduce the problem on our side.

  1. Unix/Linux flavor, version & architecture
  2. JDK type, version & architecture
  3. JVM arguments, if any
  4. We need an executable sample application covering your complete scenario in perspective of Aspose APIs. It would be appropriate that you should create a simple console application that replicates the problem in non-Windows based platform such as Unix/Linux. A simple Java class should suffice if it is complete and does not have compilation errors. Try not to use 3rd party APIs in order to keep it simple. Moreover, if you are importing data from any database, you should create the data source dynamically so that database connectivity isn’t required while testing the scenario on our side.
  5. Source spreadsheet, if different than what you have already shared in this thread.
  6. Resultant PDF generated with the sample application as mentioned in point 4) while using the latest version of Aspose.Cells for Java 8.7.1.4.

As soon as you provide the complete details we will re-initiate the investigation to assist you with this incident.

Hi again,


This is to update you that I have performed more tests on CentsOS 6.5 x64 against JDK 1.7 & Aspose.Cells for Java 8.7.1.4. Attached you will find three PDF files with following details.

  • rep19+spreadsheet.xlsx(nofonts).pdf: The file was generated with the code provided at Snippet 1 without setting fonts in the code. As a result API has substituted the required fonts with available one.
  • rep19+spreadsheet.xlsx(fonts).pdf: This file was generated with the code provided at Snippet 2 where font directory contains the TTFs of Calibri & Arial font families. In this case the font in the PDF is smaller than the font specified in the spreadsheet. Reason is the scale factor set for the said worksheet.
  • rep19+spreadsheet.xlsx(fonts-scale-fixed).pdf: This file contains the expected results because correct fonts have been embedded along with correct text size. I have verified the results using Adobe Acrobat Pro. Please refer to the code in Snippet 3.

Snippet 1

new Workbook(dir + “rep04+spreadsheet.xlsx”).save(dir + “rep04+spreadsheet.xlsx(nofonts).pdf”, SaveFormat.PDF);

Snippet 2

System.setProperty("Aspose.Cells.FontDirExc", dir + "fonts");
new Workbook(dir + "rep04+spreadsheet.xlsx").save(dir + "rep04+spreadsheet.xlsx(fonts).pdf", SaveFormat.PDF);

Snippet 3

System.setProperty("Aspose.Cells.FontDirExc", dir + "fonts");
Workbook book = new Workbook(dir + "rep19+spreadsheet.xlsx"); for(int i = 0; i < book.getWorksheets().getCount(); i++) { Worksheet sheet = book.getWorksheets().get(i); sheet.getPageSetup().setZoom(100); } book.save(dir + "rep19+spreadsheet.xlsx(fonts-scale-fixed).pdf.pdf");

As you have mentioned that the problem does not replicate in a standalone application but when you integrate the code in you main application. This suggests that the problem could be in your code (how you are using the Aspose APIs), causing the said problem, however, we cannot be sure unless you provide us an executable sample application along with other details requested in my previous response.