1 module harud.c.capi; 2 3 import harud.types; 4 import harud.c.consts; 5 6 extern (C) { 7 8 /** 9 * Basic Functions 10 */ 11 HPDF_Doc HPDF_New(void* error, void* user_data); 12 13 void HPDF_Free(HPDF_Doc pdf); 14 15 HPDF_STATUS HPDF_NewDoc(HPDF_Doc pdf); 16 17 void HPDF_FreeDoc(HPDF_Doc pdf); 18 19 void HPDF_FreeDocAll(HPDF_Doc pdf); 20 21 HPDF_STATUS HPDF_SaveToFile(HPDF_Doc pdf, const(char)* file_name); 22 23 HPDF_STATUS HPDF_SaveToStream(HPDF_Doc pdf); 24 25 uint HPDF_GetStreamSize(HPDF_Doc pdf); 26 27 HPDF_STATUS HPDF_ReadFromStream(HPDF_Doc pdf, ubyte* buf, uint* size); 28 29 HPDF_STATUS HPDF_ResetStream(HPDF_Doc pdf); 30 31 HPDF_BOOL HPDF_HasDoc(HPDF_Doc pdf); 32 33 HPDF_STATUS HPDF_SetErrorHandler(HPDF_Doc pdf, void* error); 34 35 HPDF_STATUS HPDF_GetError(HPDF_Doc pdf); 36 37 void HPDF_ResetError(HPDF_Doc pdf); 38 39 const(char)* HPDF_GetVersion(); 40 41 /* 42 * Pages Handling 43 */ 44 HPDF_STATUS HPDF_SetPagesConfiguration(HPDF_Doc pdf, uint page_per_pages); 45 46 HPDF_STATUS HPDF_SetPageLayout(HPDF_Doc pdf, PageLayout layout); 47 48 PageLayout HPDF_GetPageLayout(HPDF_Doc pdf); 49 50 HPDF_STATUS HPDF_SetPageMode(HPDF_Doc pdf, PageMode mode); 51 52 PageMode HPDF_GetPageMode(HPDF_Doc pdf); 53 54 HPDF_STATUS HPDF_SetOpenAction(HPDF_Doc pdf, HPDF_Destination open_action); 55 56 HPDF_Page HPDF_GetCurrentPage(HPDF_Doc pdf); 57 58 HPDF_Page HPDF_AddPage(HPDF_Doc pdf); 59 60 HPDF_Page HPDF_InsertPage(HPDF_Doc pdf, HPDF_Page target); 61 62 /* 63 * Font Handling 64 */ 65 66 HPDF_Font HPDF_GetFont(HPDF_Doc pdf, const(char)* font_name, const(char)* encoding_name); 67 68 const(char)* HPDF_LoadType1FontFromFile(HPDF_Doc pdf, const(char)* afmfilename, const(char)* pfmfilename); 69 70 const(char)* HPDF_LoadTTFontFromFile(HPDF_Doc pdf, const(char)* file_name, HPDF_BOOL embedding); 71 72 const(char)* HPDF_LoadTTFontFromFile2(HPDF_Doc pdf, const(char)* file_name, uint index, HPDF_BOOL embedding); 73 74 HPDF_STATUS HPDF_AddPageLabel(HPDF_Doc pdf, uint page_num, PageNumStyle style, uint first_page, const(char)* prefix); 75 76 HPDF_STATUS HPDF_UseJPFonts(HPDF_Doc pdf); 77 78 HPDF_STATUS HPDF_UseKRFonts(HPDF_Doc pdf); 79 80 HPDF_STATUS HPDF_UseCNSFonts(HPDF_Doc pdf); 81 82 HPDF_STATUS HPDF_UseCNTFonts(HPDF_Doc pdf); 83 84 /* 85 * Encodings 86 */ 87 HPDF_Encoder HPDF_GetEncoder(HPDF_Doc pdf, const(char)* encoding_name); 88 89 HPDF_Encoder HPDF_GetCurrentEncoder(HPDF_Doc pdf); 90 91 HPDF_STATUS HPDF_SetCurrentEncoder(HPDF_Doc pdf, const(char)* encoding_name); 92 93 HPDF_STATUS HPDF_UseJPEncodings(HPDF_Doc pdf); 94 95 HPDF_STATUS HPDF_UseKREncodings(HPDF_Doc pdf); 96 97 HPDF_STATUS HPDF_UseCNSEncodings(HPDF_Doc pdf); 98 99 HPDF_STATUS HPDF_UseCNTEncodings(HPDF_Doc pdf); 100 101 /* 102 *Other Functions 103 */ 104 HPDF_Outline HPDF_CreateOutline(HPDF_Doc pdf, HPDF_Outline parent, const(char)* title, HPDF_Encoder encoder); 105 106 HPDF_Image HPDF_LoadPngImageFromFile(HPDF_Doc pdf, const(char)* filename); 107 108 HPDF_Image HPDF_LoadPngImageFromFile2(HPDF_Doc pdf, const(char)* filename); 109 110 HPDF_Image HPDF_LoadRawImageFromFile(HPDF_Doc pdf, const(char)* filename, uint width, uint height, ColorSpace color_space); 111 112 HPDF_Image HPDF_LoadRawImageFromMem(HPDF_Doc pdf, ubyte* buf, uint width, uint height, ColorSpace color_space, uint bits_per_component); 113 114 HPDF_Image HPDF_LoadJpegImageFromFile(HPDF_Doc pdf, const(char)* filename); 115 116 HPDF_STATUS HPDF_SetInfoAttr(HPDF_Doc pdf, HaruInfoType type, const(char)* value); 117 118 const(char)* HPDF_GetInfoAttr(HPDF_Doc pdf, HaruInfoType type); 119 120 HPDF_STATUS HPDF_SetInfoDateAttr(HPDF_Doc pdf, HaruInfoType type, HaruDate value); 121 122 HPDF_STATUS HPDF_SetPassword(HPDF_Doc pdf, const(char)* owner_passwd, const(char)* user_passwd); 123 124 HPDF_STATUS HPDF_SetPermission(HPDF_Doc pdf, uint permission); 125 126 HPDF_STATUS HPDF_SetEncryptionMode(HPDF_Doc pdf, HaruEncryptMode mode, uint key_len); 127 128 HPDF_STATUS HPDF_SetCompressionMode(HPDF_Doc pdf, uint mode); 129 130 /* 131 * HPDF_Page 132 */ 133 HPDF_STATUS HPDF_Page_SetWidth(HPDF_Page page, float value); 134 135 HPDF_STATUS HPDF_Page_SetHeight(HPDF_Page page, float value); 136 137 HPDF_STATUS HPDF_Page_SetSize(HPDF_Page page, PageSizes size, PageDirection direction); 138 139 HPDF_STATUS HPDF_Page_SetRotate(HPDF_Page page, ushort angle); 140 141 float HPDF_Page_GetWidth(HPDF_Page page); 142 143 float HPDF_Page_GetHeight(HPDF_Page page); 144 145 HPDF_Destination HPDF_Page_CreateDestination(HPDF_Page page); 146 147 HPDF_Annotation HPDF_Page_CreateTextAnnot(HPDF_Page page, Rect rect, const(char)* text, HPDF_Encoder encoder); 148 149 HPDF_Annotation HPDF_Page_CreateLinkAnnot(HPDF_Page page, Rect rect, HPDF_Destination dst); 150 151 HPDF_Annotation HPDF_Page_CreateURILinkAnnot(HPDF_Page page, Rect rect, const(char)* uri); 152 153 float HPDF_Page_TextWidth(HPDF_Page page, const(char)* text); 154 155 uint HPDF_Page_MeasureText(HPDF_Page page, const(char)* text, float width, HPDF_BOOL wordwrap, float* real_width); 156 157 ushort HPDF_Page_GetGMode(HPDF_Page page); 158 159 Point HPDF_Page_GetCurrentPos(HPDF_Page page); 160 161 Point HPDF_Page_GetCurrentTextPos(HPDF_Page page); 162 163 HPDF_Font HPDF_Page_GetCurrentFont(HPDF_Page page); 164 165 float HPDF_Page_GetCurrentFontSize(HPDF_Page page); 166 167 TransMatrix HPDF_Page_GetTransMatrix(HPDF_Page page); 168 169 float HPDF_Page_GetLineWidth(HPDF_Page page); 170 171 HaruLineCap HPDF_Page_GetLineCap(HPDF_Page page); 172 173 HaruLineJoin HPDF_Page_GetLineJoin(HPDF_Page page); 174 175 float HPDF_Page_GetMiterLimit(HPDF_Page page); 176 177 DashMode HPDF_Page_GetDash(HPDF_Page page); 178 179 float HPDF_Page_GetFlat(HPDF_Page page); 180 181 float HPDF_Page_GetCharSpace(HPDF_Page page); 182 183 float HPDF_Page_GetWordSpace(HPDF_Page page); 184 185 float HPDF_Page_GetHorizontalScalling(HPDF_Page page); 186 187 float HPDF_Page_GetTextLeading(HPDF_Page page); 188 189 HaruTextRenderingMode HPDF_Page_GetTextRenderingMode(HPDF_Page page); 190 191 float HPDF_Page_GetTextRise(HPDF_Page page); 192 193 HaruRGBColor HPDF_Page_GetRGBFill(HPDF_Page page); 194 195 HaruRGBColor HPDF_Page_GetRGBStroke(HPDF_Page page); 196 197 HaruCMYKColor HPDF_Page_GetCMYKFill(HPDF_Page page); 198 199 HaruCMYKColor HPDF_Page_GetCMYKStroke(HPDF_Page page); 200 201 float HPDF_Page_GetGrayFill(HPDF_Page page); 202 203 float HPDF_Page_GetGrayStroke(HPDF_Page page); 204 205 ColorSpace HPDF_Page_GetStrokingColorSpace(HPDF_Page page); 206 207 ColorSpace HPDF_Page_GetFillingColorSpace(HPDF_Page page); 208 209 TransMatrix HPDF_Page_GetTextMatrix(HPDF_Page page); 210 211 uint HPDF_Page_GetGStateDepth(HPDF_Page page); 212 213 HPDF_STATUS HPDF_Page_SetSlideShow(HPDF_Page page, HaruTransitionStyle type, float disp_time, float trans_time); 214 215 /* 216 * Graphics 217 */ 218 HPDF_STATUS HPDF_Page_Arc(HPDF_Page page, float x, float y, float ray, float ang1, float ang2); 219 220 HPDF_STATUS HPDF_Page_BeginText(HPDF_Page page); 221 222 HPDF_STATUS HPDF_Page_Circle(HPDF_Page page, float x, float y, float ray); 223 224 HPDF_STATUS HPDF_Page_Clip(HPDF_Page page); 225 226 HPDF_STATUS HPDF_Page_ClosePath(HPDF_Page page); 227 228 HPDF_STATUS HPDF_Page_ClosePathStroke(HPDF_Page page); 229 230 HPDF_STATUS HPDF_Page_ClosePathEoillStroke(HPDF_Page page); 231 232 HPDF_STATUS HPDF_Page_ClosePathFillStroke(HPDF_Page page); 233 234 HPDF_STATUS HPDF_Page_Concat(HPDF_Page page, float a, float b, float c, float d, float x, float y); 235 236 HPDF_STATUS HPDF_Page_CurveTo(HPDF_Page page, float x1, float y1, float x2, float y2, float x3, float y3); 237 238 HPDF_STATUS HPDF_Page_CurveTo2(HPDF_Page page, float x2, float y2, float x3, float y3); 239 240 HPDF_STATUS HPDF_Page_CurveTo3(HPDF_Page page, float x1, float y1, float x3, float y3); 241 242 HPDF_STATUS HPDF_Page_DrawImage(HPDF_Page page, HPDF_Image image, float x, float y, float width, float height); 243 244 HPDF_STATUS HPDF_Page_Ellipse(HPDF_Page page, float x, float y, float xray, float yray); 245 246 HPDF_STATUS HPDF_Page_EndPath(HPDF_Page page); 247 248 HPDF_STATUS HPDF_Page_EndText(HPDF_Page page); 249 250 HPDF_STATUS HPDF_Page_Eoclip(HPDF_Page page); 251 252 HPDF_STATUS HPDF_Page_Eofill(HPDF_Page page); 253 254 HPDF_STATUS HPDF_Page_EofillStroke(HPDF_Page page); 255 256 HPDF_STATUS HPDF_Page_ExecuteXObject(HPDF_Page page, HPDF_XObject obj); 257 258 HPDF_XObject HPDF_Page_CreateXObjectFromImage(HPDF_Doc pdf, HPDF_Page page, Rect rect, HPDF_Image image, HPDF_BOOL zoom); 259 260 HPDF_STATUS HPDF_Page_Fill(HPDF_Page page); 261 262 HPDF_STATUS HPDF_Page_FillStroke(HPDF_Page page); 263 264 HPDF_STATUS HPDF_Page_GRestore(HPDF_Page page); 265 266 HPDF_STATUS HPDF_Page_GSave(HPDF_Page page); 267 268 HPDF_STATUS HPDF_Page_LineTo(HPDF_Page page, float x, float y); 269 270 HPDF_STATUS HPDF_Page_MoveTextPos(HPDF_Page page, float x, float y); 271 272 HPDF_STATUS HPDF_Page_MoveTextPos2(HPDF_Page page, float x, float y); 273 274 HPDF_STATUS HPDF_Page_MoveTo(HPDF_Page page, float x, float y); 275 276 HPDF_STATUS HPDF_Page_MoveToNextLine(HPDF_Page page); 277 278 HPDF_STATUS HPDF_Page_Rectangle(HPDF_Page page, float x, float y, float width, float height); 279 280 HPDF_STATUS HPDF_Page_SetCharSpace(HPDF_Page page, float value); 281 282 HPDF_STATUS HPDF_Page_SetCMYKFill(HPDF_Page page, float c, float m, float y, float k); 283 284 HPDF_STATUS HPDF_Page_SetCMYKStroke(HPDF_Page page, float c, float m, float y, float k); 285 286 HPDF_STATUS HPDF_Page_SetDash(HPDF_Page page, ushort* dash_ptn, uint num_param, uint phase); 287 288 HPDF_STATUS HPDF_Page_SetExtGState(HPDF_Page page, HPDF_ExtGState ext_gstate); 289 290 HPDF_STATUS HPDF_Page_SetGrayFill(HPDF_Page page, float gray); 291 292 HPDF_STATUS HPDF_Page_SetGrayStroke(HPDF_Page page, float gray); 293 294 HPDF_STATUS HPDF_Page_SetFontAndSize(HPDF_Page page, HPDF_Font font, float size); 295 296 HPDF_STATUS HPDF_Page_SetHorizontalScalling(HPDF_Page page, float value); 297 298 HPDF_STATUS HPDF_Page_SetLineWidth(HPDF_Page page, float line_width); 299 300 HPDF_STATUS HPDF_Page_SetLineCap(HPDF_Page page, HaruLineCap line_cap); 301 302 HPDF_STATUS HPDF_Page_SetLineJoin(HPDF_Page page, HaruLineJoin line_join); 303 304 HPDF_STATUS HPDF_Page_SetMiterLimit(HPDF_Page page, float miter_limit); 305 306 HPDF_STATUS HPDF_Page_SetTextLeading(HPDF_Page page, float value); 307 308 HPDF_STATUS HPDF_Page_SetTextMatrix(HPDF_Page page, float a, float b, float c, float d, float x, float y); 309 310 HPDF_STATUS HPDF_Page_SetTextRenderingMode(HPDF_Page page, HaruTextRenderingMode mode); 311 312 HPDF_STATUS HPDF_Page_SetTextRise(HPDF_Page page, float value); 313 314 HPDF_STATUS HPDF_Page_SetRGBFill(HPDF_Page page, float r, float g, float b); 315 316 HPDF_STATUS HPDF_Page_SetRGBStroke(HPDF_Page page, float r, float g, float b); 317 318 HPDF_STATUS HPDF_Page_SetWordSpace(HPDF_Page page, float value); 319 320 HPDF_STATUS HPDF_Page_ShowText(HPDF_Page page, const(char)* text); 321 322 HPDF_STATUS HPDF_Page_ShowTextNextLine(HPDF_Page page, const(char)* text); 323 324 HPDF_STATUS HPDF_Page_ShowTextNextLineEx(HPDF_Page page, float word_space, float char_space, const(char)* text); 325 326 HPDF_STATUS HPDF_Page_Stroke(HPDF_Page page); 327 328 HPDF_STATUS HPDF_Page_TextOut(HPDF_Page page, float xpos, float ypos, const(char)* text); 329 330 HPDF_STATUS HPDF_Page_TextRect(HPDF_Page page, float left, float top, float right, float bottom, const(char)* text, 331 HaruTextAlignment alig, uint* len); 332 333 /* 334 * Font 335 */ 336 const(char)* HPDF_Font_GetFontName(HPDF_Font font); 337 338 const(char)* HPDF_Font_GetEncodingName(HPDF_Font font); 339 340 int HPDF_Font_GetUnicodeWidth(HPDF_Font font, HPDF_UNICODE code); 341 342 HaruBox HPDF_Font_GetBBox(HPDF_Font font); 343 344 int HPDF_Font_GetAscent(HPDF_Font font); 345 346 int HPDF_Font_GetDescent(HPDF_Font font); 347 348 uint HPDF_Font_GetXHeight(HPDF_Font font); 349 350 uint HPDF_Font_GetCapHeight(HPDF_Font font); 351 352 TextWidth HPDF_Font_TextWidth(HPDF_Font font, const(char)* text, uint len); 353 354 uint HPDF_Font_MeasureText(HPDF_Font font, const(char)* text, uint len, float width, float font_size, float char_space, 355 float word_space, HPDF_BOOL wordwrap, float* real_width); 356 357 /* 358 * Encoding 359 */ 360 HaruEncoderType HPDF_Encoder_GetType(HPDF_Encoder encoder); 361 362 HaruByteType HPDF_Encoder_GetByteType(HPDF_Encoder encoder, const(char)* text, uint index); 363 364 HPDF_UNICODE HPDF_Encoder_GetUnicode(HPDF_Encoder encoder, ushort code); 365 366 HaruWritingMode HPDF_Encoder_GetWritingMode(HPDF_Encoder encoder); 367 368 /* 369 * Annotation 370 */ 371 HPDF_STATUS HPDF_LinkAnnot_SetHighlightMode(HPDF_Annotation annot, HaruAnnotHighlightMode mode); 372 373 HPDF_STATUS HPDF_LinkAnnot_SetBorderStyle(HPDF_Annotation annot, float width, ushort dash_on, ushort dash_off); 374 375 HPDF_STATUS HPDF_TextAnnot_SetIcon(HPDF_Annotation annot, HaruAnnotIcon icon); 376 377 HPDF_STATUS HPDF_TextAnnot_SetOpened(HPDF_Annotation annot, HPDF_BOOL open); 378 379 /* 380 * Outline 381 */ 382 HPDF_STATUS HPDF_Outline_SetOpened(HPDF_Outline outline, HPDF_BOOL opened); 383 HPDF_STATUS HPDF_Outline_SetDestination(HPDF_Outline outline, HPDF_Destination dst); 384 385 /* 386 * Destination 387 */ 388 HPDF_STATUS HPDF_Destination_SetXYZ(HPDF_Destination dst, float left, float top, float zoom); 389 390 HPDF_STATUS HPDF_Destination_SetFit(HPDF_Destination dst); 391 392 HPDF_STATUS HPDF_Destination_SetFitH(HPDF_Destination dst, float top); 393 394 HPDF_STATUS HPDF_Destination_SetFitV(HPDF_Destination dst, float left); 395 396 HPDF_STATUS HPDF_Destination_SetFitR(HPDF_Destination dst, float left, float bottom, float right, float top); 397 398 HPDF_STATUS HPDF_Destination_SetFitB(HPDF_Destination dst); 399 400 HPDF_STATUS HPDF_Destination_SetFitBH(HPDF_Destination dst, float top); 401 402 HPDF_STATUS HPDF_Destination_SetFitBV(HPDF_Destination dst, float top); 403 404 /* 405 * Image 406 */ 407 Point HPDF_Image_GetSize(HPDF_Image image); 408 409 uint HPDF_Image_GetWidth(HPDF_Image image); 410 411 uint HPDF_Image_GetHeight(HPDF_Image image); 412 413 uint HPDF_Image_GetBitsPerComponent(HPDF_Image image); 414 415 const(char)* HPDF_Image_GetColorSpace(HPDF_Image image); 416 417 HPDF_STATUS HPDF_Image_SetColorMask(HPDF_Image image, uint rmin, uint rmax, uint gmin, uint gmax, uint bmin, uint bmax); 418 419 HPDF_STATUS HPDF_Image_SetMaskImage(HPDF_Image image, HPDF_Image mask_image); 420 }