Aspose::Words::Layout::PageLayoutCallbackArgs Class Reference

Detailed Description

An argument passed into Notify()

#include <Aspose.Words.Cpp/Layout/PageLayoutCallbackArgs.h>

+ Inheritance diagram for Aspose::Words::Layout::PageLayoutCallbackArgs:

Public Member Functions

SharedPtr< Documentget_Document () const
 Gets document. More...
 
PageLayoutEvent get_Event () const
 Gets event. More...
 
int32_t get_PageIndex ()
 Gets 0-based index of the page in the document this event relates to. Returns negative value if there is no associated page, or if page was removed during reflow. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 

Static Public Member Functions

static const TypeInfoType ()
 

Member Function Documentation

◆ get_Document()

System::SharedPtr<Aspose::Words::Document> Aspose::Words::Layout::PageLayoutCallbackArgs::get_Document ( ) const

Gets document.

Examples

Shows how to track layout changes with a layout callback.

void PageLayoutCallback()
{
auto doc = MakeObject<Document>();
doc->get_BuiltInDocumentProperties()->set_Title(u"My Document");
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
doc->get_LayoutOptions()->set_Callback(MakeObject<ExLayout::RenderPageLayoutCallback>());
doc->UpdatePageLayout();
doc->Save(ArtifactsDir + u"Layout.PageLayoutCallback.pdf");
}
class RenderPageLayoutCallback : public IPageLayoutCallback
{
public:
void Notify(SharedPtr<PageLayoutCallbackArgs> a) override
{
switch (a->get_Event())
{
NotifyPartFinished(a);
break;
NotifyConversionFinished(a);
break;
default:
break;
}
}
RenderPageLayoutCallback() : mNum(0)
{
}
private:
int mNum;
void NotifyPartFinished(SharedPtr<PageLayoutCallbackArgs> a)
{
std::cout << "Part at page " << (a->get_PageIndex() + 1) << " reflow." << std::endl;
RenderPage(a, a->get_PageIndex());
}
void NotifyConversionFinished(SharedPtr<PageLayoutCallbackArgs> a)
{
std::cout << "Document \"" << a->get_Document()->get_BuiltInDocumentProperties()->get_Title() << "\" converted to page format." << std::endl;
}
void RenderPage(SharedPtr<PageLayoutCallbackArgs> a, int pageIndex)
{
auto saveOptions = MakeObject<ImageSaveOptions>(SaveFormat::Png);
saveOptions->set_PageSet(MakeObject<PageSet>(pageIndex));
{
auto stream = MakeObject<System::IO::FileStream>(ArtifactsDir + String::Format(u"PageLayoutCallback.page-{0} {1}.png", pageIndex + 1, ++mNum),
System::IO::FileMode::Create);
a->get_Document()->Save(stream, saveOptions);
}
}
};

◆ get_Event()

Aspose::Words::Layout::PageLayoutEvent Aspose::Words::Layout::PageLayoutCallbackArgs::get_Event ( ) const

Gets event.

Examples

Shows how to track layout changes with a layout callback.

void PageLayoutCallback()
{
auto doc = MakeObject<Document>();
doc->get_BuiltInDocumentProperties()->set_Title(u"My Document");
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
doc->get_LayoutOptions()->set_Callback(MakeObject<ExLayout::RenderPageLayoutCallback>());
doc->UpdatePageLayout();
doc->Save(ArtifactsDir + u"Layout.PageLayoutCallback.pdf");
}
class RenderPageLayoutCallback : public IPageLayoutCallback
{
public:
void Notify(SharedPtr<PageLayoutCallbackArgs> a) override
{
switch (a->get_Event())
{
NotifyPartFinished(a);
break;
NotifyConversionFinished(a);
break;
default:
break;
}
}
RenderPageLayoutCallback() : mNum(0)
{
}
private:
int mNum;
void NotifyPartFinished(SharedPtr<PageLayoutCallbackArgs> a)
{
std::cout << "Part at page " << (a->get_PageIndex() + 1) << " reflow." << std::endl;
RenderPage(a, a->get_PageIndex());
}
void NotifyConversionFinished(SharedPtr<PageLayoutCallbackArgs> a)
{
std::cout << "Document \"" << a->get_Document()->get_BuiltInDocumentProperties()->get_Title() << "\" converted to page format." << std::endl;
}
void RenderPage(SharedPtr<PageLayoutCallbackArgs> a, int pageIndex)
{
auto saveOptions = MakeObject<ImageSaveOptions>(SaveFormat::Png);
saveOptions->set_PageSet(MakeObject<PageSet>(pageIndex));
{
auto stream = MakeObject<System::IO::FileStream>(ArtifactsDir + String::Format(u"PageLayoutCallback.page-{0} {1}.png", pageIndex + 1, ++mNum),
System::IO::FileMode::Create);
a->get_Document()->Save(stream, saveOptions);
}
}
};

◆ get_PageIndex()

int32_t Aspose::Words::Layout::PageLayoutCallbackArgs::get_PageIndex ( )

Gets 0-based index of the page in the document this event relates to. Returns negative value if there is no associated page, or if page was removed during reflow.

Examples

Shows how to track layout changes with a layout callback.

void PageLayoutCallback()
{
auto doc = MakeObject<Document>();
doc->get_BuiltInDocumentProperties()->set_Title(u"My Document");
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
doc->get_LayoutOptions()->set_Callback(MakeObject<ExLayout::RenderPageLayoutCallback>());
doc->UpdatePageLayout();
doc->Save(ArtifactsDir + u"Layout.PageLayoutCallback.pdf");
}
class RenderPageLayoutCallback : public IPageLayoutCallback
{
public:
void Notify(SharedPtr<PageLayoutCallbackArgs> a) override
{
switch (a->get_Event())
{
NotifyPartFinished(a);
break;
NotifyConversionFinished(a);
break;
default:
break;
}
}
RenderPageLayoutCallback() : mNum(0)
{
}
private:
int mNum;
void NotifyPartFinished(SharedPtr<PageLayoutCallbackArgs> a)
{
std::cout << "Part at page " << (a->get_PageIndex() + 1) << " reflow." << std::endl;
RenderPage(a, a->get_PageIndex());
}
void NotifyConversionFinished(SharedPtr<PageLayoutCallbackArgs> a)
{
std::cout << "Document \"" << a->get_Document()->get_BuiltInDocumentProperties()->get_Title() << "\" converted to page format." << std::endl;
}
void RenderPage(SharedPtr<PageLayoutCallbackArgs> a, int pageIndex)
{
auto saveOptions = MakeObject<ImageSaveOptions>(SaveFormat::Png);
saveOptions->set_PageSet(MakeObject<PageSet>(pageIndex));
{
auto stream = MakeObject<System::IO::FileStream>(ArtifactsDir + String::Format(u"PageLayoutCallback.page-{0} {1}.png", pageIndex + 1, ++mNum),
System::IO::FileMode::Create);
a->get_Document()->Save(stream, saveOptions);
}
}
};

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Layout::PageLayoutCallbackArgs::GetType ( ) const
overridevirtual

Reimplemented from System::Object.

◆ Is()

virtual bool Aspose::Words::Layout::PageLayoutCallbackArgs::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from System::Object.

◆ Type()

static const System::TypeInfo& Aspose::Words::Layout::PageLayoutCallbackArgs::Type ( )
static