기본 글꼴 이름 설정

Contents
[ ]

Aspose.PDF for .NET API는 문서에서 글꼴을 사용할 수 없을 때 기본 글꼴 이름을 설정할 수 있도록 합니다. RenderingOptions 클래스의 DefaultFontName 속성을 사용하여 기본 글꼴 이름을 설정할 수 있습니다. DefaultFontName이 null로 설정된 경우 Times New Roman 글꼴이 사용됩니다. 다음 코드 조각은 PDF를 이미지로 저장할 때 기본 글꼴 이름을 설정하는 방법을 보여줍니다:

다음 코드 조각은 Aspose.Drawing 라이브러리와도 작동합니다.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ConvertPdfToImageWithDefaultFont()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "PdfToImageWithDefaultFont.pdf"))
    {
        // Open the image stream
        using (var imageStream = new FileStream(dataDir + "SetDefaultFontName.png", FileMode.Create))
        {
            // Set the resolution for the image
            var resolution = new Aspose.Pdf.Devices.Resolution(300);

            // Create the PNG device and set rendering options
            var pngDevice = new Aspose.Pdf.Devices.PngDevice(resolution);
            var ro = new Aspose.Pdf.RenderingOptions
            {
                DefaultFontName = "Arial"
            };
            pngDevice.RenderingOptions = ro;

            // Process the first page of the document and save it as an image
            pngDevice.Process(document.Pages[1], imageStream);
        }
    }
}