Add Margins to PDF Pages in C++

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

Add margins to PDF pages

Apply margins of 36 points on each side of pages 1 and 3.

  1. Create PdfFileEditor.
  2. Apply page margins with PdfFileEditor::AddMargins().
#include <Aspose.PDF.Cpp/Facades/PdfFileEditor.h>
#include <system/array.h>
#include <system/string.h>

namespace Facades::Examples::PDF_FileEditor
{
	using namespace System;
	using namespace Aspose::Pdf;
	using namespace Aspose::Pdf::Facades;

	void AddMarginsToPdfPages(String inputFile, String outputFile)
	{
		auto pdfEditor = MakeObject<PdfFileEditor>();
		pdfEditor->AddMargins(inputFile, outputFile, MakeArray<int32_t>({ 1, 3 }), 36, 36, 36, 36);
	}
} // namespace  Facades::Examples::PDF_FileEditor