I am trying to covert a file that is exclusively written in Times New Roman, although the font varies in size throughout the document. Furthermore, the Times New Roman is sometimes bold, other times italicized and other times bold and italicized (and the rest of the time it is normal with no such modifications). I wish to use Java code to convert this .docx file to a pdf format and I understand that there is a nice tutorial to specifiy the path of the font in .ttf file format given by the developer ("Font" under "Program Guide" titled: Embed Private Fonts When Saving Word to DOCX and PDF in Java). However since my file uses multiple different fonts effectively (i.e. bold Times New Roman, italicized Times New Roman, etc...), would you please tell me how do I adapt/modify the tutorial code to accomodate such multiple different fonts (all in .ttf file format) in my one conversion program?
My present code looks like this:
import com.spire.doc.Document;
import com.spire.doc.FileFormat;
import java.io.File;
public class App
{
public static void main( String[] args )
{
String cwd = System.getProperty("user.dir"); String fileName = null;
if (args.length >= 1) {
fileName = args[0];
}
Document doc = new Document(cwd + File.separator + fileName);
doc.saveToFile("convertedToPDF.pdf", FileFormat.PDF);
}
}
and I get the following error:
java.lang.IllegalStateException: Cannot find any fonts in specified font sources.
If it makes a difference, there is a table containing such text in my Word/.docx file. Thanks for any pointers you can give.
Bill