We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issue with fonts not being included when saving Word document as PDF

Hi,

I am trying to convert a Word document to PDF that contains Japanese characters on a linux machine.

The Word document includes the font Noto Sans CJK JP Regular and I verify that it is included in the document on the server with the following code

FontInfoCollection fontsInfo = doc.getFontInfos();
for (FontInfo info : fontsInfo) {
    logger*** .debug("Font name: " + info.getName());
}

And I can see the following logging on the server

“Font name: Noto Sans CJK JP Regular”

When I save the document to a PDF I am getting the following warning from the

I am getting the following warning from the IWarningCallback callback

“ Font substitution: Font 'Noto Sans CJK JP Regular' has not been found. Using 'DejaVu Sans Condensed' font instead. Reason: closest match according to font info from the document.”

The font Noto Sans CJK JP Regular is an OpenType font downloaded from https://www.google.com/get/noto/

In this thread, OTF support in aspose, it is stated that OpenType fonts should be supported.

When I try the same on my Windows machine, where the font Noto Sans CJK JP Regular is installed, it works fine.
Aspose.Word version 18.9

RetrieveJapanese.zip (2.2 MB)

@eklind

Thanks for your inquiry. Could you please ZIP and attach the problematic PDF along with operating system detail here for our reference? We will investigate the issue on our side and provide you more information on it.

@eklind

Thanks for your inquiry. Could you please ZIP and attach the problematic PDF along with operating system detail here for our reference? We will investigate the issue on our side and provide you more information on it.

Realized I had posted the wrong files. Sorry about that. A have attached a new ZIP file with one Word file using an OpenType font and one with an TrueType font + PDFs saved on Linux and Windows. When using TrueType fonts it works on Linux, when using OpenType it does not work.

I have another issue as well with fonts. Tell me if you want me to create a separate issue.

When I use a TrueType font and setting some of the text as bold, the bold text is not saved correctly in the PDF when saved on Linux. On Windows it works (where I have the fonts installed). The Word document embeds the font used.Bold.zip (1.2 MB)

@eklind

We have tested the scenario using the latest version of Aspose.Words for Java 18.9 and have not found the shared issue. Please check the attached output PDF. 18.9.pdf (1.0 MB)

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-17471. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

I am also using Aspose.Word for Java 18.9 but I cannot get it to work when using Bold on my text and saving the pdf on a machine where the fonts is not already installed. I have verified this on both Linux and Windows.

I could not download the file you uploaded (18.9) due to error “Sorry, this file is private. Only visible to topic owner and staff members.”, which is strange since I thought I was the topic owner.

This is my test code

Document doc = new Document("Test_TrueType_Bold.docx");
PdfSaveOptions saveOptions = new PdfSaveOptions();
doc.save("Test_TrueType_Bold.pdf", saveOptions);

Is there something I am doing wrong?

I have attached the word file and result when I run on Windows where the fonts does not exists.
This is the Java version I am using
java version “1.8.0_161”
Java™ SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot™ 64-Bit Server VM (build 25.161-b12, mixed mode)

Bold.zip (1.2 MB)

@eklind

Please accept my apologies for your inconvenience. The issue related to bold font formatting was logged as WORDSNET-17471. We are unable to reproduce the second issue related to OpenType fonts.

I am also using Aspose Word for Java 18.9 but I cannot get it to work when saving a PDF from a Word document and an OpenType font is embedded in the Word document. If the font is installed on the machine it works, it the font is removed it does not work. I have verified this on both Windows and Linux.

This is my code
public static void main(String[] args) throws Exception {

	Test test = new Test();
	test.generate();
}

public void generate() throws Exception {
	wordsLicense.setLicense("Aspose.Total.Java.lic");

	Document doc = new Document(new FileInputStream("Test_OpenType.docx"));
	printFontInfo(doc);

	PdfSaveOptions saveOptions = new PdfSaveOptions();
	doc.setWarningCallback(new HandleDocumentWarnings());
	doc.save(new FileOutputStream("Test_OpenType.pdf"), saveOptions);
}

public class HandleDocumentWarnings implements IWarningCallback {
	public void warning(WarningInfo info) {
		if (info.getWarningType() == WarningType.FONT_SUBSTITUTION) {
			System.out.println("Font substitution: " + info.getDescription());
		}
	}
}

private void printFontInfo(Document doc) {
	FontInfoCollection fontsInfo = doc.getFontInfos();
	for (FontInfo info : fontsInfo) {
		System.out.println("Font name: " + info.getName());
		System.out.println("   Is TrueType: " + info.isTrueType());
	}
}

and this is the output I am getting on Windows

Font name: Noto Sans CJK JP Regular
   Is TrueType: false
Font name: Times New Roman
   Is TrueType: true
Font name: MS Gothic
   Is TrueType: true
Font substitution: Font 'Noto Sans CJK JP Regular' has not been found. Using 'Malgun Gothic Semilight' font instead. Reason: closest match according to font info from the document.

and this is the output I am getting on Linux

Font name: Noto Sans CJK JP Regular
   Is TrueType: false
Font name: Times New Roman
   Is TrueType: true
Font name: MS Gothic
   Is TrueType: true
Font substitution: Font 'Noto Sans CJK JP Regular' has not been found. Using 'DejaVu Sans Condensed' font instead. Reason: closest match according to font info from the document.

Attached is the Word file I am using and the output from Windows.Windows.zip (621.5 KB)

@eklind

Thanks for sharing the detail. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-17484 . You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

I have customers that are eager to get this fixed. Is it possible to get any time estimate when WORDSNET-17471 and WORDSNET-17484 will be fixed?
Thanks

@eklind,

Thanks for your inquiry. We try our best to deal with every customer request in a timely fashion, we unfortunately cannot guarantee a delivery date to every customer issue. We work on issues on a first come, first served basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.

Currently, your issues are pending for analysis and are in the queue. Once we complete the analysis of your issues, we will then be able to provide you an estimate.

You reported this issue in the free support forum and it will be treated with normal priority. To speed up the progress of issue’s resolution, we suggest you please check our paid support policies from following link.
Paid Support Policies

@eklind,

Thanks for your patience. Please note that Aspose.Words mimics the behavior of MS Word. Regarding WORDSNET-17484, If you embed the font “Noto Sans CJK JP Regular” into document using MS Word, it is not embedded into document. So, it is not a bug in Aspose.Words.

The issues you have found earlier (filed as WORDSNET-17471) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by mudassir.raza