Set Default Font Name

[ ]

Aspose.PDF for .NET API allows you to set a default font name when a font is not available in the document. You can use DefaultFontName property of RenderingOptions class to set the default font name. In case DefaultFontName is set to null the Times New Roman font will be used. The following code snippet shows how to set a default font name when saving PDF into an image:

// For complete examples and data files, please go to
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();

using (Document pdfDocument = new Document(dataDir + "input.pdf"))
    using (FileStream imageStream = new FileStream(dataDir + "SetDefaultFontName.png", FileMode.Create))
        Resolution resolution = new Resolution(300);
        PngDevice pngDevice = new PngDevice(resolution);
        RenderingOptions ro = new RenderingOptions();
        ro.DefaultFontName = "Arial";
        pngDevice.RenderingOptions = ro;
        pngDevice.Process(pdfDocument.Pages[1], imageStream);