使用C++设置默认字体名称
Contents
[
Hide
]
Aspose.PDF for C++ API允许您在文档中没有可用字体时设置默认字体名称。您可以使用RenderingOptions类的DefaultFontName属性来设置默认字体名称。如果将DefaultFontName设置为nullptr
,将使用Times New Roman字体。以下代码片段显示了如何在将PDF保存为图像时设置默认字体名称:
void WorkingWithImages::ExampleSetDefaultFontName()
{
String _dataDir("C:\\Samples\\");
auto document = MakeObject<Document>(_dataDir + u"input.pdf");
auto imageStream = System::IO::File::OpenWrite(_dataDir + u"SetDefaultFontName.png");
auto resolution = MakeObject<Aspose::Pdf::Devices::Resolution>(300);
auto pngDevice = MakeObject<Aspose::Pdf::Devices::PngDevice>(resolution);
auto ro = MakeObject<RenderingOptions>();
ro->set_DefaultFontName(u"Arial");
pngDevice->set_RenderingOptions(ro);
pngDevice->Process(document->get_Pages()->idx_get(1), imageStream);
}