Programming with Documents | Aspose.PUB for C++

Edit MetaData of PUB Files

Metadata of .pub files

Microsoft Publisher (.pub) files have metadata information about the file itself. There is typically included:

MetadataDescription
TitleThe title of the publication.
AuthorThe name of the person or entity who created the publication.
SubjectA brief description or topic associated with the publication.
KeywordsRelevant keywords or tags to describe the content of the publication.
CommentsAdditional notes related to the publication.
Creation DateThe date when the publication was originally created.
Modification DateThe date when the publication was last edited.
Last AuthorThe name of the person who last made changes to the document.
TemplateIf the publication is created from a template, the metadata may include information about the template used.

Functionality to work with metadata of .pub files provided by Aspose.PUB for C++

A document’s metadata describes its properties such as author, tile, company, language, and other similar information. Aspose.PUB for C++ can read the metadata information as well as update it during PUB to PDF conversion. The following sample code shows how to read a .pub file, edit its metadata and convert to PDF. But first, a license object is initialized and set with a license file located in a specific directory.

 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."); 

To learn the complete C++ code examples and data files, please go to Aspose.PUB-Documentation for C++ Github project.

This and other functionality provided by Aspose.PUB is also implemented into a set of cross-platform applications to manipulate .pub files.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.