fpdf.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. // fpdf.h
  2. //
  3. #ifndef LZZ_fpdf_h
  4. #define LZZ_fpdf_h
  5. #include <string>
  6. #include <vector>
  7. #include <map>
  8. #include "pdf-font.h"
  9. typedef float pdf_float_t;
  10. #define LZZ_INLINE inline
  11. std::string & gzcompress (std::string & dest, std::string const & src);
  12. std::string & gzuncompress (std::string & dest, std::string const & src);
  13. extern char const * FPDF_FONTPATH;
  14. class FPDF
  15. {
  16. public:
  17. enum e_orientation
  18. {
  19. e_orientation_none,
  20. e_orientation_portrait,
  21. e_orientation_landscape
  22. };
  23. enum e_units
  24. {
  25. e_units_none,
  26. e_mm,
  27. e_pt,
  28. e_cm,
  29. e_in
  30. };
  31. enum e_page_sizes
  32. {
  33. e_page_size_none,
  34. e_A3,
  35. e_A4,
  36. e_A5,
  37. e_Letter,
  38. e_Legal,
  39. e_page_sizes_last
  40. };
  41. enum e_zoom_mode
  42. {
  43. e_zoom_default,
  44. e_zoom_fullpage,
  45. e_zoom_fullwidth,
  46. e_zoom_real
  47. };
  48. enum e_layout_mode
  49. {
  50. e_layout_default,
  51. e_layout_single,
  52. e_layout_continuous,
  53. e_layout_two
  54. };
  55. struct st_image
  56. {
  57. pdf_float_t w;
  58. pdf_float_t h;
  59. std::string cs;
  60. std::string dp;
  61. std::string f;
  62. std::string parms;
  63. std::string pal;
  64. std::string trns;
  65. std::string imgdata;
  66. std::string file;
  67. std::string data;
  68. std::string smask;
  69. int i;
  70. int n;
  71. int bpc;
  72. };
  73. struct st_pagesize
  74. {
  75. pdf_float_t w;
  76. pdf_float_t h;
  77. };
  78. struct st_link
  79. {
  80. int from;
  81. int to;
  82. };
  83. struct st_page_link
  84. {
  85. pdf_float_t x;
  86. pdf_float_t y;
  87. pdf_float_t w;
  88. pdf_float_t h;
  89. int link;
  90. };
  91. struct pdf_color_t
  92. {
  93. unsigned char r;
  94. unsigned char g;
  95. unsigned char b;
  96. unsigned char t;
  97. };
  98. protected:
  99. int m_page;
  100. int m_n;
  101. std::vector <int> m_offsets;
  102. std::string m_buffer;
  103. std::vector <std::string> m_pages;
  104. int m_state;
  105. int m_compress;
  106. pdf_float_t m_k;
  107. e_orientation m_DefOrientation;
  108. e_orientation m_CurOrientation;
  109. st_pagesize m_DefPageSize;
  110. st_pagesize m_CurPageSize;
  111. std::map <int, st_pagesize> m_PageSizes;
  112. pdf_float_t m_wPt;
  113. pdf_float_t m_hPt;
  114. pdf_float_t m_w;
  115. pdf_float_t m_h;
  116. pdf_float_t m_angle;
  117. pdf_float_t m_lMargin;
  118. pdf_float_t m_tMargin;
  119. pdf_float_t m_rMargin;
  120. pdf_float_t m_bMargin;
  121. pdf_float_t m_cMargin;
  122. pdf_float_t m_x;
  123. pdf_float_t m_y;
  124. pdf_float_t m_lasth;
  125. pdf_float_t m_LineWidth;
  126. std::string m_fontpath;
  127. typedef std::map <std::string, st_pdf_font_base*> font_map_t;
  128. font_map_t m_fonts;
  129. std::vector <int> m_FontFiles;
  130. std::vector <int> m_diffs;
  131. std::string m_FontFamily;
  132. std::string m_FontStyle;
  133. bool m_underline;
  134. st_pdf_font_base * m_CurrentFont;
  135. pdf_float_t m_FontSizePt;
  136. pdf_float_t m_FontSize;
  137. std::string m_DrawColor;
  138. pdf_color_t m_DrawColor_rgb;
  139. std::string m_FillColor;
  140. pdf_color_t m_FillColor_rgb;
  141. std::string m_TextColor;
  142. pdf_color_t m_TextColor_rgb;
  143. bool m_ColorFlag;
  144. pdf_float_t m_ws;
  145. typedef std::map <std::string, st_image> image_map_t;
  146. image_map_t m_images;
  147. typedef std::map <int, st_page_link> link_map_t;
  148. link_map_t m_PageLinks;
  149. std::vector <st_link> m_links;
  150. bool m_AutoPageBreak;
  151. pdf_float_t m_PageBreakTrigger;
  152. bool m_InHeader;
  153. bool m_InFooter;
  154. e_zoom_mode m_ZoomMode;
  155. int m_CustomZoom;
  156. int m_LayoutMode;
  157. std::string m_title;
  158. std::string m_subject;
  159. std::string m_author;
  160. std::string m_keywords;
  161. std::string m_creator;
  162. std::string m_AliasNbPages;
  163. std::string m_PDFVersion;
  164. char (m_scratch_buf) [128];
  165. struct st_alpha_t
  166. {
  167. int n;
  168. pdf_float_t alpha;
  169. std::string bm;
  170. };
  171. std::vector <st_alpha_t> m_extgstates;
  172. pdf_float_t m_outerMargin;
  173. pdf_float_t m_innerMargin;
  174. pdf_float_t m_xDelta;
  175. bool m_doubleSided;
  176. std::string m_javascript;
  177. int m_n_js;
  178. public:
  179. virtual ~ FPDF ();
  180. FPDF ();
  181. FPDF (e_orientation orientation, e_units unit, e_page_sizes psize);
  182. FPDF (char orientation, char const * unit, char const * psize);
  183. void reset (e_orientation orientation = e_orientation_portrait, e_units unit = e_mm, e_page_sizes psize = e_A4);
  184. void SetDoubleSided (pdf_float_t inner = 7, pdf_float_t outer = 13);
  185. void SetMargins (pdf_float_t left, pdf_float_t top, pdf_float_t right = 0.0f);
  186. void SetLeftMargin (pdf_float_t margin);
  187. void SetTopMargin (pdf_float_t margin);
  188. void SetRightMargin (pdf_float_t margin);
  189. pdf_float_t GetLeftMargin ();
  190. pdf_float_t GetRightMargin ();
  191. void SetAutoPageBreak (bool b, pdf_float_t margin = 0.0f);
  192. void CheckPageBreak (pdf_float_t height);
  193. void setCustomZoom (int zoom);
  194. int getCustomZoom ();
  195. void SetDisplayMode (e_zoom_mode zoom, e_layout_mode layout = e_layout_default);
  196. void SetCompression (bool compress);
  197. void SetTitle (char const * title);
  198. void SetSubject (char const * subject);
  199. void SetAuthor (char const * author);
  200. void SetKeywords (char const * keywords);
  201. void SetCreator (char const * creator);
  202. void AliasNbPages (char const * alias = "{nb}");
  203. std::string const & GetAliasNbPages ();
  204. void Error (char const * msg, ...);
  205. void Open ();
  206. void Close ();
  207. void AddPage (e_orientation orientation = e_orientation_none, st_pagesize * psize = 0);
  208. virtual void Header ();
  209. virtual void Footer ();
  210. int PageNo ();
  211. void SetDrawColor (unsigned char r);
  212. void SetDrawColor (unsigned char r, unsigned char g, unsigned char b);
  213. void SetDrawColor (pdf_color_t & color);
  214. void GetDrawColor (pdf_color_t & color);
  215. void SetFillColor (unsigned char r);
  216. void SetFillColor (unsigned char r, unsigned char g, unsigned char b);
  217. void SetFillColor (pdf_color_t & color);
  218. void GetFillColor (pdf_color_t & color);
  219. void SetTextColor (unsigned char r);
  220. void SetTextColor (unsigned char r, unsigned char g, unsigned char b);
  221. void SetTextColor (pdf_color_t & color);
  222. void GetTextColor (pdf_color_t & color);
  223. void SetAlpha (pdf_float_t alpha, char const * bm = 0);
  224. pdf_float_t GetStringWidth (char const * s);
  225. pdf_float_t GetStringWidth (std::string const & s);
  226. void SetLineWidth (pdf_float_t width);
  227. void SetDash (pdf_float_t black = -1, pdf_float_t white = -1);
  228. void Line (pdf_float_t x1, pdf_float_t y1, pdf_float_t x2, pdf_float_t y2);
  229. void Rect (pdf_float_t x, pdf_float_t y, pdf_float_t w, pdf_float_t h, char const * style = 0);
  230. void AddFont (char const * afamily, char const * astyle = 0, char const * afile = 0);
  231. struct font_settings_st
  232. {
  233. std::string family;
  234. std::string style;
  235. pdf_float_t size;
  236. };
  237. void GetFontSettings (font_settings_st & fs);
  238. void SetFontSettings (font_settings_st & fs);
  239. void SetFont (char const * afamily = 0, char const * astyle = 0, pdf_float_t size = 0);
  240. void SetFontSize (pdf_float_t size);
  241. pdf_float_t GetFontSize ();
  242. int AddLink ();
  243. void SetLink (int link, pdf_float_t y = 0, int page = -1);
  244. void Link (pdf_float_t x, pdf_float_t y, pdf_float_t w, pdf_float_t h, int link);
  245. protected:
  246. void _TextBase (std::string & result, pdf_float_t x, pdf_float_t y, char const * txt);
  247. public:
  248. void Rotate (pdf_float_t angle, pdf_float_t x = -1, pdf_float_t y = -1);
  249. void RotatedText (pdf_float_t x, pdf_float_t y, char const * txt, pdf_float_t angle);
  250. void RotatedText (pdf_float_t x, pdf_float_t y, std::string const & txt, pdf_float_t angle);
  251. void ClippingText (pdf_float_t x, pdf_float_t y, char const * txt, bool outline = false);
  252. void Text (pdf_float_t x, pdf_float_t y, char const * txt);
  253. void TextShadow (pdf_float_t x, pdf_float_t y, char const * txt, pdf_float_t displacement = .3);
  254. virtual bool AcceptPageBreak ();
  255. void Cell (pdf_float_t w, pdf_float_t h = 0.0f, char const * txt = 0, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0);
  256. void Cell (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0);
  257. void MultiCell (pdf_float_t w, pdf_float_t h, char const * txt, char const * border = 0, char align = 'J', bool fill = false);
  258. void MultiCell (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border = 0, char align = 'J', bool fill = false);
  259. int CalcLines (pdf_float_t w, char const * txt);
  260. void MultiCellBlt (pdf_float_t w, pdf_float_t h, char const * blt, char const * txt, char const * border = 0, char align = 'J', bool fill = false);
  261. void ClippingRect (pdf_float_t x, pdf_float_t y, pdf_float_t w, pdf_float_t h, bool outline = false);
  262. void UnsetClipping ();
  263. void ClippedCell (pdf_float_t w, pdf_float_t h = 0, char const * txt = 0, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0);
  264. void CellFit (pdf_float_t w, pdf_float_t h = 0, char const * txt = 0, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0, bool scale = false, bool force = true);
  265. void CellFitScale (pdf_float_t w, pdf_float_t h = 0, char const * txt = 0, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0);
  266. void CellFitScale (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0);
  267. void CellFitScaleForce (pdf_float_t w, pdf_float_t h = 0, char const * txt = 0, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0);
  268. void CellFitScaleForce (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0);
  269. void CellFitSpace (pdf_float_t w, pdf_float_t h = 0, char const * txt = 0, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0);
  270. void CellFitSpace (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0);
  271. void CellFitSpaceForce (pdf_float_t w, pdf_float_t h = 0, char const * txt = 0, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0);
  272. void CellFitSpaceForce (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border = 0, int ln = 0, char align = ' ', bool fill = false, int link = 0);
  273. void Write (pdf_float_t h, char const * txt, int link = 0);
  274. void Ln (pdf_float_t h = 0.0);
  275. void Image (char const * image_name, unsigned char const * image_blob, size_t blob_size, pdf_float_t x = -1, pdf_float_t y = -1, pdf_float_t w = 0.0, pdf_float_t h = 0.0, char const * atype = 0, int link = 0);
  276. void Image (char const * file, pdf_float_t x = -1, pdf_float_t y = -1, pdf_float_t w = 0.0, pdf_float_t h = 0.0, char const * atype = 0, int link = 0);
  277. pdf_float_t GetX ();
  278. void SetX (pdf_float_t x);
  279. pdf_float_t GetY ();
  280. void SetY (pdf_float_t y);
  281. void SetXY (pdf_float_t x, pdf_float_t y);
  282. pdf_float_t GetW ();
  283. pdf_float_t GetH ();
  284. std::string Output (char const * name = 0, char dest = ' ');
  285. void RoundedRect (pdf_float_t x, pdf_float_t y, pdf_float_t w, pdf_float_t h, pdf_float_t r, char const * style = "");
  286. void Circle (pdf_float_t x, pdf_float_t y, pdf_float_t r, char const * style = "D");
  287. void Ellipse (pdf_float_t x, pdf_float_t y, pdf_float_t rx, pdf_float_t ry, char const * style = "D");
  288. void IncludeJS (char const * script);
  289. protected:
  290. void _Arc (pdf_float_t x1, pdf_float_t y1, pdf_float_t x2, pdf_float_t y2, pdf_float_t x3, pdf_float_t y3);
  291. std::string & _erasestrch (std::string & str, char c);
  292. void _str_tolower (std::string & str);
  293. void _dochecks ();
  294. void _checkoutput ();
  295. st_pagesize & _getpagesize (st_pagesize & result, e_page_sizes size);
  296. void _beginpage (e_orientation orientation = e_orientation_none, st_pagesize * size = 0);
  297. void _endpage ();
  298. std::string _escape (std::string const & s);
  299. void _textstring (std::string & result, std::string const & s);
  300. int substr_count (char const * str, char c);
  301. std::string _dounderline (pdf_float_t x, pdf_float_t y, char const * txt);
  302. struct blob_stream_t
  303. {
  304. virtual bool eof () = 0;
  305. virtual size_t tell () = 0;
  306. virtual size_t read (void * dest, size_t num_read) = 0;
  307. virtual void seek (size_t to_offset, int whence) = 0;
  308. virtual ~ blob_stream_t ();
  309. };
  310. struct blob_stream_memory_t : public blob_stream_t
  311. {
  312. size_t size;
  313. size_t offset;
  314. unsigned char const * blob;
  315. blob_stream_memory_t (unsigned char const * ablob, size_t asize);
  316. bool eof ();
  317. size_t tell ();
  318. size_t read (void * dest, size_t num_read);
  319. void seek (size_t to_offset, int whence);
  320. };
  321. struct blob_stream_file_t : public blob_stream_t
  322. {
  323. FILE * fp;
  324. blob_stream_file_t (FILE * afp);
  325. ~ blob_stream_file_t ();
  326. bool eof ();
  327. size_t tell ();
  328. size_t read (void * dest, size_t num_read);
  329. void seek (size_t to_offset, int whence);
  330. };
  331. void _parsejpg (st_image & info, blob_stream_t & fp, char const * image_name);
  332. void _parsejpg (st_image & info, char const * file_name);
  333. void _parsejpg_blob (st_image & info, char const * image_name, unsigned char const * image_blob, size_t blob_size);
  334. void _parsepng (st_image & info, char const * file_name);
  335. void _parsepng_blob (st_image & info, char const * image_name, unsigned char const * image_blob, size_t blob_size);
  336. void _getGrayImgColorAndalpha (std::string & color, std::string & alpha, std::string & line);
  337. void _getRGBImgColorAndalpha (std::string & color, std::string & alpha, std::string & line);
  338. void _parsepngstream (st_image & info, blob_stream_t & fp, char const * image_name);
  339. std::string & _readstream (std::string & result, blob_stream_t & fp, size_t n);
  340. int _readint (blob_stream_t & fp);
  341. int _readshort (blob_stream_t & fp);
  342. void _parsegif (std::string & file);
  343. void _newobj ();
  344. void _putstream (std::string const & s);
  345. void _out (char const * s, size_t size, bool nl = true);
  346. std::string & pdf_sprintf (std::string & s, char const * fmt, ...);
  347. void pdf_sprintf_append (std::string & s, char const * fmt, ...);
  348. void _outfmt (bool nl, char const * fmt, ...);
  349. void _out (char const * s, bool nl = true);
  350. void _out (std::string const & s, bool nl = true);
  351. void _putpages ();
  352. void _putfonts ();
  353. void _putimages ();
  354. void _putimage (st_image & info);
  355. void _putxobjectdict ();
  356. void _putextgstates ();
  357. void _putjavascript ();
  358. void _putresourcedict ();
  359. void _putresources ();
  360. void _putinfo ();
  361. void _putcatalog ();
  362. void _putheader ();
  363. void _puttrailer ();
  364. void _enddoc ();
  365. };
  366. LZZ_INLINE void FPDF::SetTopMargin (pdf_float_t margin)
  367. {
  368. // Set top margin
  369. m_tMargin = margin;
  370. }
  371. LZZ_INLINE void FPDF::SetRightMargin (pdf_float_t margin)
  372. {
  373. // Set right margin
  374. m_rMargin = margin;
  375. }
  376. LZZ_INLINE pdf_float_t FPDF::GetLeftMargin ()
  377. {
  378. return m_lMargin;
  379. }
  380. LZZ_INLINE pdf_float_t FPDF::GetRightMargin ()
  381. {
  382. return m_rMargin;
  383. }
  384. LZZ_INLINE void FPDF::setCustomZoom (int zoom)
  385. {
  386. m_CustomZoom = zoom;
  387. }
  388. LZZ_INLINE int FPDF::getCustomZoom ()
  389. {
  390. return m_CustomZoom;
  391. }
  392. LZZ_INLINE std::string const & FPDF::GetAliasNbPages ()
  393. {
  394. // Define an alias for total number of pages
  395. return m_AliasNbPages;
  396. }
  397. LZZ_INLINE void FPDF::Open ()
  398. {
  399. // Begin document
  400. m_state = 1;
  401. }
  402. LZZ_INLINE int FPDF::PageNo ()
  403. {
  404. // Get current page number
  405. return m_page;
  406. }
  407. LZZ_INLINE void FPDF::SetDrawColor (pdf_color_t & color)
  408. {
  409. SetDrawColor(color.r, color.g, color.b);
  410. }
  411. LZZ_INLINE void FPDF::GetDrawColor (pdf_color_t & color)
  412. {
  413. color = m_DrawColor_rgb;
  414. }
  415. LZZ_INLINE void FPDF::SetFillColor (pdf_color_t & color)
  416. {
  417. SetFillColor(color.r, color.g, color.b);
  418. }
  419. LZZ_INLINE void FPDF::GetFillColor (pdf_color_t & color)
  420. {
  421. color = m_FillColor_rgb;
  422. }
  423. LZZ_INLINE void FPDF::SetTextColor (pdf_color_t & color)
  424. {
  425. SetTextColor(color.r, color.g, color.b);
  426. }
  427. LZZ_INLINE void FPDF::GetTextColor (pdf_color_t & color)
  428. {
  429. color = m_TextColor_rgb;
  430. }
  431. LZZ_INLINE pdf_float_t FPDF::GetStringWidth (std::string const & s)
  432. {
  433. return GetStringWidth(s.c_str());
  434. }
  435. LZZ_INLINE pdf_float_t FPDF::GetFontSize ()
  436. {
  437. return m_FontSizePt;
  438. }
  439. LZZ_INLINE void FPDF::RotatedText (pdf_float_t x, pdf_float_t y, std::string const & txt, pdf_float_t angle)
  440. {
  441. RotatedText(x, y, txt.c_str(), angle);
  442. }
  443. LZZ_INLINE void FPDF::Cell (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border, int ln, char align, bool fill, int link)
  444. {
  445. Cell(w, h, txt.c_str(), border, ln, align, fill, link);
  446. }
  447. LZZ_INLINE void FPDF::MultiCell (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border, char align, bool fill)
  448. {
  449. MultiCell(w, h, txt.c_str(), border, align, fill);
  450. }
  451. LZZ_INLINE void FPDF::CellFitScale (pdf_float_t w, pdf_float_t h, char const * txt, char const * border, int ln, char align, bool fill, int link)
  452. {
  453. CellFit(w,h,txt,border,ln,align,fill,link,true,false);
  454. }
  455. LZZ_INLINE void FPDF::CellFitScale (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border, int ln, char align, bool fill, int link)
  456. {
  457. CellFit(w,h,txt.c_str(),border,ln,align,fill,link,true,false);
  458. }
  459. LZZ_INLINE void FPDF::CellFitScaleForce (pdf_float_t w, pdf_float_t h, char const * txt, char const * border, int ln, char align, bool fill, int link)
  460. {
  461. CellFit(w,h,txt,border,ln,align,fill,link,true,true);
  462. }
  463. LZZ_INLINE void FPDF::CellFitScaleForce (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border, int ln, char align, bool fill, int link)
  464. {
  465. CellFit(w,h,txt.c_str(),border,ln,align,fill,link,true,true);
  466. }
  467. LZZ_INLINE void FPDF::CellFitSpace (pdf_float_t w, pdf_float_t h, char const * txt, char const * border, int ln, char align, bool fill, int link)
  468. {
  469. CellFit(w,h,txt,border,ln,align,fill,link,false,false);
  470. }
  471. LZZ_INLINE void FPDF::CellFitSpace (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border, int ln, char align, bool fill, int link)
  472. {
  473. CellFit(w,h,txt.c_str(),border,ln,align,fill,link,false,false);
  474. }
  475. LZZ_INLINE void FPDF::CellFitSpaceForce (pdf_float_t w, pdf_float_t h, char const * txt, char const * border, int ln, char align, bool fill, int link)
  476. {
  477. //Same as calling CellFit directly
  478. CellFit(w,h,txt,border,ln,align,fill,link,false,true);
  479. }
  480. LZZ_INLINE void FPDF::CellFitSpaceForce (pdf_float_t w, pdf_float_t h, std::string const & txt, char const * border, int ln, char align, bool fill, int link)
  481. {
  482. //Same as calling CellFit directly
  483. CellFit(w,h,txt.c_str(),border,ln,align,fill,link,false,true);
  484. }
  485. LZZ_INLINE pdf_float_t FPDF::GetX ()
  486. {
  487. // Get x position
  488. return m_x;
  489. }
  490. LZZ_INLINE pdf_float_t FPDF::GetY ()
  491. {
  492. // Get y position
  493. return m_y;
  494. }
  495. LZZ_INLINE void FPDF::SetXY (pdf_float_t x, pdf_float_t y)
  496. {
  497. // Set x and y positions
  498. SetY(y);
  499. SetX(x);
  500. }
  501. LZZ_INLINE pdf_float_t FPDF::GetW ()
  502. {
  503. // Get y position
  504. return m_w;
  505. }
  506. LZZ_INLINE pdf_float_t FPDF::GetH ()
  507. {
  508. // Get y position
  509. return m_h;
  510. }
  511. LZZ_INLINE void FPDF::_endpage ()
  512. {
  513. if(m_angle!=0)
  514. {
  515. m_angle=0;
  516. _out("Q");
  517. }
  518. m_state = 1;
  519. }
  520. #undef LZZ_INLINE
  521. #endif