MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::Pdf Class Reference

#include <MRPdf.h>

Classes

struct  Cell
 
struct  CellCustomParams
 
struct  ImageParams
 Parameters to adding image from file. More...
 
struct  PaletteRowStats
 
struct  TextCellParams
 
struct  TextParams
 

Public Types

enum class  AlignmentHorizontal { Left , Center , Right }
 
using TableCustomRule = std::function<CellCustomParams( int row, int column, const std::string& cellValueText)>
 

Public Member Functions

MRIOEXTRAS_API Pdf (const PdfParameters &params=PdfParameters())
 Ctor. Create a document, but not a page. To create a new page use newPage() method.
 
MRIOEXTRAS_API Pdf (Pdf &&other) noexcept
 
MRIOEXTRAS_API Pdfoperator= (Pdf other) noexcept
 
MRIOEXTRAS_API ~Pdf ()
 Dtor.
 
MRIOEXTRAS_API void addText (const std::string &text, bool isTitle=false)
 
MRIOEXTRAS_API void addText (const std::string &text, const TextParams &params)
 
MRIOEXTRAS_API float getTextWidth (const std::string &text, const TextParams &params)
 return text width
 
MRIOEXTRAS_API void addTable (const std::vector< std::pair< std::string, float > > &table)
 
MRIOEXTRAS_API void addPaletteStatsTable (const std::vector< PaletteRowStats > &paletteStats)
 
MRIOEXTRAS_API void addImageFromFile (const std::filesystem::path &imagePath, const ImageParams &params)
 Add image from file in current cursor position. If image bigger than page size, autoscale image to page size. Move cursor.
 
MRIOEXTRAS_API void addImage (const Image &image, const ImageParams &params)
 
MRIOEXTRAS_API void newPage ()
 Add new pageand move cursor on it.
 
void setNewPageAction (std::function< void(Pdf &)> action)
 set function to customize new page after creation
 
MRIOEXTRAS_API void saveToFile (const std::filesystem::path &documentPath)
 Save document to file.
 
void setCursorPosX (float posX)
 
void setCursorPosY (float posY)
 
float getCursorPosX () const
 
float getCursorPosY () const
 
MRIOEXTRAS_API Vector2f getPageSize () const
 
MRIOEXTRAS_API Box2f getPageWorkArea () const
 
MRIOEXTRAS_API operator bool () const
 Checking the ability to work with a document.
 
MRIOEXTRAS_API void newTable (int columnCount)
 
MRIOEXTRAS_API Expected< void > setTableColumnWidths (const std::vector< float > &widths)
 
MRIOEXTRAS_API Expected< void > addTableTitles (const std::vector< std::string > &titles)
 
MRIOEXTRAS_API Expected< void > setColumnValuesFormat (const std::vector< std::string > &formats)
 
MRIOEXTRAS_API Expected< void > addRow (const std::vector< Cell > &cells)
 
MRIOEXTRAS_API float getTableTextWidth (const std::string &text)
 
void setTableCustomRule (TableCustomRule rule)
 
MRIOEXTRAS_API void drawTextInRect (const std::string &text, const Box2f &rect, const TextParams &params)
 
MRIOEXTRAS_API void drawTextCell (const std::string &text, const TextCellParams &params)
 

Detailed Description

Class for simple creation pdf.

Member Typedef Documentation

◆ TableCustomRule

using MR::Pdf::TableCustomRule = std::function<CellCustomParams( int row, int column, const std::string& cellValueText)>

Member Enumeration Documentation

◆ AlignmentHorizontal

enum class MR::Pdf::AlignmentHorizontal
strong
Enumerator
Left 
Center 
Right 

Constructor & Destructor Documentation

◆ Pdf() [1/2]

MRIOEXTRAS_API MR::Pdf::Pdf ( const PdfParameters & params = PdfParameters())

Ctor. Create a document, but not a page. To create a new page use newPage() method.

◆ Pdf() [2/2]

MRIOEXTRAS_API MR::Pdf::Pdf ( Pdf && other)
noexcept

◆ ~Pdf()

MRIOEXTRAS_API MR::Pdf::~Pdf ( )

