使用文档编程 | Aspose.PUB for C++

编辑 PUB 文件的元数据

.pub 文件的元数据###

Microsoft Publisher (.pub) 文件有关于文件本身的元数据信息。通常包括

元数据描述
标题出版物的标题。
作者创建出版物的个人或实体的名称。
主题与出版物相关的简短描述或主题。
关键词用于描述出版物内容的相关关键词或标签。
评论与出版物相关的附加说明。
创建日期出版物最初创建的日期。
修改日期出版物最后编辑的日期。
最后一位作者上次对文档进行更改的人员的姓名。
模板如果出版物是基于模板创建的,则元数据可能包含有关所用模板的信息。

Aspose.PUB for C++ 提供的处理 .pub 文件元数据的功能###

文档的元数据描述了其属性,如作者、瓦片、公司、语言和其他类似信息。Aspose.PUB for C++ 可以读取元数据信息,并在将 PUB 转换为 PDF 的过程中进行更新。以下示例代码展示了如何读取 .pub 文件、编辑其元数据并转换为 PDF。但首先要初始化一个许可证对象,并使用位于特定目录中的许可证文件进行设置。

 1    // Initialize the license object
 2    auto license = System::MakeObject<Aspose::Pub::License>();
 3    // Set the license
 4    license->SetLicense(dataDir() + u"License\\Aspose.PUB.C++.lic");
 5
 6    System::String filePub = dataDir() + u"1.pub";
 7    System::String filePdf = dataDir() + u"1.pdf";
 8
 9    System::Console::WriteLine(u"Convert starting...");
10
11    System::SharedPtr<IPubParser> parser = PubFactory::CreateParser(filePub);
12    System::SharedPtr<Document> document = parser->Parse();
13
14    document->get_DocumentSummaryInfo()->SetCompany(u"company");
15    document->get_DocumentSummaryInfo()->SetCategory(u"category");
16    document->get_DocumentSummaryInfo()->SetLanguage(u"language");
17
18    document->get_SummaryInfo()->SetAuthor(u"author");
19    document->get_SummaryInfo()->SetComments(u"comments");
20    document->get_SummaryInfo()->SetTitle(u"title");
21    document->get_SummaryInfo()->SetSubject(u"subject");
22    document->get_SummaryInfo()->SetKeywords(u"keywords");
23	
24    // Convert PUB to PDF
25    PubFactory::CreatePdfConverter()->ConvertToPdf(document, filePdf);
26
27    System::Console::WriteLine(u"Convert done."); 

要了解完整的 C++ 代码示例和数据文件,请访问 Aspose.PUB-Documentation for C++ Github 项目

Aspose.PUB 提供的这一功能和其他功能也在一组 用于处理 .pub 文件的跨平台应用程序 中实现。

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.