Missing Text when Converting PPTX to PDF with Aspose.Slides for Python

Hello,

we’ve been seeing issues with all text in some PPTX files missing from generated PDFs on our linux server. I’ll attach one of the files along with the code snippet and converted PDF here. The same code works fine on our local machines, which are also running linux.

None of the two machines have the font used in the PPTX installed, so I do not think this is a missing fonts issue. Would appreciate any help here.

Programming environment: Python v3.11
Aspose.Slides version: 24.11.0
Operating System: Ubuntu

example.7z (5.4 MB)

@randomusernamego,
Thank you for contacting free support.

Unfortunately, I was unable to reproduce the problem you described.
My output PDF looks fine: output.pdf (2.0 MB)

It looks like the fonts are not available for your application. Please try to read a font from your app. I hope this will help you to find the reason for the problem.

@andrey.potapov ,
Could you please give me a code snippet or documentation link to check what fonts Aspose.Slides can use?

Thanks

@randomusernamego,
You can use the FontsLoader to check where Aspose.Slides is loading fonts from using the code snippet below.

font_folders = FontsLoader.get_font_folders()

for folder_path in font_folders:
    print(folder_path)

More examples: Custom PowerPoint Font in Python|Aspose.Slides for Python Documentation

Thanks, running the below code on the server:

import aspose.slides as slides

slides.FontsLoader.load_external_fonts(["/usr/share/fonts/truetype/msttcorefonts/"])

fontFolders = list(slides.FontsLoader.get_font_folders())

print(fontFolders)

I get: ['/usr/share/fonts/truetype/msttcorefonts', '/usr/share/fonts', '/usr/local/share/fonts', 'fonts', '/home/luciodev/.fonts']

I do not have some of the fonts installed used in that PPTX in my machine, but I’m still able to convert it just fine. This issue only props up on the server.

Is there a way to pass a replacement font if some fonts are not found?

@randomusernamego,
Yes, you can use PdfOptions to set a default font for cases when fonts are not found. Please try using the following code example.

pdf_options = PdfOptions()
pdf_options.default_regular_font = "Arial"

with Presentation("sample.pptx") as presentation:
    presentation.save("output.pdf", SaveFormat.PDF, pdf_options)

More details: Default Font|Aspose.Slides for Python Documentation

@andrey.potapov,
I tried a variation of that code:

import aspose.slides as aspose_slides

slidesLicense = aspose_slides.License()
slidesLicense.set_license("LICENSE LOCATION")

aspose_slides.FontsLoader.load_external_fonts(
    ["/usr/share/fonts/truetype/msttcorefonts/"]
)

filename = "ai_ppt.pptx"
presentation = aspose_slides.Presentation(filename)

save_options = aspose_slides.export.PdfOptions()
save_options.default_regular_font = "Arial"
presentation.save("converted.pdf", aspose_slides.export.SaveFormat.PDF, save_options)

But I still got a PDF with missing text. I confirmed that Arial is indeed installed with fc-list | grep Arial

/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf: Arial:style=Italic,Cursiva,kurzíva,kursiv,Πλάγια,Kursivoitu,Italique,Dőlt,Corsivo,Cursief,Kursywa,Itálico,Курсив,İtalik,Poševno,nghiêng,Etzana
/usr/share/fonts/truetype/msttcorefonts/ariblk.ttf: Arial Black:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/truetype/msttcorefonts/Arial.ttf: Arial:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,thường,Arrunta
/usr/share/fonts/truetype/msttcorefonts/arialbd.ttf: Arial:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,đậm,Lodia
/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf: Arial:style=Bold Italic,Negreta cursiva,tučné kurzíva,fed kursiv,Fett Kursiv,Έντονα Πλάγια,Negrita Cursiva,Lihavoitu Kursivoi,Gras Italique,Félkövér dőlt,Grassetto Corsivo,Vet Cursief,Halvfet Kursiv,Pogrubiona kursywa,Negrito Itálico,Полужирный Курсив,Tučná kurzíva,Fet Kursiv,Kalın İtalik,Krepko poševno,nghiêng đậm,Lodi etzana
/usr/share/fonts/truetype/msttcorefonts/arialbi.ttf: Arial:style=Bold Italic,Negreta cursiva,tučné kurzíva,fed kursiv,Fett Kursiv,Έντονα Πλάγια,Negrita Cursiva,Lihavoitu Kursivoi,Gras Italique,Félkövér dőlt,Grassetto Corsivo,Vet Cursief,Halvfet Kursiv,Pogrubiona kursywa,Negrito Itálico,Полужирный Курсив,Tučná kurzíva,Fet Kursiv,Kalın İtalik,Krepko poševno,nghiêng đậm,Lodi etzana
/usr/share/fonts/truetype/msttcorefonts/Arial_Black.ttf: Arial Black:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf: Arial:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,đậm,Lodia
/usr/share/fonts/truetype/msttcorefonts/ariali.ttf: Arial:style=Italic,Cursiva,kurzíva,kursiv,Πλάγια,Kursivoitu,Italique,Dőlt,Corsivo,Cursief,Kursywa,Itálico,Курсив,İtalik,Poševno,nghiêng,Etzana

@randomusernamego,
Please check if your application has access to the fonts. You can use the following code.

file_path = "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf"

try:
    with open(file_path, "rb") as file_stream:
        file_data = file_stream.read()
        data_length = len(file_data)
        print(f"Read {data_length} bytes from the file.")
except Exception as e:
        print(f"Error: {e}")

It does. Here’s the output:

Read 275572 bytes from the file.

@randomusernamego,
Could you please specify the OS version where the problem occurs?

Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
Codename: noble

@randomusernamego,
Thank you for the details. I need some time to check the problem. I will get back to you soon.

1 Like

@randomusernamego,
I’ve reproduced the problem you described. We apologize for any inconvenience caused.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESPYNET-242

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like