Initializing custom fonts for Words and PDF

Hi,

Working with an java application that uses both Aspose.Words and Aspose.PDF to convert files to PDF/A (version 23.12).

The application runs on linux and need to load windows fonts to get the correct fonts in the PDF/A file.

I have used the following code to load the fonts just before the actual convertion

// Aspose.Words
FontSettings.getDefaultInstance().setFontsFolder("/some/path/", true);

// Aspose.PDF
FontRepository.getSources().add(new FolderFontSource("/some/path/"));

and the results looks good with the correct fonts.

Why is there a difference between Words and PDF how to setup?

I have also a question about initialization. Setting up the fonts right before each conversion will take additional time.

Is there a recommended way to do font setup at application start?
and is there a way to setup for all Aspose libraries instead of using explicit setup for each?

Best Regards

@010101 Aspose.Words and Aspose.PDF are completely independent products, so they have differences in their public API.

It is not required to setup font source each time before conversion since such operation might be very time consuming. You can setup font sources once on application start. Aspose.Words caches the fonts and use them in further operations.

Actually, it is not required to use both Aspose.Words and Aspose.PDF to convert MS Word document to PDF/A. You can simply specify PDF compliance in PdfSaveOptions:

Document doc = new Document("C:\\Temp\\in.docx");
PdfSaveOptions opt = new PdfSaveOptions();
opt.setCompliance(PdfCompliance.PDF_A_1_A);
doc.save("C:\\Temp\\out.pdf", opt);