2 * << Haru Free PDF Library 2.0.6 >> -- hpdf.cs
4 * C# wrapper for libhpdf.dll
6 * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
8 * Permission to use, copy, modify, distribute and sell this software
9 * and its documentation for any purpose is hereby granted without fee,
10 * provided that the above copyright notice appear in all copies and
11 * that both that copyright notice and this permission notice appear
12 * in supporting documentation.
13 * It is provided "as is" without express or implied warranty.
18 using System.Runtime.InteropServices;
23 public enum HPdfPageLayout : uint {
24 HPDF_PAGE_LAYOUT_SINGLE = 0,
25 HPDF_PAGE_LAYOUT_ONE_COLUMN,
26 HPDF_PAGE_LAYOUT_TWO_CLUMN_LEFT,
27 HPDF_PAGE_LAYOUT_TWO_CLUMN_RIGHT,
31 public enum HPdfPageMode : uint {
32 HPDF_PAGE_MODE_USE_NONE = 0,
33 HPDF_PAGE_MODE_USE_OUTLINE,
34 HPDF_PAGE_MODE_USE_THUMBS,
35 HPDF_PAGE_MODE_FULL_SCREEN,
39 public enum HPdfPageSizes : uint {
40 HPDF_PAGE_SIZE_LETTER = 0,
47 HPDF_PAGE_SIZE_EXECUTIVE,
51 HPDF_PAGE_SIZE_COMM10,
56 public enum HPdfPageDirection : uint {
57 HPDF_PAGE_PORTRAIT = 0,
62 public enum HPdfPageNumStyle : uint {
63 HPDF_PAGE_NUM_STYLE_DECIMAL = 0,
64 HPDF_PAGE_NUM_STYLE_UPPER_ROMAN,
65 HPDF_PAGE_NUM_STYLE_LOWER_ROMAN,
66 HPDF_PAGE_NUM_STYLE_UPPER_LETTERS,
67 HPDF_PAGE_NUM_STYLE_LOWER_LETTERS,
68 HPDF_PAGE_NUM_STYLE_EOF
71 public enum HPdfWritingMode : uint {
72 HPDF_WMODE_HORIZONTAL = 0,
78 public enum HPdfEncoderType : uint {
79 HPDF_ENCODER_TYPE_SINGLE_BYTE = 0,
80 HPDF_ENCODER_TYPE_DOUBLE_BYTE,
81 HPDF_ENCODER_TYPE_UNINITIALIZED,
86 public enum HPdfByteType : uint {
87 HPDF_BYTE_TYPE_SINGLE = 0,
90 HPDF_BYTE_TYPE_UNKNOWN
94 public enum HPdfAnnotHighlightMode : uint {
95 HPDF_ANNOT_NO_HIGHTLIGHT = 0,
96 HPDF_ANNOT_INVERT_BOX,
97 HPDF_ANNOT_INVERT_BORDER,
98 HPDF_ANNOT_DOWN_APPEARANCE,
99 HPDF_ANNOT_HIGHTLIGHT_MODE_EOF
103 public enum HPdfAnnotIcon : uint {
104 HPDF_ANNOT_ICON_COMMENT = 0,
106 HPDF_ANNOT_ICON_NOTE,
107 HPDF_ANNOT_ICON_HELP,
108 HPDF_ANNOT_ICON_NEW_PARAGRAPH,
109 HPDF_ANNOT_ICON_PARAGRAPH,
110 HPDF_ANNOT_ICON_INSERT,
114 public enum HPdfColorSpace : uint {
115 HPDF_CS_DEVICE_GRAY = 0,
130 public enum HPdfInfoType : uint {
131 /* date-time type parameters */
132 HPDF_INFO_CREATION_DATE = 0,
133 HPDF_INFO_MOD_DATE = 1,
135 /* string type parameters */
136 HPDF_INFO_AUTHOR = 2,
137 HPDF_INFO_CREATOR = 3,
138 HPDF_INFO_PRODUCER = 4,
140 HPDF_INFO_SUBJECT = 6,
141 HPDF_INFO_KEYWORDS = 7,
145 public enum HPdfEncryptMode: uint {
150 public enum HPdfTextRenderingMode: uint {
153 HPDF_FILL_THEN_STROKE = 2,
155 HPDF_FILL_CLIPPING = 4,
156 HPDF_STROKE_CLIPPING = 5,
157 HPDF_FILL_STROKE_CLIPPING = 6,
159 HPDF_RENDERING_MODE_EOF = 8
162 public enum HPdfLineCap {
165 HPDF_PROJECTING_SCUARE_END = 2,
169 public enum HPdfLineJoin {
173 HPDF_LINEJOIN_EOF = 3
176 public enum HPdfTextAlignment {
177 HPDF_TALIGN_LEFT = 0,
178 HPDF_TALIGN_RIGHT = 1,
179 HPDF_TALIGN_CENTER = 2,
180 HPDF_TALIGN_JUSTIFY = 3
183 public enum HPdfTransitionStyle {
184 HPDF_TS_WIPE_RIGHT = 0,
188 HPDF_TS_BARN_DOORS_HORIZONTAL_OUT,
189 HPDF_TS_BARN_DOORS_HORIZONTAL_IN,
190 HPDF_TS_BARN_DOORS_VERTICAL_OUT,
191 HPDF_TS_BARN_DOORS_VERTICAL_IN,
194 HPDF_TS_BLINDS_HORIZONTAL,
195 HPDF_TS_BLINDS_VERTICAL,
197 HPDF_TS_GLITTER_RIGHT,
198 HPDF_TS_GLITTER_DOWN,
199 HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT,
205 public enum HPdfBlendMode {
221 [StructLayout(LayoutKind.Sequential)]
222 public struct HPdfRect {
229 [StructLayout(LayoutKind.Sequential)]
230 public struct HPdfBox {
237 [StructLayout(LayoutKind.Sequential)]
238 public struct HPdfPoint {
243 [StructLayout(LayoutKind.Sequential)]
244 public struct HPdfDate {
253 public int off_minutes;
256 [StructLayout(LayoutKind.Sequential)]
257 public struct HPdfTextWidth {
258 public uint numchars;
260 /* don't use this value (it may be change in the feature).
261 use numspace as alternated. */
262 public uint numwords;
265 public uint numspace;
268 [StructLayout(LayoutKind.Sequential)]
269 public struct HPdfTransMatrix {
278 [StructLayout(LayoutKind.Sequential)]
279 public struct HPdfDashMode_Internal {
292 public struct HPdfDashMode {
297 [StructLayout(LayoutKind.Sequential)]
298 public struct HPdfRGBColor {
304 [StructLayout(LayoutKind.Sequential)]
305 public struct HPdfCMYKColor {
313 /* error handler (call back function) */
314 public delegate void HPDF_ErrorHandler(uint error_no, uint detail_no,
317 public class HPdfDoc: IDisposable {
318 public const int HPDF_TRUE = 1;
319 public const int HPDF_FALSE = 0;
320 public const uint HPDF_COMP_NONE = 0;
321 public const uint HPDF_COMP_TEXT = 1;
322 public const uint HPDF_COMP_IMAGE = 2;
323 public const uint HPDF_COMP_METADATA = 4;
324 public const uint HPDF_COMP_ALL = 15;
326 public const uint HPDF_HIDE_TOOLBAR = 1;
327 public const uint HPDF_HIDE_MENUBAR = 2;
328 public const uint HPDF_HIDE_WINDOW_UI = 4;
329 public const uint HPDF_FIT_WINDOW = 8;
330 public const uint HPDF_CENTER_WINDOW = 16;
332 public const uint HPDF_ENABLE_READ = 0;
333 public const uint HPDF_ENABLE_PRINT = 4;
334 public const uint HPDF_ENABLE_EDIT_ALL = 8;
335 public const uint HPDF_ENABLE_COPY = 16;
336 public const uint HPDF_ENABLE_EDIT = 32;
339 [DllImport("libhpdf.dll")]
340 private extern static string HPDF_GetVersion();
342 [DllImport("libhpdf.dll")]
343 private extern static IntPtr HPDF_New(HPDF_ErrorHandler user_error_fn,
346 [DllImport("libhpdf.dll")]
347 private extern static void HPDF_Free(IntPtr pdf);
349 [DllImport("libhpdf.dll")]
350 private extern static uint HPDF_NewDoc(IntPtr pdf);
352 [DllImport("libhpdf.dll")]
353 private extern static uint HPDF_FreeDoc(IntPtr pdf);
355 [DllImport("libhpdf.dll")]
356 private extern static uint HPDF_FreeDocAll(IntPtr pdf);
358 [DllImport("libhpdf.dll")]
359 private extern static uint HPDF_HasDoc(IntPtr pdf);
361 [DllImport("libhpdf.dll")]
362 private extern static uint HPDF_SaveToFile(IntPtr pdf, string file_name);
364 [DllImport("libhpdf.dll")]
365 private extern static uint HPDF_GetError(IntPtr pdf);
367 [DllImport("libhpdf.dll")]
368 private extern static uint HPDF_GetErrorDetail(IntPtr pdf);
370 [DllImport("libhpdf.dll")]
371 private extern static void HPDF_ResetError(IntPtr pdf);
373 [DllImport("libhpdf.dll")]
374 private extern static uint HPDF_SetPagesConfiguration(IntPtr pdf,
375 uint page_per_pages);
377 [DllImport("libhpdf.dll")]
378 private extern static IntPtr HPDF_GetPageByIndex(IntPtr pdf,
381 [DllImport("libhpdf.dll")]
382 private extern static HPdfPageLayout HPDF_GetPageLayout(IntPtr pdf);
384 [DllImport("libhpdf.dll")]
385 private extern static uint HPDF_SetPageLayout(IntPtr pdf,
386 HPdfPageLayout layout);
388 [DllImport("libhpdf.dll")]
389 private extern static HPdfPageMode HPDF_GetPageMode(IntPtr pdf);
391 [DllImport("libhpdf.dll")]
392 private extern static uint HPDF_SetPageMode(IntPtr pdf, HPdfPageMode mode);
394 [DllImport("libhpdf.dll")]
395 private extern static uint HPDF_SetOpenAction(IntPtr pdf,
398 [DllImport("libhpdf.dll")]
399 private extern static uint HPDF_GetViewerPreference(IntPtr pdf);
401 [DllImport("libhpdf.dll")]
402 private extern static uint HPDF_SetViewerPreference(IntPtr pdf, uint value);
404 [DllImport("libhpdf.dll")]
405 private extern static IntPtr HPDF_GetCurrentPage(IntPtr pdf);
407 [DllImport("libhpdf.dll")]
408 private extern static IntPtr HPDF_AddPage(IntPtr pdf);
410 [DllImport("libhpdf.dll")]
411 private extern static IntPtr HPDF_InsertPage(IntPtr pdf,
414 [DllImport("libhpdf.dll")]
415 private extern static IntPtr HPDF_GetFont(IntPtr pdf, string font_name,
416 string encoding_name);
418 [DllImport("libhpdf.dll")]
419 private extern static string HPDF_LoadType1FontFromFile(IntPtr pdf,
420 string afmfilename, string pfmfilename);
422 [DllImport("libhpdf.dll")]
423 private extern static string HPDF_LoadTTFontFromFile(IntPtr pdf,
424 string file_name, int embedding);
426 [DllImport("libhpdf.dll")]
427 private extern static string HPDF_LoadTTFontFromFile2(IntPtr pdf,
428 string file_name, uint index, int embedding);
430 [DllImport("libhpdf.dll")]
431 private extern static uint HPDF_AddPageLabel(IntPtr pdf, uint page_num,
432 HPdfPageNumStyle style, uint first_page, string prefix);
434 [DllImport("libhpdf.dll")]
435 private extern static uint HPDF_UseJPFonts(IntPtr pdf);
437 [DllImport("libhpdf.dll")]
438 private extern static uint HPDF_UseKRFonts(IntPtr pdf);
440 [DllImport("libhpdf.dll")]
441 private extern static uint HPDF_UseCNSFonts(IntPtr pdf);
443 [DllImport("libhpdf.dll")]
444 private extern static uint HPDF_UseCNTFonts(IntPtr pdf);
446 [DllImport("libhpdf.dll")]
447 private extern static IntPtr HPDF_CreateOutline(IntPtr pdf, IntPtr parent,
448 string title, IntPtr encoder);
450 [DllImport("libhpdf.dll")]
451 private extern static IntPtr HPDF_GetEncoder(IntPtr pdf,
452 string encoding_name);
454 [DllImport("libhpdf.dll")]
455 private extern static IntPtr HPDF_GetCurrentEncoder(IntPtr pdf);
457 [DllImport("libhpdf.dll")]
458 private extern static uint HPDF_SetCurrentEncoder(IntPtr pdf,
459 string encoding_name);
461 [DllImport("libhpdf.dll")]
462 private extern static uint HPDF_UseJPEncodings(IntPtr pdf);
464 [DllImport("libhpdf.dll")]
465 private extern static uint HPDF_UseKREncodings(IntPtr pdf);
467 [DllImport("libhpdf.dll")]
468 private extern static uint HPDF_UseCNSEncodings(IntPtr pdf);
470 [DllImport("libhpdf.dll")]
471 private extern static uint HPDF_UseCNTEncodings(IntPtr pdf);
473 [DllImport("libhpdf.dll")]
474 private extern static IntPtr HPDF_LoadPngImageFromFile(IntPtr pdf,
477 [DllImport("libhpdf.dll")]
478 private extern static IntPtr HPDF_LoadPngImageFromFile2(IntPtr pdf,
481 [DllImport("libhpdf.dll")]
482 private extern static IntPtr HPDF_LoadJpegImageFromFile(IntPtr pdf,
485 [DllImport("libhpdf.dll")]
486 private extern static IntPtr HPDF_LoadRawImageFromFile(IntPtr pdf,
487 string filename, uint width, uint height,
488 HPdfColorSpace color_space);
490 [DllImport("libhpdf.dll")]
491 private extern static IntPtr HPDF_LoadRawImageFromMem(IntPtr pdf,
492 byte[] data, int width, int height,
493 HPdfColorSpace color_space,
494 uint bits_per_component);
496 [DllImport("libhpdf.dll")]
497 private extern static uint HPDF_SetInfoAttr(IntPtr pdf,
498 HPdfInfoType type, string value);
500 [DllImport("libhpdf.dll")]
501 private extern static uint HPDF_SetInfoDateAttr(IntPtr pdf,
502 HPdfInfoType type, HPdfDate value);
504 [DllImport("libhpdf.dll")]
505 private extern static string HPDF_GetInfoAttr(IntPtr pdf,
508 [DllImport("libhpdf.dll")]
509 private extern static uint HPDF_SetPassword(IntPtr pdf,
510 string owner_passwd, string user_passwd);
512 [DllImport("libhpdf.dll")]
513 private extern static uint HPDF_SetPermission(IntPtr pdf,
516 [DllImport("libhpdf.dll")]
517 private extern static uint HPDF_SetEncryptionMode(IntPtr pdf,
518 HPdfEncryptMode mode, uint key_len);
520 [DllImport("libhpdf.dll")]
521 private extern static uint HPDF_SetCompressionMode(IntPtr pdf,
524 [DllImport("libhpdf.dll")]
525 private extern static IntPtr HPDF_CreateExtGState(IntPtr pdf);
527 // handle to an instance of a HPdfDoc object.
531 HPDF_ErrorHandler error_handler =
532 new HPDF_ErrorHandler(HPdfDoc.ErrorProc);
533 hpdf = HPDF_New(error_handler, IntPtr.Zero);
534 if (hpdf == IntPtr.Zero) {
535 throw new Exception("cannot create HPdfDoc object.");
539 void IDisposable.Dispose() {
540 if (hpdf != IntPtr.Zero) {
548 if (hpdf != IntPtr.Zero) {
553 public static string HPdfGetVersion() {
554 return HPDF_GetVersion();
557 public static void ErrorProc(uint error_no, uint detail_no,
559 string s = "error-code=0x" + error_no.ToString("X") + " detail-code=" + detail_no;
560 throw new Exception(s);
563 public void NewDoc() {
567 public void FreeDoc() {
571 public void FreeDocAll() {
572 HPDF_FreeDocAll(hpdf);
575 public bool HasDoc() {
576 return (HPDF_HasDoc(hpdf) != 0);
579 public void SaveToFile(string file_name) {
580 HPDF_SaveToFile(hpdf, file_name);
583 public uint GetError() {
584 return HPDF_GetError(hpdf);
587 public uint GetErrorDetail() {
588 return HPDF_GetErrorDetail(hpdf);
591 public void ResetError() {
592 HPDF_ResetError(hpdf);
595 public void SetPagesConfiguration(uint page_per_pages) {
596 HPDF_SetPagesConfiguration(hpdf, page_per_pages);
599 public HPdfPage GetPageByIndex(uint index) {
602 hpage = HPDF_GetPageByIndex(hpdf, index);
603 return new HPdfPage(hpage);
606 public HPdfPageLayout GetPageLayout() {
607 return HPDF_GetPageLayout(hpdf);
610 public void SetPageLayout(HPdfPageLayout layout) {
611 HPDF_SetPageLayout(hpdf, layout);
614 public HPdfPageMode GetPageMode() {
615 return HPDF_GetPageMode(hpdf);
618 public void SetPageMode(HPdfPageMode mode) {
619 HPDF_SetPageMode(hpdf, mode);
622 public void SetOpenAction(HPdfDestination open_action) {
623 if (open_action == null) {
626 HPDF_SetOpenAction(hpdf, open_action.GetHandle());
630 public uint GetViewerPreference() {
631 return HPDF_GetViewerPreference(hpdf);
634 public void SetViewerPreference(uint value) {
635 HPDF_SetViewerPreference(hpdf, value);
638 public HPdfPage GetCurrentPage() {
641 hpage = HPDF_GetCurrentPage(hpdf);
642 return new HPdfPage(hpage);
645 public HPdfPage AddPage() {
648 hpage = HPDF_AddPage(hpdf);
649 return new HPdfPage(hpage);
652 public HPdfPage InsertPage(HPdfPage page) {
655 hpage = HPDF_InsertPage(hpdf, page.GetHandle());
656 return new HPdfPage(hpage);
659 public HPdfFont GetFont(string font_name, string encoding_name) {
662 hfont = HPDF_GetFont(hpdf, font_name, encoding_name);
663 return new HPdfFont(hfont);
666 public string LoadType1FontFromFile(string afmfilename,
667 string pfmfilename) {
670 font_name = HPDF_LoadType1FontFromFile(hpdf, afmfilename, pfmfilename);
674 public string LoadTTFontFromFile(string file_name, bool embedding) {
683 font_name = HPDF_LoadTTFontFromFile(hpdf, file_name, emb);
687 public string LoadTTFontFromFile2(string file_name, uint index,
697 font_name = HPDF_LoadTTFontFromFile2(hpdf, file_name, index, emb);
701 public void AddPageLabel(uint page_num, HPdfPageNumStyle style,
702 uint first_page, string prefix) {
703 HPDF_AddPageLabel(hpdf, page_num, style, first_page, prefix);
706 public uint UseJPFonts() {
707 return HPDF_UseJPFonts(hpdf);
710 public uint UseKRFonts() {
711 return HPDF_UseKRFonts(hpdf);
714 public uint UseCNSFonts() {
715 return HPDF_UseCNSFonts(hpdf);
718 public uint UseCNTFonts() {
719 return HPDF_UseCNTFonts(hpdf);
722 public HPdfOutline CreateOutline(HPdfOutline parent, string title,
723 HPdfEncoder encoder) {
729 hencoder = encoder.GetHandle();
731 hencoder = IntPtr.Zero;
734 hparent = parent.GetHandle();
736 hparent = IntPtr.Zero;
738 houtline = HPDF_CreateOutline(hpdf, hparent, title, hencoder);
739 return new HPdfOutline(houtline);
742 public HPdfEncoder GetEncoder(string encoding_name) {
745 hencoder = HPDF_GetEncoder(hpdf, encoding_name);
747 return new HPdfEncoder(hencoder);
750 public HPdfEncoder GetCurrentEncoder() {
753 hencoder = HPDF_GetCurrentEncoder(hpdf);
755 return new HPdfEncoder(hencoder);
758 public void SetCurrentEncoder(string encoding_name) {
759 HPDF_SetCurrentEncoder(hpdf, encoding_name);
762 public uint UseJPEncodings() {
763 return HPDF_UseJPEncodings(hpdf);
766 public uint UseKREncodings() {
767 return HPDF_UseKREncodings(hpdf);
770 public uint UseCNSEncodings() {
771 return HPDF_UseCNSEncodings(hpdf);
774 public uint UseCNTEncodings() {
775 return HPDF_UseCNTEncodings(hpdf);
778 public HPdfImage LoadPngImageFromFile(string filename) {
781 hobj = HPDF_LoadPngImageFromFile(hpdf, filename);
783 return new HPdfImage(hobj);
786 public HPdfImage LoadPngImageFromFile2(string filename) {
789 hobj = HPDF_LoadPngImageFromFile2(hpdf, filename);
791 return new HPdfImage(hobj);
794 public HPdfImage LoadJpegImageFromFile(string filename) {
797 hobj = HPDF_LoadJpegImageFromFile(hpdf, filename);
799 return new HPdfImage(hobj);
802 public HPdfImage LoadRawImageFromFile(string filename,
803 uint width, uint height,
804 HPdfColorSpace color_space) {
807 hobj = HPDF_LoadRawImageFromFile(hpdf, filename, width, height,
810 return new HPdfImage(hobj);
813 public HPdfImage LoadRawImageFromMem(byte[] data, int width, int height,
814 HPdfColorSpace color_space, uint bits_per_component) {
815 if (width * height < data.Length) {
816 string s = "error-code=0x1030 detail-code=0";
817 throw new Exception(s);
821 hobj = HPDF_LoadRawImageFromMem(hpdf, data, width, height, color_space,
824 return new HPdfImage(hobj);
827 public void SetInfoAttr(HPdfInfoType type, string value) {
828 HPDF_SetInfoAttr(hpdf, type, value);
831 public void SetInfoDateAttr(HPdfInfoType type, HPdfDate value) {
832 HPDF_SetInfoDateAttr(hpdf, type, value);
835 public string GetInfoAttr(HPdfInfoType type) {
836 return HPDF_GetInfoAttr(hpdf, type);
839 public void SetPassword(string owner_passwd, string user_passwd) {
840 HPDF_SetPassword(hpdf, owner_passwd, user_passwd);
843 public void SetPermission(uint permission) {
844 HPDF_SetPermission(hpdf, permission);
847 public void SetEncryptionMode(HPdfEncryptMode mode, uint key_len) {
848 HPDF_SetEncryptionMode(hpdf, mode, key_len);
851 public void SetCompressionMode(uint mode) {
852 HPDF_SetCompressionMode(hpdf, mode);
855 public HPdfExtGState CreateExtGState() {
858 hgstate = HPDF_CreateExtGState(hpdf);
860 return new HPdfExtGState(hgstate);
864 public class HPdfPage{
865 public const int HPDF_TRUE = 1;
866 public const int HPDF_FALSE = 0;
868 [DllImport("libhpdf.dll")]
869 private extern static uint HPDF_Page_SetWidth(IntPtr page, float value);
871 [DllImport("libhpdf.dll")]
872 private extern static uint HPDF_Page_SetHeight(IntPtr page, float value);
874 [DllImport("libhpdf.dll")]
875 private extern static uint HPDF_Page_SetSize(IntPtr page,
876 HPdfPageSizes size, HPdfPageDirection direction);
878 [DllImport("libhpdf.dll")]
879 private extern static uint HPDF_Page_SetRotate(IntPtr page, ushort angle);
881 [DllImport("libhpdf.dll")]
882 private extern static IntPtr HPDF_Page_CreateDestination(IntPtr page);
884 [DllImport("libhpdf.dll")]
885 private extern static IntPtr HPDF_Page_CreateTextAnnot(IntPtr page,
886 HPdfRect rect, string text, IntPtr encoder);
888 [DllImport("libhpdf.dll")]
889 private extern static IntPtr HPDF_Page_CreateLinkAnnot(IntPtr page,
890 HPdfRect rect, IntPtr dst);
892 [DllImport("libhpdf.dll")]
893 private extern static IntPtr HPDF_Page_CreateURILinkAnnot(IntPtr page,
894 HPdfRect rect, string url);
896 [DllImport("libhpdf.dll")]
897 private extern static float HPDF_Page_TextWidth(IntPtr page,
900 [DllImport("libhpdf.dll")]
901 private extern static uint HPDF_Page_MeasureText(IntPtr page,
902 string text, float width, int wordwrap, ref float real_width);
904 [DllImport("libhpdf.dll")]
905 private extern static float HPDF_Page_GetWidth(IntPtr page);
907 [DllImport("libhpdf.dll")]
908 private extern static float HPDF_Page_GetHeight(IntPtr page);
910 [DllImport("libhpdf.dll")]
911 private extern static ushort HPDF_Page_GetGMode(IntPtr page);
913 [DllImport("libhpdf.dll")]
914 private extern static HPdfPoint HPDF_Page_GetCurrentPos(IntPtr page);
916 [DllImport("libhpdf.dll")]
917 private extern static HPdfPoint HPDF_Page_GetCurrentTextPos(IntPtr page);
919 [DllImport("libhpdf.dll")]
920 private extern static IntPtr HPDF_Page_GetCurrentFont(IntPtr page);
922 [DllImport("libhpdf.dll")]
923 private extern static float HPDF_Page_GetCurrentFontSize(IntPtr page);
925 [DllImport("libhpdf.dll")]
926 private extern static HPdfTransMatrix HPDF_Page_GetTransMatrix(IntPtr page);
928 [DllImport("libhpdf.dll")]
929 private extern static float HPDF_Page_GetLineWidth(IntPtr page);
931 [DllImport("libhpdf.dll")]
932 private extern static HPdfLineCap HPDF_Page_GetLineCap(IntPtr page);
934 [DllImport("libhpdf.dll")]
935 private extern static HPdfLineJoin HPDF_Page_GetLineJoin(IntPtr page);
937 [DllImport("libhpdf.dll")]
938 private extern static float HPDF_Page_GetMiterLimit(IntPtr page);
940 [DllImport("libhpdf.dll")]
941 private extern static HPdfDashMode_Internal HPDF_Page_GetDash(IntPtr page);
943 [DllImport("libhpdf.dll")]
944 private extern static float HPDF_Page_GetFlat(IntPtr page);
946 [DllImport("libhpdf.dll")]
947 private extern static float HPDF_Page_GetCharSpace(IntPtr page);
949 [DllImport("libhpdf.dll")]
950 private extern static float HPDF_Page_GetWordSpace(IntPtr page);
952 [DllImport("libhpdf.dll")]
953 private extern static float HPDF_Page_GetHorizontalScalling(IntPtr page);
955 [DllImport("libhpdf.dll")]
956 private extern static float HPDF_Page_GetTextLeading(IntPtr page);
958 [DllImport("libhpdf.dll")]
959 private extern static HPdfTextRenderingMode HPDF_Page_GetTextRenderingMode(IntPtr page);
961 [DllImport("libhpdf.dll")]
962 private extern static float HPDF_Page_GetTextRaise(IntPtr page);
964 [DllImport("libhpdf.dll")]
965 private extern static HPdfRGBColor HPDF_Page_GetRGBFill(IntPtr page);
967 [DllImport("libhpdf.dll")]
968 private extern static HPdfRGBColor HPDF_Page_GetRGBStroke(IntPtr page);
970 [DllImport("libhpdf.dll")]
971 private extern static HPdfCMYKColor HPDF_Page_GetCMYKFill(IntPtr page);
973 [DllImport("libhpdf.dll")]
974 private extern static HPdfCMYKColor HPDF_Page_GetCMYKStroke(IntPtr page);
976 [DllImport("libhpdf.dll")]
977 private extern static float HPDF_Page_GetGrayFill(IntPtr page);
979 [DllImport("libhpdf.dll")]
980 private extern static float HPDF_Page_GetGrayStroke(IntPtr page);
982 [DllImport("libhpdf.dll")]
983 private extern static HPdfColorSpace HPDF_Page_GetStrokingColorSpace(IntPtr page);
985 [DllImport("libhpdf.dll")]
986 private extern static HPdfColorSpace HPDF_Page_GetFillingColorSpace(IntPtr page);
988 [DllImport("libhpdf.dll")]
989 private extern static HPdfTransMatrix HPDF_Page_GetTextMatrix(IntPtr page);
991 [DllImport("libhpdf.dll")]
992 private extern static uint HPDF_Page_GetGStateDepth(IntPtr page);
994 /*--- General graphics state -----------------------------------------------*/
996 [DllImport("libhpdf.dll")]
997 private extern static uint HPDF_Page_SetLineWidth(IntPtr page,
1000 [DllImport("libhpdf.dll")]
1001 private extern static uint HPDF_Page_SetLineCap(IntPtr page,
1002 HPdfLineCap line_cap);
1004 [DllImport("libhpdf.dll")]
1005 private extern static uint HPDF_Page_SetLineJoin(IntPtr page,
1006 HPdfLineJoin line_join);
1008 [DllImport("libhpdf.dll")]
1009 private extern static uint HPDF_Page_SetMiterLimit(IntPtr page,
1012 [DllImport("libhpdf.dll")]
1013 private extern static uint HPDF_Page_SetDash(IntPtr page,
1014 ushort[] array, uint num_param, uint phase);
1016 [DllImport("libhpdf.dll")]
1017 private extern static uint HPDF_Page_SetFlat(IntPtr page,
1020 [DllImport("libhpdf.dll")]
1021 private extern static uint HPDF_Page_SetExtGState(IntPtr page,
1024 [DllImport("libhpdf.dll")]
1025 private extern static uint HPDF_Page_GSave(IntPtr page);
1027 [DllImport("libhpdf.dll")]
1028 private extern static uint HPDF_Page_GRestore(IntPtr page);
1030 [DllImport("libhpdf.dll")]
1031 private extern static uint HPDF_Page_Concat(IntPtr page,
1032 float a, float b, float c, float d, float x, float y);
1034 [DllImport("libhpdf.dll")]
1035 private extern static uint HPDF_Page_MoveTo(IntPtr page,
1038 [DllImport("libhpdf.dll")]
1039 private extern static uint HPDF_Page_LineTo(IntPtr page,
1042 [DllImport("libhpdf.dll")]
1043 private extern static uint HPDF_Page_CurveTo(IntPtr page,
1044 float x1, float y1, float x2, float y2, float x3, float y3);
1046 [DllImport("libhpdf.dll")]
1047 private extern static uint HPDF_Page_CurveTo2(IntPtr page,
1048 float x2, float y2, float x3, float y3);
1050 [DllImport("libhpdf.dll")]
1051 private extern static uint HPDF_Page_CurveTo3(IntPtr page,
1052 float x1, float y1, float x3, float y3);
1054 [DllImport("libhpdf.dll")]
1055 private extern static uint HPDF_Page_ClosePath(IntPtr page);
1057 [DllImport("libhpdf.dll")]
1058 private extern static uint HPDF_Page_Rectangle(IntPtr page,
1059 float x, float y, float width, float height);
1061 [DllImport("libhpdf.dll")]
1062 private extern static uint HPDF_Page_Stroke(IntPtr page);
1064 [DllImport("libhpdf.dll")]
1065 private extern static uint HPDF_Page_ClosePathStroke(IntPtr page);
1067 [DllImport("libhpdf.dll")]
1068 private extern static uint HPDF_Page_Fill(IntPtr page);
1070 [DllImport("libhpdf.dll")]
1071 private extern static uint HPDF_Page_Eofill(IntPtr page);
1073 [DllImport("libhpdf.dll")]
1074 private extern static uint HPDF_Page_FillStroke(IntPtr page);
1076 [DllImport("libhpdf.dll")]
1077 private extern static uint HPDF_Page_EofillStroke(IntPtr page);
1079 [DllImport("libhpdf.dll")]
1080 private extern static uint HPDF_Page_ClosePathFillStroke(IntPtr page);
1082 [DllImport("libhpdf.dll")]
1083 private extern static uint HPDF_Page_ClosePathEofillStroke(IntPtr page);
1085 [DllImport("libhpdf.dll")]
1086 private extern static uint HPDF_Page_EndPath(IntPtr page);
1088 /*--- Clipping paths operator --------------------------------------------*/
1090 [DllImport("libhpdf.dll")]
1091 private extern static uint HPDF_Page_Clip(IntPtr page);
1093 [DllImport("libhpdf.dll")]
1094 private extern static uint HPDF_Page_Eoclip(IntPtr page);
1096 /*--- Text object operator -----------------------------------------------*/
1098 [DllImport("libhpdf.dll")]
1099 private extern static uint HPDF_Page_BeginText(IntPtr page);
1101 [DllImport("libhpdf.dll")]
1102 private extern static uint HPDF_Page_EndText(IntPtr page);
1104 /*--- Text state ---------------------------------------------------------*/
1106 [DllImport("libhpdf.dll")]
1107 private extern static uint HPDF_Page_SetCharSpace(IntPtr page,
1110 [DllImport("libhpdf.dll")]
1111 private extern static uint HPDF_Page_SetWordSpace(IntPtr page,
1114 [DllImport("libhpdf.dll")]
1115 private extern static uint HPDF_Page_SetHorizontalScalling(IntPtr page,
1118 [DllImport("libhpdf.dll")]
1119 private extern static uint HPDF_Page_SetTextLeading(IntPtr page,
1122 [DllImport("libhpdf.dll")]
1123 private extern static uint HPDF_Page_SetFontAndSize(IntPtr page,
1124 IntPtr hfont, float size);
1126 [DllImport("libhpdf.dll")]
1127 private extern static uint HPDF_Page_SetTextRenderingMode(IntPtr page,
1128 HPdfTextRenderingMode mode);
1130 [DllImport("libhpdf.dll")]
1131 private extern static uint HPDF_Page_SetTextRaise(IntPtr page,
1134 /*--- Text positioning ---------------------------------------------------*/
1136 [DllImport("libhpdf.dll")]
1137 private extern static uint HPDF_Page_MoveTextPos(IntPtr page,
1140 [DllImport("libhpdf.dll")]
1141 private extern static uint HPDF_Page_MoveTextPos2(IntPtr page,
1144 [DllImport("libhpdf.dll")]
1145 private extern static uint HPDF_Page_SetTextMatrix(IntPtr page,
1146 float a, float b, float c, float d, float x, float y);
1148 [DllImport("libhpdf.dll")]
1149 private extern static uint HPDF_Page_MoveToNextLine(IntPtr page);
1151 /*--- Text showing -------------------------------------------------------*/
1153 [DllImport("libhpdf.dll")]
1154 private extern static uint HPDF_Page_ShowText(IntPtr page,
1157 [DllImport("libhpdf.dll")]
1158 private extern static uint HPDF_Page_ShowTextNextLine(IntPtr page,
1161 [DllImport("libhpdf.dll")]
1162 private extern static uint HPDF_Page_ShowTextNextLineEx(IntPtr page,
1163 float word_space, float char_space, string text);
1165 /*--- Color showing ------------------------------------------------------*/
1167 [DllImport("libhpdf.dll")]
1168 private extern static uint HPDF_Page_SetGrayFill(IntPtr page,
1171 [DllImport("libhpdf.dll")]
1172 private extern static uint HPDF_Page_SetGrayStroke(IntPtr page,
1175 [DllImport("libhpdf.dll")]
1176 private extern static uint HPDF_Page_SetRGBFill(IntPtr page,
1177 float r, float g, float b);
1179 [DllImport("libhpdf.dll")]
1180 private extern static uint HPDF_Page_SetRGBStroke(IntPtr page,
1181 float r, float g, float b);
1183 [DllImport("libhpdf.dll")]
1184 private extern static uint HPDF_Page_SetCMYKFill(IntPtr page,
1185 float c, float m, float y, float k);
1187 [DllImport("libhpdf.dll")]
1188 private extern static uint HPDF_Page_SetCMYKStroke(IntPtr page,
1189 float c, float m, float y, float k);
1191 [DllImport("libhpdf.dll")]
1192 private extern static uint HPDF_Page_ExecuteXObject(IntPtr page,
1195 /*---------------------------------------------------------------------*/
1197 [DllImport("libhpdf.dll")]
1198 private extern static uint HPDF_Page_DrawImage(IntPtr page,
1199 IntPtr image, float x, float y, float width, float height);
1201 [DllImport("libhpdf.dll")]
1202 private extern static uint HPDF_Page_Circle(IntPtr page,
1203 float x, float y, float ray);
1205 [DllImport("libhpdf.dll")]
1206 private extern static uint HPDF_Page_Arc(IntPtr page,
1207 float x, float y, float ray, float ang1, float ang2);
1209 [DllImport("libhpdf.dll")]
1210 private extern static uint HPDF_Page_Ellipse(IntPtr page,
1211 float x, float y, float xray, float yray);
1213 [DllImport("libhpdf.dll")]
1214 private extern static uint HPDF_Page_TextOut(IntPtr page,
1215 float xpos, float ypos, string text);
1217 [DllImport("libhpdf.dll")]
1218 private extern static uint HPDF_Page_TextRect(IntPtr page,
1219 float left, float top, float right, float bottom,
1220 string text, HPdfTextAlignment align, ref uint len);
1222 [DllImport("libhpdf.dll")]
1223 private extern static uint HPDF_Page_SetSlideShow(IntPtr page,
1224 HPdfTransitionStyle type, float disp_time, float trans_time);
1227 // handle to an instance of a HPDF_Doc object.
1228 private IntPtr hpage;
1230 public HPdfPage(IntPtr hpage) {
1231 if (hpage == IntPtr.Zero) {
1232 throw new Exception("cannot create HPdfPage object.");
1238 public void SetWidth(float value) {
1239 HPDF_Page_SetWidth(hpage, value);
1242 public void SetHeight(float value) {
1243 HPDF_Page_SetHeight(hpage, value);
1246 public void SetSize(HPdfPageSizes size,
1247 HPdfPageDirection direction) {
1248 HPDF_Page_SetSize(hpage, size, direction);
1251 public void SetRotate(ushort angle) {
1252 HPDF_Page_SetRotate(hpage, angle);
1255 public HPdfDestination CreateDestination() {
1258 hdest = HPDF_Page_CreateDestination(hpage);
1259 return new HPdfDestination(hdest);
1262 public HPdfAnnotation CreateTextAnnot(HPdfRect rect, string text,
1263 HPdfEncoder encoder) {
1266 hannot = HPDF_Page_CreateTextAnnot(hpage, rect, text, encoder.GetHandle());
1267 return new HPdfAnnotation(hannot);
1270 public HPdfAnnotation CreateLinkAnnot(HPdfRect rect, HPdfDestination dst) {
1273 hannot = HPDF_Page_CreateLinkAnnot(hpage, rect, dst.GetHandle());
1274 return new HPdfAnnotation(hannot);
1277 public HPdfAnnotation CreateURILinkAnnot(HPdfRect rect, string uri) {
1280 hannot = HPDF_Page_CreateURILinkAnnot(hpage, rect, uri);
1281 return new HPdfAnnotation(hannot);
1285 public float TextWidth(string text) {
1286 return HPDF_Page_TextWidth(hpage, text);
1289 public uint MeasureText(string text, float width, bool wordwrap,
1290 ref float real_width) {
1298 return HPDF_Page_MeasureText(hpage, text, width, ww, ref real_width);
1301 public uint MeasureText(string text, float width, bool wordwrap) {
1310 return HPDF_Page_MeasureText(hpage, text, width, ww, ref dummy);
1313 public float GetWidth() {
1314 return HPDF_Page_GetWidth(hpage);
1317 public float GetHeight() {
1318 return HPDF_Page_GetHeight(hpage);
1321 public ushort GetGMode() {
1322 return HPDF_Page_GetGMode(hpage);
1325 public HPdfPoint GetCurrentPos() {
1326 return HPDF_Page_GetCurrentPos(hpage);
1329 public HPdfPoint GetCurrentTextPos() {
1330 return HPDF_Page_GetCurrentTextPos(hpage);
1333 public HPdfFont GetCurrentFont() {
1334 return new HPdfFont(HPDF_Page_GetCurrentFont(hpage));
1337 public float GetCurrentFontSize() {
1338 return HPDF_Page_GetCurrentFontSize(hpage);
1341 public HPdfTransMatrix GetTransMatrix() {
1342 return HPDF_Page_GetTransMatrix(hpage);
1345 public float GetLineWidth() {
1346 return HPDF_Page_GetLineWidth(hpage);
1349 public HPdfLineCap GetLineCap() {
1350 return HPDF_Page_GetLineCap(hpage);
1353 public HPdfLineJoin GetLineJoin() {
1354 return HPDF_Page_GetLineJoin(hpage);
1357 public float GetMiterLimit() {
1358 return HPDF_Page_GetMiterLimit(hpage);
1361 public HPdfDashMode GetDash() {
1362 HPdfDashMode_Internal mode1 = HPDF_Page_GetDash(hpage);
1365 mode2.phase = mode1.phase;
1366 mode2.ptn = new ushort[mode1.num_ptn];
1368 if (mode1.num_ptn >= 1)
1369 mode2.ptn[0] = mode1.ptn0;
1371 if (mode1.num_ptn >= 2)
1372 mode2.ptn[1] = mode1.ptn1;
1374 if (mode1.num_ptn >= 3)
1375 mode2.ptn[2] = mode1.ptn2;
1377 if (mode1.num_ptn >= 4)
1378 mode2.ptn[3] = mode1.ptn3;
1380 if (mode1.num_ptn >= 5)
1381 mode2.ptn[4] = mode1.ptn4;
1383 if (mode1.num_ptn >= 6)
1384 mode2.ptn[5] = mode1.ptn5;
1386 if (mode1.num_ptn >= 7)
1387 mode2.ptn[6] = mode1.ptn6;
1389 if (mode1.num_ptn >= 8)
1390 mode2.ptn[7] = mode1.ptn7;
1395 public float GetFlat() {
1396 return HPDF_Page_GetFlat(hpage);
1399 public float GetCharSpace() {
1400 return HPDF_Page_GetCharSpace(hpage);
1403 public float GetWordSpace() {
1404 return HPDF_Page_GetWordSpace(hpage);
1407 public float GetHorizontalScalling() {
1408 return HPDF_Page_GetHorizontalScalling(hpage);
1411 public float GetTextLeading() {
1412 return HPDF_Page_GetTextLeading(hpage);
1415 public HPdfTextRenderingMode GetTextRenderingMode() {
1416 return HPDF_Page_GetTextRenderingMode(hpage);
1419 public float GetTextRaise() {
1420 return HPDF_Page_GetTextRaise(hpage);
1423 public HPdfRGBColor GetRGBFill() {
1424 return HPDF_Page_GetRGBFill(hpage);
1427 public HPdfRGBColor GetRGBStroke() {
1428 return HPDF_Page_GetRGBStroke(hpage);
1431 public HPdfCMYKColor GetCMYKFill() {
1432 return HPDF_Page_GetCMYKFill(hpage);
1435 public HPdfCMYKColor GetCMYKStroke() {
1436 return HPDF_Page_GetCMYKStroke(hpage);
1439 public float GetGrayFill() {
1440 return HPDF_Page_GetGrayFill(hpage);
1443 public float GetGrayStroke() {
1444 return HPDF_Page_GetGrayStroke(hpage);
1447 public HPdfColorSpace GetStrokingColorSpace() {
1448 return HPDF_Page_GetStrokingColorSpace(hpage);
1451 public HPdfColorSpace GetFillingColorSpace() {
1452 return HPDF_Page_GetFillingColorSpace(hpage);
1455 public HPdfTransMatrix GetTextMatrix() {
1456 return HPDF_Page_GetTextMatrix(hpage);
1459 public uint GetGStateDepth() {
1460 return HPDF_Page_GetGStateDepth(hpage);
1463 public void SetLineWidth(float line_width) {
1464 HPDF_Page_SetLineWidth(hpage, line_width);
1467 public void SetLineCap(HPdfLineCap line_cap) {
1468 HPDF_Page_SetLineCap(hpage, line_cap);
1471 public void SetLineJoin(HPdfLineJoin line_join) {
1472 HPDF_Page_SetLineJoin(hpage, line_join);
1475 public void SetMiterLimit(float miter_limit) {
1476 HPDF_Page_SetMiterLimit(hpage, miter_limit);
1479 public void SetDash(ushort[] dash_ptn, uint phase) {
1480 if (dash_ptn == null) {
1481 HPDF_Page_SetDash(hpage, dash_ptn, 0, 0);
1485 int len = dash_ptn.Length;
1487 HPDF_Page_SetDash(hpage, dash_ptn, (uint)len, phase);
1490 public void SetFlat(float flatness) {
1491 HPDF_Page_SetFlat(hpage, flatness);
1494 public void SetExtGState(HPdfExtGState gstate) {
1495 HPDF_Page_SetExtGState(hpage, gstate.GetHandle());
1498 public void GSave() {
1499 HPDF_Page_GSave(hpage);
1502 public void GRestore() {
1503 HPDF_Page_GRestore(hpage);
1506 public void Concat(float a, float b, float c, float d, float x, float y) {
1507 HPDF_Page_Concat(hpage, a, b, c, d, x, y);
1510 public void MoveTo(float x, float y) {
1511 HPDF_Page_MoveTo(hpage, x, y);
1514 public void LineTo(float x, float y) {
1515 HPDF_Page_LineTo(hpage, x, y);
1518 public void CurveTo(float x1, float y1, float x2, float y2,
1519 float x3, float y3) {
1520 HPDF_Page_CurveTo(hpage, x1, y1, x2, y2, x3, y3);
1523 public void CurveTo2(float x2, float y2, float x3, float y3) {
1524 HPDF_Page_CurveTo2(hpage, x2, y2, x3, y3);
1527 public void CurveTo3(float x1, float y1, float x3, float y3) {
1528 HPDF_Page_CurveTo2(hpage, x1, y1, x3, y3);
1531 public void ClosePath() {
1532 HPDF_Page_ClosePath(hpage);
1535 public void Rectangle(float x, float y, float width, float height) {
1536 HPDF_Page_Rectangle(hpage, x, y, width, height);
1539 public void Stroke() {
1540 HPDF_Page_Stroke(hpage);
1543 public void ClosePathStroke() {
1544 HPDF_Page_ClosePathStroke(hpage);
1547 public void Fill() {
1548 HPDF_Page_Fill(hpage);
1551 public void Eofill() {
1552 HPDF_Page_Eofill(hpage);
1555 public void FillStroke() {
1556 HPDF_Page_FillStroke(hpage);
1559 public void EofillStroke() {
1560 HPDF_Page_EofillStroke(hpage);
1563 public void ClosePathFillStroke() {
1564 HPDF_Page_ClosePathFillStroke(hpage);
1567 public void ClosePathEofillStroke() {
1568 HPDF_Page_ClosePathEofillStroke(hpage);
1571 public void EndPath() {
1572 HPDF_Page_EndPath(hpage);
1575 public void Clip() {
1576 HPDF_Page_Clip(hpage);
1579 public void Eoclip() {
1580 HPDF_Page_Eoclip(hpage);
1583 public void BeginText() {
1584 HPDF_Page_BeginText(hpage);
1587 public void EndText() {
1588 HPDF_Page_EndText(hpage);
1591 public void SetCharSpace(float value) {
1592 HPDF_Page_SetCharSpace(hpage, value);
1595 public void SetWordSpace(float value) {
1596 HPDF_Page_SetWordSpace(hpage, value);
1599 public void SetHorizontalScalling(float value) {
1600 HPDF_Page_SetHorizontalScalling(hpage, value);
1603 public void SetTextLeading(float value) {
1604 HPDF_Page_SetTextLeading(hpage, value);
1607 public void SetFontAndSize(HPdfFont font, float size) {
1608 HPDF_Page_SetFontAndSize(hpage, font.GetHandle(), size);
1611 public void SetTextRenderingMode(HPdfTextRenderingMode mode) {
1612 HPDF_Page_SetTextRenderingMode(hpage, mode);
1615 public void SetTextRaise(float value) {
1616 HPDF_Page_SetTextRaise(hpage, value);
1619 public void MoveTextPos(float x, float y) {
1620 HPDF_Page_MoveTextPos(hpage, x, y);
1623 public void MoveTextPos2(float x, float y) {
1624 HPDF_Page_MoveTextPos2(hpage, x, y);
1627 public void SetTextMatrix(float a, float b, float c, float d, float x, float y) {
1628 HPDF_Page_SetTextMatrix(hpage, a, b, c, d, x, y);
1631 public void MoveToNextLine() {
1632 HPDF_Page_MoveToNextLine(hpage);
1635 public void ShowText(string text) {
1636 HPDF_Page_ShowText(hpage, text);
1639 public void ShowTextNextLine(string text) {
1640 HPDF_Page_ShowTextNextLine(hpage, text);
1643 public void ShowTextNextLineEx(float word_space, float char_space,
1645 HPDF_Page_ShowTextNextLineEx(hpage, word_space, char_space, text);
1648 public void SetGrayFill(float gray) {
1649 HPDF_Page_SetGrayFill(hpage, gray);
1652 public void SetGrayStroke(float gray) {
1653 HPDF_Page_SetGrayStroke(hpage, gray);
1656 public void SetRGBFill(float r, float g, float b) {
1657 HPDF_Page_SetRGBFill(hpage, r, g, b);
1660 public void SetRGBStroke(float r, float g, float b) {
1661 HPDF_Page_SetRGBStroke(hpage, r, g, b);
1664 public void SetCMYKFill(float c, float m, float y, float k) {
1665 HPDF_Page_SetCMYKFill(hpage, c, m, y, k);
1668 public void SetCMYKStroke(float c, float m, float y, float k) {
1669 HPDF_Page_SetCMYKStroke(hpage, c, m, y, k);
1672 public void ExecuteXObject(HPdfImage xobj) {
1673 HPDF_Page_ExecuteXObject(hpage, xobj.GetHandle());
1676 public void DrawImage(HPdfImage image, float x, float y,
1677 float width, float height) {
1678 HPDF_Page_DrawImage(hpage, image.GetHandle(), x, y, width, height);
1681 public void Circle(float x, float y, float ray) {
1682 HPDF_Page_Circle(hpage, x, y, ray);
1685 public void Arc(float x, float y, float ray, float ang1, float ang2) {
1686 HPDF_Page_Arc(hpage, x, y, ray, ang1, ang2);
1689 public void TextOut(float xpos, float ypos, string text) {
1690 HPDF_Page_TextOut(hpage, xpos, ypos, text);
1693 public void TextRect(float left, float top, float right,
1694 float bottom, string text, HPdfTextAlignment align,
1696 HPDF_Page_TextRect(hpage, left, top, right, bottom, text, align, ref len);
1699 public void SetSlideShow(HPdfTransitionStyle type, float disp_time,
1701 HPDF_Page_SetSlideShow(hpage, type, disp_time, trans_time);
1704 public IntPtr GetHandle() {
1709 public class HPdfFont {
1710 [DllImport("libhpdf.dll")]
1711 private extern static string HPDF_Font_GetFontName(IntPtr hfont);
1713 [DllImport("libhpdf.dll")]
1714 private extern static string HPDF_Font_GetEncodingName(IntPtr hfont);
1716 [DllImport("libhpdf.dll")]
1717 private extern static int HPDF_Font_GetUnicodeWidth(IntPtr hfont,
1720 [DllImport("libhpdf.dll")]
1721 private extern static HPdfBox HPDF_Font_GetBBox(IntPtr hfont);
1723 [DllImport("libhpdf.dll")]
1724 private extern static int HPDF_Font_GetAscent(IntPtr hfont);
1726 [DllImport("libhpdf.dll")]
1727 private extern static int HPDF_Font_GetDescent(IntPtr hfont);
1729 [DllImport("libhpdf.dll")]
1730 private extern static uint HPDF_Font_GetXHeight(IntPtr hfont);
1732 [DllImport("libhpdf.dll")]
1733 private extern static uint HPDF_Font_GetCapHeight(IntPtr hfont);
1735 [DllImport("libhpdf.dll")]
1736 private extern static HPdfTextWidth HPDF_Font_TextWidth(IntPtr hfont,
1737 string text, uint len);
1739 [DllImport("libhpdf.dll")]
1740 private extern static uint HPDF_Font_MeasureText(IntPtr hfont,
1741 string text, uint len, float width, float font_size,
1742 float char_space, float word_space, int wordwrap,
1743 ref float real_width);
1748 public HPdfFont(IntPtr hfont) {
1749 if (hfont == IntPtr.Zero) {
1750 throw new Exception("cannot create HPdfFont object.");
1756 public IntPtr GetHandle() {
1760 public string GetFontName() {
1761 return HPDF_Font_GetFontName(hfont);
1764 public string GetEncodingName() {
1765 return HPDF_Font_GetEncodingName(hfont);
1768 public int GetUnicodeWidth(ushort code) {
1769 return HPDF_Font_GetUnicodeWidth(hfont, code);
1772 public HPdfBox GetBBox() {
1773 return HPDF_Font_GetBBox(hfont);
1776 public int GetAscent() {
1777 return HPDF_Font_GetAscent(hfont);
1780 public int GetDescent() {
1781 return HPDF_Font_GetDescent(hfont);
1784 public uint GetXHeight() {
1785 return HPDF_Font_GetXHeight(hfont);
1788 public uint GetCapHeight() {
1789 return HPDF_Font_GetCapHeight(hfont);
1792 public HPdfTextWidth TextWidth(string text, uint len) {
1793 return HPDF_Font_TextWidth(hfont, text, len);
1796 public uint MeasureText(string text, uint len, float width,
1797 float font_size, float char_space, float word_space,
1798 int wordwrap, ref float real_width) {
1799 return HPDF_Font_MeasureText(hfont, text, len, width, font_size,
1800 char_space, word_space, wordwrap,
1805 public class HPdfOutline {
1806 [DllImport("libhpdf.dll")]
1807 private extern static uint HPDF_Outline_SetOpened(IntPtr houtline,
1810 [DllImport("libhpdf.dll")]
1811 private extern static uint HPDF_Outline_SetDestination(IntPtr houtline,
1816 public HPdfOutline(IntPtr houtline) {
1817 if (houtline == IntPtr.Zero) {
1818 throw new Exception("cannot create HPdfOutline object.");
1821 this.houtline = houtline;
1824 public IntPtr GetHandle() {
1828 public void SetOpened(bool opened) {
1832 iopened = HPdfDoc.HPDF_TRUE;
1834 iopened = HPdfDoc.HPDF_FALSE;
1836 HPDF_Outline_SetOpened(houtline, iopened);
1839 public void SetDestination(HPdfDestination dest) {
1840 HPDF_Outline_SetDestination(houtline, dest.GetHandle());
1844 public class HPdfEncoder {
1847 public HPdfEncoder(IntPtr hencoder) {
1848 if (hencoder == IntPtr.Zero) {
1849 throw new Exception("cannot create HPdfEncoder object.");
1852 this.hencoder = hencoder;
1855 [DllImport("libhpdf.dll")]
1856 private extern static HPdfEncoderType HPDF_Encoder_GetType(IntPtr
1859 [DllImport("libhpdf.dll")]
1860 private extern static HPdfByteType HPDF_Encoder_GetByteType(IntPtr
1861 hencoder, string text, uint index);
1863 [DllImport("libhpdf.dll")]
1864 private extern static ushort HPDF_Encoder_GetUnicode(IntPtr
1865 hencoder, ushort code);
1867 [DllImport("libhpdf.dll")]
1868 private extern static HPdfWritingMode HPDF_Encoder_GetWritingMode(IntPtr
1872 public IntPtr GetHandle() {
1876 public HPdfEncoderType GetEncoderType() {
1877 return HPDF_Encoder_GetType(hencoder);
1880 public HPdfByteType GetByteType(string text, uint index) {
1881 return HPDF_Encoder_GetByteType(hencoder, text, index);
1884 public ushort GetUnicode(ushort code) {
1885 return HPDF_Encoder_GetUnicode(hencoder, code);
1888 public HPdfWritingMode GetWritingMode() {
1889 return HPDF_Encoder_GetWritingMode(hencoder);
1894 public class HPdfDestination {
1895 [DllImport("libhpdf.dll")]
1896 private extern static uint HPDF_Destination_SetXYZ(IntPtr hdest,
1897 float left, float top, float zoom);
1899 [DllImport("libhpdf.dll")]
1900 private extern static uint HPDF_Destination_SetFit(IntPtr hdest);
1902 [DllImport("libhpdf.dll")]
1903 private extern static uint HPDF_Destination_SetFitH(IntPtr hdest,
1906 [DllImport("libhpdf.dll")]
1907 private extern static uint HPDF_Destination_SetFitV(IntPtr hdest,
1910 [DllImport("libhpdf.dll")]
1911 private extern static uint HPDF_Destination_SetFitR(IntPtr hdest,
1912 float left, float bottom, float right, float top);
1914 [DllImport("libhpdf.dll")]
1915 private extern static uint HPDF_Destination_SetFitB(IntPtr hdest);
1917 [DllImport("libhpdf.dll")]
1918 private extern static uint HPDF_Destination_SetFitBH(IntPtr hdest,
1921 [DllImport("libhpdf.dll")]
1922 private extern static uint HPDF_Destination_SetFitBV(IntPtr hdest,
1927 public HPdfDestination(IntPtr hdest) {
1928 if (hdest == IntPtr.Zero) {
1929 throw new Exception("cannot create HPdfDestination object.");
1935 public void SetXYZ(float left, float top, float zoom) {
1936 HPDF_Destination_SetXYZ(hdest, left, top, zoom);
1939 public void SetFit() {
1940 HPDF_Destination_SetFit(hdest);
1943 public void SetFitH(float top) {
1944 HPDF_Destination_SetFitH(hdest, top);
1947 public void SetFitV(float left) {
1948 HPDF_Destination_SetFitV(hdest, left);
1951 public void SetFitR(float left, float bottom, float right, float top) {
1952 HPDF_Destination_SetFitR(hdest, left, bottom, right, top);
1955 public void SetFitB() {
1956 HPDF_Destination_SetFitB(hdest);
1959 public void SetFitBH(float top) {
1960 HPDF_Destination_SetFitBH(hdest, top);
1963 public void SetFitBV(float left) {
1964 HPDF_Destination_SetFitBV(hdest, left);
1967 public IntPtr GetHandle() {
1972 public class HPdfAnnotation {
1975 [DllImport("libhpdf.dll")]
1976 private extern static uint HPDF_LinkAnnot_SetHighlightMode(IntPtr hannot,
1977 HPdfAnnotHighlightMode mode);
1979 [DllImport("libhpdf.dll")]
1980 private extern static uint HPDF_LinkAnnot_SetBorderStyle(IntPtr hannot,
1981 float width, ushort dash_on, ushort dash_off);
1983 [DllImport("libhpdf.dll")]
1984 private extern static uint HPDF_TextAnnot_SetIcon(IntPtr hannot,
1985 HPdfAnnotIcon icon);
1987 [DllImport("libhpdf.dll")]
1988 private extern static uint HPDF_TextAnnot_SetOpened(IntPtr hannot,
1992 public HPdfAnnotation(IntPtr hannot) {
1993 if (hannot == IntPtr.Zero) {
1994 throw new Exception("cannot create HPdfAnnotation object.");
1997 this.hannot = hannot;
2000 public IntPtr GetHandle() {
2004 public void SetHighlightMode(HPdfAnnotHighlightMode mode) {
2005 HPDF_LinkAnnot_SetHighlightMode(hannot, mode);
2008 public void SetBorderStyle(float width, ushort dash_on, ushort dash_off) {
2009 HPDF_LinkAnnot_SetBorderStyle(hannot, width, dash_on, dash_off);
2012 public void SetIcon(HPdfAnnotIcon icon) {
2013 HPDF_TextAnnot_SetIcon(hannot, icon);
2016 public void SetOpened(bool opened) {
2020 flg = HPdfDoc.HPDF_TRUE;
2022 flg = HPdfDoc.HPDF_FALSE;
2024 HPDF_TextAnnot_SetOpened(hannot, flg);
2029 public class HPdfXObject {
2030 protected IntPtr hobj;
2032 public HPdfXObject(IntPtr hobj) {
2033 if (hobj == IntPtr.Zero) {
2034 throw new Exception("cannot create HPdfImage object.");
2040 public IntPtr GetHandle() {
2045 public class HPdfImage: HPdfXObject {
2047 [DllImport("libhpdf.dll")]
2048 private extern static HPdfPoint HPDF_Image_GetSize(IntPtr image);
2050 [DllImport("libhpdf.dll")]
2051 private extern static uint HPDF_Image_GetWidth(IntPtr image);
2053 [DllImport("libhpdf.dll")]
2054 private extern static uint HPDF_Image_GetHeight(IntPtr image);
2056 [DllImport("libhpdf.dll")]
2057 private extern static uint HPDF_Image_GetBitsPerComponent(IntPtr image);
2059 [DllImport("libhpdf.dll")]
2060 private extern static string HPDF_Image_GetColorSpace(IntPtr image);
2062 [DllImport("libhpdf.dll")]
2063 private extern static uint HPDF_Image_SetColorMask(IntPtr image,
2064 uint rmin, uint rmax, uint gmin, uint gmax, uint bmin, uint bmax);
2066 [DllImport("libhpdf.dll")]
2067 private extern static string HPDF_Image_SetMaskImage(IntPtr image,
2070 public HPdfImage(IntPtr hobj): base (hobj) {
2073 public HPdfPoint GetSize() {
2074 return HPDF_Image_GetSize(hobj);
2077 public uint GetWidth() {
2078 return HPDF_Image_GetWidth(hobj);
2081 public uint GetHeight() {
2082 return HPDF_Image_GetHeight(hobj);
2085 public uint GetBitsPerComponent() {
2086 return HPDF_Image_GetBitsPerComponent(hobj);
2089 public string GetColorSpace() {
2090 return HPDF_Image_GetColorSpace(hobj);
2093 public void SetColorMask(uint rmin, uint rmax, uint gmin, uint gmax,
2094 uint bmin, uint bmax) {
2095 HPDF_Image_SetColorMask(hobj, rmin, rmax, gmin, gmax,
2099 public void SetMaskImage(HPdfImage mask_image) {
2100 HPDF_Image_SetMaskImage(hobj, mask_image.GetHandle());
2104 public class HPdfExtGState {
2105 protected IntPtr hgstate;
2107 [DllImport("libhpdf.dll")]
2108 private extern static uint HPDF_ExtGState_SetAlphaStroke(IntPtr gstate,
2111 [DllImport("libhpdf.dll")]
2112 private extern static uint HPDF_ExtGState_SetAlphaFill(IntPtr gstate,
2115 [DllImport("libhpdf.dll")]
2116 private extern static uint HPDF_ExtGState_SetBlendMode(IntPtr gstate,
2117 HPdfBlendMode mode);
2119 public HPdfExtGState(IntPtr hgstate) {
2120 if (hgstate == IntPtr.Zero) {
2121 throw new Exception("cannot create HPdfImage object.");
2124 this.hgstate = hgstate;
2127 public IntPtr GetHandle() {
2131 public void SetAlphaStroke(float value) {
2132 HPDF_ExtGState_SetAlphaStroke(hgstate, value);
2135 public void SetAlphaFill(float value) {
2136 HPDF_ExtGState_SetAlphaFill(hgstate, value);
2139 public void SetBlendMode(HPdfBlendMode mode) {
2140 HPDF_ExtGState_SetBlendMode(hgstate, mode);