Dtor.

Member Function Documentation

◆ addImage()

MRIOEXTRAS_API void MR::Pdf::addImage ( const Image & image,
const ImageParams & params )

◆ addImageFromFile()

MRIOEXTRAS_API void MR::Pdf::addImageFromFile ( const std::filesystem::path & imagePath,
const ImageParams & params )

Add image from file in current cursor position. If image bigger than page size, autoscale image to page size. Move cursor.

◆ addPaletteStatsTable()

MRIOEXTRAS_API void MR::Pdf::addPaletteStatsTable ( const std::vector< PaletteRowStats > & paletteStats)

◆ addRow()

MRIOEXTRAS_API Expected< void > MR::Pdf::addRow ( const std::vector< Cell > & cells)

◆ addTable()

MRIOEXTRAS_API void MR::Pdf::addTable ( const std::vector< std::pair< std::string, float > > & table)

Add set of pair string - value in current cursor position. Move cursor. Box horizontal size is page width without offset. Box vertical size is automatically for text.

◆ addTableTitles()

MRIOEXTRAS_API Expected< void > MR::Pdf::addTableTitles ( const std::vector< std::string > & titles)

◆ addText() [1/2]

MRIOEXTRAS_API void MR::Pdf::addText ( const std::string & text,
bool isTitle = false )

Add text block in current cursor position. Move cursor. Box horizontal size is page width without offset. Box vertical size is automatically for text. horAlignment = left if isTitle - horAlignment = center, use titleFontSize

◆ addText() [2/2]

MRIOEXTRAS_API void MR::Pdf::addText ( const std::string & text,
const TextParams & params )

◆ drawTextCell()

MRIOEXTRAS_API void MR::Pdf::drawTextCell ( const std::string & text,
const TextCellParams & params )

◆ drawTextInRect()

MRIOEXTRAS_API void MR::Pdf::drawTextInRect ( const std::string & text,
const Box2f & rect,
const TextParams & params )

◆ getCursorPosX()

float MR::Pdf::getCursorPosX ( ) const
inline

◆ getCursorPosY()

float MR::Pdf::getCursorPosY ( ) const
inline

◆ getPageSize()

MRIOEXTRAS_API Vector2f MR::Pdf::getPageSize ( ) const

◆ getPageWorkArea()

MRIOEXTRAS_API Box2f MR::Pdf::getPageWorkArea ( ) const

◆ getTableTextWidth()

MRIOEXTRAS_API float MR::Pdf::getTableTextWidth ( const std::string & text)

◆ getTextWidth()

MRIOEXTRAS_API float MR::Pdf::getTextWidth ( const std::string & text,
const TextParams & params )

return text width

◆ newPage()

MRIOEXTRAS_API void MR::Pdf::newPage ( )

Add new pageand move cursor on it.

◆ newTable()

MRIOEXTRAS_API void MR::Pdf::newTable ( int columnCount)

◆ operator bool()

MRIOEXTRAS_API MR::Pdf::operator bool ( ) const

Checking the ability to work with a document.

◆ operator=()

MRIOEXTRAS_API Pdf & MR::Pdf::operator= ( Pdf other)
noexcept

◆ saveToFile()

MRIOEXTRAS_API void MR::Pdf::saveToFile ( const std::filesystem::path & documentPath)

Save document to file.

◆ setColumnValuesFormat()

MRIOEXTRAS_API Expected< void > MR::Pdf::setColumnValuesFormat ( const std::vector< std::string > & formats)

◆ setCursorPosX()

void MR::Pdf::setCursorPosX ( float posX)
inline

◆ setCursorPosY()

void MR::Pdf::setCursorPosY ( float posY)
inline

◆ setNewPageAction()

void MR::Pdf::setNewPageAction ( std::function< void(Pdf &)> action)
inline

set function to customize new page after creation

◆ setTableColumnWidths()

MRIOEXTRAS_API Expected< void > MR::Pdf::setTableColumnWidths ( const std::vector< float > & widths)

◆ setTableCustomRule()

void MR::Pdf::setTableCustomRule ( TableCustomRule rule)
inline

The documentation for this class was generated from the following file: