Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
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);
}
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.