Save Metadata with XMP in C++

Use PdfFileInfo for this task. The examples below retain the original C++ code and API Reference steps.

Save info with XMP

Set subject, title, keywords, and creator and save the updated document information with XMP.

  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. Save document information and XMP with PdfFileInfo::SaveNewInfoWithXmp().
  7. 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 SaveInfoWithXmp(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->SaveNewInfoWithXmp(outputFile);
		pdfInfo->Close();
	}
} // namespace Facades::Examples::PDF_FileInfo