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.

Thu Jul 28, 2022 7:44 am

Hello!

I have a problem with the DOCX to PDF tool. When I test the tool in my local enviroment, it transforms the files correcly, but if I do the same in my server, the resultant PDF file change the font from Times New Roman to Cambria. Is there any way to prevent this? I don't understand why this diferent between local and production server.

Thanks so much!

borja981
 
Posts: 4
Joined: Thu Jun 16, 2022 7:50 am

Thu Jul 28, 2022 9:48 am

Hi,

Please note that when converting word to PDF, our Spire.Doc needs to find the corresponding font used by Word document in system. If your server lacks the font, it will select other fonts to do replacement. So please check whether your server has the Times New Roman font installed.
If the problem still exists after installation, please provide information as below to help us better investigate your issue. Please attach your file here or send to us via email (support@e-iceblue.com). Thank you in advance.
1) Your input document
2) JDK version such as, JDK 1.8.0_281
3) Your server information such as Centos 7

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Fri Jul 29, 2022 8:08 am

Hi,

Thank you for sharing the document via email.
I tested your files in Debian, but still didn’t encounter your issue. I sent the Times New Roman fonts and my output Pdfs to your email. I suggest that you install my fonts in your system to try again. Or you can add the following code to set font folder:
Code: Select all
PdfDocument.setCustomFontsFolders(fontfoldepath);
Document document=new Document();
document.loadFromFile(filepath);
document.saveToFile("result.pdf", FileFormat.PDF);

By the way, the latest Spire.Doc is Spire.Doc for Java Version:10.7.10, if you were not using the latest version, I suggest that you give it a try.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.Doc