Set PDF Metadata in C++
Contents
[
Hide
]
Use PdfFileInfo for this task. The examples below retain the original C++ code and API Reference steps.
Set PDF metadata
Set standard document information and the custom CustomKey value.
- Create PdfFileInfo with the input PDF path.
- Set subject through PdfFileInfo using the example values.
- Set title through PdfFileInfo using the example values.
- Set keywords through PdfFileInfo using the example values.
- Set creator through PdfFileInfo using the example values.
- Set custom metadata with PdfFileInfo::SetMetaInfo().
- Save the resulting PDF with PdfFileInfo::
Save(). - Close the facade with PdfFileInfo::
Close().
#include <Aspose.PDF.Cpp/Facades/PdfFileInfo.h>
#include <system/string.h>
namespace Facades::Examples::PDF_FileInfo
{
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Facades;
void SetPdfMetadata(String inputFile, String outputFile)
{
auto pdfInfo = MakeObject<PdfFileInfo>(inputFile);
pdfInfo->set_Subject(u"Aspose PDF for C++");
pdfInfo->set_Title(u"Aspose PDF for C++");
pdfInfo->set_Keywords(u"Aspose, PDF, C++");
pdfInfo->set_Creator(u"Aspose Team");
pdfInfo->SetMetaInfo(u"CustomKey", u"CustomValue");
pdfInfo->Save(outputFile);
pdfInfo->Close();
}
} // namespace Facades::Examples::PDF_FileInfo