Set PDF Metadata in C++

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.

  1. Create PdfFileInfo with the input PDF path.
  2. Set subject through PdfFileInfo using the example values.
  3. Set title through PdfFileInfo using the example values.
  4. Set keywords through PdfFileInfo using the example values.
  5. Set creator through PdfFileInfo using the example values.
  6. Set custom metadata with PdfFileInfo::SetMetaInfo().
  7. Save the resulting PDF with PdfFileInfo::Save().
  8. 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