你好,我想向pdf文件中增加水印,但是auto artifact = MakeObject();行报错,
错误代码:System::ExceptionWrapperAspose::Pdf::Details_FontNotFoundException at memory location 0x014FE370.这个错误怎么去除呢?
测试代码如下:
void GettingWatermarks() {
String _dataDir("C:\\Samples\\");
String inputFileName("watermark.pdf");
String outputFileName("watermark_out.pdf");
auto document = MakeObject<Document>(_dataDir + inputFileName);
auto artifact = MakeObject<WatermarkArtifact>();
auto textState = MakeObject<TextState>();
textState->set_FontSize(72);
textState->set_ForegroundColor(Color::get_Blue());
textState->set_Font(FontRepository::FindFont(u"Courier"));
artifact->SetTextAndState(u"WATERMARK", textState);
artifact->set_ArtifactHorizontalAlignment (HorizontalAlignment::Center);
artifact->set_ArtifactVerticalAlignment (VerticalAlignment::Center);
artifact->set_Rotation(45);
artifact->set_Opacity(0.5);
artifact->set_IsBackground(true);
document->get_Pages()->idx_get(1)->get_Artifacts()->Add(artifact);
document->Save(_dataDir + outputFileName);
}