下面是我写的全部CPP代码
#include <Aspose.Words.Cpp/Document.h>
#include <Aspose.Words.Cpp/DocumentBuilder.h>
#include <Aspose.Words.Cpp/Drawing/Shape.h>
#include <Aspose.Words.Cpp/Drawing/ImageData.h>
#include <Aspose.Words.Cpp/SaveFormat.h>
#include <Aspose.Words.Cpp/Saving/IResourceSavingCallback.h>
#include <Aspose.Words.Cpp/Saving/ResourceSavingArgs.h>
#include <Aspose.Words.Cpp/Saving/SaveOutputParameters.h>
#include <Aspose.Words.Cpp/Saving/SvgSaveOptions.h>
#include <Aspose.Words.Cpp/Saving/SvgTextOutputMode.h>
int main(void) {
auto doc{ System::MakeObject<Aspose::Words::Document>() };
auto builder{ System::MakeObject<Aspose::Words::DocumentBuilder>(doc) };
auto shape{ builder->InsertImage(u"Input.svg") };
shape->get_ImageData()->Save(u"Output.jpg");
return 0;
}
下面是当前目录的的Input.svg文件代码,其中字体Source Han Sans CN是自己Windows上安装的一个字体
<svg version="1.1"
baseProfile="full"
width="1024" height="540"
xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="black" />
<text x="50" y="50" font-family="Source Han Sans CN" font-weight="400" fill="white" font-size="16">Test Font</text>
</svg>
这里自己打开浏览器查看字体是这个样的:
1.png (7.9 KB)
但是程序生成的是这样的:
Output.png (434 字节)
如何解决呢