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:
Metadata | Description |
---|---|
Title | The title of the publication. |
Author | The name of the person or entity who created the publication. |
Subject | A brief description or topic associated with the publication. |
Keywords | Relevant keywords or tags to describe the content of the publication. |
Comments | Additional notes related to the publication. |
Creation Date | The date when the publication was originally created. |
Modification Date | The date when the publication was last edited. |
Last Author | The name of the person who last made changes to the document. |
Template | If 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.