Fonts uploaded to internal storage are not used in SaveAs pdf conversion

Hi there,

I’ve added a folder called CustomFonts to my internal storage and uploaded the font I am missing (impact.ttf) and can confirm I get the fonts back by querying the Get Available Fonts endpoint:

curl -v "https://api.aspose.cloud/v4.0/words/fonts/available?fontslocation=CustomFonts" -X GET -H "Authorization: Bearer (token here)" 

And get the response


{
"SystemFonts":
[
{
"FontFamilyName":
"Century Gothic",
"FullFontName":
"Century Gothic",
"Version":
"Version 2.35",
"FilePath":
"C:\Windows\Fonts\11528.ttf"
},
{
"FontFamilyName":
"Arial Narrow",
"FullFontName":
"Arial Narrow Italic",
"Version":
"Version 2.30",
"FilePath":
"C:\Windows\Fonts\Arial Narrow.ttf"
},
(...)
],
"AdditionalFonts":
[
],
"CustomFonts":
[
{
"FontFamilyName":
"Impact",
"FullFontName":
"Impact",
"Version":
"Version 2.35"
}
],
"RequestId":
"4dfd8183018f97ea0f1d815138abae67"
}

I then upload a docx file which has text using the impact font and specify my fontslocation again:

curl -v "https://api.aspose.cloud/v4.0/words/online/put/saveAs?fontslocation=CustomFonts" -X PUT -H "Authorization: Bearer (token here)" -H "Content-Type: multipart/form-data" -F Document="@Impact Font test.docx" -F SaveOptionsData="{ \"PreserveFormFields\": true, \"SaveFormat\": \"pdf\", \"FileName\": \"Impact Text.pdf\" }" 

And get the error:


{
"Error":
{
"Code":
"InternalError",
"Message":
"not found fonts in CustomFonts",
"Description":
"Operation Failed. Internal error."
},
"RequestId":
"9236c0587ca92e994ff9d33f74fab7da"
}

Why is the custom font now not discoverable?

@Sammyjo20

It seems that you are encountering an issue where the custom font (impact.ttf) you uploaded to your internal storage is not being recognized during the PDF conversion process. Here are a few steps you can take to troubleshoot this issue:

  1. Verify Font Upload: Ensure that the font file is correctly uploaded to the CustomFonts folder. You can confirm this by checking the response from the Get Available Fonts endpoint, which you have already done. The font should appear under the CustomFonts section.

  2. Correct Font Location: When making the request to save the document as a PDF, ensure that you are specifying the correct fontslocation parameter. It should match the folder name where the font is stored, which in your case is CustomFonts.

  3. Check Font Compatibility: Ensure that the font you are trying to use is compatible with the Aspose API. Some fonts may have restrictions or may not be supported for certain operations.

  4. Test with Different Fonts: As a troubleshooting step, try uploading a different font and see if it is recognized during the conversion process. This can help determine if the issue is specific to the impact.ttf font.

  5. Review API Documentation: Check the Aspose documentation for any specific requirements or limitations regarding custom fonts. There may be additional parameters or settings that need to be configured.

  6. Contact Support: If the issue persists after trying the above steps, consider reaching out to Aspose support for further assistance. Provide them with the details of your request and the error message you are receiving.

By following these steps, you should be able to identify the cause of the issue and resolve it. If you have any further questions or need additional assistance, feel free to ask!

  1. Yes I have done this.
  2. Yes the font locations match.
  3. Is there a list of fonts that are not compatible that you could provide?
  4. This fails with other fonts too
  5. No additional parameters I can see that would make the fonts discoverable?
  6. Any other support avenues that you would suggest?

Could you try use not an online version of the method, as when you use online saveAs it doesn’t use storage, I will check if there is an issue for that or we should remove this parameter for online versions.

Unfortunately we need to make this an online operation as we’re passing a document from syncfusion into aspose to handle the PDF generation. Are you suggesting there’s no way to add custom fonts to the online save as method?

For information it does pull in the font as expected when not an online operation

I will share your use case with the team to see if we can achieve your needs. Anyway, I will create a ticket for that matter.

1 Like