Fonts source

Hi Team, when we were onPrem , we use to add all our required fonts ( Including Customised fonts ) in c:/Windows/Font

folder so that we dont get “Font not found exception” when we are converting to PDFA3B format.

But now we are moving to Azure cloud and now we dont know from where system will try to check the Fonts. Can you please give us the code snippet to refer how we can set the Source for Font ?? from where system wil look for fonts ??

@GayatriNaik

To set the source for fonts in your application when moving to Azure cloud, you can specify the path to your font files using the FileSystemStreamSource class. This allows you to load custom fonts from a specified directory.

Here’s a code snippet demonstrating how to do this:

import com.aspose.font.FileSystemStreamSource;
import com.aspose.font.Font;
import com.aspose.font.FontDefinition;
import com.aspose.font.FontFileDefinition;
import com.aspose.font.FontType;
import com.aspose.font.TtfFont;
import com.aspose.font.utilities.Utils;

public class LoadCustomFont {
    public static void main(String[] args) {
        // Specify the full path to your font file
        String fontFilePath = "path/to/your/font/Montserrat-Regular.ttf"; // Update this path

        // Create a FontDefinition using the font file
        FontDefinition fontDefinition = new FontDefinition(FontType.TTF, new FontFileDefinition("ttf", new FileSystemStreamSource(fontFilePath)));
        
        // Open the font
        TtfFont font = (TtfFont) Font.open(fontDefinition);

        // You can now use the font in your application
        System.out.println("Loaded font: " + font.getFontName());
    }
}

In this example, replace "path/to/your/font/Montserrat-Regular.ttf" with the actual path where your font files are stored in Azure. This approach allows your application to access the required fonts without encountering “Font not found” exceptions during PDF conversions.

Make sure that the font files are accessible from the Azure environment where your application is running. You may need to adjust permissions or storage settings accordingly.

If you have any further questions or need additional assistance, feel free to ask!

can you please let me know in above code i can see its FontFilePath which is for 1 single text, But ideally we will be having aroung 150+ fonts so how we will handle it and when should we load this fonts when converting from PDF to PDFA3B format

Hi, @GayatriNaik
Are you using a self-hosting Pdf Cloud image or the cloud service itself?

We are using Azure WebService for Hosting our application . we also will be using azure Cloud storage to store documents