Myo Scol plugin
Loading...
Searching...
No Matches
sPdf.h
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
25#ifndef S_SPDF_H
26#define S_SPDF_H
27
28#include <scolPlugin.h>
29#include <string>
30#include "hpdf.h"
31
36{
37public:
38 enum ElementAlign
39 {
40 EM_LEFT = 0,
41 EM_RIGHT = 1,
42 EM_CENTER = 2,
43 EM_TOP = 4,
44 EM_BOTTOM = 8,
45 EM_MIDDLE = 16
46 };
47
48protected:
49
50private:
51 HPDF_Doc mDocument;
52 std::string mCharset;
53 unsigned int mDpi;
54public:
58 SPdfDoc(std::string title, std::string creator, std::string author, unsigned int dpiResolution = 72);
59
63 ~SPdfDoc();
64
65 static void ErrorHandler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void *user_data);
66 void SetCharset(std::string charset);
67 void SetPageMode(HPDF_PageMode mode);
68 HPDF_PageMode GetPageMode();
69 void SetPageLayout(HPDF_PageLayout layout);
70 HPDF_PageLayout GetPageLayout();
71
72 HPDF_Page AddPage(HPDF_PageSizes sizes, HPDF_PageDirection direction);
73 HPDF_Page GetPageByIndex(HPDF_UINT index);
74
75 float GetPageWidth(HPDF_Page page);
76 float GetPageHeight(HPDF_Page page);
77
78 std::string LoadFontTTF(std::string fontpath);
79 void AddPageLabel(HPDF_UINT pagenum, HPDF_PageNumStyle style, HPDF_UINT firstpage, std::string prefix);
80 void AddPageText(HPDF_Page page, std::string text, float posx, float posy, int color, std::string fontname, float fontsize, int align, bool relative = false);
81 void AddPageBitmap(HPDF_Page page, PtrObjBitmap bitmap, float posx, float posy, float width, float height, int align);
82 void AddPageImage(HPDF_Page page, std::string path, float posx, float posy, float width, float height, int align);
83 void AddPageRectangle(HPDF_Page page, float posx, float posy, float width, float height, float lineWith, int lineColor, int fillColor, bool filled, int align);
84 void AddPageEllipse(HPDF_Page page, float posx, float posy, float xradius, float yradius, float lineWith, int lineColor, int fillColor, bool filled, int align);
85 void AddPageLine(HPDF_Page page, float posx, float posy, float dstx, float dsty, float lineWith, int lineColor);
86
87 float GetTextWidth(HPDF_Page page, std::string text, std::string fontname, float fontsize);
88 void SaveToFile(std::string path);
89
90protected:
91private:
92 float MmtoDpi(float value);
93 float DpiToMm(float value);
94 float DpiScale(float value);
95 HPDF_Image ConvertBitmap(PtrObjBitmap scolBitmap);
96 HPDF_RGBColor ConvertColor(int color);
97 void AlignCoords(int flags, float pageWidth, float pageHeight, float eltWidth, float eltHeight, float &x, float &y);
98};
99
100#endif
Definition sPdf.h:36
~SPdfDoc()
Definition sPdf.cpp:49