4#ifndef MRIOEXTRAS_NO_PDF
6#include "MRMesh/MRMeshFwd.h"
106 MRIOEXTRAS_API
void addText(
const std::string& text,
bool isTitle =
false );
117 MRIOEXTRAS_API
void addTable(
const std::vector<std::pair<std::string, float>>& table );
167 MRIOEXTRAS_API
void saveToFile(
const std::filesystem::path& documentPath );
178 MRIOEXTRAS_API
operator bool()
const;
185 using Value = std::variant<int, float, bool, std::string, Empty>;
195 MRIOEXTRAS_API std::string
toString(
const std::string& fmtStr =
"{}" )
const;
215 std::optional<std::string>
text;
245 std::vector<float> calcTextLineWidths_(
const std::string& text,
float width,
const TextParams& params );
247 struct HPDF_Image_Wraper;
249 void addImage_(
const HPDF_Image_Wraper& image,
const ImageParams& params );
252 std::unique_ptr<State> state_;
256 std::function<void(
Pdf& )> newPageAction_;
261 bool checkDocument_(
const std::string& logAction );
262 void moveCursorToNewLine_();
263 void checkAndCreateNewPageIfNeed_(
float height );
272 std::vector<ColumnInfo> columnsInfo_;
274 struct TableGeneralParams
auto width(const Box< V > &box)
returns size along x axis
Definition MRBox.h:354
auto height(const Box< V > &box)
returns size along y axis
Definition MRBox.h:361
std::string caption
caption if not empty - add caption under marks (if exist) or image.
Definition MRPdf.h:136
MRIOEXTRAS_API void drawTextCell(const std::string &text, const TextCellParams ¶ms)
AlignmentHorizontal
Definition MRPdf.h:81
static constexpr Color transparent() noexcept
Definition MRColor.h:37
std::string rangeMin
Definition MRPdf.h:122
std::variant< int, float, bool, std::string, Empty > Value
Definition MRPdf.h:185
float fontSize
Definition MRPdf.h:92
float getCursorPosY() const
Definition MRPdf.h:172
MRIOEXTRAS_API Pdf & operator=(Pdf other) noexcept
Color colorBackground
Definition MRPdf.h:233
std::string valueFormat
Definition MRPdf.h:270
MRIOEXTRAS_API void addText(const std::string &text, const TextParams ¶ms)
PdfBuildinFont
Definition MRPdf.h:27
Cell(const T &value)
Definition MRPdf.h:191
MRIOEXTRAS_API void newTable(int columnCount)
set up new table (clear table customization, reset parameters to default values)
std::string rangeMax
Definition MRPdf.h:123
MRIOEXTRAS_API void drawRect(const Box2f &rect, const Color &fillColor, const Color &strokeColor)
draw rect (filled with border)
float getCursorPosX() const
Definition MRPdf.h:171
MRIOEXTRAS_API void addText(const std::string &text, bool isTitle=false)
void setCursorPosX(float posX)
Definition MRPdf.h:169
enum MR::Pdf::ImageParams::UniformScale uniformScale
float fontSize
Definition MRPdf.h:285
void setTableCustomRule(TableCustomRule rule)
add rule to customize table cells
Definition MRPdf.h:219
Color colorCellBg2
Definition MRPdf.h:281
MRIOEXTRAS_API void addImageFromFile(const std::filesystem::path &imagePath, const ImageParams ¶ms)
Add image from file in current cursor position. If image bigger than page size, autoscale image to pa...
std::variant< PdfBuildinFont, std::filesystem::path > PdfGeneralFont
Definition MRPdf.h:45
enum MR::Pdf::ImageParams::AlignmentVertical alignmentVertical
MRIOEXTRAS_API Expected< void > setColumnValuesFormat(const std::vector< std::string > &formats)
set format for conversion values to string for each column
Value data
Definition MRPdf.h:186
Color colorText
Definition MRPdf.h:95
Color colorCellText
Definition MRPdf.h:279
static constexpr Color black() noexcept
Definition MRColor.h:29
MRIOEXTRAS_API float getTextWidth(const std::string &text, const TextParams ¶ms)
return text width
float titleSize
Definition MRPdf.h:52
Vector2f size
Definition MRPdf.h:134
Color colorTitleText
Definition MRPdf.h:276
MRIOEXTRAS_API void newPage()
Add new pageand move cursor on it.
tl::expected< T, E > Expected
Definition MRExpected.h:31
std::function< CellCustomParams(int row, int column, const std::string &cellValueText)> TableCustomRule
Definition MRPdf.h:217
std::optional< Color > colorCellBg
Definition MRPdf.h:213
MRIOEXTRAS_API void addPaletteStatsTable(const std::vector< PaletteRowStats > &paletteStats)
Cell()
Definition MRPdf.h:188
Color colorCellBg1
Definition MRPdf.h:280
bool underline
Definition MRPdf.h:96
MRIOEXTRAS_API Box2f getPageWorkArea() const
float textSize
Definition MRPdf.h:53
PdfGeneralFont defaultFont
Font name.
Definition MRPdf.h:58
PdfGeneralFont defaultFontBold
Definition MRPdf.h:59
AlignmentHorizontal alignmentHorizontal
Definition MRPdf.h:151
Color colorLines
Definition MRPdf.h:283
std::optional< Color > colorText
Definition MRPdf.h:212
MRIOEXTRAS_API Pdf(const PdfParameters ¶ms=PdfParameters())
Ctor. Create a document, but not a page. To create a new page use newPage() method.
std::optional< Color > colorCellBorder
Definition MRPdf.h:214
PdfGeneralFont tableFont
Definition MRPdf.h:63
MRIOEXTRAS_API Expected< void > addRow(const std::vector< Cell > &cells)
add in pdf table row with values
float width
Definition MRPdf.h:269
MRIOEXTRAS_API void addImage(const Image &image, const ImageParams ¶ms)
Color colorBorder
Definition MRPdf.h:232
MRIOEXTRAS_API void saveToFile(const std::filesystem::path &documentPath)
Save document to file.
std::optional< std::string > text
Definition MRPdf.h:215
PdfGeneralFont tableFontBold
Definition MRPdf.h:64
MRIOEXTRAS_API void addTable(const std::vector< std::pair< std::string, float > > &table)
void setCursorPosY(float posY)
Definition MRPdf.h:170
MRIOEXTRAS_API void drawTextInRect(const std::string &text, const Box2f &rect, const TextParams ¶ms)
basic drawing methods without automatic cursor position control
UniformScale
set height to keep same scale as width scale
Definition MRPdf.h:139
Box2f rect
Definition MRPdf.h:231
MRIOEXTRAS_API Expected< void > setTableColumnWidths(const std::vector< float > &widths)
set table column widths
AlignmentVertical
Definition MRPdf.h:146
Color color
Definition MRPdf.h:121
MRIOEXTRAS_API float getTableTextWidth(const std::string &text)
MRIOEXTRAS_API Vector2f getPageSize() const
Color colorTitleBg
Definition MRPdf.h:277
MRIOEXTRAS_API std::string toString(const std::string &fmtStr="{}") const
AlignmentHorizontal alignment
Definition MRPdf.h:94
TextParams textParams
Definition MRPdf.h:229
PdfGeneralFont fontName
Definition MRPdf.h:90
MRIOEXTRAS_API ~Pdf()
Dtor.
void setNewPageAction(std::function< void(Pdf &)> action)
set function to customize new page after creation
Definition MRPdf.h:164
std::string percent
Definition MRPdf.h:124
MRIOEXTRAS_API Pdf(Pdf &&other) noexcept
MRIOEXTRAS_API Expected< void > addTableTitles(const std::vector< std::string > &titles)
add in pdf table row with titles
static constexpr Color white() noexcept
Definition MRColor.h:28
@ other
Angle, normally float. Measure in radians.
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Parameters of document style.
Definition MRPdf.h:51
Parameters to adding image from file.
Definition MRPdf.h:130
parameters to drawing text
Definition MRPdf.h:89