4#ifndef MRIOEXTRAS_NO_PDF
103 MRIOEXTRAS_API
void addText(
const std::string& text,
bool isTitle =
false );
114 MRIOEXTRAS_API
void addTable(
const std::vector<std::pair<std::string, float>>& table );
164 MRIOEXTRAS_API
void saveToFile(
const std::filesystem::path& documentPath );
175 MRIOEXTRAS_API
operator bool()
const;
182 using Value = std::variant<int, float, bool, std::string, Empty>;
192 MRIOEXTRAS_API std::string
toString(
const std::string& fmtStr =
"{}" )
const;
212 std::optional<std::string>
text;
236 MRIOEXTRAS_API
void drawRect_(
const Box2f& rect,
const Color& fillColor,
const Color& strokeColor );
242 std::vector<float> calcTextLineWidths_(
const std::string& text,
float width,
const TextParams& params );
244 struct HPDF_Image_Wraper;
246 void addImage_(
const HPDF_Image_Wraper& image,
const ImageParams& params );
249 std::unique_ptr<State> state_;
253 std::function<void(
Pdf& )> newPageAction_;
258 bool checkDocument_(
const std::string& logAction );
259 void moveCursorToNewLine_();
260 void checkAndCreateNewPageIfNeed_(
float height );
267 std::string valueFormat =
"{}";
269 std::vector<ColumnInfo> columnsInfo_;
271 struct TableGeneralParams
274 Color colorTitleBg{ 42, 102, 246 };
277 Color colorCellBg1{ 170, 194, 251 };
278 Color colorCellBg2{ 212, 224, 253 };
282 float fontSize = 12.f;
MRIOEXTRAS_API void drawTextCell(const std::string &text, const TextCellParams ¶ms)
AlignmentHorizontal
Definition MRPdf.h:78
float getCursorPosY() const
Definition MRPdf.h:169
MRIOEXTRAS_API Pdf & operator=(Pdf other) noexcept
MRIOEXTRAS_API void addText(const std::string &text, const TextParams ¶ms)
MRIOEXTRAS_API void newTable(int columnCount)
float getCursorPosX() const
Definition MRPdf.h:168
MRIOEXTRAS_API void addText(const std::string &text, bool isTitle=false)
void setCursorPosX(float posX)
Definition MRPdf.h:166
void setTableCustomRule(TableCustomRule rule)
Definition MRPdf.h:216
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...
MRIOEXTRAS_API Expected< void > setColumnValuesFormat(const std::vector< std::string > &formats)
MRIOEXTRAS_API float getTextWidth(const std::string &text, const TextParams ¶ms)
return text width
MRIOEXTRAS_API void newPage()
Add new pageand move cursor on it.
std::function< CellCustomParams(int row, int column, const std::string &cellValueText)> TableCustomRule
Definition MRPdf.h:214
MRIOEXTRAS_API void addPaletteStatsTable(const std::vector< PaletteRowStats > &paletteStats)
MRIOEXTRAS_API Box2f getPageWorkArea() const
MRIOEXTRAS_API Pdf(const PdfParameters ¶ms=PdfParameters())
Ctor. Create a document, but not a page. To create a new page use newPage() method.
MRIOEXTRAS_API Expected< void > addRow(const std::vector< Cell > &cells)
MRIOEXTRAS_API void addImage(const Image &image, const ImageParams ¶ms)
MRIOEXTRAS_API void saveToFile(const std::filesystem::path &documentPath)
Save document to file.
MRIOEXTRAS_API void addTable(const std::vector< std::pair< std::string, float > > &table)
void setCursorPosY(float posY)
Definition MRPdf.h:167
MRIOEXTRAS_API void drawTextInRect(const std::string &text, const Box2f &rect, const TextParams ¶ms)
MRIOEXTRAS_API Expected< void > setTableColumnWidths(const std::vector< float > &widths)
MRIOEXTRAS_API float getTableTextWidth(const std::string &text)
MRIOEXTRAS_API Vector2f getPageSize() const
MRIOEXTRAS_API ~Pdf()
Dtor.
void setNewPageAction(std::function< void(Pdf &)> action)
set function to customize new page after creation
Definition MRPdf.h:161
MRIOEXTRAS_API Pdf(Pdf &&other) noexcept
MRIOEXTRAS_API Expected< void > addTableTitles(const std::vector< std::string > &titles)
auto width(const Box< V > &box)
returns size along x axis
Definition MRMesh/MRBox.h:341
auto height(const Box< V > &box)
returns size along y axis
Definition MRMesh/MRBox.h:348
Definition MRCameraOrientationPlugin.h:8
PdfBuildinFont
Definition MRPdf.h:24
std::variant< PdfBuildinFont, std::filesystem::path > PdfGeneralFont
Definition MRPdf.h:42
tl::expected< T, E > Expected
Definition MRExpected.h:25
Definition MRMesh/MRColor.h:9
static constexpr Color transparent() noexcept
Definition MRMesh/MRColor.h:34
static constexpr Color black() noexcept
Definition MRMesh/MRColor.h:26
static constexpr Color white() noexcept
Definition MRMesh/MRColor.h:25
Parameters of document style.
Definition MRPdf.h:48
float titleSize
Definition MRPdf.h:49
float textSize
Definition MRPdf.h:50
PdfGeneralFont defaultFont
Font name.
Definition MRPdf.h:55
PdfGeneralFont defaultFontBold
Definition MRPdf.h:56
PdfGeneralFont tableFont
Definition MRPdf.h:60
PdfGeneralFont tableFontBold
Definition MRPdf.h:61
std::optional< Color > colorCellBg
Definition MRPdf.h:210
std::optional< Color > colorText
Definition MRPdf.h:209
std::optional< Color > colorCellBorder
Definition MRPdf.h:211
std::optional< std::string > text
Definition MRPdf.h:212
std::variant< int, float, bool, std::string, Empty > Value
Definition MRPdf.h:182
Cell(const T &value)
Definition MRPdf.h:188
Value data
Definition MRPdf.h:183
Cell()
Definition MRPdf.h:185
MRIOEXTRAS_API std::string toString(const std::string &fmtStr="{}") const
Parameters to adding image from file.
Definition MRPdf.h:127
std::string caption
caption if not empty - add caption under marks (if exist) or image.
Definition MRPdf.h:133
enum MR::Pdf::ImageParams::UniformScale uniformScale
enum MR::Pdf::ImageParams::AlignmentVertical alignmentVertical
Vector2f size
Definition MRPdf.h:131
AlignmentHorizontal alignmentHorizontal
Definition MRPdf.h:148
UniformScale
set height to keep same scale as width scale
Definition MRPdf.h:136
AlignmentVertical
Definition MRPdf.h:143
std::string rangeMin
Definition MRPdf.h:119
std::string rangeMax
Definition MRPdf.h:120
Color color
Definition MRPdf.h:118
std::string percent
Definition MRPdf.h:121
Color colorBackground
Definition MRPdf.h:230
Color colorBorder
Definition MRPdf.h:229
Box2f rect
Definition MRPdf.h:228
TextParams textParams
Definition MRPdf.h:226
float fontSize
Definition MRPdf.h:89
Color colorText
Definition MRPdf.h:92
bool underline
Definition MRPdf.h:93
AlignmentHorizontal alignment
Definition MRPdf.h:91
PdfGeneralFont fontName
Definition MRPdf.h:87