Inspect PDF shape bounds checking in C++

Bounds checking: disabled source example

Page creation, graph setup, and bounds checking are inside a block comment. The active function does not perform a bounds check or explicitly add a page.

  1. Create a Document.
  2. Inspect the commented setup for a 100-by-100 Graph.
  3. Review the drawing Aspose::Pdf::Drawing::Rectangle positioned at x = -1.
  4. Inspect the call to UpdateBoundsCheckMode() with ThrowExceptionIfDoesNotFit.
  5. Review the shape addition and System::Exception handler.
  6. Save the PDF with Save().
#include <Aspose.PDF.Cpp/Color.h>
#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/Generator/BorderInfo.h>
#include <Aspose.PDF.Cpp/Generator/BorderSide.h>
#include <Aspose.PDF.Cpp/Generator/BoundsCheckableList/BoundsCheckableList.h>
#include <Aspose.PDF.Cpp/Generator/BoundsCheckableList/BoundsCheckMode.h>
#include <Aspose.PDF.Cpp/Generator/Drawing/Graph.h>
#include <Aspose.PDF.Cpp/Generator/Drawing/Rectangle.h>
#include <Aspose.PDF.Cpp/Generator/GraphInfo.h>
#include <Aspose.PDF.Cpp/Generator/Paragraphs.h>
#include <Aspose.PDF.Cpp/Page.h>
#include <Aspose.PDF.Cpp/PageCollection.h>
#include <system/exceptions.h>
#include <iostream>

using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Drawing;

void GraphExamples::CheckShapeBounds(String outputFile)
{
    auto document = MakeObject<Document>();
    /*auto page = document->get_Pages()->Add();
    auto graph = MakeObject<Graph>(100.0, 100.0);
    graph->set_Top(10);
    graph->set_Left(15);
    graph->set_Border(MakeObject<BorderInfo>(BorderSide::Box, 1, Color::get_Black()));
    page->get_Paragraphs()->Add(graph);

    auto rectangle = MakeObject<Aspose::Pdf::Drawing::Rectangle>(-1, 0, 50, 50);
    rectangle->get_GraphInfo()->set_FillColor(Color::get_Tomato());
    try
    {
        graph->get_Shapes()->UpdateBoundsCheckMode(BoundsCheckMode::ThrowExceptionIfDoesNotFit);
        graph->get_Shapes()->Add(rectangle);
    }
    catch (const System::Exception &ex)
    {
        std::cout << ex->get_Message() << std::endl;
    }*/

    document->Save(outputFile);
}