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.

Mon Apr 15, 2024 5:13 am

Hello,
We are trying to convert a DOCX to PDF using spire.doc v12.3.12 in .net8 and we are getting this error:

System.InvalidOperationException: 'Cannot find any fonts in specified font sources.'

The code I am using is as follows:

string subPath = "wwwroot/temp/";
Spire.Doc.Document doc2 = new Spire.Doc.Document();
doc2.LoadFromFile(@subPath + "/" + formSubmissionId.ToString() + ".docx");

bool fileexists = System.IO.File.Exists(subPath + "/" + formSubmissionId.ToString() + ".pdf");

if (fileexists)
System.IO.File.Delete(subPath + "/" + formSubmissionId.ToString() + ".pdf");

//Convert Word to PDF
doc2.SaveToFile(subPath + "/" + formSubmissionId.ToString() + ".pdf", FileFormat.PDF);

I have uploaded a sample word document with some details modified to protect the user.

If you need anything else, please let me know.

Thanks
Michael

michaelvanderveeke
 
Posts: 1
Joined: Mon Apr 15, 2024 4:29 am

Mon Apr 15, 2024 6:07 am

Hi,

Thanks for your inquiry.
According to the exception message(Cannot find any fonts in specified font sources.), the reason of your issue is that the fonts used in Word file don’t exist in the server. Please put these fonts into system font folder then test again, if your server is Linux system, the system font folder is
Code: Select all
/usr/share/font.


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.Doc

cron