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"

1 Like

Yes it worked. Thanks @tilal.ahmad

1 Like

Hello @tilal.ahmad ,

I’m currently testing the Aspose.Slides cloud docker container, and I can’t seem to get the /fonts volume feature to work.

I’ve mounted a fonts folder as “/fonts”, same way as I mounted a different folder as “/storage”.
If I try to place the font file in /fonts and perform a conversion, the PDF has the wrong front.
If I use the fontsFolder parameter method, and point it to a fonts folder inside /storage, the PDF has the right font.
What am I doing wrong?

@totoguy,
Thank you for contacting support.

I’ve added a ticket with ID SLIDESCLOUD-1463 to our issue tracking system. Our development team will investigate this case. We will reply to you soon.

@totoguy,
Our development team investigated the issue. The fonts folder works successfully if you start the container with a command like as follows:
docker run -p 8088:80 -v "/home/user/test/data:/storage" -v "/home/user/test/fonts:/fonts" aspose/slides-cloud
If you place files into the folder after the container was started, it will not work. The fonts are initialized once when the container is started. So, you have to restart the container to apply the changes in fonts folder.