Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Jul 17, 2024 6:46 am

Hello,

I am encountering the following error while using the Python Spire.Doc library within a Docker container:

Code: Select all
2024-07-17 08:28:29 An error occurred during conversion: Cannot found font installed on the system.:   at sprdv4..ctor() + 0x69d
2024-07-17 08:28:29    at Spire.Doc.Layout.Fields.FieldOptions..ctor() + 0x64
2024-07-17 08:28:29    at sprddu.sprc(sprc6c) + 0x3d
2024-07-17 08:28:29    at sprddu.sprd(sprc6c) + 0x1c
2024-07-17 08:28:29    at sprddu.sprl(sprddn) + 0x6a
2024-07-17 08:28:29    at sprddu.spro(sprddn) + 0xbb
2024-07-17 08:28:29    at sprddu.sprr(sprddn) + 0x5a
2024-07-17 08:28:29    at sprddu.sprb(sprddo) + 0xa7
2024-07-17 08:28:29    at sprddu.spra(sprddx, sprddx) + 0x5a
2024-07-17 08:28:29    at sprddu.sprd(sprc6c, sprc7m) + 0x6e
2024-07-17 08:28:29    at sprddu.sprb(sprc6c, sprc7m) + 0x60
2024-07-17 08:28:29    at sprddu.sprc(sprc6c, sprc7m) + 0x14
2024-07-17 08:28:29    at sprdpb.spra(sprc6c, sprdpc, Boolean) + 0x31
2024-07-17 08:28:29    at sprdkz.spra(sprdlp, sprdby) + 0x123
2024-07-17 08:28:29    at sprdkz.spra(sprdl4, Hashtable, sprdby) + 0xc0
2024-07-17 08:28:29    at sprdkz.spra(sprdoe) + 0xc4
2024-07-17 08:28:29    at sprc5l.spra(Document, sprc4q) + 0x2c8
2024-07-17 08:28:29    at Spire.Doc.Document.spra(ToPdfParameterList) + 0x9e
2024-07-17 08:28:29    at Spire.Doc.Document.UpdatePageLayout() + 0x1e
2024-07-17 08:28:29    at sprdda.spra() + 0x31
2024-07-17 08:28:29    at sprdc9.sprc(sprddx) + 0x74
2024-07-17 08:28:29    at sprddu.spra(sprddx, sprddx) + 0x4f
2024-07-17 08:28:29    at sprddu.spra(DocumentObject, sprddu) + 0x57
2024-07-17 08:28:29    at Spire.Doc.Document.sprc() + 0x4c
2024-07-17 08:28:29    at Spire.Doc.Document.spra(Stream, ToPdfParameterList, FileFormat) + 0x1ac
2024-07-17 08:28:29    at Spire.Doc.Document.spre(String, ToPdfParameterList) + 0xfa
2024-07-17 08:28:29    at Spire.Doc.AOT.NLDocument.Document_SaveToFileFP(IntPtr, IntPtr, IntPtr, IntPtr) + 0x83


Code: Select all
from spire.doc import Document as SpireDocument, FileFormat
document = SpireDocument(f"{name_generated_file}.docx")
document.SaveToFile("temp.pdf", FileFormat.PDF)
document.Close()


I have searched online for solutions and tried several methods, but none have worked so far. Do you have any suggestions on how to resolve this issue?

Thank you for your help.

yruffieux
 
Posts: 3
Joined: Wed Jul 17, 2024 6:17 am

Wed Jul 17, 2024 8:18 am

Hello,

Thanks for your inquiry.
Kindly note that the conversion file will read the font files in the "/usr/share/fonts“ directory, so before converting, please make sure that the fonts used in the word file have been installed in the container. In addition, the docker container does not seem to have a font directory by default. So you need to create this directory first and then install the fonts for the container. You can also search on Google for how to install fonts for Docker containers. If you have any other questions, please feel free to write back.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Wed Jul 17, 2024 1:33 pm

We had a very similar issue in a Debian-based container! The solution for us was to add the following lines to the Dockerfile:

Code: Select all
RUN echo "deb http://deb.debian.org/debian bookworm contrib non-free" > /etc/apt/sources.list.d/contrib.list
RUN apt-get update && apt-get install -y --no-install-recommends ttf-mscorefonts-installer
ENV LD_LIBRARY_PATH=/usr/share/fonts:usr/local/share/fonts

ericcampbell
 
Posts: 10
Joined: Thu Jun 27, 2024 10:39 pm

Thu Jul 18, 2024 6:45 am

ericcampbell wrote:We had a very similar issue in a Debian-based container! The solution for us was to add the following lines to the Dockerfile:

Code: Select all
RUN echo "deb http://deb.debian.org/debian bookworm contrib non-free" > /etc/apt/sources.list.d/contrib.list
RUN apt-get update && apt-get install -y --no-install-recommends ttf-mscorefonts-installer
ENV LD_LIBRARY_PATH=/usr/share/fonts:usr/local/share/fonts


Thank you so much Eric, it works also for me !

Have a good day ;)

yruffieux
 
Posts: 3
Joined: Wed Jul 17, 2024 6:17 am

Return to Spire.Doc