Font is displayed as DejaVu when converting to PDF

Hello,

We are doing an API call to transform a XSL spreadsheet into a XLSX and a PDF file. The XLSX is coming out correctly with the Arial and Calibri fonts in the cells, however we are getting a Dejavu font in the PDF where we expected to see the same fonts used in Excel.

@Brian.Ginoza

When converting an XLSX file to PDF using the Aspose.Cells API, if you notice that the fonts in the PDF are displayed as DejaVu instead of the expected Arial or Calibri, it may be due to the absence of the required fonts on the server where the conversion is taking place.

To resolve this issue, you can take the following steps:

  1. Ensure Fonts are Installed: Make sure that the Arial and Calibri fonts are installed on the server or environment where the conversion is being executed. If these fonts are not available, Aspose.Cells will substitute them with a default font, which may be DejaVu.

  2. Use Font Substitution: If you cannot install the required fonts, you can specify font substitution settings in your conversion options. This allows you to define alternative fonts that should be used in place of the missing ones.

Here is an example of how to set up font substitution in your code:

PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setFontSubstitution("Arial", "DejaVu Sans");
saveOptions.setFontSubstitution("Calibri", "DejaVu Sans");

// Proceed with the conversion
PostWorkbookSaveAsRequest request = new PostWorkbookSaveAsRequest();
request.setName(remoteName);
request.setNewfilename(newfilename);
request.setSaveOptions(saveOptions);
request.setFolder(remoteFolder);

SaveResponse response = this.api.postWorkbookSaveAs(request);

In this example, if Arial or Calibri is not available, it will use “DejaVu Sans” as a substitute. Adjust the font names as necessary based on your requirements.

By ensuring the necessary fonts are available or by configuring font substitution, you should be able to achieve the desired font appearance in your PDF output.

If you continue to experience issues, consider checking the Aspose.Cells documentation or community forums for further assistance.

Sources: