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

Free Support Forum - aspose.cloud

How to use custom fonts in the docker container for PPTX to PDF conversion using Aspose.Slides REST API?

I am checking the docs here: https://apireference.aspose.cloud/slides/#/Document/PutSlidesConvert

There is a param to supply the fonts folder path. How can I do this inside the docker container? I have all the files using Calibri font-family and my docker containers just don’t convert to pdf properly with this font. It adds a random large-sized font which is leading to the improper layout.
Please guide. Thanks!

@beingignite

Please create a fonts folder in your storage(mounted path of file storage in container), copy the custom fonts in it and pass the font folder path in fontsFolder parameter. It will resolve the issue.

Hey @tilal.ahmad ! I uploaded the Calibri font family files on my server in the volume at root. And I am passing the value as
const slidesApi = new api.SlidesApi(’’, ‘’, process.env.ASPOSE_URL);
const postSlidesConvertRequest = new api.GetSlidesApiInfoRequest();
postSlidesConvertRequest.format = ‘pdf’;
postSlidesConvertRequest.document = readStream;
postSlidesConvertRequest.fontsFolder = '/storage’

But still, the conversion is giving a bad format. What surprises me is that when I upload the same file here it gives me the exact formatted pdf. Attaching screenshots of both conversions.

This is my original ppt file :
Screenshot 2021-07-05 at 4.50.09 PM.png (82.7 KB)

This is what I get from docker container :
Screenshot 2021-07-05 at 4.56.15 PM.png (84.5 KB)

And this is the one that I get from aspose online conversion tool :
Screenshot 2021-07-05 at 4.57.08 PM.png (180.6 KB)

Here is the file :

1 Like

@beingignite

I have created a folder Fonts in the storage, uploaded my fonts in it and used the path as following without any issue. Please paste/upload your fonts to a folder instead of root and pass its path in the API call. It will resolve the issue.

SAPMPLE1.pdf (50.0 KB)

curl -X POST "http://localhost:8101/v3.0/slides/convert/Pdf?fontsFolder=Fonts" 
-H "accept: multipart/form-data" 
-H "authorization: Bearer [Access_Token]" 
-H "Content-Type: multipart/form-data" 
-F "document"="@C:/Temp/SAMPLE1.pptx" 
--output C:/Temp/SAPMPLE1.pdf

@beingignite

Please note with the release of Aspose.Slides Cloud 20.6 now another option is available for the use of custom fonts in addition to fontsFolder parameter option. You can mount a font volume for custom fonts when running Aspose.Slides Cloud Docker container and paste your custom fonts in it. In this case, you do not need to set fontsFolder parameter value anymore. These custom fonts will be available for all the API methods automatically.

-v "I:/Aspose/Docker/fonts:/fonts"