Parcourir la source

Text.PDF. Initial Import.

Brucey il y a 2 ans
Parent
commit
9f8d1129be
100 fichiers modifiés avec 25677 ajouts et 0 suppressions
  1. 971 0
      pdf.mod/common.bmx
  2. 74 0
      pdf.mod/examples/arc_example.bmx
  3. 32 0
      pdf.mod/examples/encryption.bmx
  4. 158 0
      pdf.mod/examples/ext_gstate_example.bmx
  5. 63 0
      pdf.mod/examples/font_example.bmx
  6. 108 0
      pdf.mod/examples/grid_sheet.bmx
  7. 290 0
      pdf.mod/examples/line_example.bmx
  8. 74 0
      pdf.mod/examples/outline_example.bmx
  9. 106 0
      pdf.mod/examples/text_annotation.bmx
  10. 263 0
      pdf.mod/examples/text_example.bmx
  11. 34 0
      pdf.mod/glue.c
  12. 42 0
      pdf.mod/libharu/.gitignore
  13. 140 0
      pdf.mod/libharu/CHANGES
  14. 148 0
      pdf.mod/libharu/CMakeLists.txt
  15. 22 0
      pdf.mod/libharu/INSTALL
  16. 20 0
      pdf.mod/libharu/LICENSE
  17. 138 0
      pdf.mod/libharu/README.md
  18. 106 0
      pdf.mod/libharu/README_cmake
  19. 47 0
      pdf.mod/libharu/bindings/c#/README.c#
  20. 60 0
      pdf.mod/libharu/bindings/c#/demo/Encryption.cs
  21. 99 0
      pdf.mod/libharu/bindings/c#/demo/FontDemo.cs
  22. 195 0
      pdf.mod/libharu/bindings/c#/demo/ImageDemo.cs
  23. 147 0
      pdf.mod/libharu/bindings/c#/demo/JPFontDemo.cs
  24. 313 0
      pdf.mod/libharu/bindings/c#/demo/LineDemo.cs
  25. 95 0
      pdf.mod/libharu/bindings/c#/demo/OutlineDemo.cs
  26. 64 0
      pdf.mod/libharu/bindings/c#/demo/Permission.cs
  27. 104 0
      pdf.mod/libharu/bindings/c#/demo/RawImageDemo.cs
  28. 171 0
      pdf.mod/libharu/bindings/c#/demo/SlideShowDemo.cs
  29. 321 0
      pdf.mod/libharu/bindings/c#/demo/TextDemo.cs
  30. 2150 0
      pdf.mod/libharu/bindings/c#/hpdf.cs
  31. 212 0
      pdf.mod/libharu/bindings/delphi/ExtGStateDemo.dpr
  32. 368 0
      pdf.mod/libharu/bindings/delphi/LineDemo.dpr
  33. 26 0
      pdf.mod/libharu/bindings/delphi/README.delphi
  34. 872 0
      pdf.mod/libharu/bindings/delphi/hpdf.pas
  35. 547 0
      pdf.mod/libharu/bindings/delphi/hpdf_consts.pas
  36. 463 0
      pdf.mod/libharu/bindings/delphi/hpdf_types.pas
  37. 25 0
      pdf.mod/libharu/bindings/freebasic/README.freebasic
  38. 217 0
      pdf.mod/libharu/bindings/freebasic/hpdf.bi
  39. 473 0
      pdf.mod/libharu/bindings/freebasic/hpdf_consts.bi
  40. 415 0
      pdf.mod/libharu/bindings/freebasic/hpdf_types.bi
  41. 154 0
      pdf.mod/libharu/bindings/freebasic/hpdftest.bas
  42. 9 0
      pdf.mod/libharu/bindings/oberon-2/README.oberon-2
  43. 2 0
      pdf.mod/libharu/bindings/oberon-2/build.bat
  44. 1255 0
      pdf.mod/libharu/bindings/oberon-2/hpdf.ob2
  45. 338 0
      pdf.mod/libharu/bindings/oberon-2/test.ob2
  46. 10 0
      pdf.mod/libharu/bindings/oberon-2/test.prj
  47. 36 0
      pdf.mod/libharu/bindings/python/History.txt
  48. 125 0
      pdf.mod/libharu/bindings/python/README.python
  49. 5 0
      pdf.mod/libharu/bindings/python/__init__.py
  50. 8 0
      pdf.mod/libharu/bindings/python/c_func.py
  51. 123 0
      pdf.mod/libharu/bindings/python/demo/arc_demo.py
  52. 265 0
      pdf.mod/libharu/bindings/python/demo/character_map.py
  53. 124 0
      pdf.mod/libharu/bindings/python/demo/chfont_demo.py
  54. 178 0
      pdf.mod/libharu/bindings/python/demo/cnfont_demo.py
  55. 206 0
      pdf.mod/libharu/bindings/python/demo/encoding_list.py
  56. 85 0
      pdf.mod/libharu/bindings/python/demo/encryption.py
  57. 208 0
      pdf.mod/libharu/bindings/python/demo/ext_gstate_demo.py
  58. 139 0
      pdf.mod/libharu/bindings/python/demo/font_demo.py
  59. 183 0
      pdf.mod/libharu/bindings/python/demo/grid_sheet.py
  60. 224 0
      pdf.mod/libharu/bindings/python/demo/image_demo.py
  61. 111 0
      pdf.mod/libharu/bindings/python/demo/jpeg_demo.py
  62. 180 0
      pdf.mod/libharu/bindings/python/demo/jpfont_demo.py
  63. 346 0
      pdf.mod/libharu/bindings/python/demo/line_demo.py
  64. 255 0
      pdf.mod/libharu/bindings/python/demo/link_annotation.py
  65. 85 0
      pdf.mod/libharu/bindings/python/demo/make_rawimage.py
  66. 127 0
      pdf.mod/libharu/bindings/python/demo/outline_demo.py
  67. 142 0
      pdf.mod/libharu/bindings/python/demo/outline_demo_jp.py
  68. 86 0
      pdf.mod/libharu/bindings/python/demo/permission.py
  69. 143 0
      pdf.mod/libharu/bindings/python/demo/png_demo.py
  70. 129 0
      pdf.mod/libharu/bindings/python/demo/raw_image_demo.py
  71. 190 0
      pdf.mod/libharu/bindings/python/demo/slide_show_demo.py
  72. 167 0
      pdf.mod/libharu/bindings/python/demo/text_annotation.py
  73. 358 0
      pdf.mod/libharu/bindings/python/demo/text_demo.py
  74. 271 0
      pdf.mod/libharu/bindings/python/demo/text_demo2.py
  75. 139 0
      pdf.mod/libharu/bindings/python/demo/ttfont_demo.py
  76. 160 0
      pdf.mod/libharu/bindings/python/demo/ttfont_demo_cn.py
  77. 158 0
      pdf.mod/libharu/bindings/python/demo/ttfont_demo_jp.py
  78. 2103 0
      pdf.mod/libharu/bindings/python/hpdf.py
  79. 545 0
      pdf.mod/libharu/bindings/python/hpdf_consts.py
  80. 164 0
      pdf.mod/libharu/bindings/python/hpdf_errorcode.py
  81. 552 0
      pdf.mod/libharu/bindings/python/hpdf_types.py
  82. 178 0
      pdf.mod/libharu/bindings/ruby/Makefile.msvc
  83. 77 0
      pdf.mod/libharu/bindings/ruby/demo/arc_demo.rb
  84. 86 0
      pdf.mod/libharu/bindings/ruby/demo/demo.rb
  85. 36 0
      pdf.mod/libharu/bindings/ruby/demo/encryption.rb
  86. 166 0
      pdf.mod/libharu/bindings/ruby/demo/ext_gstater_demo.rb
  87. 61 0
      pdf.mod/libharu/bindings/ruby/demo/font_demo.rb
  88. 117 0
      pdf.mod/libharu/bindings/ruby/demo/jpfont_demo.rb
  89. 296 0
      pdf.mod/libharu/bindings/ruby/demo/line_demo.rb
  90. 134 0
      pdf.mod/libharu/bindings/ruby/demo/slide_show_demo.rb
  91. 186 0
      pdf.mod/libharu/bindings/ruby/demo/text_demo2.rb
  92. 106 0
      pdf.mod/libharu/bindings/ruby/demo/ttfont_demo.rb
  93. 6 0
      pdf.mod/libharu/bindings/ruby/extconf.rb
  94. 6 0
      pdf.mod/libharu/bindings/ruby/extconf.rb.all
  95. 6 0
      pdf.mod/libharu/bindings/ruby/extconf.rb.nopnglib
  96. 6 0
      pdf.mod/libharu/bindings/ruby/extconf.rb.nozlib
  97. 3779 0
      pdf.mod/libharu/bindings/ruby/hpdf.c
  98. 51 0
      pdf.mod/libharu/bindings/vb.net/README.vbnet
  99. 38 0
      pdf.mod/libharu/bindings/vb.net/demo/Encryption.vb
  100. 81 0
      pdf.mod/libharu/bindings/vb.net/demo/FontDemo.vb

+ 971 - 0
pdf.mod/common.bmx

@@ -0,0 +1,971 @@
+' Copyright (c) 2023 Bruce A Henderson
+' 
+' This software is provided 'as-is', without any express or implied
+' warranty. In no event will the authors be held liable for any damages
+' arising from the use of this software.
+' 
+' Permission is granted to anyone to use this software for any purpose,
+' including commercial applications, and to alter it and redistribute it
+' freely, subject to the following restrictions:
+' 
+' 1. The origin of this software must not be misrepresented; you must not
+'    claim that you wrote the original software. If you use this software
+'    in a product, an acknowledgment in the product documentation would be
+'    appreciated but is not required.
+' 2. Altered source versions must be plainly marked as such, and must not be
+'    misrepresented as being the original software.
+' 3. This notice may not be removed or altered from any source distribution.
+' 
+SuperStrict
+
+Import Pub.Zlib
+Import BRL.Stream
+
+Import "source.bmx"
+
+Extern
+
+	Function bmx_pdf_HPDF_New:Byte Ptr()
+
+	Function HPDF_Free(handle:Byte Ptr)
+	Function HPDF_SaveToStream:ULongInt(handle:Byte Ptr)
+	Function HPDF_ResetStream:ULongInt(handle:Byte Ptr)
+	Function HPDF_ReadFromStream:ULongInt(handle:Byte Ptr, buf:Byte Ptr, size:UInt Var)
+	Function HPDF_AddPage:Byte Ptr(handle:Byte Ptr)
+	Function HPDF_GetFont:Byte Ptr(handle:Byte Ptr, fn:Byte Ptr, en:Byte Ptr)
+	Function HPDF_GetCurrentPage:Byte Ptr(handle:Byte Ptr)
+	Function HPDF_InsertPage:Byte Ptr(handle:Byte Ptr, page:Byte Ptr)
+	Function HPDF_SetCompressionMode:ULongInt(handle:Byte Ptr, mode:EPDFCompressionMode)
+	Function HPDF_CreateExtGState:Byte Ptr(handle:Byte Ptr)
+	Function HPDF_SetPassword:ULongInt(handle:Byte Ptr, owner:Byte Ptr, user:Byte Ptr)
+	Function HPDF_SetPermission:ULongInt(handle:Byte Ptr, permission:UInt)
+	Function HPDF_SetEncryptionMode:ULongInt(handle:Byte Ptr, mode:EPDFEncryptMode, keyLen:UInt)
+	Function HPDF_SetPagesConfiguration:ULongInt(handle:Byte Ptr, pagePerPages:UInt)
+	Function HPDF_SetPageLayout:ULongInt(handle:Byte Ptr, layout:EPDFPageLayout)
+	Function HPDF_CreateOutline:Byte Ptr(handle:Byte Ptr, parent:Byte Ptr, t:Byte Ptr, encoder:Byte Ptr)
+	Function HPDF_SetPageMode:ULongInt(handle:Byte Ptr, mode:EPDFPageMode)
+	Function HPDF_GetPageMode:EPDFPageMode(handle:Byte Ptr)
+	Function HPDF_AddPageLabel:ULongInt(handle:Byte Ptr, pageNum:UInt, style:EPDFPageNumStyle, firstPage:UInt, p:Byte Ptr)
+	Function HPDF_GetPageLayout:EPDFPageLayout(handle:Byte Ptr)
+	Function HPDF_UseJPFonts:ULongInt(handle:Byte Ptr)
+	Function HPDF_UseKRFonts:ULongInt(handle:Byte Ptr)
+	Function HPDF_UseCNSFonts:ULongInt(handle:Byte Ptr)
+	Function HPDF_UseCNTFonts:ULongInt(handle:Byte Ptr)
+	Function HPDF_SetInfoAttr:ULongInt(handle:Byte Ptr, infoType:EPDFInfoType, v:Byte Ptr)
+	Function HPDF_GetInfoAttr:Byte Ptr(handle:Byte Ptr, infoType:EPDFInfoType)
+	Function HPDF_SetInfoDateAttr:ULongInt(handle:Byte Ptr, infoType:EPDFInfoType, date:SPDFDate)
+	Function HPDF_GetEncoder:Byte Ptr(handler:Byte Ptr, encodingName:Byte Ptr)
+	Function HPDF_GetCurrentEncoder:Byte ptr(handler:Byte Ptr, encodingName:Byte Ptr)
+	Function HPDF_SetCurrentEncoder:ULongInt(handler:Byte Ptr, encodingName:Byte Ptr)
+
+	Function HPDF_Page_BeginText:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_EndText:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_ShowText:ULongInt(handle:Byte Ptr, text:Byte Ptr)
+	Function HPDF_Page_ShowTextNextLine:ULongInt(handle:Byte Ptr, text:Byte Ptr)
+	Function HPDF_Page_ShowTextNextLineEx:ULongInt(handle:Byte Ptr, wordSpace:Float, charSpace:Float, text:Byte Ptr)
+	Function HPDF_Page_SetWidth:ULongInt(handle:Byte Ptr, width:Float)
+	Function HPDF_Page_SetHeight:ULongInt(handle:Byte Ptr, height:Float)
+	Function HPDF_Page_SetRotate:ULongInt(handle:Byte Ptr, angle:Short)
+		
+	Function HPDF_Page_TextWidth:Float(handle:Byte Ptr, text:Byte Ptr)
+	Function HPDF_Page_SetLineWidth:ULongInt(handle:Byte Ptr, width:Float)
+	Function HPDF_Page_SetLineCap:ULongInt(handle:Byte Ptr, lineCap:EPDFLineCap)
+	Function HPDF_Page_SetLineJoin:ULongInt(handle:Byte Ptr, lineJoin:EPDFLineJoin)
+	Function HPDF_Page_SetMiterLimit:ULongInt(handle:Byte Ptr, miterLimit:Float)
+	Function HPDF_Page_GetWidth:Float(handle:Byte Ptr)
+	Function HPDF_Page_GetHeight:Float(handle:Byte Ptr)
+	Function HPDF_Page_Rectangle:ULongInt(handle:Byte Ptr, x:Float, y:Float, width:Float, height:Float)
+	Function HPDF_Page_Stroke:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_ClosePathStroke:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_Fill:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_Eofill:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_FillStroke:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_EofillStroke:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_ClosePathFillStroke:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_ClosePathEofillStroke:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_EndPath:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_GSave:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_GRestore:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_Clip:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_Eoclip:ULongInt(handle:Byte Ptr)
+	Function HPDF_Page_Circle:ULongInt(handle:Byte Ptr, x:Float, y:Float, r:Float)
+	Function HPDF_Page_Ellipse:ULongInt(handle:Byte Ptr, x:Float, y:Float, xr:Float, yr:Float)
+	Function HPDF_Page_Arc:ULongInt(handle:Byte Ptr, x:Float, y:Float, r:Float, a1:Float, a2:Float)
+	Function HPDF_Page_TextOut:ULongInt(handle:Byte Ptr, xpos:Float, ypos:Float, t:Byte Ptr)
+	Function HPDF_Page_TextRect:ULongInt(handle:Byte Ptr, left:Float, top:Float, right:Float, bottom:Float, t:Byte Ptr, align:EPDFTextAlignment, length:UInt Var)
+	Function HPDF_Page_MeasureText:UInt(handle:Byte Ptr, t:Byte Ptr, width:Float, wordwrap:Int, realWidth:Float Ptr)
+	Function HPDF_Page_CreateTextAnnot:Byte Ptr(handle:Byte Ptr, rect:SPDFRect, t:Byte Ptr, encoder:Byte Ptr)
+	Function HPDF_Page_CreateLinkAnnot:Byte Ptr(handle:Byte Ptr, rect:SPDFRect, dest:Byte Ptr)
+	Function HPDF_Page_CreateURILinkAnnot:Byte Ptr(handle:Byte Ptr, rect:SPDFRect, uri:Byte Ptr)
+	Function HPDF_Page_GetGrayFill:Float(handle:Byte Ptr)
+	Function HPDF_Page_GetGrayStroke:Float(handle:Byte Ptr)
+
+	Function HPDF_Page_SetFontAndSize:ULongInt(handle:Byte Ptr, font:Byte Ptr, size:Float)
+	Function HPDF_Page_SetCharSpace:ULongInt(handle:Byte Ptr, value:Float)
+	Function HPDF_Page_SetWordSpace:ULongInt(handle:Byte Ptr, value:Float)
+	Function HPDF_Page_SetHorizontalScalling:ULongInt(handle:Byte Ptr, value:Float)
+	Function HPDF_Page_SetTextLeading:ULongInt(handle:Byte Ptr, value:Float)
+	Function HPDF_Page_GetCurrentFont:Byte Ptr(handle:Byte Ptr)
+	Function HPDF_Page_GetCurrentFontSize:Float(handle:Byte Ptr)
+
+	Function HPDF_Page_MoveTextPos:ULongInt(handle:Byte Ptr, x:Float, y:Float)
+	Function HPDF_Page_MoveTextPos2:ULongInt(handle:Byte Ptr, x:Float, y:Float)
+	Function HPDF_Page_SetTextMatrix:ULongInt(handle:Byte Ptr, a:Float, b:Float, c:Float, d:Float, x:Float, y:Float)
+	Function HPDF_Page_MoveToNextLine:ULongInt(handle:Byte Ptr)
+
+	Function HPDF_Page_MoveTo:ULongInt(handle:Byte Ptr, x:Float, y:Float)
+	Function HPDF_Page_LineTo:ULongInt(handle:Byte Ptr, x:Float, y:Float)
+	Function HPDF_Page_CurveTo:ULongInt(handle:Byte Ptr, x1:Float, y1:Float, x2:Float, y2:Float, x3:Float, y3:Float)
+	Function HPDF_Page_CurveTo2:ULongInt(handle:Byte Ptr, x2:Float, y2:Float, x3:Float, y3:Float)
+	Function HPDF_Page_CurveTo3:ULongInt(handle:Byte Ptr, x1:Float, y1:Float, x3:Float, y3:Float)
+	
+	Function HPDF_Page_SetDash:ULongInt(handle:Byte Ptr, dashes:Float Ptr, count:UInt, phase:Float)
+	Function HPDF_Page_SetRGBFill:ULongInt(handle:Byte Ptr, r:Float, g:Float, b:Float)
+	Function HPDF_Page_SetRGBStroke:ULongInt(handle:Byte Ptr, r:Float, g:Float, b:Float)
+	Function HPDF_Page_SetCMYKFill:ULongInt(handle:Byte Ptr, c:Float, m:Float, y:Float, k:Float)
+	Function HPDF_Page_SetCMYKStroke:ULongInt(handle:Byte Ptr, c:Float, m:Float, y:Float, k:Float)
+	Function HPDF_Page_SetGrayFill:ULongInt(handle:Byte Ptr, gray:Float)
+	Function HPDF_Page_SetGrayStroke:ULongInt(handle:Byte Ptr, gray:Float)
+	Function HPDF_Page_GetLineWidth:Float(handle:Byte Ptr)
+	Function HPDF_Page_GetCurrentPos:SPDFPoint(handle:Byte Ptr)
+	Function HPDF_Page_GetCurrentTextPos:SPDFPoint(handle:Byte Ptr)
+	Function HPDF_Page_GetRGBFill:SPDFRGBColor(handle:Byte Ptr)
+	Function HPDF_Page_GetRGBStroke:SPDFRGBColor(handle:Byte Ptr)
+	Function HPDF_Page_GetCMYKFill:SPDFCMYKColor(handle:Byte Ptr)
+	Function HPDF_Page_GetCMYKStroke:SPDFCMYKColor(handle:Byte Ptr)
+	Function HPDF_Page_SetTextRenderingMode:ULongInt(handle:Byte Ptr, mode:EPDFTextRenderingMode)
+	Function HPDF_Page_SetExtGState:ULongInt(handle:Byte Ptr, gstate:Byte Ptr)
+	Function HPDF_Page_GetStrokingColorSpace:EPDFColorSpace(handle:Byte Ptr)
+	Function HPDF_Page_GetFillingColorSpace:EPDFColorSpace(handle:Byte Ptr)
+	Function HPDF_Page_GetTextMatrix:SPDFTransMatrix(handle:Byte Ptr)
+	Function HPDF_Page_GetGStateDepth:UInt(handle:Byte Ptr)
+	Function HPDF_Page_GetTextRise:Float(handle:Byte Ptr)
+	Function HPDF_Page_GetTextLeading:Float(handle:Byte Ptr)
+	Function HPDF_Page_GetTextRenderingMode:EPDFTextRenderingMode(handle:Byte Ptr)
+	Function HPDF_Page_GetHorizontalScalling:Float(handle:Byte Ptr)
+	Function HPDF_Page_GetWordSpace:Float(handle:Byte Ptr)
+	Function HPDF_Page_GetCharSpace:Float(handle:Byte Ptr)
+	Function HPDF_Page_GetFlat:Float(handle:Byte Ptr)
+	Function HPDF_Page_GetDash:SPDFDashMode(handle:Byte Ptr)
+	Function HPDF_Page_GetMiterLimit:Float(handle:Byte Ptr)
+	Function HPDF_Page_GetLineJoin:EPDFLineJoin(handle:Byte Ptr)
+	Function HPDF_Page_GetLineCap:EPDFLineCap(handle:Byte Ptr)
+	Function HPDF_Page_GetTransMatrix:SPDFTransMatrix(handle:Byte Ptr)
+	Function HPDF_Page_GetGMode:Short(handle:Byte Ptr)
+	Function HPDF_Page_SetFlat:ULongInt(handle:Byte Ptr, flatness:Float)
+	Function HPDF_Page_Concat:ULongInt(handle:Byte Ptr, a:Float, b:Float, c:Float, d:Float, x:Float, y:Float)
+	Function HPDF_Page_SetSize:ULongInt(handle:Byte Ptr, size:EPDFPageSize, direction:EPDFPageDirection)
+	Function HPDF_Page_CreateDestination:Byte Ptr(handle:Byte Ptr)
+	Function HPDF_SetOpenAction:ULongInt(handle:Byte Ptr, action:Byte Ptr)
+	Function HPDF_Page_SetSlideShow:ULongInt(handle:Byte Ptr, style:EPDFTransitionStyle, dispTime:Float, transTime:Float)
+
+	Function HPDF_Font_MeasureText:UInt(handle:Byte Ptr, t:Byte Ptr, length:UInt, width:Float, fontSize:Float, charSpace:Float, wordSpace:Float, wordwrap:Int, realWidth:Float Ptr)
+	Function HPDF_Font_GetFontName:Byte Ptr(handle:Byte Ptr)
+	Function HPDF_Font_GetEncodingName:Byte Ptr(handle:Byte Ptr)
+	Function HPDF_Font_GetBBox:SPDFRect(handle:Byte Ptr)
+	Function HPDF_Font_GetAscent:Int(handle:Byte Ptr)
+	Function HPDF_Font_GetDescent:Int(handle:Byte Ptr)
+	Function HPDF_Font_GetXHeight:UInt(handle:Byte Ptr)
+	Function HPDF_Font_GetCapHeight:UInt(handle:Byte Ptr)
+	Function HPDF_Font_TextWidth:SPDFTextWidth(handle:Byte Ptr, t:Byte Ptr, length:UInt)
+
+	Function HPDF_ExtGState_SetAlphaStroke:ULongInt(handle:Byte Ptr, value:Float)
+	Function HPDF_ExtGState_SetAlphaFill:ULongInt(handle:Byte Ptr, value:Float)
+	Function HPDF_ExtGState_SetBlendMode:ULongInt(handle:Byte Ptr, mode:EPDFBlendMode)
+
+	Function HPDF_Destination_SetXYZ:ULongInt(handle:Byte Ptr, left:Float, top:Float, zoom:Float)
+	Function HPDF_Destination_SetFit:ULongInt(handle:Byte Ptr)
+	Function HPDF_Destination_SetFitH:ULongInt(handle:Byte Ptr, top:Float)
+	Function HPDF_Destination_SetFitV:ULongInt(handle:Byte Ptr, left:Float)
+	Function HPDF_Destination_SetFitR:ULongInt(handle:Byte Ptr, left:Float, bottom:Float, right:Float, top:Float)
+	Function HPDF_Destination_SetFitB:ULongInt(handle:Byte Ptr)
+	Function HPDF_Destination_SetFitBH:ULongInt(handle:Byte Ptr, top:Float)
+	Function HPDF_Destination_SetFitBV:ULongInt(handle:Byte Ptr, left:Float)
+
+	Function HPDF_Outline_SetOpened:ULongInt(handle:Byte Ptr, opened:Int)
+	Function HPDF_Outline_SetDestination:ULongInt(handle:Byte Ptr, dest:Byte Ptr)
+	
+	Function HPDF_LinkAnnot_SetHighlightMode:ULongInt(handle:Byte Ptr, mode:EPDFAnnotHighlightMode)
+	Function HPDF_LinkAnnot_SetBorderStyle:ULongInt(handle:Byte Ptr, width:Float, dashOn:Short, dashOff:Short)
+	Function HPDF_TextAnnot_SetIcon:ULongInt(handle:Byte Ptr, icon:EPDFAnnotIcon)
+	Function HPDF_TextAnnot_SetOpened:ULongInt(handle:Byte Ptr, open:Int)
+	Function HPDF_Annotation_SetBorderStyle:ULongInt(handle:Byte Ptr, subtype:EPDFBSSubtype, width:Float, dashOn:Short, dashOff:Short, dashPhase:Short)
+
+	Function HPDF_Encoder_GetType:EPDFEncoderType(handle:Byte Ptr)
+	Function HPDF_Encoder_GetByteType:EPDFByteType(handle:Byte Ptr, text:Byte Ptr, index:UInt)
+	Function HPDF_Encoder_GetUnicode:Short(handle:Byte Ptr, code:Short)
+	Function HPDF_Encoder_GetWritingMode:EPDFWritingMode(handle:Byte Ptr)
+
+		
+End Extern
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFLineCap
+	BUTT_END
+	ROUND_END
+	PROJECTING_SQUARE_END
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFLineJoin
+	MITER_JOIN
+    ROUND_JOIN
+    BEVEL_JOIN
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Struct SPDFPoint
+	Field x:Float
+	Field y:Float
+End Struct
+
+Rem
+bbdoc: 
+End Rem
+Struct SPDFRGBColor
+	Field r:Float
+	Field g:Float
+	Field b:Float
+End Struct
+
+Rem
+bbdoc: 
+End Rem
+Struct SPDFCMYKColor
+	Field c:Float
+	Field m:Float
+	Field y:Float
+	Field k:Float
+End Struct
+
+Rem
+bbdoc: 
+End Rem
+Struct SPDFTransMatrix
+	Field a:Float
+	Field b:Float
+	Field c:Float
+	Field d:Float
+	Field x:Float
+	Field y:Float
+End Struct
+
+Rem
+bbdoc: 
+End Rem
+Struct SPDF3DMatrix
+	Field a:Float
+	Field b:Float
+	Field c:Float
+	Field d:Float
+	Field e:Float
+	Field f:Float
+	Field g:Float
+	Field h:Float
+	Field i:Float
+	Field tx:Float
+	Field ty:Float
+	Field tz:Float
+End Struct
+
+Rem
+bbdoc: 
+End Rem
+Struct SPDFDashMode
+	Field StaticArray ptn:Float[8]
+	Field numPtn:UInt
+	Field phase:Float
+End Struct
+
+Rem
+bbdoc: 
+End Rem
+Struct SPDFRect
+	Field left:Float
+	Field bottom:Float
+	Field right:Float
+	Field top:Float
+
+	Method New(left:Float, bottom:Float, right:Float, top:Float)
+		Self.left = left
+		Self.bottom = bottom
+		Self.right = right
+		Self.top = top
+	End Method
+End Struct
+
+Rem
+bbdoc: 
+End Rem
+Struct SPDFTextWidth
+	Field numChars:UInt
+	Field _numwords:UInt ' unused
+	Field width:UInt
+	Field numSpace:UInt
+End Struct
+
+Struct SPDFDate
+	Field year:Int
+	Field month:Int
+	Field day:Int
+	Field hour:Int
+	Field minutes:Int
+	Field seconds:Int
+	Field ind:Byte
+	Field offHour:Int
+	Field offMinutes:Int
+End Struct
+
+Rem
+bbdoc: Compression mode.
+End Rem
+Enum EPDFCompressionMode Flags
+	NONE = $00
+	TEXT = $01
+	IMAGE = $02
+	METADATA = $04
+	ALL = $0F
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFTextAlignment
+	LEFT
+	RIGHT
+	CENTER
+	JUSTIFY
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFTextRenderingMode
+	FILL
+    STROKE
+    FILL_THEN_STROKE
+    INVISIBLE
+    FILL_CLIPPING
+    STROKE_CLIPPING
+    FILL_STROKE_CLIPPING
+    CLIPPING
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFPageSize
+	LETTER
+	LEGAL
+	A3
+	A4
+	A5
+	B4
+	B5
+	EXECUTIVE
+	US4x6
+	US4x8
+	US5x7
+	COMM10
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFPageDirection
+	PORTRAIT
+	LANDSCAPE
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFBlendMode
+	NORMAL
+	MULTIPLY
+	SCREEN
+	OVERLAY
+	DARKEN
+	LIGHTEN
+	COLOR_DODGE
+	COLOR_BUM
+	HARD_LIGHT
+	SOFT_LIGHT
+	DIFFERENCE
+	EXCLUSION
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFWritingMode
+	HORIZONTAL
+	VERTICAL
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFPageLayout
+	SINGLE
+	ONE_COLUMN
+	TWO_COLUMN_LEFT
+	TWO_COLUMN_RIGHT
+	TWO_PAGE_LEFT
+	TWO_PAGE_RIGHT
+End Enum
+
+Rem
+bbdoc: Document page mode.
+End Rem
+Enum EPDFPageMode
+	USE_NONE
+	USE_OUTLINE
+	USE_THUMBS
+	FULL_SCREEN
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFPageNumStyle
+	DECIMAL
+	UPPER_ROMAN
+	LOWER_ROMAN
+	UPPER_LETTERS
+	LOWER_LETTERS
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFColorSpace
+    DEVICE_GRAY
+    DEVICE_RGB
+    DEVICE_CMYK
+    CAL_GRAY
+    CAL_RGB
+    LAB
+    ICC_BASED
+    SEPARATION
+    DEVICE_N
+    INDEXED
+    PATTERN
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFEncryptMode
+	R2
+	R3
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFInfoType
+	CREATION_DATE
+    MOD_DATE
+    AUTHOR
+    CREATOR
+    PRODUCER
+    TITLE
+    SUBJECT
+    KEYWORDS
+    TRAPPED
+    GTS_PDFX
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFTransitionStyle
+    WIPE_RIGHT
+    WIPE_UP
+    WIPE_LEFT
+    WIPE_DOWN
+    BARN_DOORS_HORIZONTAL_OUT
+    BARN_DOORS_HORIZONTAL_IN
+    BARN_DOORS_VERTICAL_OUT
+    BARN_DOORS_VERTICAL_IN
+    BOX_OUT
+    BOX_IN
+    BLINDS_HORIZONTAL
+    BLINDS_VERTICAL
+    DISSOLVE
+    GLITTER_RIGHT
+    GLITTER_DOWN
+    GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT
+    REPLACE
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFAnnotHighlightMode
+	NO_HIGHTLIGHT
+	INVERT_BOX
+	INVERT_BORDER
+	DOWN_APPEARANCE
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFAnnotIcon
+    COMMENT
+    KEY
+    NOTE
+	HELP
+    NEW_PARAGRAPH
+    PARAGRAPH
+    INSERT
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFBSSubtype
+    SOLID
+    DASHED
+    BEVELED
+    INSET
+    UNDERLINED
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFEncoderType
+	SINGLE_BYTE
+    DOUBLE_BYTE
+    UNINITIALIZED
+End Enum
+
+Rem
+bbdoc: 
+End Rem
+Enum EPDFByteType
+    SINGLE
+    LEAD
+    TRAIL
+End Enum
+
+Rem
+bbdoc: Succeeded.
+End Rem
+Const HPDF_OK:ULongInt = 0
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_ARRAY_COUNT_ERR:ULongInt = $1001
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_ARRAY_ITEM_NOT_FOUND:ULongInt = $1002
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_ARRAY_ITEM_UNEXPECTED_TYPE:ULongInt = $1003
+Rem
+bbdoc: Data length > HPDF_LIMIT_MAX_STRING_LEN.
+End Rem
+Const HPDF_BINARY_LENGTH_ERR:ULongInt = $1004
+Rem
+bbdoc: Cannot get pallet data from PNG image.
+End Rem
+Const HPDF_CANNOT_GET_PALLET:ULongInt = $1005
+Rem
+bbdoc: Dictionary elements > HPDF_LIMIT_MAX_DICT_ELEMENT
+End Rem
+Const HPDF_DICT_COUNT_ERR:ULongInt = $1007
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_DICT_ITEM_NOT_FOUND:ULongInt = $1008
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_DICT_ITEM_UNEXPECTED_TYPE:ULongInt = $1009
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_DICT_STREAM_LENGTH_NOT_FOUND:ULongInt = $100A
+Rem
+bbdoc: HPDF_SetEncryptMode() or HPDF_SetPermission() called before password set.
+End Rem
+Const HPDF_DOC_ENCRYPTDICT_NOT_FOUND:ULongInt = $100B
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_DOC_INVALID_OBJECT:ULongInt = $100C
+Rem
+bbdoc: Tried to re-register a registered font.
+End Rem
+Const HPDF_DUPLICATE_REGISTRATION:ULongInt = $100E
+Rem
+bbdoc: Cannot register a character to the Japanese word wrap characters list.
+End Rem
+Const HPDF_EXCEED_JWW_CODE_NUM_LIMIT:ULongInt = $100F
+Rem
+bbdoc: Tried to set the owner password to Null, or Owner and user password are the same.
+End Rem
+Const HPDF_ENCRYPT_INVALID_PASSWORD:ULongInt = $1011
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_ERR_UNKNOWN_CLASS:ULongInt = $1013
+Rem
+bbdoc: Stack depth > HPDF_LIMIT_MAX_GSTATE.
+End Rem
+Const HPDF_EXCEED_GSTATE_LIMIT:ULongInt = $1014
+Rem
+bbdoc: Memory allocation failed.
+End Rem
+Const HPDF_FAILD_TO_ALLOC_MEM:ULongInt = $1015
+Rem
+bbdoc: File processing failed. (Detailed code is set.)
+End Rem
+Const HPDF_FILE_IO_ERROR:ULongInt = $1016
+Rem
+bbdoc: Cannot open a file. (Detailed code is set.)
+End Rem
+Const HPDF_FILE_OPEN_ERROR:ULongInt = $1017
+Rem
+bbdoc: Tried to load a font that has been registered.
+End Rem
+Const HPDF_FONT_EXISTS:ULongInt = $1019
+Rem
+bbdoc: Font-file format is invalid.
+about: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_FONT_INVALID_WIDTHS_TABLE:ULongInt = $101A
+Rem
+bbdoc: Cannot recognize header of afm file.
+End Rem
+Const HPDF_INVALID_AFM_HEADER:ULongInt = $101B
+Rem
+bbdoc: Specified annotation handle is invalid.
+End Rem
+Const HPDF_INVALID_ANNOTATION:ULongInt = $101C
+Rem
+bbdoc: Bit-per-component of a image which was set as mask-image is invalid.
+End Rem
+Const HPDF_INVALID_BIT_PER_COMPONENT:ULongInt = $101E
+Rem
+bbdoc: Cannot recognize char-matrics-data of afm file.
+End Rem
+Const HPDF_INVALID_CHAR_MATRICS_DATA:ULongInt = $101F
+Rem
+bbdoc: Invalid color_space parameter of HPDF_LoadRawImage.
+about: Color-space of a image which was set as mask-image is invalid.
+
+Invoked function invalid in present color-space.
+End Rem
+Const HPDF_INVALID_COLOR_SPACE:ULongInt = $1020
+Rem
+bbdoc: Invalid value set when invoking HPDF_SetCommpressionMode().
+End Rem
+Const HPDF_INVALID_COMPRESSION_MODE:ULongInt = $1021
+Rem
+bbdoc: An invalid date-time value was set.
+End Rem
+Const HPDF_INVALID_DATE_TIME:ULongInt = $1022
+Rem
+bbdoc: An invalid destination handle was set.
+End Rem
+Const HPDF_INVALID_DESTINATION:ULongInt = $1023
+Rem
+bbdoc: An invalid document handle was set.
+End Rem
+Const HPDF_INVALID_DOCUMENT:ULongInt = $1025
+Rem
+bbdoc: Function invalid in the present state was invoked.
+End Rem
+Const HPDF_INVALID_DOCUMENT_STATE:ULongInt = $1026
+Rem
+bbdoc: An invalid encoder handle was set.
+End Rem
+Const HPDF_INVALID_ENCODER:ULongInt = $1027
+Rem
+bbdoc: Combination between font and encoder is wrong.
+End Rem
+Const HPDF_INVALID_ENCODER_TYPE:ULongInt = $1028
+Rem
+bbdoc: An Invalid encoding name is specified.
+End Rem
+Const HPDF_INVALID_ENCODING_NAME:ULongInt = $102B
+Rem
+bbdoc: Encryption key length is invalid.
+End Rem
+Const HPDF_INVALID_ENCRYPT_KEY_LEN:ULongInt = $102C
+Rem
+bbdoc: An invalid font handle was set.
+about: Unsupported font format.
+End Rem
+Const HPDF_INVALID_FONTDEF_DATA:ULongInt = $102D
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_INVALID_FONTDEF_TYPE:ULongInt = $102E
+Rem
+bbdoc: Font with the specified name is not found.
+End Rem
+Const HPDF_INVALID_FONT_NAME:ULongInt = $102F
+Rem
+bbdoc: Unsupported image format.
+End Rem
+Const HPDF_INVALID_IMAGE:ULongInt = $1030
+Rem
+bbdoc: Unsupported image format.
+End Rem
+Const HPDF_INVALID_JPEG_DATA:ULongInt = $1031
+Rem
+bbdoc: Cannot read a postscript-name from an afm file.
+End Rem
+Const HPDF_INVALID_N_DATA:ULongInt = $1032
+Rem
+bbdoc: An invalid object is set.
+about: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_INVALID_OBJECT:ULongInt = $1033
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_INVALID_OBJ_ID:ULongInt = $1034
+Rem
+bbdoc: Invoked HPDF_Image_SetColorMask() against the image-object which was set a mask-image.
+End Rem
+Const HPDF_INVALID_OPERATION:ULongInt = $1035
+Rem
+bbdoc: An invalid outline-handle was specified.
+End Rem
+Const HPDF_INVALID_OUTLINE:ULongInt = $1036
+Rem
+bbdoc: An invalid page-handle was specified.
+End Rem
+Const HPDF_INVALID_PAGE:ULongInt = $1037
+Rem
+bbdoc: An invalid pages-handle was specified. (internal error)
+End Rem
+Const HPDF_INVALID_PAGES:ULongInt = $1038
+Rem
+bbdoc: An invalid value is set.
+End Rem
+Const HPDF_INVALID_PARAMETER:ULongInt = $1039
+Rem
+bbdoc: Invalid PNG image format.
+End Rem
+Const HPDF_INVALID_PNG_IMAGE:ULongInt = $103B
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_INVALID_STREAM:ULongInt = $103C
+Rem
+bbdoc: Internal error. "_FILE_NAME" entry for delayed loading is missing.
+End Rem
+Const HPDF_MISSING_FILE_NAME_ENTRY:ULongInt = $103D
+Rem
+bbdoc: Invalid .TTC file format.
+End Rem
+Const HPDF_INVALID_TTC_FILE:ULongInt = $103F
+Rem
+bbdoc: Index parameter > number of included fonts.
+End Rem
+Const HPDF_INVALID_TTC_INDEX:ULongInt = $1040
+Rem
+bbdoc: Cannot read a width-data from an afm file.
+End Rem
+Const HPDF_INVALID_WX_DATA:ULongInt = $1041
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_ITEM_NOT_FOUND:ULongInt = $1042
+Rem
+bbdoc: Error returned from PNGLIB while loading image.
+End Rem
+Const HPDF_LIBPNG_ERROR:ULongInt = $1043
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_NAME_INVALID_VALUE:ULongInt = $1044
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_NAME_OUT_OF_RANGE:ULongInt = $1045
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_PAGES_MISSING_KIDS_ENTRY:ULongInt = $1049
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_PAGE_CANNOT_FIND_OBJECT:ULongInt = $104A
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_PAGE_CANNOT_GET_ROOT_PAGES:ULongInt = $104B
+Rem
+bbdoc: There are no graphics-states to be restored.
+End Rem
+Const HPDF_PAGE_CANNOT_RESTORE_GSTATE:ULongInt = $104C
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_PAGE_CANNOT_SET_PARENT:ULongInt = $104D
+Rem
+bbdoc: The current font is not set.
+End Rem
+Const HPDF_PAGE_FONT_NOT_FOUND:ULongInt = $104E
+Rem
+bbdoc: An invalid font-handle was specified.
+End Rem
+Const HPDF_PAGE_INVALID_FONT:ULongInt = $104F
+Rem
+bbdoc: An invalid font-size was set.
+End Rem
+Const HPDF_PAGE_INVALID_FONT_SIZE:ULongInt = $1050
+Rem
+bbdoc: See Graphics mode.
+End Rem
+Const HPDF_PAGE_INVALID_GMODE:ULongInt = $1051
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_PAGE_INVALID_INDEX:ULongInt = $1052
+Rem
+bbdoc: Specified value is not multiple of 90.
+End Rem
+Const HPDF_PAGE_INVALID_ROTATE_VALUE:ULongInt = $1053
+Rem
+bbdoc: An invalid page-size was set.
+End Rem
+Const HPDF_PAGE_INVALID_SIZE:ULongInt = $1054
+Rem
+bbdoc: An invalid image-handle was set.
+End Rem
+Const HPDF_PAGE_INVALID_XOBJECT:ULongInt = $1055
+Rem
+bbdoc: The specified value is out of range.
+End Rem
+Const HPDF_PAGE_OUT_OF_RANGE:ULongInt = $1056
+Rem
+bbdoc: The specified value is out of range.
+End Rem
+Const HPDF_REAL_OUT_OF_RANGE:ULongInt = $1057
+Rem
+bbdoc: Unexpected EOF marker was detected.
+End Rem
+Const HPDF_STREAM_EOF:ULongInt = $1058
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_STREAM_READLN_CONTINUE:ULongInt = $1059
+Rem
+bbdoc: The length of the text is too long.
+End Rem
+Const HPDF_STRING_OUT_OF_RANGE:ULongInt = $105B
+Rem
+bbdoc: Function not executed because of other errors.
+End Rem
+Const HPDF_THIS_FUNC_WAS_SKIPPED:ULongInt = $105C
+Rem
+bbdoc: Font cannot be embedded. (license restriction)
+End Rem
+Const HPDF_TTF_CANNOT_EMBEDDING_FONT:ULongInt = $105D
+Rem
+bbdoc: Unsupported ttf format. (cannot find unicode cmap)
+End Rem
+Const HPDF_TTF_INVALID_CMAP:ULongInt = $105E
+Rem
+bbdoc: Unsupported ttf format.
+End Rem
+Const HPDF_TTF_INVALID_FOMAT:ULongInt = $105F
+Rem
+bbdoc: Unsupported ttf format. (cannot find a necessary table)
+End Rem
+Const HPDF_TTF_MISSING_TABLE:ULongInt = $1060
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_UNSUPPORTED_FONT_TYPE:ULongInt = $1061
+Rem
+bbdoc: Library not configured to use PNGLIB.
+about: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_UNSUPPORTED_FUNC:ULongInt = $1062
+Rem
+bbdoc: Unsupported JPEG format.
+End Rem
+Const HPDF_UNSUPPORTED_JPEG_FORMAT:ULongInt = $1063
+Rem
+bbdoc: Failed to parse .PFB file.
+End Rem
+Const HPDF_UNSUPPORTED_TYPE1_FONT:ULongInt = $1064
+Rem
+bbdoc: Internal error. Data consistency was lost.
+End Rem
+Const HPDF_XREF_COUNT_ERR:ULongInt = $1065
+Rem
+bbdoc: Error while executing ZLIB function.
+End Rem
+Const HPDF_ZLIB_ERROR:ULongInt = $1066
+Rem
+bbdoc: An invalid page index was passed.
+End Rem
+Const HPDF_INVALID_PAGE_INDEX:ULongInt = $1067
+Rem
+bbdoc: An invalid URI was set.
+End Rem
+Const HPDF_INVALID_URI:ULongInt = $1068
+Rem
+bbdoc: An invalid page-layout was set.
+End Rem
+Const HPDF_PAGELAYOUT_OUT_OF_RANGE:ULongInt = $1069
+Rem
+bbdoc: An invalid page-mode was set.
+End Rem
+Const HPDF_PAGEMODE_OUT_OF_RANGE:ULongInt = $1070
+Rem
+bbdoc: An invalid page-num-style was set.
+End Rem
+Const HPDF_PAGENUM_STYLE_OUT_OF_RANGE:ULongInt = $1071
+Rem
+bbdoc: An invalid icon was set.
+End Rem
+Const HPDF_ANNOT_INVALID_ICON:ULongInt = $1072
+Rem
+bbdoc: An invalid border-style was set.
+End Rem
+Const HPDF_ANNOT_INVALID_BORDER_STYLE:ULongInt = $1073
+Rem
+bbdoc: An invalid page-direction was set.
+End Rem
+Const HPDF_PAGE_INVALID_DIRECTION:ULongInt = $1074
+Rem
+bbdoc: An invalid font-handle was specified.
+End Rem
+Const HPDF_INVALID_FONT:ULongInt = $1075
+Const HPDF_PAGE_INSUFFICIENT_SPACE:ULongInt = $1076
+Const HPDF_PAGE_INVALID_DISPLAY_TIME:ULongInt = $1077
+Const HPDF_PAGE_INVALID_TRANSITION_TIME:ULongInt = $1078
+Const HPDF_INVALID_PAGE_SLIDESHOW_TYPE:ULongInt = $1079
+Const HPDF_EXT_GSTATE_OUT_OF_RANGE:ULongInt = $1080
+Const HPDF_INVALID_EXT_GSTATE:ULongInt = $1081
+Const HPDF_EXT_GSTATE_READ_ONLY:ULongInt = $1082
+Const HPDF_INVALID_U3D_DATA:ULongInt = $1083
+Const HPDF_NAME_CANNOT_GET_NAMES:ULongInt = $1084
+Const HPDF_INVALID_ICC_COMPONENT_NUM:ULongInt = $1085
+Const HPDF_INVALID_SHADING_TYPE:ULongInt = $1088
+
+Rem
+bbdoc: The default line width.
+End Rem
+Const HPDF_DEF_LINEWIDTH:Float = 1

+ 74 - 0
pdf.mod/examples/arc_example.bmx

@@ -0,0 +1,74 @@
+SuperStrict
+
+Framework Text.PDF
+
+Import "grid_sheet.bmx"
+
+Local pdf:TPDFDoc = New TPDFDoc
+
+' add a new page object
+Local page:TPDFPage = pdf.AddPage()
+
+page.SetHeight(220)
+page.SetWidth(200)
+
+'draw grid to the page
+PrintGrid(pdf, page)
+
+
+' draw pie chart
+'
+'   A: 45% Red
+'   B: 25% Blue
+'   C: 15% green
+'   D: other yellow
+'
+
+' A
+page.SetRGBFill(1.0, 0, 0)
+page.MoveTo(100, 100)
+page.LineTo(100, 180)
+page.Arc(100, 100, 80, 0, 360 * 0.45)
+Local pos:SPDFPoint = page.GetCurrentPos()
+page.LineTo(100, 100)
+page.Fill()
+
+' B
+page.SetRGBFill(0, 0, 1.0)
+page.MoveTo(100, 100)
+page.LineTo(pos.x, pos.y)
+page.Arc(100, 100, 80, 360 * 0.45, 360 * 0.7)
+pos = page.GetCurrentPos()
+page.LineTo(100, 100)
+page.Fill()
+
+' C
+page.SetRGBFill(0, 1.0, 0)
+page.MoveTo(100, 100)
+page.LineTo(pos.x, pos.y)
+page.Arc(100, 100, 80, 360 * 0.7, 360 * 0.85)
+pos = page.GetCurrentPos()
+page.LineTo(100, 100)
+page.Fill()
+
+' D
+page.SetRGBFill(1.0, 1.0, 0)
+page.MoveTo(100, 100)
+page.LineTo(pos.x, pos.y)
+page.Arc(100, 100, 80, 360 * 0.85, 360)
+pos = page.GetCurrentPos()
+page.LineTo(100, 100)
+page.Fill()
+
+' draw center circle
+page.SetGrayStroke(0)
+page.SetGrayFill(1)
+page.Circle(100, 100, 30)
+page.Fill()
+
+
+' save the document to a file
+pdf.Save("arc_example.pdf")
+
+' free up
+pdf.Free()

+ 32 - 0
pdf.mod/examples/encryption.bmx

@@ -0,0 +1,32 @@
+SuperStrict
+
+Framework Text.PDF
+
+Const txt:String = "This is an encrypt document example."
+Const ownerPasswd:String = "owner"
+Const userPasswd:String = "user"
+
+Local pdf:TPDFDoc = New TPDFDoc
+
+' create default-font
+Local font:TPDFFont = pdf.GetFont("Helvetica", Null)
+
+' add a new page object
+Local page:TPDFPage = pdf.AddPage()
+
+page.SetSize(EPDFPageSize.B5, EPDFPageDirection.LANDSCAPE)
+
+page.BeginText()
+page.SetFontAndSize(font, 20)
+Local tw:Float = page.TextWidth(txt)
+page.MoveTextPos((page.GetWidth() - tw) / 2, (page.GetHeight()  - 20) / 2)
+page.ShowText(txt)
+page.EndText()
+
+pdf.SetPassword(ownerPasswd, userPasswd)
+
+' save the document to a file
+pdf.Save("encryption.pdf")
+
+' free up
+pdf.Free()

+ 158 - 0
pdf.mod/examples/ext_gstate_example.bmx

@@ -0,0 +1,158 @@
+SuperStrict
+
+Framework Text.PDF
+
+Const PAGE_WIDTH:Float = 600
+Const PAGE_HEIGHT:Float = 900
+
+
+Local pdf:TPDFDoc = New TPDFDoc
+
+Local hfont:TPDFFont = pdf.GetFont("Helvetica-Bold", Null)
+
+' Add a new page object.
+Local page:TPDFPage = pdf.AddPage()
+
+page.SetFontAndSize(hfont, 10)
+
+page.SetHeight(PAGE_HEIGHT)
+page.SetWidth(PAGE_WIDTH)
+
+' normal
+page.GSave()
+DrawCircles(page, "normal", 40.0, PAGE_HEIGHT - 170)
+page.GRestore()
+
+' transparency(0.8)
+page.GSave()
+Local gstate:TPDFExtGState = pdf.CreateExtGState()
+gstate.SetAlphaFill(0.8)
+gstate.SetAlphaStroke(0.8)
+page.SetExtGState(gstate)
+DrawCircles(page, "alpha fill = 0.8", 230.0, PAGE_HEIGHT - 170)
+page.GRestore()
+
+' transparency(0.4)
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetAlphaFill(0.4)
+page.SetExtGState(gstate)
+DrawCircles(page, "alpha fill = 0.4", 420.0, PAGE_HEIGHT - 170)
+page.GRestore()
+
+' blend-mode=MULTIPLY
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetBlendMode(EPDFBlendMode.MULTIPLY)
+page.SetExtGState(gstate)
+DrawCircles(page, "MULTIPLY", 40.0, PAGE_HEIGHT - 340)
+page.GRestore()
+
+' blend-mode=SCREEN
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetBlendMode(EPDFBlendMode.SCREEN)
+page.SetExtGState(gstate)
+DrawCircles(page, "SCREEN", 230.0, PAGE_HEIGHT - 340)
+page.GRestore()
+
+' blend-mode=OVERLAY
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetBlendMode(EPDFBlendMode.OVERLAY)
+page.SetExtGState(gstate)
+DrawCircles(page, "OVERLAY", 420.0, PAGE_HEIGHT - 340)
+page.GRestore()
+
+' blend-mode=DARKEN
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetBlendMode(EPDFBlendMode.DARKEN)
+page.SetExtGState(gstate)
+DrawCircles(page, "DARKEN", 40.0, PAGE_HEIGHT - 510)
+page.GRestore()
+
+' blend-mode=LIGHTEN
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetBlendMode(EPDFBlendMode.LIGHTEN)
+page.SetExtGState(gstate)
+DrawCircles(page, "LIGHTEN", 230.0, PAGE_HEIGHT - 510)
+page.GRestore()
+
+' blend-mode=COLOR_DODGE
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetBlendMode(EPDFBlendMode.COLOR_DODGE)
+page.SetExtGState(gstate)
+DrawCircles(page, "COLOR_DODGE", 420.0, PAGE_HEIGHT - 510)
+page.GRestore()
+
+
+' blend-mode=COLOR_BUM
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetBlendMode(EPDFBlendMode.COLOR_BUM)
+page.SetExtGState(gstate)
+DrawCircles(page, "COLOR_BUM", 40.0, PAGE_HEIGHT - 680)
+page.GRestore()
+
+' blend-mode=HARD_LIGHT
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetBlendMode(EPDFBlendMode.HARD_LIGHT)
+page.SetExtGState(gstate)
+DrawCircles(page, "HARD_LIGHT", 230.0, PAGE_HEIGHT - 680)
+page.GRestore()
+
+' blend-mode=SOFT_LIGHT
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetBlendMode(EPDFBlendMode.SOFT_LIGHT)
+page.SetExtGState(gstate)
+DrawCircles(page, "SOFT_LIGHT", 420.0, PAGE_HEIGHT - 680)
+page.GRestore()
+
+' blend-mode=DIFFERENCE
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetBlendMode(EPDFBlendMode.DIFFERENCE)
+page.SetExtGState(gstate)
+DrawCircles(page, "DIFFERENCE", 40.0, PAGE_HEIGHT - 850)
+page.GRestore()
+
+
+' blend-mode=EXCLUSION
+page.GSave()
+gstate = pdf.CreateExtGState()
+gstate.SetBlendMode(EPDFBlendMode.EXCLUSION)
+page.SetExtGState(gstate)
+DrawCircles(page, "EXCLUSION", 230.0, PAGE_HEIGHT - 850)
+page.GRestore()
+
+
+' save the document to a file
+pdf.Save("ext_gstate_example.pdf")
+
+' free up
+pdf.Free()
+
+
+Function DrawCircles(page:TPDFPage, description:String, x:Float, y:Float)
+	page.SetLineWidth(1.0)
+	page.SetRGBStroke(0, 0, 0)
+	page.SetRGBFill(1.0, 0, 0)
+	page.Circle(x + 40, y + 40, 40)
+	page.ClosePathFillStroke()
+	page.SetRGBFill(0, 1.0, 0)
+	page.Circle(x + 100, y + 40, 40)
+	page.ClosePathFillStroke()
+	page.SetRGBFill(0, 0, 1.0)
+	page.Circle(x + 70, y + 74.64, 40)
+	page.ClosePathFillStroke()
+	
+	page.SetRGBFill(0, 0, 0)
+	page.BeginText()
+	page.TextOut(x + 0, y + 130, description)
+	page.EndText()	
+End Function

+ 63 - 0
pdf.mod/examples/font_example.bmx

@@ -0,0 +1,63 @@
+SuperStrict
+
+Framework Text.PDF
+
+Const pageTitle:String = "Font example"
+
+Local fontList:String[] = ["Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", ..
+	"Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique","Times-Roman", ..
+	"Times-Bold", "Times-Italic", "Times-BoldItalic", "Symbol", "ZapfDingbats"]
+
+Local pdf:TPDFDoc = New TPDFDoc
+
+' Add a new page object.
+Local page:TPDFPage = pdf.AddPage()
+
+Local height:Float = page.GetHeight()
+Local width:Float = page.GetWidth()
+
+' Print the lines of the page.
+page.SetLineWidth(1)
+page.Rectangle(50, 50, width - 100, height - 110)
+page.Stroke()
+
+' Print the title of the page(with positioning center).
+Local defaultFont:TPDFFont = pdf.GetFont("Helvetica", NULL)
+page.SetFontAndSize(defaultFont, 24)
+
+Local tw:Float = page.TextWidth(pageTitle)
+page.BeginText()
+page.TextOut((width - tw) / 2, height - 50, pageTitle)
+page.EndText()
+
+' output subtitle.
+page.BeginText()
+page.SetFontAndSize(defaultFont, 16)
+page.TextOut(60, height - 80, "<Standerd Type1 fonts samples>")
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(60, height - 105)
+
+For Local i:Int = 0 Until fontList.Length
+	Const sampText:String = "abcdefgABCDEFG12345!#$%&+-@?"
+	Local font:TPDFFont = pdf.GetFont(fontList[i], Null)
+
+	'print a label of text
+	page.SetFontAndSize(defaultFont, 9)
+	page.ShowText(fontList[i])
+	page.MoveTextPos(0, -18)
+
+	'print a sample text.
+	page.SetFontAndSize(font, 20)
+	page.ShowText(sampText)
+	page.MoveTextPos(0, -20)
+Next
+
+page.EndText()
+
+' save the document to a file
+pdf.Save("font_example.pdf")
+
+' free up
+pdf.Free()

+ 108 - 0
pdf.mod/examples/grid_sheet.bmx

@@ -0,0 +1,108 @@
+SuperStrict
+
+Function PrintGrid(pdf:TPDFDoc, page:TPDFPage)
+	Local height:Float = page.GetHeight()
+    Local width:Float = page.GetWidth()
+    Local font:TPDFFont = pdf.GetFont("Helvetica", Null)
+
+	page.SetFontAndSize(font, 5)
+	page.SetGrayFill(0.5)
+	page.SetGrayStroke(0.8)
+	
+	' Draw horizontal lines
+	Local y:UInt = 0
+	While y < height
+		If y Mod 10 = 0 Then
+			page.SetLineWidth(0.5)
+		Else
+			If page.GetLineWidth() <> 0.25 Then
+				page.SetLineWidth(0.25)
+			End If
+		End If
+		
+		page.MoveTo(0, y)
+		page.LineTo(width, y)
+		page.Stroke()
+		
+		If y Mod 10 = 0 And y > 0 Then
+			page.SetGrayStroke(0.5)
+			
+			page.MoveTo(0, y)
+			page.LineTo(5, y)
+			page.Stroke()
+			
+			page.SetGrayStroke(0.8)
+		End If
+
+		y :+ 5
+	Wend
+	
+	
+	' Draw vertical lines
+	Local x:UInt = 0
+	While x < width
+		If x Mod 10 = 0 Then
+			page.SetLineWidth(0.5)
+		Else
+			If page.GetLineWidth() <> 0.25 Then
+				page.SetLineWidth(0.25)
+			End If
+		End If
+		
+		page.MoveTo(x, 0)
+		page.LineTo(x, height)
+		page.Stroke()
+		
+		If x Mod 50 = 0 And x > 0 Then
+			page.SetGrayStroke(0.5)
+			
+			page.MoveTo(x, 0)
+			page.LineTo(x, 5)
+			page.Stroke()
+			
+			page.MoveTo(x, height)
+			page.LineTo(x, height - 5)
+			page.Stroke()
+			
+			page.SetGrayStroke(0.8)
+		End If
+		
+		x :+ 5
+	Wend
+	
+	' Draw horizontal text
+	y = 0
+	while y < height
+		If y Mod 10 = 0 And y > 0 Then
+			page.BeginText()
+			page.MoveTextPos(5, y - 2)
+			page.ShowText(y)
+			page.EndText()
+		End If
+		
+		y :+ 5
+	Wend
+	
+	
+	' Draw vertical text
+	x = 0
+	While x < width
+		If x Mod 50 = 0 And x > 0 Then
+			page.BeginText()
+			page.MoveTextPos(x, 5)
+			page.ShowText(x)
+			page.EndText()
+			
+			page.BeginText()
+			page.MoveTextPos(x, height - 10)
+			page.ShowText(x)
+			page.EndText()
+		End If
+	
+		x :+ 5
+	Wend
+	
+	page.SetGrayFill(0)
+	page.SetGrayStroke(0)
+
+End Function

+ 290 - 0
pdf.mod/examples/line_example.bmx

@@ -0,0 +1,290 @@
+SuperStrict
+
+Framework Text.PDF
+
+Local pageTitle:String = "Line Example"
+
+Local DASH_MODE1:Float[] = [3]
+Local DASH_MODE2:Float[] = [3, 7]
+Local DASH_MODE3:Float[] = [8, 7, 2, 7]
+
+
+Local pdf:TPDFDoc = New TPDFDoc
+
+Local font:TPDFFont = pdf.GetFont("Helvetica", NULL);
+
+' add a new page object
+Local page:TPDFPage = pdf.AddPage()
+
+' print the lines of the page
+page.SetLineWidth(1)
+page.Rectangle(50, 50, page.GetWidth() - 100, page.GetHeight() - 110)
+page.Stroke()
+
+
+
+' print the title of the page (with positioning center).
+page.SetFontAndSize(font, 24)
+Local textWidth:Float = page.TextWidth(pageTitle)
+page.BeginText()
+page.MoveTextPos((page.GetWidth() - textWidth) / 2, page.GetHeight() - 50)
+page.ShowText(pageTitle)
+page.EndText()
+
+page.SetFontAndSize(font, 10)
+
+' Draw various widths of lines.
+page.SetLineWidth(0)
+DrawLine(page, 60, 770, "line width = 0")
+
+page.SetLineWidth(1.0)
+DrawLine(page, 60, 740, "line width = 1.0")
+
+page.SetLineWidth(2.0)
+DrawLine(page, 60, 710, "line width = 2.0")
+
+' Line dash pattern
+page.SetLineWidth(1.0)
+
+page.SetDash(DASH_MODE1, 1, 1)
+DrawLine(page, 60, 680, "dash_ptn=[3], phase=1 -- 2 on, 3 off, 3 on...")
+
+page.SetDash(DASH_MODE2, 2, 2)
+DrawLine(page, 60, 650, "dash_ptn=[7, 3], phase=2 -- 5 on 3 off, 7 on,...")
+
+page.SetDash(DASH_MODE3, 4, 0)
+DrawLine(page, 60, 620, "dash_ptn=[8, 7, 2, 7], phase=0")
+
+page.SetDash(Null, 0, 0)
+
+page.SetLineWidth(30)
+page.SetRGBStroke(0.0, 0.5, 0.0)
+
+' Line Cap Style
+page.SetLineCap(EPDFLineCap.BUTT_END)
+DrawLine2(page, 60, 570, "BUTT_END")
+
+page.SetLineCap(EPDFLineCap.ROUND_END)
+DrawLine2(page, 60, 505, "ROUND_END")
+
+page.SetLineCap(EPDFLineCap.PROJECTING_SQUARE_END)
+DrawLine2(page, 60, 440, "PROJECTING_SQUARE_END")
+
+' Line Join Style
+page.SetLineWidth(30)
+page.SetRGBStroke(0.0, 0.0, 0.5)
+
+page.SetLineJoin(EPDFLineJoin.MITER_JOIN)
+page.MoveTo(120, 300)
+page.LineTo(160, 340)
+page.LineTo(200, 300)
+page.Stroke()
+
+page.BeginText()
+page.MoveTextPos(60, 360)
+page.ShowText("MITER_JOIN")
+page.EndText()
+
+page.SetLineJoin(EPDFLineJoin.ROUND_JOIN)
+page.MoveTo(120, 195)
+page.LineTo(160, 235)
+page.LineTo(200, 195)
+page.Stroke()
+
+page.BeginText()
+page.MoveTextPos(60, 255)
+page.ShowText("ROUND_JOIN")
+page.EndText()
+
+page.SetLineJoin(EPDFLineJoin.BEVEL_JOIN)
+page.MoveTo(120, 90)
+page.LineTo(160, 130)
+page.LineTo(200, 90)
+page.Stroke()
+
+page.BeginText()
+page.MoveTextPos(60, 150)
+page.ShowText("BEVEL_JOIN")
+page.EndText()
+
+' Draw Rectangle
+page.SetLineWidth(2)
+page.SetRGBStroke(0, 0, 0)
+page.SetRGBFill(0.75, 0.0, 0.0)
+
+DrawRect(page, 300, 770, "Stroke")
+page.Stroke()
+
+DrawRect(page, 300, 720, "Fill")
+page.Fill()
+
+DrawRect(page, 300, 670, "Fill then Stroke")
+page.FillStroke()
+
+' Clip Rect
+page.GSave()  ' Save the current graphic state
+DrawRect(page, 300, 620, "Clip Rectangle")
+page.Clip()
+page.Stroke()
+page.SetFontAndSize(font, 13)
+
+page.BeginText()
+page.MoveTextPos(290, 600)
+page.SetTextLeading(12)
+page.ShowText("Clip Clip Clip Clip Clip Clipi Clip Clip Clip")
+page.ShowTextNextLine("Clip Clip Clip Clip Clip Clip Clip Clip Clip")
+page.ShowTextNextLine("Clip Clip Clip Clip Clip Clip Clip Clip Clip")
+page.EndText()
+page.GRestore()
+
+' Curve Example(CurveTo2)
+Local x:Float = 330
+Local y:Float = 440
+Local x1:Float = 430
+Local y1:Float = 530
+Local x2:Float = 480
+Local y2:Float = 470
+Local x3 :Float= 480
+Local y3:Float = 90
+
+page.SetRGBFill(0, 0, 0)
+
+page.BeginText()
+page.MoveTextPos(300, 540)
+page.ShowText("CurveTo2(x1, y1, x2, y2)")
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(x + 5, y - 5)
+page.ShowText("Current point")
+page.MoveTextPos(x1 - x, y1 - y)
+page.ShowText("(x1, y1)")
+page.MoveTextPos(x2 - x1, y2 - y1)
+page.ShowText("(x2, y2)")
+page.EndText()
+
+page.SetDash(DASH_MODE1, 1, 0)
+
+page.SetLineWidth(0.5)
+page.MoveTo(x1, y1)
+page.LineTo(x2, y2)
+page.Stroke()
+
+page.SetDash(Null, 0, 0)
+
+page.SetLineWidth(1.5)
+
+page.MoveTo(x, y)
+page.CurveTo2(x1, y1, x2, y2)
+page.Stroke()
+
+' Curve Example(CurveTo3)
+y :- 150
+y1 :- 150
+y2 :- 150
+
+page.BeginText()
+page.MoveTextPos(300, 390)
+page.ShowText("CurveTo3(x1, y1, x2, y2)")
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(x + 5, y - 5)
+page.ShowText("Current point")
+page.MoveTextPos(x1 - x, y1 - y)
+page.ShowText("(x1, y1)")
+page.MoveTextPos(x2 - x1, y2 - y1)
+page.ShowText("(x2, y2)")
+page.EndText()
+
+page.SetDash(DASH_MODE1, 1, 0)
+
+page.SetLineWidth(0.5)
+page.MoveTo(x, y)
+page.LineTo(x1, y1)
+page.Stroke()
+
+page.SetDash(Null, 0, 0)
+
+page.SetLineWidth(1.5)
+page.MoveTo(x, y)
+page.CurveTo3(x1, y1, x2, y2)
+page.Stroke()
+
+' Curve Example(CurveTo)
+y :- 150
+y1 :- 160
+y2 :- 130
+x2 :+ 10
+
+page.BeginText()
+page.MoveTextPos(300, 240)
+page.ShowText("CurveTo(x1, y1, x2. y2, x3, y3)")
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(x + 5, y - 5)
+page.ShowText("Current point")
+page.MoveTextPos(x1 - x, y1 - y)
+page.ShowText("(x1, y1)")
+page.MoveTextPos(x2 - x1, y2 - y1)
+page.ShowText("(x2, y2)")
+page.MoveTextPos(x3 - x2, y3 - y2)
+page.ShowText("(x3, y3)")
+page.EndText()
+
+page.SetDash(DASH_MODE1, 1, 0)
+
+page.SetLineWidth(0.5)
+page.MoveTo(x, y)
+page.LineTo(x1, y1)
+page.Stroke()
+page.MoveTo(x2, y2)
+page.LineTo(x3, y3)
+page.Stroke()
+
+page.SetDash(Null, 0, 0)
+
+page.SetLineWidth(1.5)
+page.MoveTo(x, y)
+page.CurveTo(x1, y1, x2, y2, x3, y3)
+page.Stroke()
+
+
+' save the document to a file
+pdf.Save("line_example.pdf")
+
+' free up
+pdf.Free()
+
+
+Function DrawLine(page:TPDFPage, x:Float, y:Float, label:String)
+	page.BeginText()
+	page.MoveTextPos(x, y - 10)
+	page.ShowText(label)
+	page.EndText()
+
+	page.MoveTo(x, y - 15)
+	page.LineTo(x + 220, y - 15)
+	page.Stroke()
+End Function
+
+Function DrawLine2(page:TPDFPage, x:Float, y:Float, label:String)
+	page.BeginText()
+	page.MoveTextPos(x, y)
+	page.ShowText(label)
+	page.EndText()
+
+	page.MoveTo(x + 30, y - 25)
+	page.LineTo(x + 160, y - 25)
+	page.Stroke()
+End Function
+
+Function DrawRect(page:TPDFPage, x:Float, y:Float, label:String)
+	page.BeginText()
+	page.MoveTextPos(x, y - 10)
+	page.ShowText(label)
+	page.EndText()
+
+	page.Rectangle(x, y - 40, 220, 25)
+End Function

+ 74 - 0
pdf.mod/examples/outline_example.bmx

@@ -0,0 +1,74 @@
+SuperStrict
+
+Framework Text.PDF
+
+Local pageTitle:String = "Outline Example"
+
+Local page:TPDFPage[] = New TPDFPage[3]
+Local outline:TPDFOutline[] = New TPDFOutline[3]
+
+Local pdf:TPDFDoc = New TPDFDoc
+
+' create default-font
+Local font:TPDFFont = pdf.GetFont("Helvetica", Null)
+
+' Set page mode to use outlines.
+pdf.SetPageMode(EPDFPageMode.USE_OUTLINE)
+
+' Add 3 pages to the document.
+page[0] = pdf.AddPage()
+page[0].SetFontAndSize(font, 30)
+PrintPage(page[0], 1)
+
+page[1] = pdf.AddPage()
+page[1].SetFontAndSize(font, 30)
+PrintPage(page[1], 2)
+
+page[2] = pdf.AddPage()
+page[2].SetFontAndSize(font, 30)
+PrintPage(page[2], 3)
+
+' create outline root.
+Local root:TPDFOutline = pdf.CreateOutline(Null, "OutlineRoot2", Null)
+root.SetOpened(True)
+
+outline[0] = pdf.CreateOutline(root, "page1.2", Null)
+outline[1] = pdf.CreateOutline(root, "page2.2", Null)
+
+' create outline with test which is ISO8859-2 encoding
+Local buf:Byte Ptr = "ISO8859-2 text �������".ToCString()
+outline[2] = pdf.CreateOutline(root, buf, pdf.GetEncoder("ISO8859-2"))
+MemFree(buf)
+
+' create destination objects on each pages
+' and link it to outline items.
+Local dst:TPDFDestination = page[0].CreateDestination()
+dst.SetXYZ(0, page[0].GetHeight(), 1)
+outline[0].SetDestination(dst)
+' pdf.Catalog_SetOpenAction(dst)
+
+dst = page[1].CreateDestination()
+dst.SetXYZ(0, page[1].GetHeight(), 1)
+outline[1].SetDestination(dst)
+
+dst = page[2].CreateDestination()
+dst.SetXYZ(0, page[2].GetHeight(), 1)
+outline[2].SetDestination(dst)
+
+' save the document to a file
+pdf.Save("outline_example.pdf")
+
+' free up
+pdf.Free()
+
+
+Function PrintPage(page:TPDFPage,  pageNum:Int)
+	page.SetWidth(800)
+	page.SetHeight(800)
+
+	page.BeginText()
+	page.MoveTextPos(30, 740)
+
+	page.ShowText(pageNum)
+	page.EndText()
+End Function

+ 106 - 0
pdf.mod/examples/text_annotation.bmx

@@ -0,0 +1,106 @@
+SuperStrict
+
+Framework Text.PDF
+
+
+Local rect1:SPDFRect = New SPDFRect(50, 350, 150, 400)
+Local rect2:SPDFRect = New SPDFRect(210, 350, 350, 400)
+Local rect3:SPDFRect = New SPDFRect(50, 250, 150, 300)
+Local rect4:SPDFRect = New SPDFRect(210, 250, 350, 300)
+Local rect5:SPDFRect = New SPDFRect(50, 150, 150, 200)
+Local rect6:SPDFRect = New SPDFRect(210, 150, 350, 200)
+Local rect7:SPDFRect = New SPDFRect(50, 50, 150, 100)
+Local rect8:SPDFRect = New SPDFRect(210, 50, 350, 100)
+
+
+Local pdf:TPDFDoc = New TPDFDoc
+
+' use Times-Roman font.
+Local font:TPDFFont = pdf.GetFont("Times-Roman", "WinAnsiEncoding")
+
+Local page:TPDFPage = pdf.AddPage()
+
+page.SetWidth(400)
+page.SetHeight(500)
+
+page.BeginText()
+page.SetFontAndSize(font, 16)
+page.MoveTextPos(130, 450)
+page.ShowText("Annotation Demo")
+page.EndText()
+
+Local annot:TPDFAnnotation = page.CreateTextAnnot(rect1, "Annotation with Comment Icon. ~n This annotation set to be opened initially.", Null)
+
+annot.SetIcon(EPDFAnnotIcon.COMMENT)
+annot.SetOpened(True)
+
+annot = page.CreateTextAnnot(rect2, "Annotation with Key Icon", Null)
+annot.SetIcon(EPDFAnnotIcon.PARAGRAPH)
+
+annot = page.CreateTextAnnot(rect3, "Annotation with Note Icon", Null)
+annot.SetIcon(EPDFAnnotIcon.NOTE)
+
+annot = page.CreateTextAnnot(rect4, "Annotation with Help Icon", Null)
+annot.SetIcon(EPDFAnnotIcon.HELP)
+
+annot = page.CreateTextAnnot(rect5, "Annotation with NewParagraph Icon", Null)
+annot.SetIcon(EPDFAnnotIcon.NEW_PARAGRAPH)
+
+annot = page.CreateTextAnnot(rect6, "Annotation with Paragraph Icon", Null)
+annot.SetIcon(EPDFAnnotIcon.PARAGRAPH)
+
+annot = page.CreateTextAnnot(rect7, "Annotation with Insert Icon", Null)
+annot.SetIcon(EPDFAnnotIcon.INSERT)
+
+Local encoding:TPDFEncoder = pdf.GetEncoder("ISO8859-2")
+
+page.CreateTextAnnot(rect8, "Annotation with ISO8859 text �������", encoding)
+
+page.SetFontAndSize(font, 11)
+
+page.BeginText()
+page.MoveTextPos(rect1.left + 35, rect1.top - 20)
+page.ShowText("Comment Icon.")
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(rect2.left + 35, rect2.top - 20)
+page.ShowText("Key Icon")
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(rect3.left + 35, rect3.top - 20)
+page.ShowText("Note Icon.")
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(rect4.left + 35, rect4.top - 20)
+page.ShowText("Help Icon")
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(rect5.left + 35, rect5.top - 20)
+page.ShowText("NewParagraph Icon")
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(rect6.left + 35, rect6.top - 20)
+page.ShowText("Paragraph Icon")
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(rect7.left + 35, rect7.top - 20)
+page.ShowText("Insert Icon")
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(rect8.left + 35, rect8.top - 20)
+page.ShowText("Text Icon(ISO8859-2 text)")
+page.EndText()
+
+' save the document to a file
+pdf.Save("text_annotation.pdf")
+
+' free up
+pdf.Free()
+

+ 263 - 0
pdf.mod/examples/text_example.bmx

@@ -0,0 +1,263 @@
+SuperStrict
+
+Framework Text.PDF
+Import BRL.Math
+
+Import "grid_sheet.bmx"
+
+
+Const pageTitle:String = "Text example"
+Const sampText:String = "abcdefgABCDEFG123!#$%&+-@?"
+Const sampText2:String = "The quick brown fox jumps over the lazy dog."
+
+
+
+Local pdf:TPDFDoc = New TPDFDoc
+
+pdf.SetCompressionMode(EPDFCompressionMode.COMP_ALL)
+
+' create default-font */
+Local font:TPDFFont = pdf.GetFont("Helvetica", Null)
+
+' add a new page object
+Local page:TPDFPage = pdf.AddPage()
+
+PrintGrid(pdf, page)
+
+' print the title of the page (with positioning center).
+page.SetFontAndSize(font, 24)
+Local tw:Float = page.TextWidth(pageTitle)
+page.BeginText()
+page.TextOut((page.GetWidth() - tw) / 2, page.GetHeight() - 50, pageTitle)
+page.EndText()
+
+page.BeginText()
+page.MoveTextPos(60, page.GetHeight() - 60)
+
+' font size
+
+Local fsize:Float = 8
+While fsize < 60
+
+	' set style and size of font.
+	page.SetFontAndSize(font, fsize)
+
+	' set the position of the text.
+	page.MoveTextPos(0, -5 - fsize)
+
+	' measure the number of characters which included in the page.
+	Local length:Int = page.MeasureText(sampText, page.GetWidth() - 120, False, Null)
+
+	page.ShowText(sampText[..length])
+
+	' print the description.
+	page.MoveTextPos(0, -10)
+	page.SetFontAndSize(font, 8)
+	page.ShowText("Fontsize=" + Int(fsize))
+
+	fsize :* 1.5
+Wend
+
+' font color
+
+page.SetFontAndSize(font, 8)
+page.MoveTextPos(0, -30)
+page.ShowText("Font color")
+
+page.SetFontAndSize(font, 18)
+page.MoveTextPos(0, -20)
+Local length:Int = sampText.Length
+for Local i:Int = 0 Until length
+	Local r:Float =Float(i) / Float(length)
+	Local g:Float = 1 - (Float(i) / Float(length))
+
+	page.SetRGBFill(r, g, 0.0)
+	page.ShowText(sampText[i..i+1])
+Next
+page.MoveTextPos(0, -25)
+
+For Local i:Int = 0 Until length
+	Local r:Float = Float(i) / Float(length)
+	Local b:Float = 1 - (Float(i) / Float(length))
+
+	page.SetRGBFill(r, 0.0, b)
+	page.ShowText(sampText[i..i+1])
+Next
+page.MoveTextPos(0, -25)
+
+For Local i:Int = 0 Until length
+	Local b:Float = Float(i) / Float(length)
+	Local g:Float = 1 - (Float(i) / Float(length))
+
+	page.SetRGBFill(0.0, g, b)
+	page.ShowText(sampText[i..i+1])
+Next
+
+page.EndText()
+
+Local ypos:Float = 450
+
+' Font rendering mode
+page.SetFontAndSize(font, 32)
+page.SetRGBFill(0.5, 0.5, 0.0)
+page.SetLineWidth(1.5)
+
+' PDF_FILL
+ShowDescription(page, 60, ypos, "RenderingMode=FILL")
+page.SetTextRenderingMode(EPDFTextRenderingMode.FILL)
+page.BeginText()
+page.TextOut(60, ypos, "ABCabc123")
+page.EndText()
+
+' PDF_STROKE
+ShowDescription(page, 60, ypos - 50, "RenderingMode=STROKE")
+page.SetTextRenderingMode(EPDFTextRenderingMode.STROKE)
+page.BeginText()
+page.TextOut(60, ypos - 50, "ABCabc123")
+page.EndText()
+
+' PDF_FILL_THEN_STROKE
+ShowDescription(page, 60, ypos - 100, "RenderingMode=FILL_THEN_STROKE")
+page.SetTextRenderingMode(EPDFTextRenderingMode.FILL_THEN_STROKE)
+page.BeginText()
+page.TextOut(60, ypos - 100, "ABCabc123")
+page.EndText()
+
+' PDF_FILL_CLIPPING
+ShowDescription(page, 60, ypos - 150, "RenderingMode=FILL_CLIPPING")
+page.GSave()
+page.SetTextRenderingMode(EPDFTextRenderingMode.FILL_CLIPPING)
+page.BeginText()
+page.TextOut(60, ypos - 150, "ABCabc123")
+page.EndText()
+ShowStripePattern(page, 60, ypos - 150)
+page.GRestore()
+
+' PDF_STROKE_CLIPPING
+ShowDescription(page, 60, ypos - 200, "RenderingMode=STROKE_CLIPPING")
+page.GSave()
+page.SetTextRenderingMode(EPDFTextRenderingMode.STROKE_CLIPPING)
+page.BeginText()
+page.TextOut(60, ypos - 200, "ABCabc123")
+page.EndText()
+ShowStripePattern(page, 60, ypos - 200)
+page.GRestore()
+
+' PDF_FILL_STROKE_CLIPPING
+ShowDescription(page, 60, ypos - 250, "RenderingMode=FILL_STROKE_CLIPPING")
+page.GSave()
+page.SetTextRenderingMode(EPDFTextRenderingMode.FILL_STROKE_CLIPPING)
+page.BeginText()
+page.TextOut(60, ypos - 250, "ABCabc123")
+page.EndText()
+ShowStripePattern(page, 60, ypos - 250)
+page.GRestore()
+
+' Reset text attributes
+page.SetTextRenderingMode(EPDFTextRenderingMode.FILL)
+page.SetRGBFill(0, 0, 0)
+page.SetFontAndSize(font, 30)
+
+
+' Rotating text
+Local angle1:Float = 30 ' A rotation of 30 degrees.
+
+ShowDescription(page, 320, ypos - 60, "Rotating text")
+page.BeginText()
+page.SetTextMatrix(Float(Cos(angle1)), Float(Sin(angle1)), Float(-Sin(angle1)), Float(Cos(angle1)), 330, ypos - 60)
+page.ShowText("ABCabc123")
+page.EndText()
+
+' Skewing text.
+ShowDescription(page, 320, ypos - 120, "Skewing text")
+page.BeginText()
+
+angle1 = 10
+Local angle2:Float = 20
+
+page.SetTextMatrix(1, Float(Tan(angle1)), Float(tan(angle2)), 1, 320, ypos - 120)
+page.ShowText("ABCabc123")
+page.EndText()
+
+' scaling text(X direction)
+ShowDescription(page, 320, ypos - 175, "Scaling text(X direction)")
+page.BeginText()
+page.SetTextMatrix(1.5, 0, 0, 1, 320, ypos - 175)
+page.ShowText("ABCabc12")
+page.EndText()
+
+
+' scaling text(Y direction)
+ShowDescription(page, 320, ypos - 250, "Scaling text(Y direction)")
+page.BeginText()
+page.SetTextMatrix(1, 0, 0, 2, 320, ypos - 250)
+page.ShowText("ABCabc123")
+page.EndText()
+
+' char spacing, word spacing
+
+ShowDescription(page, 60, 140, "char-spacing 0")
+ShowDescription(page, 60, 100, "char-spacing 1.5")
+ShowDescription(page, 60, 60, "char-spacing 1.5, word-spacing 2.5")
+
+page.SetFontAndSize(font, 20)
+page.SetRGBFill(0.1, 0.3, 0.1)
+
+' char-spacing 0
+page.BeginText()
+page.TextOut(60, 140, sampText2)
+page.EndText()
+
+' char-spacing 1.5
+page.SetCharSpace(1.5)
+
+page.BeginText()
+page.TextOut(60, 100, sampText2)
+page.EndText()
+
+' char-spacing 1.5, word-spacing 3.5
+page.SetWordSpace(2.5)
+
+page.BeginText()
+page.TextOut(60, 60, sampText2)
+page.EndText()
+
+' save the document to a file
+pdf.Save("text_example.pdf")
+
+' free up
+pdf.Free()
+
+
+Function ShowDescription(page:TPDFPage, x:Float, y:Float, text:String)
+
+	Local fsize:Float = page.GetCurrentFontSize()
+	Local font:TPDFFont = page.GetCurrentFont()
+	Local c:SPDFRGBColor = page.GetRGBFill()
+
+	page.BeginText()
+	page.SetRGBFill(0, 0, 0)
+	page.SetTextRenderingMode(EPDFTextRenderingMode.FILL)
+	page.SetFontAndSize(font, 10)
+	page.TextOut(x, y - 12, text)
+	page.EndText()
+
+	page.SetFontAndSize(font, fsize)
+	page.SetRGBFill(c.r, c.g, c.b)
+End Function
+
+Function ShowStripePattern(page:TPDFPage, x:Float, y:Float)
+
+	Local iy:UInt = 0
+
+	While iy < 50
+		page.SetRGBStroke(0.0, 0.0, 0.5)
+		page.SetLineWidth(1)
+		page.MoveTo(x, y + iy)
+		page.LineTo(x + page.TextWidth("ABCabc123"), y + iy)
+		page.Stroke()
+		iy :+ 3
+	Wend
+
+	page.SetLineWidth(2.5)
+End Function

+ 34 - 0
pdf.mod/glue.c

@@ -0,0 +1,34 @@
+/*
+  Copyright (c) 2023 Bruce A Henderson
+  
+  This software is provided 'as-is', without any express or implied
+  warranty. In no event will the authors be held liable for any damages
+  arising from the use of this software.
+  
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+  
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/ 
+#include "hpdf.h"
+#include "brl.mod/blitz.mod/blitz.h"
+
+BBObject * text_pdf_TPDFException__create(BBUINT errorNo, BBUINT detailNo);
+void text_pdf_TPDFDoc__setLastError(BBObject * error);
+
+
+void bmx_pdf_HPDF_Error_Handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_data) {
+    BBObject * ex = text_pdf_TPDFException__create(error_no, detail_no);
+    text_pdf_TPDFDoc__setLastError(ex);
+}
+
+HPDF_Doc bmx_pdf_HPDF_New() {
+    return HPDF_New(bmx_pdf_HPDF_Error_Handler, NULL);
+}

+ 42 - 0
pdf.mod/libharu/.gitignore

@@ -0,0 +1,42 @@
+Makefile
+Makefile.in
+acconfig.h
+aclocal.m4
+autom4te.cache
+buildmk.stamp
+config.h.in
+config.cache
+config.log
+config.status
+meta_cc
+meta_ccld
+mkinstalldirs
+missing
+install-sh
+*.lo
+*.la
+.deps
+*.plg
+*.opt
+*.ncb
+.libs
+_libs
+*.o
+*.a
+*.tmp
+*.so
+*.so.*
+cscope.out
+config.guess
+config.sub
+configure
+configure.in~
+libtool
+ltmain.sh
+_configs.sed
+CMakeCache.txt
+CMakeFiles
+CPackConfig.cmake
+CPackSourceConfig.cmake
+cmake_install.cmake
+depcomp

+ 140 - 0
pdf.mod/libharu/CHANGES

@@ -0,0 +1,140 @@
+libHaru news
+-------------------------------------------------------------------------------
+
+Version 2.3.0 RC2 (2011.10.12)
+- Changed package naming, no other changes.
+
+Version 2.3.0 RC1 (2011.09.28)
+
+- Added support for 3dMeasures of subtype PD3 and 3DC, projection annotations, 
+  ExData and javascript attached to a U3D model. (Robert Würfel)
+- Added support for 1- and 2-byte UTF8 codes. (Clayman)
+- Added full PDF/A1-b support. (Petr Pytelka)
+- Added support for CCITT compression for B/W images. (Petr Pytelka)
+- Add support for TwoPageLeft and TwoPageRight layouts. (Vincent Dupont)
+
+- Const-ified arrays used in the sources. (Ilkka Lehtoranta)
+
+- Fixed build with libpng 1.5.0
+- Fixed bug in HPDF_GetContents() - isize variable was not initialized. 
+  (Vincent Dupont)
+- Fixed possible endless loop in PNG handling code.
+  (reported by Mathew Waters)
+- Fixed several issues based on the warnings generated by clang-analyzer.
+  (Daniel Höpfl)
+- Fixed quite a number of warnings. (Davide Achilli)
+- Added 'd' postfix to debug build, fixed wrong filename. (Wim Dumon)
+- Fixed HPDF_Text_Rect() not to split words in some obscure cases.
+
+Version 2.2.0 (2010.10.12)
+
+ - Greatly improved U3D support (Nikhil Soman)
+    - Markup Annotations
+    - Free Text Annotations
+    - Line Annotations
+    - Circle and Squre Annotations
+    - Text Markup Annotations
+    - Rubber Stamp Annotations
+    - Popup Annotations	
+
+ - Added VB.Net bindings. (Matt Underwood) 
+ - Added CMake build system (experimental). (Werner Smekal) 
+ - Added preliminary ICC support. (vbrasseur at gmail dot com)
+
+ - Added HPDF_Image_AddSMask(). (patch by Adam Blokus)
+ - Added HPDF_LoadPngImageFromMem() and HPDF_LoadJpegImageFromMem(). 
+   (patch by Adam Blokus)
+ - Added HPDF_GetContents().
+ - Added HPDF_Page_SetZoom().
+ - Added support for CMYK in HPDF_Image_LoadRawImageFromMem().
+
+ - Applied a bunch of fixes and improvements from bug report #13.
+ - HPDF_Page_TextRect() corrections and improvements. (Ralf Junker)
+ - Fixed build failure when zlib was not found. (Werner Smekal)
+ - Fixed build with newer libtool versions.
+ - Fixed external build. (thanks to Jeremiah Willcock)
+ - Fixed memleak in HPDF_EmbeddedFile_New(). (Ralf Junker) 
+ - Fixed uninitialized fields in HPDF_Type1FontDef_New(). (Ralf Junker)
+ - Fixed issue with grayscale PNG images. (Ralf Junker)
+ - Fixed missing parentheses from empty string object. (Ralf Junker)
+
+ - Fixed bug #21 (Build fails on Win CE because of errno and errno.h usage).
+ - Fixed bug #18 (Missing compiler flag -fexceptions)
+ - Fixed bug #11 (sqrtf() is missing on Winblows).
+ - Fixed bug #10 (missing HPDF_LoadPngImageFromMem from win32/msvc/libhpdf.def).
+ - Fixed bug #7 (HPDF_String_SetValue() is declared twice).
+ - Fixed bug #6 (possible NULL dereference in HPDF_LoadPngImageFromFile2()).
+ - Fixed bug #5 (possible NULL dereference in HPDF_LoadRawImageFromFile()).
+ - Fixed bug #4 (possible NULL dereference in HPDF_AToI()).
+ - Fixed bug #2 (Ruby binding: hpdf_insert_page has stray printf).
+
+Version 2.1.0 (2008.05.27)
+ - Added initial support for Alpha channel in RGB and palette-based PNG images.
+ - Added HPDF_GetTTFontDefFromFile() function. This closes [FR #1604475] (HPDF_FONT_EXISTS not error) 
+ - Added FreeBasic bindings. (Klaus Siebke)
+ - Added Python bindings. (Li Jun)
+ - Added U3D support. (Michail Vidiassov)
+
+ - Changed the build system to use autotools.
+
+ - Fixed bug #1682456 (NULL dereference in LoadType1FontFromStream()). 
+ - Fixed bug #1628096 (NULL pointer may be dereferenced).
+
+Version 2.0.8 (2006.11.25)
+ - Fixed a problem of HPDF_Circle() which causes buffer overflow. 
+ - Added HPDF_Ellipse().
+
+Version 2.0.7 (2006.11.05)
+ - Fixed a bug of HPDF_Annotation_New() (the values of bottom and top are set 
+  upside down).
+ - Added HPDF_Page_GetCurrentPos2(), HPDF_Page_GetCurrentTextPos2() and
+  HPDF_Image_GetSize2().
+
+Version 2.0.6 (2006.10.16)
+ - Added opacity and blend-mode features.
+ - Added slide-show functions (contributed by Adrian Nelson). 
+ - Added an interface for VB6 (contributed by Ko, Chi-Chih).
+ - Fixed a bug that HPDF_MemStream_Rewrite() may cause segmentation fault.
+ - Fixed a bug of error checking of HPDF_Page_Concat().
+ - Fixed a bug of calculation for the position of text showing.
+
+Version 2.0.5 (2006.09.20)
+ - Fixed a bug that an image which loaded by HPDF_LoadRawImageFromFile() or 
+  HPDF_LoadRawImageFromMem() is not compressed.
+ - Added C# interface.
+ - Added viewer-preference feature.
+ - Fixed a bug that HPDF_SetPassword does not raise error when NULL string set
+  to owner-password.
+ - Fixed a bug that causes program crash when using interlaced PNG images.
+
+Version 2.0.4 (2006.08.25)
+ - Fixed a bug of the TrueType font feature related to composite glyph.
+
+Version 2.0.3 (2006.08.20)
+ - Fixed a bug that HPDF_Page_TextRect() always returns 
+  HPDF_PAGE_INSUFFICIENT_SPACE.
+ - Added delayed loading function for a png image (HPDF_LoadPngImageFromFile2).
+ *change HPDF_SaveToStream function.
+ *correct hpdf_ttfontdef.c to avoid warning from a compiler.
+
+Version 2.0.2
+ - Modified HPDF_Page_ShowTextNextLine() to invoking HPDF_Page_MoveToNextLine()
+  if it is invoked with null or zero-length text.
+ - Fixed a bug in which HPDF_Page_MeasureText() returns wrong value when using 
+  CID fonts.
+ - Changed the feature of HPDF_Page_MeasureText().
+ - Added Japanese word wrap feature to HPDF_Page_MeasureText() and 
+  HPDF_Page_TextRect().
+ - Fixed typos of HPDF_PageLayout values.
+ - Modified options of makefile for BCC32 to multi-thread.
+  rebuild libz.a, libpng.a for BCC32 with -WM option.
+
+Version 2.0.1a (2006-08-03)
+ - Fixed a bug that HPDFPage::draw_image does not work correctly. (Ruby module 
+  only.)
+
+Version 2.0.1 (2006-07-29)
+ - Fixed a bug that HPDF_TextRect() does not work correctly when using CID fonts.
+ - Added HPDF_Font_GetAscent(), HPDF_Font_GetDescent(), HPDF_Font_GetXHeight(),
+  HPDF_Font_GetCapHeight().
+

+ 148 - 0
pdf.mod/libharu/CMakeLists.txt

@@ -0,0 +1,148 @@
+cmake_minimum_required(VERSION 3.10)
+
+file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/include/hpdf_version.h HPDF_VERSION_H_CONTENTS REGEX " HPDF_(MAJOR|MINOR|BUGFIX)_VERSION ")
+string(REGEX MATCH "MAJOR_VERSION [0-9]+"  HPDF_MAJOR_VERSION  ${HPDF_VERSION_H_CONTENTS})
+string(REGEX MATCH "MINOR_VERSION [0-9]+"  HPDF_MINOR_VERSION  ${HPDF_VERSION_H_CONTENTS})
+string(REGEX MATCH "BUGFIX_VERSION [0-9]+" HPDF_BUGFIX_VERSION ${HPDF_VERSION_H_CONTENTS})
+string(REGEX MATCH "[0-9]+" HPDF_MAJOR_VERSION  ${HPDF_MAJOR_VERSION})
+string(REGEX MATCH "[0-9]+" HPDF_MINOR_VERSION  ${HPDF_MINOR_VERSION})
+string(REGEX MATCH "[0-9]+" HPDF_BUGFIX_VERSION ${HPDF_BUGFIX_VERSION})
+
+project(libharu
+    VERSION ${HPDF_MAJOR_VERSION}.${HPDF_MINOR_VERSION}.${HPDF_BUGFIX_VERSION}
+    DESCRIPTION "libHaru is a free, cross platform, open source library for generating PDF files."
+    LANGUAGES C)
+
+include(GNUInstallDirs)
+
+
+# Location where the haru cmake build system first looks for cmake modules
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
+
+# =======================================================================
+# command line options
+# =======================================================================
+option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" ON)
+option(LIBHPDF_EXAMPLES "Build libharu examples" OFF)
+option(LIBHPDF_DEBUG "Enable HPDF Debug")
+option(LIBHPDF_DEBUG_TRACE "Enable HPDF Debug trace")
+
+# Enable exceptions on linux if required
+# (eg if you are using libharu in a C++ environment,
+# and you want your error-callback to throw an exception,
+# you will need to enable this for the exception to be
+# able to throw through the libharu callstack).
+if (CMAKE_COMPILER_IS_GNUCC OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
+   option (LIBHPDF_ENABLE_EXCEPTIONS "Enable exceptions" NO)
+   if (LIBHPDF_ENABLE_EXCEPTIONS)
+      set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions")
+   endif (LIBHPDF_ENABLE_EXCEPTIONS)
+endif ()
+
+include_directories(${PROJECT_SOURCE_DIR}/include)
+
+# =======================================================================
+# look for headers and libraries
+# =======================================================================
+include(haru)
+include(summary)
+
+# check zlib availability
+find_package(ZLIB)
+
+# check png availability
+find_package(PNG)
+
+# Find math library, sometimes needs to be explicitly linked against
+find_library(M_LIB m)
+
+# =======================================================================
+# configure header files, add compiler flags
+# =======================================================================
+# add definitions and directories to include
+#if(CMAKE_COMPILER_IS_GNUCC)
+#  add_definitions("-Wall")
+#endif(CMAKE_COMPILER_IS_GNUCC)
+if(MSVC_VERSION GREATER 1399)
+  add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
+endif(MSVC_VERSION GREATER 1399)
+
+# Will export symbols to a .lib file on Windows
+set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS 1)
+
+# Just set to 1, we'll assume they are always available.
+# If not, then someone will have to add some tests in here to correctly determine
+# the headers existence.
+set (LIBHPDF_STDC_HEADERS 1)
+
+# support all of the different variations of LIBPNG defines in HARU
+set (LIBHPDF_HAVE_LIBPNG ${PNG_FOUND})
+
+# support different zlib defines
+set (LIBHPDF_HAVE_ZLIB ${ZLIB_FOUND})
+
+# create hpdf_config.h
+configure_file(
+  ${PROJECT_SOURCE_DIR}/include/hpdf_config.h.cmake
+  ${PROJECT_BINARY_DIR}/include/hpdf_config.h
+)
+include_directories(${PROJECT_BINARY_DIR}/include)
+
+# =======================================================================
+# create library and demos
+# =======================================================================
+add_subdirectory(src)
+if(LIBHPDF_EXAMPLES)
+    add_subdirectory(demo)
+endif(LIBHPDF_EXAMPLES)
+
+# =======================================================================
+# installation configuration
+# =======================================================================
+set(
+  haru_HDRS
+    include/hpdf.h
+    include/hpdf_types.h
+    include/hpdf_consts.h
+    include/hpdf_annotation.h
+    include/hpdf_catalog.h
+    include/hpdf_conf.h
+    include/hpdf_destination.h
+    include/hpdf_doc.h
+    include/hpdf_encoder.h
+    include/hpdf_encrypt.h
+    include/hpdf_encryptdict.h
+    include/hpdf_error.h
+    include/hpdf_ext_gstate.h
+    include/hpdf_font.h
+    include/hpdf_fontdef.h
+    include/hpdf_gstate.h
+    include/hpdf_image.h
+    include/hpdf_info.h
+    include/hpdf_list.h
+    include/hpdf_mmgr.h
+    include/hpdf_objects.h
+    include/hpdf_outline.h
+    include/hpdf_pages.h
+    include/hpdf_page_label.h
+    include/hpdf_streams.h
+    include/hpdf_u3d.h
+    include/hpdf_utils.h
+    include/hpdf_pdfa.h
+    include/hpdf_3dmeasure.h
+    include/hpdf_exdata.h
+    include/hpdf_version.h
+    ${PROJECT_BINARY_DIR}/include/hpdf_config.h
+)
+
+# install header files
+install(FILES ${haru_HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+
+# install various files
+install(FILES README.md CHANGES INSTALL DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/libharu)
+install(DIRECTORY bindings DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/libharu)
+
+# =======================================================================
+# print out some information
+# =======================================================================
+summary()

+ 22 - 0
pdf.mod/libharu/INSTALL

@@ -0,0 +1,22 @@
+Installation
+------------
+
+Installing libHaru on Linux/Unix is as easy as this:
+./configure && make && make install
+
+If you're using a Git checkout or a Github tarball, 
+don't forget to run ./buildconf.sh in order to create 
+./configure script.
+
+See more detailed instructions here:
+https://github.com/libharu/libharu/wiki/Installation
+
+Alternatively, you can build and install libHaru using [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
+
+    git clone https://github.com/Microsoft/vcpkg.git
+    cd vcpkg
+    ./bootstrap-vcpkg.sh
+    ./vcpkg integrate install
+    ./vcpkg install libharu
+
+The libHaru port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.

+ 20 - 0
pdf.mod/libharu/LICENSE

@@ -0,0 +1,20 @@
+
+Copyright (C) 1999-2006 Takeshi Kanno
+Copyright (C) 2007-2009 Antony Dovgal
+
+This software is provided 'as-is', without any express or implied warranty.
+
+In no event will the authors be held liable for any damages arising from the 
+use of this software.
+
+Permission is granted to anyone to use this software for any purpose,including 
+commercial applications, and to alter it and redistribute it freely, subject 
+to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not claim 
+    that you wrote the original software. If you use this software in a 
+    product, an acknowledgment in the product documentation would be 
+    appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be 
+    misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.

+ 138 - 0
pdf.mod/libharu/README.md

@@ -0,0 +1,138 @@
+# Haru Free PDF Library [![Build Status](https://github.com/libharu/libharu/actions/workflows/cmake.yml/badge.svg)](https://github.com/libharu/libharu/actions/workflows/cmake.yml)
+
+  **URL http://libharu.org/**
+
+  **Copyright 2000-2006 (c) Takeshi Kanno**
+
+  **Copyright 2007-2009 (c) Antony Dovgal et al.**
+
+See INSTALL for instructions on how to install libHaru.
+
+
+# What is Haru Free PDF Library?
+
+Haru is a free, cross platform, open-sourced software library for generating 
+PDF. It supports the following features.
+
+   1. Generating PDF files with lines, text, images.
+   2. Outline, text annotation, link annotation.
+   3. Compressing document with deflate-decode.
+   4. Embedding PNG, Jpeg images.
+   5. Embedding Type1 font and TrueType font.
+   6. Creating encrypted PDF files.
+   7. Using various character set (ISO8859-1~16, MSCP1250~8, KOI8-R).
+   8. Supporting CJK fonts and encodings.
+
+You can add the feature of PDF creation by using Haru without understanding 
+complicated internal structure of PDF.
+
+
+# The differences from the previous version 
+
+
+The biggest differences are that all code is written in C. 
+To our regret, because internal structures changed greatly, The API is not 
+compatible with previous version.
+
+However, the new-version has the following advantages compared with the 
+previous version.
+
+ 1. Supported shared-library build.
+    A new-version library is able to be built as shared-library.
+ 2. The performance has been greatly improved.
+    A new-version library is about 4-15 times faster than a previous version. 
+ 3. Supported more features.
+    TrueType font, 128 bit encryption, arc function, and so on.
+
+
+# Supporting platforms
+
+Haru is written in ANSI-C and should compile easily with any compliant C 
+compiler.
+I inspected Haru in the following environment and make files for these 
+environments are included in a package.
+
+   1. Cygwin + GCC (Microsoft Windows)
+   2. Cygwin + MinGW (Microsoft Windows)
+   3. MSYS + MinGW (Microsoft Windows)
+   3. Microsoft VC++ (Microsoft Windows)
+   4. Borland C++ (Microsoft Windows)
+   5. GCC (Linux, FreeBSD, NetBSD, Solaris...)
+
+Also on platforms except the above, it is easy to build HARU. If you success to build HARU on other platforms, please send makefile to me.
+In addition, ZLIB and PNGLIB are required when you want to use the features of 
+compression and embedding PNG images. (In the case of Windows, static library 
+files for several compilers are included in the package for WIndows.  In the 
+case of  most of UNIX, these libraries are usually installed.)
+
+
+# Available development environment
+
+Haru can work as both static-library (.a, .lib) and shared-library (.so, .dll).
+When you use it as static-library, It can be used by C and a C++.
+But when you use it as shared-library, it can be used by many development 
+languages which support shared library.
+So far, Haru provides bindings for Ruby, Delphi/Free Pascal and C#.
+
+If you write bindings for other programming languages, please notice me!
+
+
+# Runtime environment of programs using Haru
+
+1. static-library
+   No runtime files are required.
+
+2. shared-library
+   In Windows, you have to distribute libhpdf.dll with a program. In UNIX you 
+   have to distribute libhpdf.so* with a program.
+
+
+
+NOTE:
+In the UNIX environment, there are the cases that libz.so, libpng.so.x are 
+necessary. About this, please refer to the documentation of PNGLIB and ZLIB.
+
+
+# License
+
+Haru is distributed under the ZLIB/LIBPNG License. Because ZLIB/LIBPNG License 
+is one of the freest licenses, You can use Haru for various purposes.
+
+The license of Haru is as follows.
+
+Copyright (C) 1999-2006 Takeshi Kanno
+Copyright (C) 2007-2009 Antony Dovgal
+
+This software is provided 'as-is', without any express or implied warranty.
+
+In no event will the authors be held liable for any damages arising from the 
+use of this software.
+
+Permission is granted to anyone to use this software for any purpose,including 
+commercial applications, and to alter it and redistribute it freely, subject 
+to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not claim 
+    that you wrote the original software. If you use this software in a 
+    product, an acknowledgment in the product documentation would be 
+    appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be 
+    misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+
+
+# Acknowledgment
+
+1. Information-technology Promotion Agency(IPA)
+   The development of Haru has been supported by Exploratory Software Project 
+   of Information-technology Promotion Agency(IPA), Japan. 
+
+2. All users of libHaru.
+   We wish to thank all users of Haru.
+   In particular, we thank Thomas Nimstad, LeslieM, Par Hogberg, adenelson, 
+   Riccardo Cohen, sea_sbs, Andrew. 
+   They gave me very useful advices.
+
+3. Adobe Systems Inc.
+   We thank Adobe Systems Inc. for publishing PDF specification.

+ 106 - 0
pdf.mod/libharu/README_cmake

@@ -0,0 +1,106 @@
+Instruction for the CMake Build System
+======================================
+
+CMake is a family of tools designed to build, test and
+package software and it is cross-platform and open
+source. CMake and can obtained from http://www.cmake.org.
+
+0 Setup CMake
+-------------
+CMake is available in most of Linux repositories and can 
+be therefore easily installed. In Cygwin just use the 
+usual method with setup.exe to get the latest version of CMake.
+For Windows and Mac OS X go to http://www.cmake.org and 
+download the appropriate binary package. Make sure that the
+bin directory of the extracted CMake package is in the 
+PATH environment variable. Check in the CLI with
+
+cmake --version
+
+that CMake can be found. There is also a graphical interface
+to CMake available which can be run with ccmake (Linux, Mac OS X)
+or cmake-gui (Windows, Linux, Mac OS X). In the next section
+the command line tool cmake is used, but the graphical interface
+works similar. Note, that CMake should always operate in a 
+out-of-source directory. If you need to run CMake again it's best
+to remove the whole folder and start with the directory creation
+in order to prevent problems with stale CMake cache files.
+
+X Specific instructions for Linux and Mac OS X
+==============================================
+Create a directory at the same level as the libharu source directory,
+e.g. "mkdir libharu_build". Cd into this directory.
+Than run cmake with the command
+
+cmake ../libharu
+
+CMake will configure the build and create the appropriate makefiles.
+Run "make" to create the library and the examples. There are some
+options available which are described below.
+
+X Specific instructions for Windows
+===================================
+Create a directory at the same level as the libharu source directory,
+e.g. "mkdir libharu_build". Cd into this directory.
+Since there are more compiler toolsets available for Windows than
+the standard gcc compiler, you need to tell cmake which makefile
+generator to use
+
+cmake -G "Makefile Generator" ..\libharu
+
+where Make Generator is one of the following (most important listed)
+
+  Borland Makefiles           = Generates Borland makefiles.
+  MSYS Makefiles              = Generates MSYS makefiles.
+  MinGW Makefiles             = Generates a make file for use with
+                                mingw32-make.
+  NMake Makefiles             = Generates NMake makefiles.
+  Visual Studio 6             = Generates Visual Studio 6 project files.
+  Visual Studio 9 2008        = Generates Visual Studio 9 2008 project files.
+
+You get a complete list of all available generators for your platform
+with "cmake --help". I'll go into details for one specific compiler toolset.
+The other generators work similar.
+
+Using CMake to produce Visual C++ 2008 Makfiles
+-----------------------------------------------
+First you need to have the command line interface setup correctly. Start
+cmd.exe and run "%VS90COMNTOOLS%vsvars32.bat". This will set up the
+command line tools of Visual C++ 2008. Cd into the created build
+directory and run
+
+cmake -G "NMake Makefiles" ..\libharu
+
+After the configuration and creation of the makefile run "nmake" to create
+the libraries and demonstrations. By default a shared library will be 
+created therefore you need to copy the haru.dll from the src directory
+in the demo directory in order for the demonstrations to run correctly.
+
+X Useful CMake options
+======================
+There are some options available where you can influence the configuration
+stage. These options must be given at the command line with the -D flag, e.g.
+
+cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug ..\libharu
+
+  CMAKE_BUILD_TYPE=Debug|Release - debug or release build
+  BUILD_SHARED_LIBS=ON|OFF - shared or static build
+  CMAKE_COLOR_MAKEFILE=ON|OFF - color output
+  CMAKE_VERBOSE_MAKEFILE=ON|OFF - verbose makefile output
+  
+More options can be found here: http://www.cmake.org/Wiki/CMake_Useful_Variables
+
+X How does CMake find libraries
+===============================
+CMake searches usually in the standard locations to find libraries, which
+works well on Linux and Mac OS X. This is not the case for Windows (where
+there are simply no standard locations for libraries) or if you want to
+use a library at a non-standard location. You can help CMake to find
+libraries via two environment variables, e.g. for Windows:
+
+set CMAKE_INCLUDE_PATH=path_to_zlib_headers
+set CMAKE_LIBRARY_PATH=path_to_zlib
+
+and then CMake will be able to find zlib.
+  
+  

+ 47 - 0
pdf.mod/libharu/bindings/c#/README.c#

@@ -0,0 +1,47 @@
+To use this interface, build Haru as a shared-library (DLL) or use binary 
+package for win32(libharu_x_x_x_dll_win32.zip).
+
+There are some example programs in demo directory. The steps to run the 
+demonstration programs is as follows. 
+
+1. Build libharu as a shared library and copy libhpdf.dll to "if\c#\demo"
+   directory. (Or expand binary package for win32(libharu_x_x_x_dll_win32.zip) 
+   and copy libhpdf.dll to "if\c#\demo" directory.)
+
+2. Compile and run demo programs. (Don't forget to compile hpdf.cs together.)
+
+   csc /out:FontDemo.exe FontDemo.cs ..\hpdf.cs 
+   FontDemo.exe
+
+   csc /out:ImageDemo.exe ImageDemo.cs ..\hpdf.cs 
+   ImageDemo.exe
+
+   csc /out:JPFontDemo.exe JPFontDemo.cs ..\hpdf.cs
+   JPFontDemo.exe
+
+   csc /out:LineDemo.exe LineDemo.cs ..\hpdf.cs
+   LineDemo.exe
+
+   csc /out:OutlineDemo.exe OutlineDemo.cs ..\hpdf.cs
+   OutlineDemo.exe
+
+   csc /out:Encryption.exe Encryption.cs ..\hpdf.cs
+   Encryption.exe
+
+   csc /out:Permission.exe Permission.cs ..\hpdf.cs
+   Permission.exe
+
+   csc /out:RawImageDemo.exe RawImageDemo.cs ..\hpdf.cs
+   RawImageDemo.exe
+
+   csc /out:TextDemo.exe TextDemo.cs ..\hpdf.cs
+   TextDemo.exe
+
+Because I do not know the Visual studio well, I do not explain usage on Visual 
+Studio here.  
+
+
+NOTE:
+libhpdf.dll is required to run the program which uses C# interface for libharu.
+I tested this interface only in Microsoft .NET Framework SDK 1.1. 
+

+ 60 - 0
pdf.mod/libharu/bindings/c#/demo/Encryption.cs

@@ -0,0 +1,60 @@
+/*
+ * << Haru Free PDF Library 2.0.5 >> -- Encryption.cs
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+using System;
+using System.IO;
+using HPdf;
+
+
+public class Encryption {
+
+    public static void Main() {
+        string owner_passwd = "owner";
+        string user_passwd = "user";
+        string text = "This is an encrypt document example.";
+        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion());
+
+        try {
+            HPdfDoc pdf = new HPdfDoc();
+
+            /* create default-font */
+            HPdfFont font = pdf.GetFont("Helvetica", null);
+
+            /* add a new page object. */
+            HPdfPage page = pdf.AddPage();
+
+            page.SetSize(HPdfPageSizes.HPDF_PAGE_SIZE_B5, 
+                    HPdfPageDirection.HPDF_PAGE_LANDSCAPE);
+
+            page.BeginText();
+            page.SetFontAndSize(font, 20);
+            float tw = page.TextWidth(text);
+            page.MoveTextPos((page.GetWidth() - tw) / 2,
+                (page.GetHeight()  - 20) / 2);
+            page.ShowText(text);
+            page.EndText();
+
+            pdf.SetPassword(owner_passwd, user_passwd);
+
+            /* save the document to a file */
+            pdf.SaveToFile("Encryption.pdf");
+
+        } catch (Exception e) {
+            Console.Error.WriteLine(e.Message);
+        }
+    }
+}
+
+
+

+ 99 - 0
pdf.mod/libharu/bindings/c#/demo/FontDemo.cs

@@ -0,0 +1,99 @@
+/*
+ * << Haru Free PDF Library 2.0.5 >> -- FontDemo.cs
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+using System;
+using System.IO;
+using HPdf;
+
+
+public class FontDemo {
+    public static void Main() {
+        string[] font_list = new string[] {
+            "Courier",
+            "Courier-Bold",
+            "Courier-Oblique",
+            "Courier-BoldOblique",
+            "Helvetica",
+            "Helvetica-Bold",
+            "Helvetica-Oblique",
+            "Helvetica-BoldOblique",
+            "Times-Roman",
+            "Times-Bold",
+            "Times-Italic",
+            "Times-BoldItalic",
+            "Symbol",
+            "ZapfDingbats"
+        };
+
+        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion());
+
+        try {
+            const string page_title = "FontDemo";
+
+            HPdfDoc pdf = new HPdfDoc();
+
+            HPdfPage page = pdf.AddPage();
+
+            float height = page.GetHeight();
+            float width = page.GetWidth();
+
+            /* Print the lines of the page. */
+            page.SetLineWidth(1);
+            page.Rectangle(50, 50, width - 100, height - 110);
+            page.Stroke();
+
+            /* Print the title of the page (with positioning center). */
+            HPdfFont def_font = pdf.GetFont ("Helvetica", null);
+            page.SetFontAndSize(def_font, 24);
+
+            float tw = page.TextWidth(page_title);
+            page.BeginText();
+            page.TextOut((width - tw) / 2, height - 50, page_title);
+            page.EndText();
+
+            /* output subtitle. */
+            page.BeginText();
+            page.SetFontAndSize(def_font, 16);
+            page.TextOut(60, height - 80, "<Standerd Type1 fonts samples>");
+            page.EndText();
+
+            page.BeginText();
+            page.MoveTextPos(60, height - 105);
+
+            for (int i = 0; i < font_list.Length; i++) {
+                const string samp_text = "abcdefgABCDEFG12345!#$%&+-@?";
+                HPdfFont font = pdf.GetFont(font_list[i], null);
+
+                /* print a label of text */
+                page.SetFontAndSize(def_font, 9);
+                page.ShowText(font_list[i]);
+                page.MoveTextPos(0, -18);
+
+                /* print a sample text. */
+                page.SetFontAndSize(font, 20);
+                page.ShowText(samp_text);
+                page.MoveTextPos(0, -20);
+            }
+
+            page.EndText();
+
+            pdf.SaveToFile("FontDemo.pdf");
+        } catch (Exception e) {
+            Console.Error.WriteLine(e.Message);
+        }
+    }
+}
+
+
+

+ 195 - 0
pdf.mod/libharu/bindings/c#/demo/ImageDemo.cs

@@ -0,0 +1,195 @@
+/*
+ * << Haru Free PDF Library 2.0.5 >> -- ImageDemo.cs
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+using System;
+using System.IO;
+using HPdf;
+
+
+public class ImageDemo {
+    private static void ShowDescription(HPdfPage page, float x, float y,
+            string text) {
+        string buf;
+
+        page.MoveTo(x, y - 10);
+        page.LineTo(x, y + 10);
+        page.MoveTo(x - 10, y);
+        page.LineTo(x + 10, y);
+        page.Stroke();
+
+        page.SetFontAndSize(page.GetCurrentFont(), 8);
+        page.SetRGBFill(0, 0, 0);
+
+        page.BeginText();
+
+        buf = "(x=" + x + ",y=" + y + ")";
+        page.MoveTextPos(x - page.TextWidth(buf) - 5,
+            y - 10);
+        page.ShowText(buf);
+        page.EndText();
+
+        page.BeginText();
+        page.MoveTextPos(x - 20, y - 25);
+        page.ShowText(text);
+        page.EndText();
+    }
+
+    public static void Main() {
+        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion());
+
+        try {
+            HPdfDoc pdf = new HPdfDoc();
+
+            pdf.SetCompressionMode(HPdfDoc.HPDF_COMP_ALL);
+
+            /* create default-font */
+            HPdfFont font = pdf.GetFont("Helvetica", null);
+
+            /* add a new page object. */
+            HPdfPage page = pdf.AddPage();
+
+            page.SetWidth(550);
+            page.SetHeight(500);
+
+            HPdfDestination dst = page.CreateDestination();
+            dst.SetXYZ(0, page.GetHeight(), 1);
+            pdf.SetOpenAction(dst);
+
+            page.BeginText();
+            page.SetFontAndSize(font, 20);
+            page.MoveTextPos(220, page.GetHeight() - 70);
+            page.ShowText("ImageDemo");
+            page.EndText();
+
+            /* load image file. */
+            HPdfImage image = pdf.LoadPngImageFromFile("demo\\pngsuite\\basn3p02.png");
+
+            /* image1 is masked by image2. */
+            HPdfImage image1 = pdf.LoadPngImageFromFile("demo\\pngsuite\\basn3p02.png");
+
+            /* image2 is a mask image. */
+            HPdfImage image2 = pdf.LoadPngImageFromFile("demo\\pngsuite\\basn0g01.png");
+
+            /* image3 is a RGB-color image. we use this image for color-mask
+             * demo.
+             */
+            HPdfImage image3 = pdf.LoadPngImageFromFile("demo\\pngsuite\\maskimage.png");
+
+            float iw = image.GetWidth();
+            float ih = image.GetHeight();
+
+            page.SetLineWidth(0.5f);
+
+            float x = 100;
+            float y = page.GetHeight() - 150;
+
+            /* Draw image to the canvas. (normal-mode with actual size.)*/
+            page.DrawImage(image, x, y, iw, ih);
+
+            ShowDescription(page, x, y, "Actual Size");
+
+            x += 150;
+
+            /* Scalling image (X direction) */
+            page.DrawImage(image, x, y, iw * 1.5f, ih);
+
+            ShowDescription(page, x, y, "Scalling image (X direction)");
+
+            x += 150;
+
+            /* Scalling image (Y direction). */
+            page.DrawImage(image, x, y, iw, ih * 1.5f);
+            ShowDescription(page, x, y, "Scalling image (Y direction)");
+
+            x = 100;
+            y -= 120;
+
+            /* Skewing image. */
+            float angle1 = 10;
+            float angle2 = 20;
+            float rad1 = angle1 / 180 * 3.141592f;
+            float rad2 = angle2 / 180 * 3.141592f;
+
+            page.GSave();
+
+            page.Concat(iw, (float)Math.Tan(rad1) * iw, (float)Math.Tan(rad2) * ih, 
+                    ih, x, y);
+
+            page.ExecuteXObject(image);
+            page.GRestore();
+
+            ShowDescription(page, x, y, "Skewing image");
+
+            x += 150;
+
+            /* Rotating image */
+            float angle = 30;     /* rotation of 30 degrees. */
+            float rad = angle / 180 * 3.141592f; /* Calculate the radian value. */
+
+            page.GSave();
+
+            page.Concat((float)(iw * Math.Cos(rad)),
+                (float)(iw * Math.Sin(rad)),
+                (float)(ih * -Math.Sin(rad)),
+                (float)(ih * Math.Cos(rad)),
+                x, y);
+
+            page.ExecuteXObject(image);
+            page.GRestore();
+
+            ShowDescription(page, x, y, "Rotating image");
+
+                x += 150;
+
+            /* draw masked image. */
+
+            /* Set image2 to the mask image of image1 */
+            image1.SetMaskImage (image2);
+
+            page.SetRGBFill(0, 0, 0);
+            page.BeginText();
+            page.MoveTextPos(x - 6, y + 14);
+            page.ShowText("MASKMASK");
+            page.EndText();
+
+            page.DrawImage(image1, x - 3, y - 3, iw + 6, ih + 6);
+
+            ShowDescription(page, x, y, "masked image");
+
+            x = 100;
+            y -= 120;
+
+            /* color mask. */
+            page.SetRGBFill(0, 0, 0);
+            page.BeginText();
+            page.MoveTextPos(x - 6, y + 14);
+            page.ShowText("MASKMASK");
+            page.EndText();
+
+            image3.SetColorMask (0, 255, 0, 0, 0, 255);
+            page.DrawImage(image3, x, y, iw, ih);
+
+            ShowDescription(page, x, y, "Color Mask");
+
+            /* save the document to a file */
+            pdf.SaveToFile("ImageDemo.pdf");
+
+        } catch (Exception e) {
+            Console.Error.WriteLine(e.Message);
+        }
+    }
+}
+
+
+

+ 147 - 0
pdf.mod/libharu/bindings/c#/demo/JPFontDemo.cs

@@ -0,0 +1,147 @@
+/*
+ * << Haru Free PDF Library 2.0.5 >> -- JPFontDemo.cs
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+using System;
+using System.IO;
+using HPdf;
+
+public class JPFontDemo {
+    public static void Main() {
+        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion());
+
+        try {
+            const int PAGE_HEIGHT = 210;
+            string samp_text = "アメンボ赤いなあいうえお。浮き藻に小エビもおよいでる。";
+            HPdfFont[] detail_font = new HPdfFont[16];
+
+            HPdfDoc pdf = new HPdfDoc();
+
+            /*declaration for using Japanese font, encoding. */
+            pdf.UseJPEncodings();
+            pdf.UseJPFonts();
+
+            detail_font[0] = pdf.GetFont("MS-Mincyo", "90ms-RKSJ-H");
+            detail_font[1] = pdf.GetFont("MS-Mincyo,Bold", "90ms-RKSJ-H");
+            detail_font[2] = pdf.GetFont("MS-Mincyo,Italic", "90ms-RKSJ-H");
+            detail_font[3] = pdf.GetFont("MS-Mincyo,BoldItalic", "90ms-RKSJ-H");
+            detail_font[4] = pdf.GetFont("MS-PMincyo", "90msp-RKSJ-H");
+            detail_font[5] = pdf.GetFont("MS-PMincyo,Bold", "90msp-RKSJ-H");
+            detail_font[6] = pdf.GetFont("MS-PMincyo,Italic", "90msp-RKSJ-H");
+            detail_font[7] = pdf.GetFont("MS-PMincyo,BoldItalic",
+            "90msp-RKSJ-H");
+            detail_font[8] = pdf.GetFont("MS-Gothic", "90ms-RKSJ-H");
+            detail_font[9] = pdf.GetFont("MS-Gothic,Bold", "90ms-RKSJ-H");
+            detail_font[10] = pdf.GetFont("MS-Gothic,Italic", "90ms-RKSJ-H");
+            detail_font[11] = pdf.GetFont("MS-Gothic,BoldItalic", "90ms-RKSJ-H");
+            detail_font[12] = pdf.GetFont("MS-PGothic", "90msp-RKSJ-H");
+            detail_font[13] = pdf.GetFont("MS-PGothic,Bold", "90msp-RKSJ-H");
+            detail_font[14] = pdf.GetFont("MS-PGothic,Italic", "90msp-RKSJ-H");
+            detail_font[15] = pdf.GetFont("MS-PGothic,BoldItalic",
+            "90msp-RKSJ-H");
+
+            /*configure pdf-document to be compressed. */
+            pdf.SetCompressionMode(HPdfDoc.HPDF_COMP_ALL);
+
+            /*Set page mode to use outlines. */
+            pdf.SetPageMode(HPdfPageMode.HPDF_PAGE_MODE_USE_OUTLINE);
+
+            /*create outline root. */
+            HPdfOutline root = pdf.CreateOutline(null, "JP font demo", null);
+            root.SetOpened (true);
+
+            for (int i = 0; i <= 15; i++) {
+                float x_pos;
+
+                /*add a new page object. */
+                HPdfPage page = pdf.AddPage();
+
+                /*create outline entry */
+                HPdfOutline outline = pdf.CreateOutline(root,
+                        detail_font[i].GetFontName(), null);
+                HPdfDestination dst = page.CreateDestination();
+                outline.SetDestination(dst);
+
+                HPdfFont title_font = pdf.GetFont("Helvetica", null);
+                page.SetFontAndSize(title_font, 10);
+
+                page.BeginText();
+
+                /*move the position of the text to top of the page. */
+                page.MoveTextPos(10, 190);
+                page.ShowText(detail_font[i].GetFontName());
+
+                page.SetFontAndSize(detail_font[i], 15);
+                page.MoveTextPos(10, -20);
+                page.ShowText("abcdefghijklmnopqrstuvwxyz");
+                page.MoveTextPos(0, -20);
+                page.ShowText("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+                page.MoveTextPos(0, -20);
+                page.ShowText("1234567890");
+                page.MoveTextPos(0, -20);
+
+                page.SetFontAndSize(detail_font[i], 10);
+                page.ShowText(samp_text);
+                page.MoveTextPos(0, -18);
+
+                page.SetFontAndSize(detail_font[i], 16);
+                page.ShowText(samp_text);
+                page.MoveTextPos(0, -27);
+
+                page.SetFontAndSize(detail_font[i], 23);
+                page.ShowText(samp_text);
+                page.MoveTextPos(0, -36);
+
+                page.SetFontAndSize(detail_font[i], 30);
+                page.ShowText(samp_text);
+
+                HPdfPoint p = page.GetCurrentTextPos();
+
+                /*finish to print text. */
+                page.EndText();
+
+                page.SetLineWidth(0.5f);
+
+                x_pos = 20;
+                for (int j = 0; j <= samp_text.Length / 2; j++) {
+                    page.MoveTo(x_pos, p.y - 10);
+                    page.LineTo(x_pos, p.y - 12);
+                    page.Stroke();
+                    x_pos = x_pos + 30;
+                }
+
+                page.SetWidth(p.x + 20);
+                page.SetHeight(PAGE_HEIGHT);
+
+                page.MoveTo(10, PAGE_HEIGHT - 25);
+                page.LineTo(p.x + 10, PAGE_HEIGHT - 25);
+                page.Stroke();
+
+                page.MoveTo(10, PAGE_HEIGHT - 85);
+                page.LineTo(p.x + 10, PAGE_HEIGHT - 85);
+                page.Stroke();
+
+                page.MoveTo(10, p.y - 12);
+                page.LineTo(p.x + 10, p.y - 12);
+                page.Stroke();
+            }
+
+            pdf.SaveToFile("JPFontDemo.pdf");
+        } catch (Exception e) {
+            Console.Error.WriteLine(e.Message);
+        }
+    }
+}
+
+
+

+ 313 - 0
pdf.mod/libharu/bindings/c#/demo/LineDemo.cs

@@ -0,0 +1,313 @@
+/*
+ * << Haru Free PDF Library 2.0.5 >> -- LineDemo.cs
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+using System;
+using System.IO;
+using HPdf;
+
+
+public class LineDemo {
+    private static void DrawLine(HPdfPage page, float x, float y, string label) {
+        page.BeginText();
+        page.MoveTextPos(x, y - 10);
+        page.ShowText(label);
+        page.EndText();
+
+        page.MoveTo(x, y - 15);
+        page.LineTo(x + 220, y - 15);
+        page.Stroke();
+    }
+
+    private static void DrawLine2(HPdfPage page, float x, float y, string label) {
+        page.BeginText();
+        page.MoveTextPos(x, y);
+        page.ShowText(label);
+        page.EndText();
+
+        page.MoveTo(x + 30, y - 25);
+        page.LineTo(x + 160, y - 25);
+        page.Stroke();
+    }
+
+    private static void DrawRect(HPdfPage page, float x, float y, string label) {
+        page.BeginText();
+        page.MoveTextPos(x, y - 10);
+        page.ShowText(label);
+        page.EndText();
+
+        page.Rectangle(x, y - 40, 220, 25);
+    }
+
+    public static void Main() {
+        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion());
+
+        try {
+            const string page_title = "LineDemo";
+
+            HPdfDoc pdf = new HPdfDoc();
+
+            /* create default-font */
+            HPdfFont font = pdf.GetFont ("Helvetica", null);
+
+            /* add a new page object. */
+            HPdfPage page = pdf.AddPage();
+
+            /* print the lines of the page. */
+            page.SetLineWidth(1);
+            page.Rectangle(50, 50, page.GetWidth() - 100,
+                        page.GetHeight() - 110);
+            page.Stroke();
+
+            /* print the title of the page (with positioning center). */
+            page.SetFontAndSize(font, 24);
+            float tw = page.TextWidth(page_title);
+            page.BeginText();
+            page.MoveTextPos ((page.GetWidth() - tw) / 2,
+                        page.GetHeight() - 50);
+            page.ShowText(page_title);
+            page.EndText();
+
+            page.SetFontAndSize(font, 10);
+
+            /* Draw various widths of lines. */
+            page.SetLineWidth(0);
+            DrawLine(page, 60, 770, "line width = 0");
+
+            page.SetLineWidth(1.0f);
+            DrawLine(page, 60, 740, "line width = 1.0");
+
+            page.SetLineWidth(2.0f);
+            DrawLine(page, 60, 710, "line width = 2.0");
+
+            /* Line dash pattern */
+            ushort[] dash_mode1 = new ushort[] {3};
+            ushort[] dash_mode2 = new ushort[] {3, 7};
+            ushort[] dash_mode3 = new ushort[] {8, 7, 2, 7};
+
+            page.SetLineWidth(1.0f);
+
+            page.SetDash(dash_mode1, 1);
+            DrawLine(page, 60, 680, "dash_ptn=[3], phase=1 -- 2 on, 3 off, 3 on...");
+
+            Console.Error.WriteLine("001");
+            page.SetDash(dash_mode2, 2);
+            DrawLine(page, 60, 650, "dash_ptn=[7, 3], phase=2 -- 5 on 3 off, 7 on,...");
+
+            page.SetDash(dash_mode3, 0);
+            DrawLine(page, 60, 620, "dash_ptn=[8, 7, 2, 7], phase=0");
+
+            page.SetDash(null, 0);
+
+            page.SetLineWidth(30);
+            page.SetRGBStroke(0.0f, 0.5f, 0.0f);
+
+            /* Line Cap Style */
+            page.SetLineCap(HPdfLineCap.HPDF_BUTT_END);
+            DrawLine2(page, 60, 570, "HPDF_BUTT_END");
+
+            page.SetLineCap(HPdfLineCap.HPDF_ROUND_END);
+            DrawLine2(page, 60, 505, "HPDF_ROUND_END");
+
+            page.SetLineCap(HPdfLineCap.HPDF_PROJECTING_SQUARE_END);
+            DrawLine2(page, 60, 440, "HPDF_PROJECTING_SQUARE_END");
+
+            /* Line Join Style */
+            page.SetLineWidth(30);
+            page.SetRGBStroke(0.0f, 0.0f, 0.5f);
+
+            page.SetLineJoin(HPdfLineJoin.HPDF_MITER_JOIN);
+            page.MoveTo(120, 300);
+            page.LineTo(160, 340);
+            page.LineTo(200, 300);
+            page.Stroke();
+
+            page.BeginText();
+            page.MoveTextPos(60, 360);
+            page.ShowText("HPDF_MITER_JOIN");
+            page.EndText();
+
+            page.SetLineJoin(HPdfLineJoin.HPDF_ROUND_JOIN);
+            page.MoveTo(120, 195);
+            page.LineTo(160, 235);
+            page.LineTo(200, 195);
+            page.Stroke();
+
+            page.BeginText();
+            page.MoveTextPos(60, 255);
+            page.ShowText("HPDF_ROUND_JOIN");
+            page.EndText();
+
+            page.SetLineJoin(HPdfLineJoin.HPDF_BEVEL_JOIN);
+            page.MoveTo(120, 90);
+            page.LineTo(160, 130);
+            page.LineTo(200, 90);
+            page.Stroke();
+
+            page.BeginText();
+            page.MoveTextPos(60, 150);
+            page.ShowText("HPDF_BEVEL_JOIN");
+            page.EndText();
+
+            /* Draw Rectangle */
+            page.SetLineWidth(2);
+            page.SetRGBStroke(0, 0, 0);
+            page.SetRGBFill(0.75f, 0.0f, 0.0f);
+
+            DrawRect(page, 300, 770, "Stroke");
+            page.Stroke();
+
+            DrawRect(page, 300, 720, "Fill");
+            page.Fill();
+
+            DrawRect(page, 300, 670, "Fill then Stroke");
+            page.FillStroke();
+
+            /* Clip Rect */
+            page.GSave();  /* Save the current graphic state */
+            DrawRect(page, 300, 620, "Clip Rectangle");
+            page.Clip();
+            page.Stroke();
+            page.SetFontAndSize(font, 13);
+
+            page.BeginText();
+            page.MoveTextPos(290, 600);
+            page.SetTextLeading(12);
+            page.ShowText("Clip Clip Clip Clip Clip Clipi Clip Clip Clip");
+            page.ShowTextNextLine("Clip Clip Clip Clip Clip Clip Clip Clip Clip");
+            page.ShowTextNextLine("Clip Clip Clip Clip Clip Clip Clip Clip Clip");
+            page.EndText();
+            page.GRestore();
+
+            /* Curve Example(CurveTo2) */
+            float x = 330;
+            float y = 440;
+            float x1 = 430;
+            float y1 = 530;
+            float x2 = 480;
+            float y2 = 470;
+            float x3 = 480;
+            float y3 = 90;
+
+            page.SetRGBFill(0, 0, 0);
+
+            page.BeginText();
+            page.MoveTextPos(300, 540);
+            page.ShowText("CurveTo2(x1, y1, x2. y2)");
+            page.EndText();
+
+            page.BeginText();
+            page.MoveTextPos(x + 5, y - 5);
+            page.ShowText("Current point");
+            page.MoveTextPos(x1 - x, y1 - y);
+            page.ShowText("(x1, y1)");
+            page.MoveTextPos(x2 - x1, y2 - y1);
+            page.ShowText("(x2, y2)");
+            page.EndText();
+
+            page.SetDash(dash_mode1, 0);
+
+            page.SetLineWidth(0.5f);
+            page.MoveTo(x1, y1);
+            page.LineTo(x2, y2);
+            page.Stroke();
+
+            page.SetDash(null, 0);
+
+            page.SetLineWidth(1.5f);
+
+            page.MoveTo(x, y);
+            page.CurveTo2(x1, y1, x2, y2);
+            page.Stroke();
+
+            /* Curve Example(CurveTo3) */
+            y -= 150;
+            y1 -= 150;
+            y2 -= 150;
+
+            page.BeginText();
+            page.MoveTextPos(300, 390);
+            page.ShowText("CurveTo3(x1, y1, x2. y2)");
+            page.EndText();
+
+            page.BeginText();
+            page.MoveTextPos(x + 5, y - 5);
+            page.ShowText("Current point");
+            page.MoveTextPos(x1 - x, y1 - y);
+            page.ShowText("(x1, y1)");
+            page.MoveTextPos(x2 - x1, y2 - y1);
+            page.ShowText("(x2, y2)");
+            page.EndText();
+
+            page.SetDash(dash_mode1, 0);
+
+            page.SetLineWidth(0.5f);
+            page.MoveTo(x, y);
+            page.LineTo(x1, y1);
+            page.Stroke();
+
+            page.SetDash(null, 0);
+
+            page.SetLineWidth(1.5f);
+            page.MoveTo(x, y);
+            page.CurveTo3(x1, y1, x2, y2);
+            page.Stroke();
+
+            /* Curve Example(CurveTo) */
+            y -= 150;
+            y1 -= 160;
+            y2 -= 130;
+            x2 += 10;
+
+            page.BeginText();
+            page.MoveTextPos(300, 240);
+            page.ShowText("CurveTo(x1, y1, x2. y2, x3, y3)");
+            page.EndText();
+
+            page.BeginText();
+            page.MoveTextPos(x + 5, y - 5);
+            page.ShowText("Current point");
+            page.MoveTextPos(x1 - x, y1 - y);
+            page.ShowText("(x1, y1)");
+            page.MoveTextPos(x2 - x1, y2 - y1);
+            page.ShowText("(x2, y2)");
+            page.MoveTextPos(x3 - x2, y3 - y2);
+            page.ShowText("(x3, y3)");
+            page.EndText();
+
+            page.SetDash(dash_mode1, 0);
+
+            page.SetLineWidth(0.5f);
+            page.MoveTo(x, y);
+            page.LineTo(x1, y1);
+            page.Stroke();
+            page.MoveTo(x2, y2);
+            page.LineTo(x3, y3);
+            page.Stroke();
+
+            page.SetDash(null, 0);
+
+            page.SetLineWidth(1.5f);
+            page.MoveTo(x, y);
+            page.CurveTo(x1, y1, x2, y2, x3, y3);
+            page.Stroke();
+
+            pdf.SaveToFile("LineDemo.pdf");
+        } catch (Exception e) {
+            Console.Error.WriteLine(e.Message);
+        }
+    }
+}
+
+
+

+ 95 - 0
pdf.mod/libharu/bindings/c#/demo/OutlineDemo.cs

@@ -0,0 +1,95 @@
+/*
+ * << Haru Free PDF Library 2.0.5 >> -- OutlineDemo.cs
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+using System;
+using System.IO;
+using HPdf;
+
+
+public class OutlineDemo {
+    private static void PrintPage(HPdfPage page, int page_num) {
+        page.SetWidth(800);
+        page.SetHeight(800);
+
+        page.BeginText();
+        page.MoveTextPos(30, 740);
+        string buf = "Page:" + page_num;
+        page.ShowText(buf);
+        page.EndText();
+    }
+
+    public static void Main() {
+        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion());
+
+        try {
+            HPdfDoc pdf = new HPdfDoc();
+
+            pdf.SetCompressionMode(HPdfDoc.HPDF_COMP_ALL);
+
+            /* create default-font */
+            HPdfFont font = pdf.GetFont("Helvetica", null);
+
+            pdf.SetPageMode(HPdfPageMode.HPDF_PAGE_MODE_USE_OUTLINE);
+
+            /* add a new page object. */
+            /* Add 3 pages to the document. */
+            HPdfPage page0 = pdf.AddPage();
+            page0.SetFontAndSize (font, 30);
+            PrintPage(page0, 1);
+
+            HPdfPage page1 = pdf.AddPage();
+            page1.SetFontAndSize(font, 30);
+            PrintPage(page1, 2);
+
+            HPdfPage page2 = pdf.AddPage();
+            page2.SetFontAndSize(font, 30);
+            PrintPage(page2, 3);
+
+            /* create outline root. */
+            HPdfOutline root = pdf.CreateOutline(null, "OutlineRoot", null);
+            root.SetOpened (true);
+
+            HPdfOutline outline0 = pdf.CreateOutline(root, "page1", null);
+            HPdfOutline outline1 = pdf.CreateOutline(root, "page2", null);
+
+            /* create outline with test which is ISO8859-2 encoding */
+            HPdfOutline outline2 = pdf.CreateOutline(root, "ISO8859-2 text ÓÔÕÖרÙ",
+                    pdf.GetEncoder("ISO8859-2"));
+
+            /* create destination objects on each pages
+             * and link it to outline items.
+             */
+            HPdfDestination dst = page0.CreateDestination();
+            dst.SetXYZ(0, page0.GetHeight(), 1);
+            outline0.SetDestination(dst);
+
+            dst = page1.CreateDestination();
+            dst.SetXYZ(0, page1.GetHeight(), 1);
+            outline1.SetDestination(dst);
+
+            dst = page2.CreateDestination();
+            dst.SetXYZ(0, page2.GetHeight(), 1);
+            outline2.SetDestination(dst);
+
+            /* save the document to a file */
+            pdf.SaveToFile("OutlineDemo.pdf");
+
+        } catch (Exception e) {
+            Console.Error.WriteLine(e.Message);
+        }
+    }
+}
+
+
+

+ 64 - 0
pdf.mod/libharu/bindings/c#/demo/Permission.cs

@@ -0,0 +1,64 @@
+/*
+ * << Haru Free PDF Library 2.0.5 >> -- Permission.cs
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+using System;
+using System.IO;
+using HPdf;
+
+
+public class Permission {
+
+    public static void Main() {
+        string owner_passwd = "owner";
+        string user_passwd = "";
+        string text = "User cannot print and copy this document.";
+        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion());
+
+        try {
+            HPdfDoc pdf = new HPdfDoc();
+
+            /* create default-font */
+            HPdfFont font = pdf.GetFont("Helvetica", null);
+
+            /* add a new page object. */
+            HPdfPage page = pdf.AddPage();
+
+            page.SetSize(HPdfPageSizes.HPDF_PAGE_SIZE_B5, 
+                    HPdfPageDirection.HPDF_PAGE_LANDSCAPE);
+
+            page.BeginText();
+            page.SetFontAndSize(font, 20);
+            float tw = page.TextWidth(text);
+            page.MoveTextPos((page.GetWidth() - tw) / 2,
+                (page.GetHeight()  - 20) / 2);
+            page.ShowText(text);
+            page.EndText();
+
+            pdf.SetPassword(owner_passwd, user_passwd);
+            pdf.SetPermission(HPdfDoc.HPDF_ENABLE_READ);
+
+            /* use 128 bit revision 3 encryption */
+            pdf.SetEncryptionMode(HPdfEncryptMode.HPDF_ENCRYPT_R3, 16);
+
+            /* save the document to a file */
+            pdf.SaveToFile("Permission.pdf");
+
+        } catch (Exception e) {
+            Console.Error.WriteLine(e.Message);
+        }
+    }
+}
+
+
+

+ 104 - 0
pdf.mod/libharu/bindings/c#/demo/RawImageDemo.cs

@@ -0,0 +1,104 @@
+/*
+ * << Haru Free PDF Library 2.0.5 >> -- RawImageDemo.cs
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+using System;
+using System.IO;
+using HPdf;
+
+
+public class RawImageDemo {
+
+    public static void Main() {
+        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion());
+
+        byte[] raw_image_data = new byte[] {
+            0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfc,
+            0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0,
+            0xf3, 0xf3, 0xff, 0xe0, 0xf3, 0xf3, 0xff, 0xc0,
+            0xf3, 0xf3, 0xff, 0x80, 0xf3, 0x33, 0xff, 0x00,
+            0xf3, 0x33, 0xfe, 0x00, 0xf3, 0x33, 0xfc, 0x00,
+            0xf8, 0x07, 0xf8, 0x00, 0xf8, 0x07, 0xf0, 0x00,
+            0xfc, 0xcf, 0xe0, 0x00, 0xfc, 0xcf, 0xc0, 0x00,
+            0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0x00, 0x00,
+            0xff, 0xfe, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00,
+            0xff, 0xf8, 0x0f, 0xe0, 0xff, 0xf0, 0x0f, 0xe0,
+            0xff, 0xe0, 0x0c, 0x30, 0xff, 0xc0, 0x0c, 0x30,
+            0xff, 0x80, 0x0f, 0xe0, 0xff, 0x00, 0x0f, 0xe0,
+            0xfe, 0x00, 0x0c, 0x30, 0xfc, 0x00, 0x0c, 0x30,
+            0xf8, 0x00, 0x0f, 0xe0, 0xf0, 0x00, 0x0f, 0xe0,
+            0xe0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00,
+            0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+        };
+
+        try {
+            HPdfDoc pdf = new HPdfDoc();
+
+            pdf.SetCompressionMode(HPdfDoc.HPDF_COMP_ALL);
+
+            /* create default-font */
+            HPdfFont font = pdf.GetFont("Helvetica", null);
+
+            /* add a new page object. */
+            HPdfPage page = pdf.AddPage();
+
+            page.SetWidth(172);
+            page.SetHeight(80);
+
+            page.BeginText();
+            page.SetFontAndSize(font, 20);
+            page.MoveTextPos(220, page.GetHeight() - 70);
+            page.ShowText("RawImageDemo");
+            page.EndText();
+
+            /* load RGB raw-image file. */
+            HPdfImage image = pdf.LoadRawImageFromFile("demo\\rawimage\\32_32_rgb.dat",
+                    32, 32, HPdfColorSpace.HPDF_CS_DEVICE_RGB);
+
+            float x = 20;  
+            float y = 20;
+
+            /* Draw image to the canvas. (normal-mode with actual size.)*/
+            page.DrawImage(image, x, y, 32, 32);
+
+            /* load GrayScale raw-image file. */
+            image = pdf.LoadRawImageFromFile("demo\\rawimage\\32_32_gray.dat",
+                    32, 32, HPdfColorSpace.HPDF_CS_DEVICE_GRAY);
+
+            x = 70;
+            y = 20;
+
+            /* Draw image to the canvas. (normal-mode with actual size.)*/
+            page.DrawImage(image, x, y, 32, 32);
+
+            /* load GrayScale raw-image (1bit) file from memory. */
+            image = pdf.LoadRawImageFromMem(raw_image_data, 32, 32,
+                        HPdfColorSpace.HPDF_CS_DEVICE_GRAY, 1);
+
+            x = 120;
+            y = 20;
+
+            /* Draw image to the canvas. (normal-mode with actual size.)*/
+            page.DrawImage(image, x, y, 32, 32);
+
+            /* save the document to a file */
+            pdf.SaveToFile("RawImageDemo.pdf");
+
+        } catch (Exception e) {
+            Console.Error.WriteLine(e.Message);
+        }
+    }
+}
+
+
+

+ 171 - 0
pdf.mod/libharu/bindings/c#/demo/SlideShowDemo.cs

@@ -0,0 +1,171 @@
+/*
+ * << Haru Free PDF Library 2.0.5 >> -- SlideShow.cs
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+using System;
+using System.IO;
+using HPdf;
+
+
+public class TextDemo {
+    private static Random rand;
+
+    private static void PrintPage (HPdfPage page, string caption, HPdfFont font,
+            HPdfTransitionStyle type, HPdfPage prev, HPdfPage next) {
+        float r = (float)rand.Next(255) / 255;
+        float g = (float)rand.Next(255) / 255;
+        float b = (float)rand.Next(255) / 255;
+        HPdfRect rect;
+        HPdfDestination dst;
+        HPdfAnnotation annot;
+    
+        page.SetWidth (800);
+        page.SetHeight (600);
+    
+        page.SetRGBFill (r, g, b);
+    
+        page.Rectangle ( 0, 0, 800, 600);
+        page.Fill ();
+    
+        page.SetRGBFill (1.0f - r, 1.0f - g, 1.0f - b);
+    
+        page.SetFontAndSize (font, 30);
+    
+        page.BeginText ();
+        page.SetTextMatrix (0.8f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);   
+        page.TextOut (50, 530, caption);
+    
+        page.SetTextMatrix (1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);   
+        page.SetFontAndSize (font, 20);
+        page.TextOut (55, 300, 
+                "Type \"Ctrl+L\" in order to return from full screen mode.");
+        page.EndText ();
+    
+        page.SetSlideShow (type, 5.0f, 1.0f);
+    
+        page.SetFontAndSize (font, 20);
+    
+        if (next != null) {
+            page.BeginText ();
+            page.TextOut (680, 50, "Next=>");
+            page.EndText ();
+    
+            rect.left = 680;
+            rect.right = 750;
+            rect.top = 70;
+            rect.bottom = 50;
+            dst = next.CreateDestination();
+            dst.SetFit();
+            annot = page.CreateLinkAnnot (rect, dst);
+            annot.SetBorderStyle (0, 0, 0);
+            annot.SetHighlightMode (HPdfAnnotHighlightMode.HPDF_ANNOT_INVERT_BOX);
+        } 
+    
+        if (prev != null) {
+            page.BeginText ();
+            page.TextOut (50, 50, "<=Prev");
+            page.EndText ();
+    
+            rect.left = 50;
+            rect.right = 110;
+            rect.top = 70;
+            rect.bottom = 50;
+            dst = prev.CreateDestination();
+            dst.SetFit();
+            annot = page.CreateLinkAnnot (rect, dst);
+            annot.SetBorderStyle (0, 0, 0);
+            annot.SetHighlightMode (HPdfAnnotHighlightMode.HPDF_ANNOT_INVERT_BOX);
+        }
+    }
+
+
+    public static void Main() {
+        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion());
+
+        rand = new Random();
+
+        try {
+            HPdfDoc pdf = new HPdfDoc();
+            HPdfPage[] page = new HPdfPage[17];
+
+            /* create default-font */
+            HPdfFont font = pdf.GetFont ("Courier", null);
+        
+            /* Add 17 pages to the document. */
+            page[0] = pdf.AddPage();
+            page[1] = pdf.AddPage();
+            page[2] = pdf.AddPage();
+            page[3] = pdf.AddPage();
+            page[4] = pdf.AddPage();
+            page[5] = pdf.AddPage();
+            page[6] = pdf.AddPage();
+            page[7] = pdf.AddPage();
+            page[8] = pdf.AddPage();
+            page[9] = pdf.AddPage();
+            page[10] = pdf.AddPage();
+            page[11] = pdf.AddPage();
+            page[12] = pdf.AddPage();
+            page[13] = pdf.AddPage();
+            page[14] = pdf.AddPage();
+            page[15] = pdf.AddPage();
+            page[16] = pdf.AddPage();
+        
+            PrintPage(page[0], "HPDF_TS_WIPE_RIGHT", font, 
+                    HPdfTransitionStyle.HPDF_TS_WIPE_RIGHT, null, page[1]);
+            PrintPage(page[1], "HPDF_TS_WIPE_UP", font, 
+                    HPdfTransitionStyle.HPDF_TS_WIPE_UP, page[0], page[2]);
+            PrintPage(page[2], "HPDF_TS_WIPE_LEFT", font, 
+                    HPdfTransitionStyle.HPDF_TS_WIPE_LEFT, page[1], page[3]);
+            PrintPage(page[3], "HPDF_TS_WIPE_DOWN", font, 
+                    HPdfTransitionStyle.HPDF_TS_WIPE_DOWN, page[2], page[4]);
+            PrintPage(page[4], "HPDF_TS_BARN_DOORS_HORIZONTAL_OUT", font, 
+                    HPdfTransitionStyle.HPDF_TS_BARN_DOORS_HORIZONTAL_OUT, page[3], page[5]);
+            PrintPage(page[5], "HPDF_TS_BARN_DOORS_HORIZONTAL_IN", font, 
+                    HPdfTransitionStyle.HPDF_TS_BARN_DOORS_HORIZONTAL_IN, page[4], page[6]);
+            PrintPage(page[6], "HPDF_TS_BARN_DOORS_VERTICAL_OUT", font, 
+                    HPdfTransitionStyle.HPDF_TS_BARN_DOORS_VERTICAL_OUT, page[5], page[7]);
+            PrintPage(page[7], "HPDF_TS_BARN_DOORS_VERTICAL_IN", font, 
+                    HPdfTransitionStyle.HPDF_TS_BARN_DOORS_VERTICAL_IN, page[6], page[8]);
+            PrintPage(page[8], "HPDF_TS_BOX_OUT", font, 
+                    HPdfTransitionStyle.HPDF_TS_BOX_OUT, page[7], page[9]);
+            PrintPage(page[9], "HPDF_TS_BOX_IN", font, 
+                    HPdfTransitionStyle.HPDF_TS_BOX_IN, page[8], page[10]);
+            PrintPage(page[10], "HPDF_TS_BLINDS_HORIZONTAL", font, 
+                    HPdfTransitionStyle.HPDF_TS_BLINDS_HORIZONTAL, page[9], page[11]);
+            PrintPage(page[11], "HPDF_TS_BLINDS_VERTICAL", font, 
+                    HPdfTransitionStyle.HPDF_TS_BLINDS_VERTICAL, page[10], page[12]);
+            PrintPage(page[12], "HPDF_TS_DISSOLVE", font, 
+                    HPdfTransitionStyle.HPDF_TS_DISSOLVE, page[11], page[13]);
+            PrintPage(page[13], "HPDF_TS_GLITTER_RIGHT", font, 
+                    HPdfTransitionStyle.HPDF_TS_GLITTER_RIGHT, page[12], page[14]);
+            PrintPage(page[14], "HPDF_TS_GLITTER_DOWN", font, 
+                    HPdfTransitionStyle.HPDF_TS_GLITTER_DOWN, page[13], page[15]);
+            PrintPage(page[15], "HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT", font, 
+                    HPdfTransitionStyle.HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT, page[14], page[16]);
+            PrintPage(page[16], "HPDF_TS_REPLACE", font, 
+                    HPdfTransitionStyle.HPDF_TS_REPLACE, page[15], null);
+        
+        
+            pdf.SetPageMode (HPdfPageMode.HPDF_PAGE_MODE_FULL_SCREEN);
+        
+            /* save the document to a file */
+            pdf.SaveToFile("SlideShowDemo.pdf");
+
+        } catch (Exception e) {
+            Console.Error.WriteLine(e.Message);
+        }
+    }
+}
+
+
+

+ 321 - 0
pdf.mod/libharu/bindings/c#/demo/TextDemo.cs

@@ -0,0 +1,321 @@
+/*
+ * << Haru Free PDF Library 2.0.5 >> -- TextDemo.cs
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+using System;
+using System.IO;
+using HPdf;
+
+
+public class TextDemo {
+    private static void ShowStripePattern (HPdfPage page, float x, float y) {
+        int iy = 0;
+
+        while (iy < 50) {
+            page.SetRGBStroke(0.0f, 0.0f, 0.5f);
+            page.SetLineWidth(1);
+            page.MoveTo(x, y + iy);
+            page.LineTo(x + page.TextWidth("ABCabc123"),
+                    y + iy);
+            page.Stroke();
+            iy += 3;
+        }
+
+        page.SetLineWidth(2.5f);
+    }
+
+    private static void ShowDescription (HPdfPage page, float x, float y,
+            string text) {
+        float fsize = page.GetCurrentFontSize();
+        HPdfFont font = page.GetCurrentFont();
+        HPdfRGBColor c = page.GetRGBFill();
+
+        page.BeginText();
+        page.SetRGBFill(0, 0, 0);
+        page.SetTextRenderingMode(HPdfTextRenderingMode.HPDF_FILL);
+        page.SetFontAndSize(font, 10);
+        page.TextOut(x, y - 12, text);
+        page.EndText();
+
+        page.SetFontAndSize(font, fsize);
+        page.SetRGBFill(c.r, c.g, c.b);
+    }
+
+
+
+    public static void Main() {
+        const string page_title = "Text Demo";
+        const string samp_text = "abcdefgABCDEFG123!#$%&+-@?";
+        const string samp_text2 = "The quick brown fox jumps over the lazy dog.";
+        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion());
+
+        try {
+            HPdfDoc pdf = new HPdfDoc();
+
+            pdf.SetCompressionMode(HPdfDoc.HPDF_COMP_ALL);
+
+            /* create default-font */
+            HPdfFont font = pdf.GetFont("Helvetica", null);
+
+            /* add a new page object. */
+            HPdfPage page = pdf.AddPage();
+
+            /*print the title of the page (with positioning center). */
+            page.SetFontAndSize(font, 24);
+            float tw = page.TextWidth(page_title);
+            page.BeginText();
+            page.TextOut((page.GetWidth() - tw) / 2,
+                        page.GetHeight () - 50, page_title);
+            page.EndText();
+
+            page.BeginText();
+            page.MoveTextPos(60, page.GetHeight() - 60);
+
+            /*
+             * font size
+             */
+            float fsize = 8;
+            while (fsize < 60) {
+                /* set style and size of font. */
+                page.SetFontAndSize(font, fsize);
+
+                /* set the position of the text. */
+                page.MoveTextPos(0, -5 - fsize);
+
+                /* measure the number of characters which included in the page. */
+                uint tlen = page.MeasureText(samp_text,
+                                page.GetWidth() - 120, false);
+
+                page.ShowText(samp_text.Substring(0, (int)tlen));
+
+                /* print the description. */
+                page.MoveTextPos(0, -10);
+                page.SetFontAndSize(font, 8);
+                page.ShowText("Fontsize=" + fsize);
+
+                fsize *= 1.5f;
+            }
+
+            /*
+             * font color
+             */
+            page.SetFontAndSize(font, 8);
+            page.MoveTextPos(0, -30);
+            page.ShowText("Font color");
+
+            page.SetFontAndSize(font, 18);
+            page.MoveTextPos(0, -20);
+            int len = samp_text.Length;
+
+            for (int i = 0; i < len; i++) {
+                string buf;
+
+                float r = (float)i / (float)len;
+                float g = 1 - ((float)i / (float)len);
+                buf = samp_text.Substring(i, 1);
+
+                page.SetRGBFill(r, g, 0);
+                page.ShowText(buf);
+            }
+            page.MoveTextPos(0, -25);
+
+            for (int i = 0; i < len; i++) {
+                string buf;
+
+                float r = (float)i / (float)len;
+                float b = 1 - ((float)i / (float)len);
+                buf = samp_text.Substring(i, 1);
+
+                page.SetRGBFill(r, 0, b);
+                page.ShowText(buf);
+            }
+            page.MoveTextPos(0, -25);
+
+            for (int i = 0; i < len; i++) {
+                string buf;
+
+                float b = (float)i / (float)len;
+                float g = 1 - ((float)i / (float)len);
+                buf = samp_text.Substring(i, 1);
+
+                page.SetRGBFill(0, g, b);
+                page.ShowText(buf);
+           }
+ 
+            page.EndText();
+
+            int ypos = 450;
+
+            /*
+             * Font rendering mode
+             */
+            page.SetFontAndSize(font, 32);
+            page.SetRGBFill(0.5f, 0.5f, 0);
+            page.SetLineWidth(1.5f);
+
+            /* PDF_FILL */
+            ShowDescription(page, 60, ypos,
+                "RenderingMode=PDF_FILL");
+            page.SetTextRenderingMode(HPdfTextRenderingMode.HPDF_FILL);
+            page.BeginText();
+            page.TextOut(60, ypos, "ABCabc123");
+            page.EndText();
+
+            /*PDF_STROKE */
+            ShowDescription(page, 60, ypos - 50,
+                "RenderingMode=PDF_STROKE");
+            page.SetTextRenderingMode(HPdfTextRenderingMode.HPDF_STROKE);
+            page.BeginText();
+            page.TextOut(60, ypos - 50, "ABCabc123");
+            page.EndText();
+
+            /*PDF_FILL_THEN_STROKE */
+            ShowDescription(page, 60, ypos - 100,
+                "RenderingMode=PDF_FILL_THEN_STROKE");
+            page.SetTextRenderingMode(HPdfTextRenderingMode.HPDF_FILL_THEN_STROKE);
+            page.BeginText();
+            page.TextOut(60, ypos - 100, "ABCabc123");
+            page.EndText();
+
+            /*PDF_FILL_CLIPPING */
+            ShowDescription(page, 60, ypos - 150,
+                "RenderingMode=PDF_FILL_CLIPPING");
+            page.GSave();
+            page.SetTextRenderingMode(HPdfTextRenderingMode.HPDF_FILL_CLIPPING);
+            page.BeginText();
+            page.TextOut(60, ypos - 150, "ABCabc123");
+            page.EndText();
+            ShowStripePattern(page, 60, ypos - 150);
+            page.GRestore();
+
+            /*PDF_STROKE_CLIPPING */
+            ShowDescription(page, 60, ypos - 200,
+                "RenderingMode=PDF_STROKE_CLIPPING");
+            page.GSave();
+            page.SetTextRenderingMode(HPdfTextRenderingMode.HPDF_STROKE_CLIPPING);
+            page.BeginText();
+            page.TextOut(60, ypos - 200, "ABCabc123");
+            page.EndText();
+            ShowStripePattern(page, 60, ypos - 200);
+            page.GRestore();
+
+            /*PDF_FILL_STROKE_CLIPPING */
+            ShowDescription(page, 60, ypos - 250,
+                "RenderingMode=PDF_FILL_STROKE_CLIPPING");
+            page.GSave();
+            page.SetTextRenderingMode(HPdfTextRenderingMode.HPDF_FILL_STROKE_CLIPPING);
+            page.BeginText();
+            page.TextOut(60, ypos - 250, "ABCabc123");
+            page.EndText();
+            ShowStripePattern(page, 60, ypos - 250);
+            page.GRestore();
+
+            /*Reset text attributes */
+            page.SetTextRenderingMode(HPdfTextRenderingMode.HPDF_FILL);
+            page.SetRGBFill(0, 0, 0);
+            page.SetFontAndSize(font, 30);
+
+
+            /*
+             * Rotating text
+             */
+            float angle1 = 30;                   /* A rotation of 30 degrees. */
+            float rad1 = angle1 / 180 * 3.141592f; /* Calculate the radian value. */
+
+            ShowDescription(page, 320, ypos - 60, "Rotating text");
+            page.BeginText();
+            page.SetTextMatrix((float)Math.Cos(rad1), (float)Math.Sin(rad1), 
+                -(float)Math.Sin(rad1), (float)Math.Cos(rad1),
+                330, ypos - 60);
+            page.ShowText("ABCabc123");
+            page.EndText();
+
+
+            /*
+             * Skewing text.
+             */
+            ShowDescription(page, 320, ypos - 120, "Skewing text");
+            page.BeginText();
+
+            angle1 = 10;
+            float angle2 = 20;
+            rad1 = angle1 / 180 * 3.141592f;
+            float rad2 = angle2 / 180 * 3.141592f;
+
+            page.SetTextMatrix(1, (float)Math.Tan(rad1), (float)Math.Tan(rad2), 1, 
+                    320, ypos - 120);
+            page.ShowText("ABCabc123");
+            page.EndText();
+
+
+            /*
+             * scaling text (X direction)
+             */
+            ShowDescription(page, 320, ypos - 175, "Scaling text (X direction)");
+            page.BeginText();
+            page.SetTextMatrix(1.5f, 0, 0, 1, 320, ypos - 175);
+            page.ShowText("ABCabc12");
+            page.EndText();
+
+
+            /*
+             * scaling text (Y direction)
+             */
+            ShowDescription(page, 320, ypos - 250, "Scaling text (Y direction)");
+            page.BeginText();
+            page.SetTextMatrix(1, 0, 0, 2, 320, ypos - 250);
+            page.ShowText("ABCabc123");
+            page.EndText();
+
+
+            /*
+             * char spacing, word spacing
+             */
+
+            ShowDescription(page, 60, 140, "char-spacing 0");
+            ShowDescription(page, 60, 100, "char-spacing 1.5");
+            ShowDescription(page, 60, 60, "char-spacing 1.5, word-spacing 2.5");
+
+            page.SetFontAndSize(font, 20);
+            page.SetRGBFill(0.1f, 0.3f, 0.1f);
+
+            /*char-spacing 0 */
+            page.BeginText();
+            page.TextOut(60, 140, samp_text2);
+            page.EndText();
+
+            /*char-spacing 1.5 */
+            page.SetCharSpace(1.5f);
+
+            page.BeginText();
+            page.TextOut(60, 100, samp_text2);
+            page.EndText();
+
+            /*char-spacing 1.5, word-spacing 3.5 */
+            page.SetWordSpace(2.5f);
+
+            page.BeginText();
+            page.TextOut(60, 60, samp_text2);
+            page.EndText();
+
+            /* save the document to a file */
+            pdf.SaveToFile("TextDemo.pdf");
+
+        } catch (Exception e) {
+            Console.Error.WriteLine(e.Message);
+        }
+    }
+}
+
+
+

+ 2150 - 0
pdf.mod/libharu/bindings/c#/hpdf.cs

@@ -0,0 +1,2150 @@
+/*
+ * << Haru Free PDF Library 2.0.6 >> -- hpdf.cs
+ *
+ * C# wrapper for libhpdf.dll
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+
+namespace HPdf {
+
+public enum HPdfPageLayout : uint {
+    HPDF_PAGE_LAYOUT_SINGLE = 0,
+    HPDF_PAGE_LAYOUT_ONE_COLUMN,
+    HPDF_PAGE_LAYOUT_TWO_CLUMN_LEFT,
+    HPDF_PAGE_LAYOUT_TWO_CLUMN_RIGHT,
+    HPDF_PAGE_LAYOUT_EOF
+};
+
+public enum HPdfPageMode : uint {
+    HPDF_PAGE_MODE_USE_NONE = 0,
+    HPDF_PAGE_MODE_USE_OUTLINE,
+    HPDF_PAGE_MODE_USE_THUMBS,
+    HPDF_PAGE_MODE_FULL_SCREEN,
+    HPDF_PAGE_MODE_EOF
+};
+
+public enum HPdfPageSizes : uint {
+    HPDF_PAGE_SIZE_LETTER = 0,
+    HPDF_PAGE_SIZE_LEGAL,
+    HPDF_PAGE_SIZE_A3,
+    HPDF_PAGE_SIZE_A4,
+    HPDF_PAGE_SIZE_A5,
+    HPDF_PAGE_SIZE_B4,
+    HPDF_PAGE_SIZE_B5,
+    HPDF_PAGE_SIZE_EXECUTIVE,
+    HPDF_PAGE_SIZE_US4x6,
+    HPDF_PAGE_SIZE_US4x8,
+    HPDF_PAGE_SIZE_US5x7,
+    HPDF_PAGE_SIZE_COMM10,
+    HPDF_PAGE_SIZE_EOF
+};
+
+
+public enum HPdfPageDirection : uint {
+    HPDF_PAGE_PORTRAIT = 0,
+    HPDF_PAGE_LANDSCAPE
+};
+
+
+public enum HPdfPageNumStyle : uint {
+    HPDF_PAGE_NUM_STYLE_DECIMAL = 0,
+    HPDF_PAGE_NUM_STYLE_UPPER_ROMAN,
+    HPDF_PAGE_NUM_STYLE_LOWER_ROMAN,
+    HPDF_PAGE_NUM_STYLE_UPPER_LETTERS,
+    HPDF_PAGE_NUM_STYLE_LOWER_LETTERS,
+    HPDF_PAGE_NUM_STYLE_EOF
+};
+
+public enum HPdfWritingMode : uint {
+    HPDF_WMODE_HORIZONTAL = 0,
+    HPDF_WMODE_VERTICAL,
+    HPDF_WMODE_EOF
+};
+
+
+public enum HPdfEncoderType : uint {
+    HPDF_ENCODER_TYPE_SINGLE_BYTE = 0,
+    HPDF_ENCODER_TYPE_DOUBLE_BYTE,
+    HPDF_ENCODER_TYPE_UNINITIALIZED,
+    HPDF_ENCODER_UNKNOWN
+};
+
+
+public enum HPdfByteType : uint {
+    HPDF_BYTE_TYPE_SINGLE = 0,
+    HPDF_BYTE_TYPE_LEAD,
+    HPDF_BYTE_TYPE_TRAIL,
+    HPDF_BYTE_TYPE_UNKNOWN
+};
+
+
+public enum HPdfAnnotHighlightMode : uint {
+    HPDF_ANNOT_NO_HIGHTLIGHT = 0,
+    HPDF_ANNOT_INVERT_BOX,
+    HPDF_ANNOT_INVERT_BORDER,
+    HPDF_ANNOT_DOWN_APPEARANCE,
+    HPDF_ANNOT_HIGHTLIGHT_MODE_EOF
+};
+
+
+public enum HPdfAnnotIcon : uint {
+    HPDF_ANNOT_ICON_COMMENT = 0,
+    HPDF_ANNOT_ICON_KEY,
+    HPDF_ANNOT_ICON_NOTE,
+    HPDF_ANNOT_ICON_HELP,
+    HPDF_ANNOT_ICON_NEW_PARAGRAPH,
+    HPDF_ANNOT_ICON_PARAGRAPH,
+    HPDF_ANNOT_ICON_INSERT,
+    HPDF_ANNOT_ICON_EOF
+};
+
+public enum HPdfColorSpace : uint {
+    HPDF_CS_DEVICE_GRAY = 0,
+    HPDF_CS_DEVICE_RGB,
+    HPDF_CS_DEVICE_CMYK,
+    HPDF_CS_CAL_GRAY,
+    HPDF_CS_CAL_RGB,
+    HPDF_CS_LAB,
+    HPDF_CS_ICC_BASED,
+    HPDF_CS_SEPARATION,
+    HPDF_CS_DEVICE_N,
+    HPDF_CS_INDEXED,
+    HPDF_CS_PATTERN,
+    HPDF_CS_EOF
+};
+
+
+public enum HPdfInfoType : uint {
+    /* date-time type parameters */
+    HPDF_INFO_CREATION_DATE = 0,
+    HPDF_INFO_MOD_DATE = 1,
+
+    /* string type parameters */
+    HPDF_INFO_AUTHOR = 2,
+    HPDF_INFO_CREATOR = 3,
+    HPDF_INFO_PRODUCER = 4,
+    HPDF_INFO_TITLE = 5,
+    HPDF_INFO_SUBJECT = 6,
+    HPDF_INFO_KEYWORDS = 7,
+    HPDF_INFO_EOF = 8
+};
+
+public enum  HPdfEncryptMode: uint {
+    HPDF_ENCRYPT_R2    = 2,
+    HPDF_ENCRYPT_R3    = 3
+};
+
+public enum  HPdfTextRenderingMode: uint {
+    HPDF_FILL = 0,
+    HPDF_STROKE = 1,
+    HPDF_FILL_THEN_STROKE = 2,
+    HPDF_INVISIBLE = 3,
+    HPDF_FILL_CLIPPING = 4,
+    HPDF_STROKE_CLIPPING = 5,
+    HPDF_FILL_STROKE_CLIPPING = 6,
+    HPDF_CLIPPING = 7,
+    HPDF_RENDERING_MODE_EOF = 8
+};
+
+public enum HPdfLineCap {
+    HPDF_BUTT_END = 0,
+    HPDF_ROUND_END = 1,
+    HPDF_PROJECTING_SQUARE_END = 2,
+    HPDF_LINECAP_EOF = 3
+};
+
+public enum HPdfLineJoin {
+    HPDF_MITER_JOIN = 0,
+    HPDF_ROUND_JOIN = 1,
+    HPDF_BEVEL_JOIN = 2,
+    HPDF_LINEJOIN_EOF = 3
+};
+
+public enum HPdfTextAlignment {
+    HPDF_TALIGN_LEFT = 0,
+    HPDF_TALIGN_RIGHT = 1,
+    HPDF_TALIGN_CENTER = 2,
+    HPDF_TALIGN_JUSTIFY = 3
+};
+
+public enum HPdfTransitionStyle {
+    HPDF_TS_WIPE_RIGHT = 0,
+    HPDF_TS_WIPE_UP,
+    HPDF_TS_WIPE_LEFT,
+    HPDF_TS_WIPE_DOWN,
+    HPDF_TS_BARN_DOORS_HORIZONTAL_OUT,
+    HPDF_TS_BARN_DOORS_HORIZONTAL_IN,
+    HPDF_TS_BARN_DOORS_VERTICAL_OUT,
+    HPDF_TS_BARN_DOORS_VERTICAL_IN,
+    HPDF_TS_BOX_OUT,
+    HPDF_TS_BOX_IN,
+    HPDF_TS_BLINDS_HORIZONTAL,
+    HPDF_TS_BLINDS_VERTICAL,
+    HPDF_TS_DISSOLVE,
+    HPDF_TS_GLITTER_RIGHT,
+    HPDF_TS_GLITTER_DOWN,
+    HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT,
+    HPDF_TS_REPLACE,
+    HPDF_TS_EOF
+};
+
+
+public enum HPdfBlendMode {
+    HPDF_BM_NORMAL = 0,
+    HPDF_BM_MULTIPLY,
+    HPDF_BM_SCREEN,
+    HPDF_BM_OVERLAY,
+    HPDF_BM_DARKEN,
+    HPDF_BM_LIGHTEN,
+    HPDF_BM_COLOR_DODGE,
+    HPDF_BM_COLOR_BUM,
+    HPDF_BM_HARD_LIGHT,
+    HPDF_BM_SOFT_LIGHT,
+    HPDF_BM_DIFFERENCE,
+    HPDF_BM_EXCLUSHON,
+    HPDF_BM_EOF
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public struct HPdfRect {
+    public float left;
+    public float  bottom;
+    public float  right;
+    public float  top;
+}
+
+[StructLayout(LayoutKind.Sequential)]
+public struct HPdfBox {
+    public float left;
+    public float  bottom;
+    public float  right;
+    public float  top;
+}
+
+[StructLayout(LayoutKind.Sequential)]
+public struct HPdfPoint {
+    public float  x;
+    public float  y;
+}
+
+[StructLayout(LayoutKind.Sequential)]
+public struct HPdfDate {
+    public int    year;
+    public int    month;
+    public int    day;
+    public int    hour;
+    public int    minutes;
+    public int    seconds;
+    public char   ind;
+    public int    off_hour;
+    public int    off_minutes;
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public struct HPdfTextWidth {
+    public uint numchars;
+
+    /* don't use this value (it may be change in the feature).
+       use numspace as alternated. */
+    public uint numwords;
+
+    public uint width;
+    public uint numspace;
+}
+
+[StructLayout(LayoutKind.Sequential)]
+public struct HPdfTransMatrix {
+    public float    a;
+    public float    b;
+    public float    c;
+    public float    d;
+    public float    x;
+    public float    y;
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public struct HPdfDashMode_Internal {
+    public ushort  ptn0;
+    public ushort  ptn1;
+    public ushort  ptn2;
+    public ushort  ptn3;
+    public ushort  ptn4;
+    public ushort  ptn5;
+    public ushort  ptn6;
+    public ushort  ptn7;
+    public uint    num_ptn;
+    public uint    phase;
+};
+
+public struct HPdfDashMode {
+    public ushort[]  ptn;
+    public uint      phase;
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public struct HPdfRGBColor {
+    public float   r;
+    public float   g;
+    public float   b;
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public struct HPdfCMYKColor {
+    public float   c;
+    public float   y;
+    public float   m;
+    public float   k;
+};
+
+
+/* error handler (call back function) */
+public delegate void HPDF_ErrorHandler(uint error_no, uint detail_no,
+        IntPtr user_data);
+
+public class HPdfDoc: IDisposable {
+    public const int HPDF_TRUE = 1;
+    public const int HPDF_FALSE = 0;
+    public const uint HPDF_COMP_NONE = 0;
+    public const uint HPDF_COMP_TEXT = 1;
+    public const uint HPDF_COMP_IMAGE = 2;
+    public const uint HPDF_COMP_METADATA = 4;
+    public const uint HPDF_COMP_ALL = 15;
+
+    public const uint HPDF_HIDE_TOOLBAR = 1;
+    public const uint HPDF_HIDE_MENUBAR = 2;
+    public const uint HPDF_HIDE_WINDOW_UI = 4;
+    public const uint HPDF_FIT_WINDOW = 8;
+    public const uint HPDF_CENTER_WINDOW = 16;
+
+    public const uint HPDF_ENABLE_READ = 0;
+    public const uint HPDF_ENABLE_PRINT = 4;
+    public const uint HPDF_ENABLE_EDIT_ALL = 8;
+    public const uint HPDF_ENABLE_COPY = 16;
+    public const uint HPDF_ENABLE_EDIT = 32;
+
+
+    [DllImport("libhpdf.dll")]
+    private extern static string HPDF_GetVersion();
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_New(HPDF_ErrorHandler user_error_fn,
+            IntPtr user_data);
+
+    [DllImport("libhpdf.dll")]
+    private extern static void HPDF_Free(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_NewDoc(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_FreeDoc(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_FreeDocAll(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_HasDoc(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SaveToFile(IntPtr pdf, string file_name);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_GetError(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_GetErrorDetail(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static void HPDF_ResetError(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetPagesConfiguration(IntPtr pdf,
+            uint page_per_pages);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_GetPageByIndex(IntPtr pdf,
+            uint index);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfPageLayout HPDF_GetPageLayout(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetPageLayout(IntPtr pdf,
+            HPdfPageLayout layout);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfPageMode HPDF_GetPageMode(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetPageMode(IntPtr pdf, HPdfPageMode mode);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetOpenAction(IntPtr pdf,
+            IntPtr open_action);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_GetViewerPreference(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetViewerPreference(IntPtr pdf, uint value);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_GetCurrentPage(IntPtr  pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_AddPage(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_InsertPage(IntPtr pdf,
+                    IntPtr  page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_GetFont(IntPtr pdf, string font_name,
+                    string encoding_name);
+
+    [DllImport("libhpdf.dll")]
+    private extern static string HPDF_LoadType1FontFromFile(IntPtr pdf,
+                    string afmfilename, string pfmfilename);
+
+    [DllImport("libhpdf.dll")]
+    private extern static string HPDF_LoadTTFontFromFile(IntPtr pdf,
+                    string file_name, int embedding);
+
+    [DllImport("libhpdf.dll")]
+    private extern static string HPDF_LoadTTFontFromFile2(IntPtr pdf,
+                    string file_name, uint index, int embedding);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_AddPageLabel(IntPtr pdf, uint page_num,
+                  HPdfPageNumStyle style, uint first_page, string prefix);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_UseJPFonts(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_UseKRFonts(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_UseCNSFonts(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_UseCNTFonts(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_CreateOutline(IntPtr pdf, IntPtr parent,
+                    string title, IntPtr encoder);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_GetEncoder(IntPtr pdf,
+                    string encoding_name);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_GetCurrentEncoder(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetCurrentEncoder(IntPtr pdf,
+                    string encoding_name);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_UseJPEncodings(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_UseKREncodings(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_UseCNSEncodings(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_UseCNTEncodings(IntPtr pdf);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_LoadPngImageFromFile(IntPtr pdf,
+                    string filename);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_LoadPngImageFromFile2(IntPtr pdf,
+                    string filename);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_LoadJpegImageFromFile(IntPtr pdf,
+                    string filename);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_LoadRawImageFromFile(IntPtr pdf,
+                    string filename, uint width, uint height,
+                    HPdfColorSpace color_space);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_LoadRawImageFromMem(IntPtr pdf,
+                    byte[] data, int width, int height,
+                    HPdfColorSpace color_space,
+                    uint bits_per_component);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetInfoAttr(IntPtr pdf,
+                    HPdfInfoType type, string value);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetInfoDateAttr(IntPtr pdf,
+                    HPdfInfoType type, HPdfDate value);
+
+    [DllImport("libhpdf.dll")]
+    private extern static string HPDF_GetInfoAttr(IntPtr pdf,
+                    HPdfInfoType type);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetPassword(IntPtr pdf,
+                    string owner_passwd, string user_passwd);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetPermission(IntPtr pdf,
+                    uint permission);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetEncryptionMode(IntPtr pdf,
+                    HPdfEncryptMode mode, uint key_len);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_SetCompressionMode(IntPtr pdf,
+                    uint mode);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_CreateExtGState(IntPtr pdf);
+
+    // handle to an instance of a HPdfDoc object.
+    private IntPtr hpdf;
+
+    public HPdfDoc() {
+        HPDF_ErrorHandler error_handler =
+                new HPDF_ErrorHandler(HPdfDoc.ErrorProc);
+        hpdf = HPDF_New(error_handler, IntPtr.Zero);
+        if (hpdf == IntPtr.Zero) {
+            throw new Exception("cannot create HPdfDoc object.");
+        }
+    }
+
+    void IDisposable.Dispose() {
+        if (hpdf != IntPtr.Zero) {
+            HPDF_Free(hpdf);
+        }
+
+        hpdf = IntPtr.Zero;
+    }
+
+    ~HPdfDoc() {
+        if (hpdf != IntPtr.Zero) {
+            HPDF_Free(hpdf);
+        }
+    }
+
+    public static string HPdfGetVersion() {
+        return HPDF_GetVersion();
+    }
+
+    public static void ErrorProc(uint error_no, uint detail_no,
+            IntPtr user_data) {
+        string s = "error-code=0x" + error_no.ToString("X") + " detail-code=" + detail_no;
+        throw new Exception(s);
+    }
+
+    public void NewDoc() {
+        HPDF_NewDoc(hpdf);
+    }
+
+    public void FreeDoc() {
+        HPDF_FreeDoc(hpdf);
+    }
+
+    public void FreeDocAll() {
+        HPDF_FreeDocAll(hpdf);
+    }
+
+    public bool HasDoc() {
+        return (HPDF_HasDoc(hpdf) != 0);
+    }
+
+    public void SaveToFile(string file_name) {
+        HPDF_SaveToFile(hpdf, file_name);
+    }
+
+    public uint GetError() {
+        return HPDF_GetError(hpdf);
+    }
+
+    public uint GetErrorDetail() {
+        return HPDF_GetErrorDetail(hpdf);
+    }
+
+    public void ResetError() {
+        HPDF_ResetError(hpdf);
+    }
+
+    public void SetPagesConfiguration(uint page_per_pages) {
+        HPDF_SetPagesConfiguration(hpdf, page_per_pages);
+    }
+
+    public HPdfPage GetPageByIndex(uint index) {
+        IntPtr hpage;
+
+        hpage = HPDF_GetPageByIndex(hpdf, index);
+        return new HPdfPage(hpage);
+    }
+
+    public HPdfPageLayout GetPageLayout() {
+        return HPDF_GetPageLayout(hpdf);
+    }
+
+    public void SetPageLayout(HPdfPageLayout layout) {
+        HPDF_SetPageLayout(hpdf, layout);
+    }
+
+    public HPdfPageMode GetPageMode() {
+        return HPDF_GetPageMode(hpdf);
+    }
+
+    public void SetPageMode(HPdfPageMode mode) {
+        HPDF_SetPageMode(hpdf, mode);
+    }
+
+    public void SetOpenAction(HPdfDestination open_action) {
+        if (open_action == null) {
+            // ERROR!!
+        } else {
+            HPDF_SetOpenAction(hpdf, open_action.GetHandle());
+        }
+    }
+
+    public uint GetViewerPreference() {
+        return HPDF_GetViewerPreference(hpdf);
+    }
+
+    public void SetViewerPreference(uint value) {
+        HPDF_SetViewerPreference(hpdf, value);
+    }
+
+    public HPdfPage GetCurrentPage() {
+        IntPtr hpage;
+
+        hpage = HPDF_GetCurrentPage(hpdf);
+        return new HPdfPage(hpage);
+    }
+
+    public HPdfPage AddPage() {
+        IntPtr hpage;
+
+        hpage = HPDF_AddPage(hpdf);
+        return new HPdfPage(hpage);
+    }
+
+    public HPdfPage InsertPage(HPdfPage page) {
+        IntPtr hpage;
+
+        hpage = HPDF_InsertPage(hpdf, page.GetHandle());
+        return new HPdfPage(hpage);
+    }
+
+    public HPdfFont GetFont(string font_name, string encoding_name) {
+        IntPtr hfont;
+
+        hfont = HPDF_GetFont(hpdf, font_name, encoding_name);
+        return new HPdfFont(hfont);
+    }
+
+    public string LoadType1FontFromFile(string afmfilename,
+            string pfmfilename) {
+        string font_name;
+
+        font_name = HPDF_LoadType1FontFromFile(hpdf, afmfilename, pfmfilename);
+        return font_name;
+    }
+
+    public string LoadTTFontFromFile(string file_name, bool embedding) {
+        string font_name;
+        int emb;
+
+        if (embedding)
+            emb = HPDF_TRUE;
+        else
+            emb = HPDF_FALSE;
+
+        font_name = HPDF_LoadTTFontFromFile(hpdf, file_name, emb);
+        return font_name;
+    }
+
+    public string LoadTTFontFromFile2(string file_name, uint index,
+            bool embedding) {
+        string font_name;
+        int emb;
+
+        if (embedding)
+            emb = HPDF_TRUE;
+        else
+            emb = HPDF_FALSE;
+
+        font_name = HPDF_LoadTTFontFromFile2(hpdf, file_name, index, emb);
+        return font_name;
+    }
+
+    public void AddPageLabel(uint page_num, HPdfPageNumStyle style,
+            uint first_page, string prefix) {
+        HPDF_AddPageLabel(hpdf, page_num, style, first_page, prefix);
+    }
+
+    public uint UseJPFonts() {
+        return HPDF_UseJPFonts(hpdf);
+    }
+
+    public uint UseKRFonts() {
+        return HPDF_UseKRFonts(hpdf);
+    }
+
+    public uint UseCNSFonts() {
+        return HPDF_UseCNSFonts(hpdf);
+    }
+
+    public uint UseCNTFonts() {
+        return HPDF_UseCNTFonts(hpdf);
+    }
+
+    public HPdfOutline CreateOutline(HPdfOutline parent, string title,
+            HPdfEncoder encoder) {
+        IntPtr hparent;
+        IntPtr hencoder;
+        IntPtr houtline;
+
+        if (encoder != null)
+            hencoder = encoder.GetHandle();
+        else
+            hencoder = IntPtr.Zero;
+
+        if (parent != null)
+            hparent = parent.GetHandle();
+        else
+            hparent = IntPtr.Zero;
+
+        houtline = HPDF_CreateOutline(hpdf, hparent, title, hencoder);
+        return new HPdfOutline(houtline);
+    }
+
+    public HPdfEncoder GetEncoder(string encoding_name) {
+        IntPtr hencoder;
+
+        hencoder = HPDF_GetEncoder(hpdf, encoding_name);
+
+        return new HPdfEncoder(hencoder);
+    }
+
+    public HPdfEncoder GetCurrentEncoder() {
+        IntPtr hencoder;
+
+        hencoder = HPDF_GetCurrentEncoder(hpdf);
+
+        return new HPdfEncoder(hencoder);
+    }
+
+    public void SetCurrentEncoder(string encoding_name) {
+        HPDF_SetCurrentEncoder(hpdf, encoding_name);
+    }
+
+    public uint UseJPEncodings() {
+        return HPDF_UseJPEncodings(hpdf);
+    }
+
+    public uint UseKREncodings() {
+        return HPDF_UseKREncodings(hpdf);
+    }
+
+    public uint UseCNSEncodings() {
+        return HPDF_UseCNSEncodings(hpdf);
+    }
+
+    public uint UseCNTEncodings() {
+        return HPDF_UseCNTEncodings(hpdf);
+    }
+
+    public HPdfImage LoadPngImageFromFile(string filename) {
+        IntPtr hobj;
+
+        hobj = HPDF_LoadPngImageFromFile(hpdf, filename);
+
+        return new HPdfImage(hobj);
+    }
+
+    public HPdfImage LoadPngImageFromFile2(string filename) {
+        IntPtr hobj;
+
+        hobj = HPDF_LoadPngImageFromFile2(hpdf, filename);
+
+        return new HPdfImage(hobj);
+    }
+
+    public HPdfImage LoadJpegImageFromFile(string filename) {
+        IntPtr hobj;
+
+        hobj = HPDF_LoadJpegImageFromFile(hpdf, filename);
+
+        return new HPdfImage(hobj);
+    }
+
+    public HPdfImage LoadRawImageFromFile(string filename,
+                    uint width, uint height,
+                    HPdfColorSpace color_space) {
+        IntPtr hobj;
+
+        hobj = HPDF_LoadRawImageFromFile(hpdf, filename, width, height,
+                    color_space);
+
+        return new HPdfImage(hobj);
+    }
+
+    public HPdfImage LoadRawImageFromMem(byte[] data, int width, int height,
+                    HPdfColorSpace color_space, uint bits_per_component) {
+        if (width * height < data.Length) {
+            string s = "error-code=0x1030 detail-code=0";
+            throw new Exception(s);
+        }
+        IntPtr hobj;
+
+        hobj = HPDF_LoadRawImageFromMem(hpdf, data, width, height, color_space,
+            bits_per_component);
+
+        return new HPdfImage(hobj);
+    }
+
+    public void SetInfoAttr(HPdfInfoType type, string value) {
+        HPDF_SetInfoAttr(hpdf, type, value);
+    }
+
+    public void SetInfoDateAttr(HPdfInfoType type, HPdfDate value) {
+        HPDF_SetInfoDateAttr(hpdf, type, value);
+    }
+
+    public string GetInfoAttr(HPdfInfoType type) {
+        return HPDF_GetInfoAttr(hpdf, type);
+    }
+
+    public void SetPassword(string owner_passwd, string user_passwd) {
+        HPDF_SetPassword(hpdf, owner_passwd, user_passwd);
+    }
+
+    public void SetPermission(uint permission) {
+        HPDF_SetPermission(hpdf, permission);
+    }
+
+    public void SetEncryptionMode(HPdfEncryptMode mode, uint key_len) {
+        HPDF_SetEncryptionMode(hpdf, mode, key_len);
+    }
+
+    public void SetCompressionMode(uint mode) {
+        HPDF_SetCompressionMode(hpdf, mode);
+    }
+
+    public HPdfExtGState CreateExtGState() {
+        IntPtr hgstate;
+
+        hgstate = HPDF_CreateExtGState(hpdf);
+
+        return new HPdfExtGState(hgstate);
+    }
+}
+
+public class HPdfPage{
+    public const int HPDF_TRUE = 1;
+    public const int HPDF_FALSE = 0;
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetWidth(IntPtr page, float value);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetHeight(IntPtr page, float value);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetSize(IntPtr page,
+            HPdfPageSizes size, HPdfPageDirection direction);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetRotate(IntPtr page, ushort angle);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_Page_CreateDestination(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_Page_CreateTextAnnot(IntPtr page,
+        HPdfRect rect, string text, IntPtr encoder);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_Page_CreateLinkAnnot(IntPtr page,
+        HPdfRect rect, IntPtr dst);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_Page_CreateURILinkAnnot(IntPtr page,
+        HPdfRect rect, string url);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_TextWidth(IntPtr page,
+        string text);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_MeasureText(IntPtr page,
+        string text, float width, int wordwrap, ref float real_width);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetWidth(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetHeight(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static ushort HPDF_Page_GetGMode(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfPoint HPDF_Page_GetCurrentPos(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfPoint HPDF_Page_GetCurrentTextPos(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static IntPtr HPDF_Page_GetCurrentFont(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetCurrentFontSize(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfTransMatrix HPDF_Page_GetTransMatrix(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetLineWidth(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfLineCap HPDF_Page_GetLineCap(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfLineJoin HPDF_Page_GetLineJoin(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetMiterLimit(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfDashMode_Internal HPDF_Page_GetDash(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetFlat(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetCharSpace(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetWordSpace(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetHorizontalScalling(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetTextLeading(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfTextRenderingMode HPDF_Page_GetTextRenderingMode(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetTextRaise(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfRGBColor HPDF_Page_GetRGBFill(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfRGBColor HPDF_Page_GetRGBStroke(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfCMYKColor HPDF_Page_GetCMYKFill(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfCMYKColor HPDF_Page_GetCMYKStroke(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetGrayFill(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static float HPDF_Page_GetGrayStroke(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfColorSpace HPDF_Page_GetStrokingColorSpace(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfColorSpace HPDF_Page_GetFillingColorSpace(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfTransMatrix HPDF_Page_GetTextMatrix(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_GetGStateDepth(IntPtr page);
+
+/*--- General graphics state -----------------------------------------------*/
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetLineWidth(IntPtr page,
+                float line_width);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetLineCap(IntPtr page,
+                HPdfLineCap line_cap);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetLineJoin(IntPtr page,
+                HPdfLineJoin line_join);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetMiterLimit(IntPtr page,
+                float miter_limit);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetDash(IntPtr page,
+                ushort[] array, uint num_param, uint phase);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetFlat(IntPtr page,
+                float flatness);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetExtGState(IntPtr page,
+                IntPtr ext_gstate);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_GSave(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_GRestore(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_Concat(IntPtr page,
+            float a, float b, float c, float d, float x, float y);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_MoveTo(IntPtr page,
+            float x, float y);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_LineTo(IntPtr page,
+            float x, float y);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_CurveTo(IntPtr page,
+            float x1, float y1, float x2, float y2, float x3, float y3);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_CurveTo2(IntPtr page,
+            float x2, float y2, float x3, float y3);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_CurveTo3(IntPtr page,
+            float x1, float y1, float x3, float y3);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_ClosePath(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_Rectangle(IntPtr page,
+            float x, float y, float width, float height);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_Stroke(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_ClosePathStroke(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_Fill(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_Eofill(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_FillStroke(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_EofillStroke(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_ClosePathFillStroke(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_ClosePathEofillStroke(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_EndPath(IntPtr page);
+
+/*--- Clipping paths operator --------------------------------------------*/
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_Clip(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_Eoclip(IntPtr page);
+
+/*--- Text object operator -----------------------------------------------*/
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_BeginText(IntPtr page);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_EndText(IntPtr page);
+
+/*--- Text state ---------------------------------------------------------*/
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetCharSpace(IntPtr page,
+                float value);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetWordSpace(IntPtr page,
+                float value);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetHorizontalScalling(IntPtr page,
+                float value);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetTextLeading(IntPtr page,
+                float value);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetFontAndSize(IntPtr page,
+                IntPtr hfont, float size);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetTextRenderingMode(IntPtr page,
+                HPdfTextRenderingMode  mode);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetTextRaise(IntPtr page,
+                float value);
+
+/*--- Text positioning ---------------------------------------------------*/
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_MoveTextPos(IntPtr page,
+            float x, float y);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_MoveTextPos2(IntPtr page,
+            float x, float y);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetTextMatrix(IntPtr page,
+            float a, float b, float c, float d, float x, float y);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_MoveToNextLine(IntPtr page);
+
+/*--- Text showing -------------------------------------------------------*/
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_ShowText(IntPtr page,
+                string text);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_ShowTextNextLine(IntPtr page,
+                string text);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_ShowTextNextLineEx(IntPtr page,
+                float word_space, float char_space, string text);
+
+/*--- Color showing ------------------------------------------------------*/
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetGrayFill(IntPtr page,
+                float gray);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetGrayStroke(IntPtr page,
+                float gray);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetRGBFill(IntPtr page,
+                float r, float g, float b);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetRGBStroke(IntPtr page,
+                float r, float g, float b);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetCMYKFill(IntPtr page,
+                float c, float m, float y, float k);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetCMYKStroke(IntPtr page,
+                float c, float m, float y, float k);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_ExecuteXObject(IntPtr page,
+                IntPtr obj);
+
+/*---------------------------------------------------------------------*/
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_DrawImage(IntPtr page,
+                IntPtr image, float x, float y, float width, float height);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_Circle(IntPtr page,
+                float x, float y, float ray);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_Arc(IntPtr page,
+                float x, float y, float ray, float ang1, float ang2);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_Ellipse(IntPtr page,
+                float x, float y, float xray, float yray);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_TextOut(IntPtr page,
+                float xpos, float ypos, string text);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_TextRect(IntPtr page,
+                float left, float top, float right, float bottom,
+                string text, HPdfTextAlignment align, ref uint len);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Page_SetSlideShow(IntPtr page,
+                HPdfTransitionStyle type, float disp_time, float trans_time);
+
+
+    // handle to an instance of a HPDF_Doc object.
+    private IntPtr hpage;
+
+    public HPdfPage(IntPtr hpage) {
+        if (hpage == IntPtr.Zero) {
+            throw new Exception("cannot create HPdfPage object.");
+        }
+
+        this.hpage = hpage;
+    }
+
+    public void SetWidth(float value) {
+        HPDF_Page_SetWidth(hpage, value);
+    }
+
+    public void SetHeight(float value) {
+        HPDF_Page_SetHeight(hpage, value);
+    }
+
+    public void SetSize(HPdfPageSizes size,
+            HPdfPageDirection direction) {
+        HPDF_Page_SetSize(hpage, size, direction);
+    }
+
+    public void SetRotate(ushort angle) {
+        HPDF_Page_SetRotate(hpage, angle);
+    }
+
+    public HPdfDestination CreateDestination() {
+        IntPtr hdest;
+
+        hdest = HPDF_Page_CreateDestination(hpage);
+        return new HPdfDestination(hdest);
+    }
+
+    public HPdfAnnotation CreateTextAnnot(HPdfRect rect, string text,
+            HPdfEncoder encoder) {
+        IntPtr hannot;
+
+        hannot = HPDF_Page_CreateTextAnnot(hpage, rect, text, encoder.GetHandle());
+        return new HPdfAnnotation(hannot);
+    }
+
+    public HPdfAnnotation CreateLinkAnnot(HPdfRect rect, HPdfDestination dst) {
+        IntPtr hannot;
+
+        hannot = HPDF_Page_CreateLinkAnnot(hpage, rect, dst.GetHandle());
+        return new HPdfAnnotation(hannot);
+    }
+
+    public HPdfAnnotation CreateURILinkAnnot(HPdfRect rect, string uri) {
+        IntPtr hannot;
+
+        hannot = HPDF_Page_CreateURILinkAnnot(hpage, rect, uri);
+        return new HPdfAnnotation(hannot);
+    }
+
+
+    public float TextWidth(string text) {
+        return HPDF_Page_TextWidth(hpage, text);
+    }
+
+    public uint MeasureText(string text, float width, bool wordwrap,
+                ref float real_width) {
+        int ww;
+
+        if (wordwrap)
+            ww = HPDF_TRUE;
+        else
+            ww = HPDF_FALSE;
+
+        return HPDF_Page_MeasureText(hpage, text, width, ww, ref real_width);
+    }
+
+    public uint MeasureText(string text, float width, bool wordwrap) {
+        float dummy = 0;
+        int ww;
+
+        if (wordwrap)
+            ww = HPDF_TRUE;
+        else
+            ww = HPDF_FALSE;
+
+        return HPDF_Page_MeasureText(hpage, text, width, ww, ref dummy);
+    }
+
+    public float GetWidth() {
+        return HPDF_Page_GetWidth(hpage);
+    }
+
+    public float GetHeight() {
+        return HPDF_Page_GetHeight(hpage);
+    }
+
+    public ushort GetGMode() {
+        return HPDF_Page_GetGMode(hpage);
+    }
+
+    public HPdfPoint GetCurrentPos() {
+        return HPDF_Page_GetCurrentPos(hpage);
+    }
+
+    public HPdfPoint GetCurrentTextPos() {
+        return HPDF_Page_GetCurrentTextPos(hpage);
+    }
+
+    public HPdfFont GetCurrentFont() {
+        return new HPdfFont(HPDF_Page_GetCurrentFont(hpage));
+    }
+
+    public float GetCurrentFontSize() {
+        return HPDF_Page_GetCurrentFontSize(hpage);
+    }
+
+    public HPdfTransMatrix GetTransMatrix() {
+        return HPDF_Page_GetTransMatrix(hpage);
+    }
+
+    public float GetLineWidth() {
+        return HPDF_Page_GetLineWidth(hpage);
+    }
+
+    public HPdfLineCap GetLineCap() {
+        return HPDF_Page_GetLineCap(hpage);
+    }
+
+    public HPdfLineJoin GetLineJoin() {
+        return HPDF_Page_GetLineJoin(hpage);
+    }
+
+    public float GetMiterLimit() {
+        return HPDF_Page_GetMiterLimit(hpage);
+    }
+
+    public HPdfDashMode GetDash() {
+        HPdfDashMode_Internal mode1 = HPDF_Page_GetDash(hpage);
+        HPdfDashMode mode2;
+
+        mode2.phase = mode1.phase;
+        mode2.ptn = new ushort[mode1.num_ptn];
+
+        if (mode1.num_ptn >= 1)
+            mode2.ptn[0] = mode1.ptn0;
+
+        if (mode1.num_ptn >= 2)
+            mode2.ptn[1] = mode1.ptn1;
+
+        if (mode1.num_ptn >= 3)
+            mode2.ptn[2] = mode1.ptn2;
+
+        if (mode1.num_ptn >= 4)
+            mode2.ptn[3] = mode1.ptn3;
+
+        if (mode1.num_ptn >= 5)
+            mode2.ptn[4] = mode1.ptn4;
+
+        if (mode1.num_ptn >= 6)
+            mode2.ptn[5] = mode1.ptn5;
+
+        if (mode1.num_ptn >= 7)
+            mode2.ptn[6] = mode1.ptn6;
+
+        if (mode1.num_ptn >= 8)
+            mode2.ptn[7] = mode1.ptn7;
+
+        return mode2;
+    }
+
+    public float GetFlat() {
+        return HPDF_Page_GetFlat(hpage);
+    }
+
+    public float GetCharSpace() {
+        return HPDF_Page_GetCharSpace(hpage);
+    }
+
+    public float GetWordSpace() {
+        return HPDF_Page_GetWordSpace(hpage);
+    }
+
+    public float GetHorizontalScalling() {
+        return HPDF_Page_GetHorizontalScalling(hpage);
+    }
+
+    public float GetTextLeading() {
+        return HPDF_Page_GetTextLeading(hpage);
+    }
+
+    public HPdfTextRenderingMode GetTextRenderingMode() {
+        return HPDF_Page_GetTextRenderingMode(hpage);
+    }
+
+    public float GetTextRaise() {
+        return HPDF_Page_GetTextRaise(hpage);
+    }
+
+    public HPdfRGBColor GetRGBFill() {
+        return HPDF_Page_GetRGBFill(hpage);
+    }
+
+    public HPdfRGBColor GetRGBStroke() {
+        return HPDF_Page_GetRGBStroke(hpage);
+    }
+
+    public HPdfCMYKColor GetCMYKFill() {
+        return HPDF_Page_GetCMYKFill(hpage);
+    }
+
+    public HPdfCMYKColor GetCMYKStroke() {
+        return HPDF_Page_GetCMYKStroke(hpage);
+    }
+
+    public float GetGrayFill() {
+        return HPDF_Page_GetGrayFill(hpage);
+    }
+
+    public float GetGrayStroke() {
+        return HPDF_Page_GetGrayStroke(hpage);
+    }
+
+    public HPdfColorSpace GetStrokingColorSpace() {
+        return HPDF_Page_GetStrokingColorSpace(hpage);
+    }
+
+    public HPdfColorSpace GetFillingColorSpace() {
+        return HPDF_Page_GetFillingColorSpace(hpage);
+    }
+
+    public HPdfTransMatrix GetTextMatrix() {
+        return HPDF_Page_GetTextMatrix(hpage);
+    }
+
+    public uint GetGStateDepth() {
+        return HPDF_Page_GetGStateDepth(hpage);
+    }
+
+    public void SetLineWidth(float line_width) {
+        HPDF_Page_SetLineWidth(hpage, line_width);
+    }
+
+    public void SetLineCap(HPdfLineCap line_cap) {
+        HPDF_Page_SetLineCap(hpage, line_cap);
+    }
+
+    public void SetLineJoin(HPdfLineJoin line_join) {
+        HPDF_Page_SetLineJoin(hpage, line_join);
+    }
+
+    public void SetMiterLimit(float miter_limit) {
+        HPDF_Page_SetMiterLimit(hpage, miter_limit);
+    }
+
+    public void SetDash(ushort[] dash_ptn, uint phase) {
+        if (dash_ptn == null) {
+            HPDF_Page_SetDash(hpage, dash_ptn, 0, 0);
+            return;
+        }
+
+        int len = dash_ptn.Length;
+
+        HPDF_Page_SetDash(hpage, dash_ptn, (uint)len, phase);
+    }
+
+    public void SetFlat(float flatness) {
+        HPDF_Page_SetFlat(hpage, flatness);
+    }
+
+    public void SetExtGState(HPdfExtGState gstate) {
+        HPDF_Page_SetExtGState(hpage, gstate.GetHandle());
+    }
+
+    public void GSave() {
+        HPDF_Page_GSave(hpage);
+    }
+
+    public void GRestore() {
+        HPDF_Page_GRestore(hpage);
+    }
+
+    public void Concat(float a, float b, float c, float d, float x, float y) {
+        HPDF_Page_Concat(hpage, a, b, c, d, x, y);
+    }
+
+    public void MoveTo(float x, float y) {
+        HPDF_Page_MoveTo(hpage, x, y);
+    }
+
+    public void LineTo(float x, float y) {
+        HPDF_Page_LineTo(hpage, x, y);
+    }
+
+    public void CurveTo(float x1, float y1, float x2, float y2,
+                float x3, float y3) {
+        HPDF_Page_CurveTo(hpage, x1, y1, x2, y2, x3, y3);
+    }
+
+    public void CurveTo2(float x2, float y2, float x3, float y3) {
+        HPDF_Page_CurveTo2(hpage, x2, y2, x3, y3);
+    }
+
+    public void CurveTo3(float x1, float y1, float x3, float y3) {
+        HPDF_Page_CurveTo2(hpage, x1, y1, x3, y3);
+    }
+
+    public void ClosePath() {
+        HPDF_Page_ClosePath(hpage);
+    }
+
+    public void Rectangle(float x, float y, float width, float height) {
+        HPDF_Page_Rectangle(hpage, x, y, width, height);
+    }
+
+    public void Stroke() {
+        HPDF_Page_Stroke(hpage);
+    }
+
+    public void ClosePathStroke() {
+        HPDF_Page_ClosePathStroke(hpage);
+    }
+
+    public void Fill() {
+        HPDF_Page_Fill(hpage);
+    }
+
+    public void Eofill() {
+        HPDF_Page_Eofill(hpage);
+    }
+
+    public void FillStroke() {
+        HPDF_Page_FillStroke(hpage);
+    }
+
+    public void EofillStroke() {
+        HPDF_Page_EofillStroke(hpage);
+    }
+
+    public void ClosePathFillStroke() {
+        HPDF_Page_ClosePathFillStroke(hpage);
+    }
+
+    public void ClosePathEofillStroke() {
+        HPDF_Page_ClosePathEofillStroke(hpage);
+    }
+
+    public void EndPath() {
+        HPDF_Page_EndPath(hpage);
+    }
+
+    public void Clip() {
+        HPDF_Page_Clip(hpage);
+    }
+
+    public void Eoclip() {
+        HPDF_Page_Eoclip(hpage);
+    }
+
+    public void BeginText() {
+        HPDF_Page_BeginText(hpage);
+    }
+
+    public void EndText() {
+        HPDF_Page_EndText(hpage);
+    }
+
+    public void SetCharSpace(float value) {
+        HPDF_Page_SetCharSpace(hpage, value);
+    }
+
+    public void SetWordSpace(float value) {
+        HPDF_Page_SetWordSpace(hpage, value);
+    }
+
+    public void SetHorizontalScalling(float value) {
+        HPDF_Page_SetHorizontalScalling(hpage, value);
+    }
+
+    public void SetTextLeading(float value) {
+        HPDF_Page_SetTextLeading(hpage, value);
+    }
+
+    public void SetFontAndSize(HPdfFont font, float size) {
+        HPDF_Page_SetFontAndSize(hpage, font.GetHandle(), size);
+    }
+
+    public void SetTextRenderingMode(HPdfTextRenderingMode  mode) {
+        HPDF_Page_SetTextRenderingMode(hpage, mode);
+    }
+
+    public void SetTextRaise(float  value) {
+        HPDF_Page_SetTextRaise(hpage, value);
+    }
+
+    public void MoveTextPos(float x, float y) {
+        HPDF_Page_MoveTextPos(hpage, x, y);
+    }
+
+    public void MoveTextPos2(float x, float y) {
+        HPDF_Page_MoveTextPos2(hpage, x, y);
+    }
+
+    public void SetTextMatrix(float a, float b, float c, float d, float x, float y) {
+        HPDF_Page_SetTextMatrix(hpage, a, b, c, d, x, y);
+    }
+
+    public void MoveToNextLine() {
+        HPDF_Page_MoveToNextLine(hpage);
+    }
+
+    public void ShowText(string text) {
+        HPDF_Page_ShowText(hpage, text);
+    }
+
+    public void ShowTextNextLine(string text) {
+        HPDF_Page_ShowTextNextLine(hpage, text);
+    }
+
+    public void ShowTextNextLineEx(float word_space, float char_space,
+                string text) {
+        HPDF_Page_ShowTextNextLineEx(hpage, word_space, char_space, text);
+    }
+
+    public void SetGrayFill(float gray) {
+        HPDF_Page_SetGrayFill(hpage, gray);
+    }
+
+    public void SetGrayStroke(float gray) {
+        HPDF_Page_SetGrayStroke(hpage, gray);
+    }
+
+    public void SetRGBFill(float r, float g, float b) {
+        HPDF_Page_SetRGBFill(hpage, r, g, b);
+    }
+
+    public void SetRGBStroke(float r, float g, float b) {
+        HPDF_Page_SetRGBStroke(hpage, r, g, b);
+    }
+
+    public void SetCMYKFill(float c, float m, float y, float k) {
+        HPDF_Page_SetCMYKFill(hpage, c, m, y, k);
+    }
+
+    public void SetCMYKStroke(float c, float m, float y, float k) {
+        HPDF_Page_SetCMYKStroke(hpage, c, m, y, k);
+    }
+
+    public void ExecuteXObject(HPdfImage xobj) {
+        HPDF_Page_ExecuteXObject(hpage, xobj.GetHandle());
+    }
+
+    public void DrawImage(HPdfImage image, float x, float y,
+                float width, float height) {
+        HPDF_Page_DrawImage(hpage, image.GetHandle(), x, y, width, height);
+    }
+
+    public void Circle(float x, float y, float ray) {
+        HPDF_Page_Circle(hpage, x, y, ray);
+    }
+
+    public void Arc(float x, float y, float ray, float ang1, float ang2) {
+        HPDF_Page_Arc(hpage, x, y, ray, ang1, ang2);
+    }
+
+    public void TextOut(float xpos, float ypos, string text) {
+        HPDF_Page_TextOut(hpage, xpos, ypos, text);
+    }
+
+    public void TextRect(float left, float top, float right,
+                float bottom, string text, HPdfTextAlignment align,
+                ref uint len) {
+        HPDF_Page_TextRect(hpage, left, top, right, bottom, text, align, ref len);
+    }
+
+    public void SetSlideShow(HPdfTransitionStyle type, float disp_time,
+                float trans_time) {
+        HPDF_Page_SetSlideShow(hpage, type, disp_time, trans_time);
+    }
+
+    public IntPtr GetHandle() {
+        return hpage;
+    }
+}
+
+public class HPdfFont {
+    [DllImport("libhpdf.dll")]
+    private extern static string HPDF_Font_GetFontName(IntPtr hfont);
+
+    [DllImport("libhpdf.dll")]
+    private extern static string HPDF_Font_GetEncodingName(IntPtr hfont);
+
+    [DllImport("libhpdf.dll")]
+    private extern static int HPDF_Font_GetUnicodeWidth(IntPtr hfont,
+            ushort code);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfBox HPDF_Font_GetBBox(IntPtr hfont);
+
+    [DllImport("libhpdf.dll")]
+    private extern static int HPDF_Font_GetAscent(IntPtr hfont);
+
+    [DllImport("libhpdf.dll")]
+    private extern static int HPDF_Font_GetDescent(IntPtr hfont);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Font_GetXHeight(IntPtr hfont);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Font_GetCapHeight(IntPtr hfont);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfTextWidth HPDF_Font_TextWidth(IntPtr hfont,
+            string text, uint len);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Font_MeasureText(IntPtr hfont,
+            string text, uint len, float width, float font_size,
+            float char_space, float word_space, int wordwrap,
+            ref float real_width);
+
+
+    IntPtr hfont;
+
+    public HPdfFont(IntPtr hfont) {
+        if (hfont == IntPtr.Zero) {
+            throw new Exception("cannot create HPdfFont object.");
+        }
+
+        this.hfont = hfont;
+    }
+
+    public IntPtr GetHandle() {
+        return hfont;
+    }
+
+    public string GetFontName() {
+        return HPDF_Font_GetFontName(hfont);
+    }
+
+    public string GetEncodingName() {
+        return HPDF_Font_GetEncodingName(hfont);
+    }
+
+    public int GetUnicodeWidth(ushort code) {
+        return HPDF_Font_GetUnicodeWidth(hfont, code);
+    }
+
+    public HPdfBox GetBBox() {
+        return HPDF_Font_GetBBox(hfont);
+    }
+
+    public int GetAscent() {
+        return HPDF_Font_GetAscent(hfont);
+    }
+
+    public int GetDescent() {
+        return HPDF_Font_GetDescent(hfont);
+    }
+
+    public uint GetXHeight() {
+        return HPDF_Font_GetXHeight(hfont);
+    }
+
+    public uint GetCapHeight() {
+        return HPDF_Font_GetCapHeight(hfont);
+    }
+
+    public HPdfTextWidth TextWidth(string text, uint len) {
+        return HPDF_Font_TextWidth(hfont, text, len);
+    }
+
+    public uint MeasureText(string text, uint len, float width,
+            float font_size, float char_space, float word_space,
+            int wordwrap, ref float real_width) {
+        return HPDF_Font_MeasureText(hfont, text, len, width, font_size,
+            char_space, word_space, wordwrap,
+            ref real_width);
+    }
+}
+
+public class HPdfOutline {
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Outline_SetOpened(IntPtr houtline,
+        int opened);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Outline_SetDestination(IntPtr houtline,
+        IntPtr hdest);
+
+    IntPtr houtline;
+
+    public HPdfOutline(IntPtr houtline) {
+        if (houtline == IntPtr.Zero) {
+            throw new Exception("cannot create HPdfOutline object.");
+        }
+
+        this.houtline = houtline;
+    }
+
+    public IntPtr GetHandle() {
+        return houtline;
+    }
+
+    public void SetOpened(bool opened) {
+        int iopened;
+
+        if (opened)
+            iopened = HPdfDoc.HPDF_TRUE;
+        else
+            iopened = HPdfDoc.HPDF_FALSE;
+
+        HPDF_Outline_SetOpened(houtline, iopened);
+    }
+
+    public void SetDestination(HPdfDestination dest) {
+        HPDF_Outline_SetDestination(houtline, dest.GetHandle());
+    }
+}
+
+public class HPdfEncoder {
+    IntPtr hencoder;
+
+    public HPdfEncoder(IntPtr hencoder) {
+        if (hencoder == IntPtr.Zero) {
+            throw new Exception("cannot create HPdfEncoder object.");
+        }
+
+        this.hencoder = hencoder;
+    }
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfEncoderType HPDF_Encoder_GetType(IntPtr
+                hencoder);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfByteType HPDF_Encoder_GetByteType(IntPtr
+                hencoder, string text, uint index);
+
+    [DllImport("libhpdf.dll")]
+    private extern static ushort HPDF_Encoder_GetUnicode(IntPtr
+                hencoder, ushort code);
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfWritingMode HPDF_Encoder_GetWritingMode(IntPtr
+                hencoder);
+
+
+    public IntPtr GetHandle() {
+        return hencoder;
+    }
+
+    public HPdfEncoderType GetEncoderType() {
+        return HPDF_Encoder_GetType(hencoder);
+    }
+
+    public HPdfByteType GetByteType(string text, uint index) {
+        return HPDF_Encoder_GetByteType(hencoder, text, index);
+    }
+
+    public ushort GetUnicode(ushort code) {
+        return HPDF_Encoder_GetUnicode(hencoder, code);
+    }
+
+    public HPdfWritingMode GetWritingMode() {
+        return HPDF_Encoder_GetWritingMode(hencoder);
+    }
+
+}
+
+public class HPdfDestination {
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Destination_SetXYZ(IntPtr hdest,
+        float left, float top, float zoom);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Destination_SetFit(IntPtr hdest);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Destination_SetFitH(IntPtr hdest,
+        float top);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Destination_SetFitV(IntPtr hdest,
+        float left);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Destination_SetFitR(IntPtr hdest,
+        float left, float bottom, float right, float top);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Destination_SetFitB(IntPtr hdest);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Destination_SetFitBH(IntPtr hdest,
+        float top);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Destination_SetFitBV(IntPtr hdest,
+        float left);
+
+    IntPtr hdest;
+
+    public HPdfDestination(IntPtr hdest) {
+        if (hdest == IntPtr.Zero) {
+            throw new Exception("cannot create HPdfDestination object.");
+        }
+
+        this.hdest = hdest;
+    }
+
+    public void SetXYZ(float left, float top, float zoom) {
+        HPDF_Destination_SetXYZ(hdest, left, top, zoom);
+    }
+
+    public void SetFit() {
+        HPDF_Destination_SetFit(hdest);
+    }
+
+    public void SetFitH(float top) {
+        HPDF_Destination_SetFitH(hdest, top);
+    }
+
+    public void SetFitV(float left) {
+        HPDF_Destination_SetFitV(hdest, left);
+    }
+
+    public void SetFitR(float left, float bottom, float right, float top) {
+        HPDF_Destination_SetFitR(hdest, left, bottom, right, top);
+    }
+
+    public void SetFitB() {
+        HPDF_Destination_SetFitB(hdest);
+    }
+
+    public void SetFitBH(float top) {
+        HPDF_Destination_SetFitBH(hdest, top);
+    }
+
+    public void SetFitBV(float left) {
+        HPDF_Destination_SetFitBV(hdest, left);
+    }
+
+    public IntPtr GetHandle() {
+        return hdest;
+    }
+}
+
+public class HPdfAnnotation {
+    IntPtr hannot;
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_LinkAnnot_SetHighlightMode(IntPtr hannot,
+        HPdfAnnotHighlightMode mode);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_LinkAnnot_SetBorderStyle(IntPtr hannot,
+        float width, ushort dash_on, ushort dash_off);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_TextAnnot_SetIcon(IntPtr hannot,
+        HPdfAnnotIcon icon);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_TextAnnot_SetOpened(IntPtr hannot,
+        int opened);
+
+
+    public HPdfAnnotation(IntPtr hannot) {
+        if (hannot == IntPtr.Zero) {
+            throw new Exception("cannot create HPdfAnnotation object.");
+        }
+
+        this.hannot = hannot;
+    }
+
+    public IntPtr GetHandle() {
+        return hannot;
+    }
+
+    public void SetHighlightMode(HPdfAnnotHighlightMode mode) {
+        HPDF_LinkAnnot_SetHighlightMode(hannot, mode);
+    }
+
+    public void SetBorderStyle(float width, ushort dash_on, ushort dash_off) {
+        HPDF_LinkAnnot_SetBorderStyle(hannot, width, dash_on, dash_off);
+    }
+
+    public void SetIcon(HPdfAnnotIcon icon) {
+        HPDF_TextAnnot_SetIcon(hannot, icon);
+    }
+
+    public void SetOpened(bool opened) {
+        int flg;
+
+        if (opened)
+            flg = HPdfDoc.HPDF_TRUE;
+        else
+            flg = HPdfDoc.HPDF_FALSE;
+
+        HPDF_TextAnnot_SetOpened(hannot, flg);
+    }
+
+}
+
+public class HPdfXObject {
+    protected IntPtr hobj;
+
+    public HPdfXObject(IntPtr hobj) {
+        if (hobj == IntPtr.Zero) {
+            throw new Exception("cannot create HPdfImage object.");
+        }
+
+        this.hobj = hobj;
+    }
+
+    public IntPtr GetHandle() {
+        return hobj;
+    }
+}
+
+public class HPdfImage: HPdfXObject {
+
+    [DllImport("libhpdf.dll")]
+    private extern static HPdfPoint HPDF_Image_GetSize(IntPtr image);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Image_GetWidth(IntPtr image);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Image_GetHeight(IntPtr image);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Image_GetBitsPerComponent(IntPtr image);
+
+    [DllImport("libhpdf.dll")]
+    private extern static string HPDF_Image_GetColorSpace(IntPtr image);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_Image_SetColorMask(IntPtr image,
+        uint rmin, uint rmax, uint gmin, uint gmax, uint bmin, uint bmax);
+
+    [DllImport("libhpdf.dll")]
+    private extern static string HPDF_Image_SetMaskImage(IntPtr image,
+        IntPtr mask_image);
+
+    public HPdfImage(IntPtr hobj): base (hobj)  {
+    }
+
+    public HPdfPoint GetSize() {
+        return HPDF_Image_GetSize(hobj);
+    }
+
+    public uint GetWidth() {
+        return HPDF_Image_GetWidth(hobj);
+    }
+
+    public uint GetHeight() {
+        return HPDF_Image_GetHeight(hobj);
+    }
+
+    public uint GetBitsPerComponent() {
+        return HPDF_Image_GetBitsPerComponent(hobj);
+    }
+
+    public string GetColorSpace() {
+        return HPDF_Image_GetColorSpace(hobj);
+    }
+
+    public void SetColorMask(uint rmin, uint rmax, uint gmin, uint gmax,
+            uint bmin, uint bmax) {
+        HPDF_Image_SetColorMask(hobj, rmin, rmax, gmin, gmax,
+            bmin, bmax);
+    }
+
+    public void SetMaskImage(HPdfImage mask_image) {
+        HPDF_Image_SetMaskImage(hobj, mask_image.GetHandle());
+    }
+}
+
+public class HPdfExtGState {
+    protected IntPtr hgstate;
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_ExtGState_SetAlphaStroke(IntPtr gstate,
+        float value);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_ExtGState_SetAlphaFill(IntPtr gstate,
+        float value);
+
+    [DllImport("libhpdf.dll")]
+    private extern static uint HPDF_ExtGState_SetBlendMode(IntPtr gstate,
+        HPdfBlendMode mode);
+
+    public HPdfExtGState(IntPtr hgstate) {
+        if (hgstate == IntPtr.Zero) {
+            throw new Exception("cannot create HPdfImage object.");
+        }
+
+        this.hgstate = hgstate;
+    }
+
+    public IntPtr GetHandle() {
+        return hgstate;
+    }
+
+    public void SetAlphaStroke(float value) {
+        HPDF_ExtGState_SetAlphaStroke(hgstate, value);
+    }
+
+    public void SetAlphaFill(float value) {
+        HPDF_ExtGState_SetAlphaFill(hgstate, value);
+    }
+
+    public void SetBlendMode(HPdfBlendMode mode) {
+        HPDF_ExtGState_SetBlendMode(hgstate, mode);
+    }
+
+
+
+
+}
+
+}
+
+

+ 212 - 0
pdf.mod/libharu/bindings/delphi/ExtGStateDemo.dpr

@@ -0,0 +1,212 @@
+{*
+ * << Haru Free PDF Library 2.0.5 >> -- ExtGStateDemo.dpr
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided 'as is' without express or implied warranty.
+ *
+ *}
+program LineDemo;
+
+{$APPTYPE CONSOLE}
+
+uses
+  SysUtils, hpdf, hpdf_types, hpdf_consts;
+
+procedure
+error_handler (error_no: HPDF_STATUS; detail_no: HPDF_STATUS;
+              user_data: Pointer); stdcall;
+var
+  message: string;
+begin
+  message := 'ERROR: ' + IntToStr(error_no) + '-' + IntToStr(detail_no);
+  raise Exception.Create(message);
+end;
+
+procedure draw_circles (page: HPDF_Page; const description: PChar; x: 
+            HPDF_REAL; y: HPDF_REAL);
+begin
+    HPDF_Page_SetLineWidth (page, 1.0);
+    HPDF_Page_SetRGBStroke (page, 0.0, 0.0, 0.0);
+    HPDF_Page_SetRGBFill (page, 1.0, 0.0, 0.0);
+    HPDF_Page_Circle (page,x +  40, y + 40, 40);
+    HPDF_Page_FillStroke (page);
+    HPDF_Page_SetRGBFill (page, 0.0, 1.0, 0.0);
+    HPDF_Page_Circle (page, x + 100, y + 40, 40);
+    HPDF_Page_FillStroke (page);
+    HPDF_Page_SetRGBFill (page, 0.0, 0.0, 1.0);
+    HPDF_Page_Circle (page, x + 70, y + 74.64, 40);
+    HPDF_Page_FillStroke (page);
+
+    HPDF_Page_SetRGBFill (page, 0.0, 0.0, 0.0);
+    HPDF_Page_BeginText (page);
+    HPDF_Page_TextOut (page, x + 0.0, y + 130.0, description);
+    HPDF_Page_EndText (page);
+end;
+
+procedure make_pdf ();
+const
+  fname: string = 'ExtGStateDemo.pdf';
+  PAGE_WIDTH: HPDF_REAL = 600;
+  PAGE_HEIGHT: HPDF_REAL = 900;
+var
+  pdf: HPDF_Doc;
+  font: HPDF_Font;
+  page: HPDF_Page;
+  gstate: HPDF_ExtGState;
+begin
+  pdf := HPDF_New(@error_handler, nil);
+  if pdf = nil then
+  begin
+    WriteLn('error: cannot create PdfDoc object\n');
+    Halt (1);
+  end;
+
+  try
+//    HPDF_SetCompressionMode(pdf, HPDF_COMP_ALL);
+
+    {* create default-font *}
+    font := HPDF_GetFont (pdf, 'Helvetica-Bold', nil);
+
+    {* add a new page object. *}
+    page := HPDF_AddPage(pdf);
+    HPDF_Page_SetFontAndSize (page, font, 10);
+
+    HPDF_Page_SetHeight (page, PAGE_HEIGHT);
+    HPDF_Page_SetWidth (page, PAGE_WIDTH);
+    
+
+    {* normal *}
+    HPDF_Page_GSave (page);
+    draw_circles (page, 'normal', 40.0, PAGE_HEIGHT - 170);
+    HPDF_Page_GRestore (page);
+
+    {* alpha fill *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetAlphaFill (gstate, 0.8);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'alpha fill = 0.8', 230.0, PAGE_HEIGHT - 170);
+    HPDF_Page_GRestore (page);
+
+    {* alpha stroke *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetAlphaFill (gstate, 0.4);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'alpha fill = 0.4', 420.0, PAGE_HEIGHT - 170);
+    HPDF_Page_GRestore (page);
+
+    {* blend-mode=HPDF_BM_MULTIPLY *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_MULTIPLY);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'HPDF_BM_MULTIPLY', 40.0, PAGE_HEIGHT - 340);
+    HPDF_Page_GRestore (page);
+
+    {* blend-mode=HPDF_BM_SCREEN *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_SCREEN);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'HPDF_BM_SCREEN', 230.0, PAGE_HEIGHT - 340);
+    HPDF_Page_GRestore (page);
+
+    {* blend-mode=HPDF_BM_OVERLAY *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_OVERLAY);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'HPDF_BM_OVERLAY', 420.0, PAGE_HEIGHT - 340);
+    HPDF_Page_GRestore (page);
+
+    {* blend-mode=HPDF_BM_DARKEN *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_DARKEN);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'HPDF_BM_DARKEN', 40.0, PAGE_HEIGHT - 510);
+    HPDF_Page_GRestore (page);
+
+    {* blend-mode=HPDF_BM_LIGHTEN *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_LIGHTEN);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'HPDF_BM_LIGHTEN', 230.0, PAGE_HEIGHT - 510);
+    HPDF_Page_GRestore (page);
+
+    {* blend-mode=HPDF_BM_COLOR_DODGE *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_COLOR_DODGE);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'HPDF_BM_COLOR_DODGE', 420.0, PAGE_HEIGHT - 510);
+    HPDF_Page_GRestore (page);
+
+    {* blend-mode=HPDF_BM_COLOR_BUM *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_COLOR_BUM);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'HPDF_BM_COLOR_BUM', 40.0, PAGE_HEIGHT - 680);
+    HPDF_Page_GRestore (page);
+
+    {* blend-mode=HPDF_BM_HARD_LIGHT *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_HARD_LIGHT);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'HPDF_BM_HARD_LIGHT', 230.0, PAGE_HEIGHT - 680);
+    HPDF_Page_GRestore (page);
+
+    {* blend-mode=HPDF_BM_SOFT_LIGHT *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_SOFT_LIGHT);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'HPDF_BM_SOFT_LIGHT', 420.0, PAGE_HEIGHT - 680);
+    HPDF_Page_GRestore (page);
+
+    {* blend-mode=HPDF_BM_DIFFERENCE *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_DIFFERENCE);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'HPDF_BM_DIFFERENCE', 40.0, PAGE_HEIGHT - 850);
+    HPDF_Page_GRestore (page);
+
+    {* blend-mode=HPDF_BM_EXCLUSHON *}
+    HPDF_Page_GSave (page);
+    gstate := HPDF_CreateExtGState (pdf);
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_EXCLUSHON);
+    HPDF_Page_SetExtGState (page, gstate);
+    draw_circles (page, 'HPDF_BM_EXCLUSHON', 230.0, PAGE_HEIGHT - 850);
+    HPDF_Page_GRestore (page);
+
+    {* save the document to a file *}
+    HPDF_SaveToFile (pdf, PChar(fname));
+
+  except
+    on e: Exception do
+    begin
+      Writeln (e.message);
+      HPDF_Free (pdf);
+      Halt (1);
+    end;
+  end;
+
+  {* clean up *}
+  HPDF_Free (pdf);
+end;
+
+begin
+  make_pdf;
+end.
+

+ 368 - 0
pdf.mod/libharu/bindings/delphi/LineDemo.dpr

@@ -0,0 +1,368 @@
+{*
+ * << Haru Free PDF Library 2.0.5 >> -- LineDemo.dpr
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided 'as is' without express or implied warranty.
+ *
+ *}
+program LineDemo;
+
+{$APPTYPE CONSOLE}
+
+uses
+  SysUtils, hpdf, hpdf_types, hpdf_consts;
+
+procedure
+error_handler (error_no: HPDF_STATUS; detail_no: HPDF_STATUS;
+              user_data: Pointer); stdcall;
+var
+  message: string;
+begin
+  message := 'ERROR: ' + IntToStr(error_no) + '-' + IntToStr(detail_no);
+  raise Exception.Create(message);
+end;
+
+procedure draw_line (page: HPDF_Page; x: Single; y: Single; const text: PChar);
+begin
+  HPDF_Page_BeginText(page);
+  HPDF_Page_MoveTextPos(page, x, y - 10);
+  HPDF_Page_ShowText(page, text);
+  HPDF_Page_EndText(page);
+
+  HPDF_Page_MoveTo(page, x, y - 15);
+  HPDF_Page_LineTo(page, x + 220, y - 15);
+  HPDF_Page_Stroke(page);
+end;
+
+procedure draw_line2 (page: HPDF_Page; x: Single; y: Single; const text: PChar);
+begin
+  HPDF_Page_BeginText(page);
+  HPDF_Page_MoveTextPos(page, x, y);
+  HPDF_Page_ShowText(page, text);
+  HPDF_Page_EndText(page);
+
+  HPDF_Page_MoveTo(page, x + 30, y - 25);
+  HPDF_Page_LineTo(page, x + 160, y - 25);
+  HPDF_Page_Stroke(page);
+end;
+
+procedure draw_rect (page: HPDF_Page; x: Single; y: Single; const text: PChar);
+begin
+  HPDF_Page_BeginText(page);
+  HPDF_Page_MoveTextPos(page, x, y - 10);
+  HPDF_Page_ShowText(page, text);
+  HPDF_Page_EndText(page);
+
+  HPDF_Page_Rectangle(page, x, y - 40, 220, 25);
+end;
+
+
+procedure make_pdf ();
+const
+  page_title: string = 'Line Demo';
+  fname: string = 'LineDemo.pdf';
+
+  DASH_MODE1: array[0..0] of HPDF_UINT16 = (3);
+  DASH_MODE2: array[0..1] of HPDF_UINT16 = (7, 3);
+  DASH_MODE3: array[0..3] of HPDF_UINT16 = (8, 7, 2, 7);
+var
+  pdf: HPDF_Doc;
+  font: HPDF_Font;
+  page: HPDF_Page;
+
+  x: Double;
+  y: Double;
+  x0: Double;
+  y0: Double;
+  x1: Double;
+  y1: Double;
+  x2: Double;
+  y2: Double;
+  x3: Double;
+  y3: Double;
+
+  tw: Single;
+begin
+  pdf := HPDF_New(@error_handler, nil);
+  if pdf = nil then
+  begin
+    WriteLn('error: cannot create PdfDoc object\n');
+    Halt (1);
+  end;
+
+  try
+    HPDF_SetCompressionMode(pdf, HPDF_COMP_ALL);
+
+    {* create default-font *}
+    font := HPDF_GetFont(pdf, 'Helvetica', nil);
+
+    {* add a new page object. *}
+    page := HPDF_AddPage(pdf);
+
+    {* print the lines of the page. *}
+    HPDF_Page_SetLineWidth(page, 1);
+    x := HPDF_Page_GetWidth(page) - 100;
+    y := HPDF_Page_GetHeight(page) - 110;
+    HPDF_Page_Rectangle(page, 50, 50, x, y);
+    HPDF_Page_Stroke(page);
+
+    {* print the title of the page (with positioning center). *}
+    HPDF_Page_SetFontAndSize(page, font, 24);
+    tw := HPDF_Page_TextWidth(page, PChar(page_title));
+    HPDF_Page_BeginText(page);
+
+    x := (HPDF_Page_GetWidth(page) - tw) / 2;
+    y := HPDF_Page_GetHeight(page) - 50;
+    HPDF_Page_MoveTextPos (page, x, y);
+
+    HPDF_Page_ShowText (page, PChar(page_title));
+    HPDF_Page_EndText (page);
+
+    HPDF_Page_SetFontAndSize (page, font, 10);
+
+    {* Draw various widths of lines. *}
+    HPDF_Page_SetLineWidth (page, 0);
+    draw_line (page, 60, 770, 'line width := 0');
+
+    HPDF_Page_SetLineWidth (page, 1.0);
+    draw_line (page, 60, 740, 'line width := 1.0');
+
+    HPDF_Page_SetLineWidth (page, 2.0);
+    draw_line (page, 60, 710, 'line width := 2.0');
+
+    {* Line dash pattern *}
+    HPDF_Page_SetLineWidth (page, 1.0);
+
+    HPDF_Page_SetDash (page, @DASH_MODE1, 1, 1);
+    draw_line (page, 60, 680, 'dash_ptn=[3], phase=1 -- 2 on, 3 off, 3 on...');
+
+    HPDF_Page_SetDash (page, @DASH_MODE2, 2, 2);
+    draw_line (page, 60, 650, 'dash_ptn=[7, 3], phase=2 -- 5 on 3 off, 7 on,...');
+
+    HPDF_Page_SetDash (page, @DASH_MODE3, 4, 0);
+    draw_line (page, 60, 620, 'dash_ptn=[8, 7, 2, 7], phase=0');
+
+    HPDF_Page_SetDash (page, nil, 0, 0);
+
+    HPDF_Page_SetLineWidth (page, 30);
+    HPDF_Page_SetRGBStroke (page, 0.0, 0.5, 0.0);
+
+    {* Line Cap Style *}
+    HPDF_Page_SetLineCap (page, HPDF_BUTT_END);
+    draw_line2 (page, 60, 570, 'PDF_BUTT_END');
+
+    HPDF_Page_SetLineCap (page, HPDF_ROUND_END);
+    draw_line2 (page, 60, 505, 'PDF_ROUND_END');
+
+    HPDF_Page_SetLineCap (page, HPDF_PROJECTING_SQUARE_END);
+    draw_line2 (page, 60, 440, 'PDF_PROJECTING_SCUARE_END');
+
+    {* Line Join Style *}
+    HPDF_Page_SetLineWidth (page, 30);
+    HPDF_Page_SetRGBStroke (page, 0.0, 0.0, 0.5);
+
+    HPDF_Page_SetLineJoin (page, HPDF_MITER_JOIN);
+    HPDF_Page_MoveTo (page, 120, 300);
+    HPDF_Page_LineTo (page, 160, 340);
+    HPDF_Page_LineTo (page, 200, 300);
+    HPDF_Page_Stroke (page);
+
+    HPDF_Page_BeginText (page);
+    HPDF_Page_MoveTextPos (page, 60, 360);
+    HPDF_Page_ShowText (page, 'PDF_MITER_JOIN');
+    HPDF_Page_EndText (page);
+
+    HPDF_Page_SetLineJoin (page, HPDF_ROUND_JOIN);
+    HPDF_Page_MoveTo (page, 120, 195);
+    HPDF_Page_LineTo (page, 160, 235);
+    HPDF_Page_LineTo (page, 200, 195);
+    HPDF_Page_Stroke (page);
+
+    HPDF_Page_BeginText (page);
+    HPDF_Page_MoveTextPos (page, 60, 255);
+    HPDF_Page_ShowText (page, 'PDF_ROUND_JOIN');
+    HPDF_Page_EndText (page);
+
+    HPDF_Page_SetLineJoin (page, HPDF_BEVEL_JOIN);
+    HPDF_Page_MoveTo (page, 120, 90);
+    HPDF_Page_LineTo (page, 160, 130);
+    HPDF_Page_LineTo (page, 200, 90);
+    HPDF_Page_Stroke (page);
+
+    HPDF_Page_BeginText (page);
+    HPDF_Page_MoveTextPos (page, 60, 150);
+    HPDF_Page_ShowText (page, 'PDF_BEVEL_JOIN');
+    HPDF_Page_EndText (page);
+
+    {* Draw Rectangle *}
+    HPDF_Page_SetLineWidth (page, 2);
+    HPDF_Page_SetRGBStroke (page, 0, 0, 0);
+    HPDF_Page_SetRGBFill (page, 0.75, 0.0, 0.0);
+
+    draw_rect (page, 300, 770, 'Stroke');
+    HPDF_Page_Stroke (page);
+
+    draw_rect (page, 300, 720, 'Fill');
+    HPDF_Page_Fill (page);
+
+    draw_rect (page, 300, 670, 'Fill then Stroke');
+    HPDF_Page_FillStroke (page);
+
+    {* Clip Rect *}
+    HPDF_Page_GSave (page);  {* Save the current graphic state *}
+    draw_rect (page, 300, 620, 'Clip Rectangle');
+    HPDF_Page_Clip (page);
+    HPDF_Page_Stroke (page);
+    HPDF_Page_SetFontAndSize (page, font, 13);
+
+    HPDF_Page_BeginText (page);
+    HPDF_Page_MoveTextPos (page, 290, 600);
+    HPDF_Page_SetTextLeading (page, 12);
+    HPDF_Page_ShowText (page,
+                'Clip Clip Clip Clip Clip Clipi Clip Clip Clip');
+    HPDF_Page_ShowTextNextLine (page,
+                'Clip Clip Clip Clip Clip Clip Clip Clip Clip');
+    HPDF_Page_ShowTextNextLine (page,
+               'Clip Clip Clip Clip Clip Clip Clip Clip Clip');
+    HPDF_Page_EndText (page);
+    HPDF_Page_GRestore (page);
+
+    x0 := 330;
+    y0 := 440;
+    x1 := 430;
+    y1 := 530;
+    x2 := 480;
+    y2 := 470;
+    x3 := 480;
+    y3 := 90;
+
+    {* Curve Example(CurveTo2) *}
+    HPDF_Page_SetRGBFill (page, 0, 0, 0);
+
+    HPDF_Page_BeginText (page);
+    HPDF_Page_MoveTextPos (page, 300, 540);
+    HPDF_Page_ShowText (page, 'CurveTo2(x1, y1, x2. y2)');
+    HPDF_Page_EndText (page);
+
+    HPDF_Page_BeginText (page);
+    HPDF_Page_MoveTextPos (page, x0 + 5, y0 - 5);
+    HPDF_Page_ShowText (page, 'Current point');
+    HPDF_Page_MoveTextPos (page, x1 - x0, y1 - y0);
+    HPDF_Page_ShowText (page, '(x1, y1)');
+    HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1);
+    HPDF_Page_ShowText (page, '(x2, y2)');
+    HPDF_Page_EndText (page);
+
+    HPDF_Page_SetDash (page, nil, 0, 0);
+
+    HPDF_Page_SetLineWidth (page, 0.5);
+    HPDF_Page_MoveTo (page, x1, y1);
+    HPDF_Page_LineTo (page, x2, y2);
+    HPDF_Page_Stroke (page);
+
+    HPDF_Page_SetDash (page, nil, 0, 0);
+
+    HPDF_Page_SetLineWidth (page, 1.5);
+
+    HPDF_Page_MoveTo (page, x0, y0);
+    HPDF_Page_CurveTo2 (page, x1, y1, x2, y2);
+    HPDF_Page_Stroke (page);
+
+    {* Curve Example(CurveTo3) *}
+    y0 := y0 - 150;
+    y1 := y1 - 150;
+    y2 := y2 - 150;
+
+    HPDF_Page_BeginText (page);
+    HPDF_Page_MoveTextPos (page, 300, 390);
+    HPDF_Page_ShowText (page, 'CurveTo3(x1, y1, x2. y2)');
+    HPDF_Page_EndText (page);
+
+    HPDF_Page_BeginText (page);
+    HPDF_Page_MoveTextPos (page, x0 + 5, y0 - 5);
+    HPDF_Page_ShowText (page, 'Current point');
+    HPDF_Page_MoveTextPos (page, x1 - x0, y1 - y0);
+    HPDF_Page_ShowText (page, '(x1, y1)');
+    HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1);
+    HPDF_Page_ShowText (page, '(x2, y2)');
+    HPDF_Page_EndText (page);
+
+    HPDF_Page_SetDash (page, @DASH_MODE1, 1, 1);
+
+    HPDF_Page_SetLineWidth (page, 0.5);
+    HPDF_Page_MoveTo (page, x0, y0);
+    HPDF_Page_LineTo (page, x1, y1);
+    HPDF_Page_Stroke (page);
+
+    HPDF_Page_SetDash (page, nil, 0, 0);
+
+    HPDF_Page_SetLineWidth (page, 1.5);
+    HPDF_Page_MoveTo (page, x0, y0);
+    HPDF_Page_CurveTo3 (page, x1, y1, x2, y2);
+    HPDF_Page_Stroke (page);
+
+    {* Curve Example(CurveTo) *}
+    y0 := y0 - 150;
+    y1 := y1 - 160;
+    y2 := y2 - 130;
+    x2 := x2 + 10;
+
+    HPDF_Page_BeginText (page);
+    HPDF_Page_MoveTextPos (page, 300, 240);
+    HPDF_Page_ShowText (page, 'CurveTo(x1, y1, x2. y2, x3, y3)');
+    HPDF_Page_EndText (page);
+
+    HPDF_Page_BeginText (page);
+    HPDF_Page_MoveTextPos (page, x0 + 5, y0 - 5);
+    HPDF_Page_ShowText (page, 'Current point');
+    HPDF_Page_MoveTextPos (page, x1 - x0, y1 - y0);
+    HPDF_Page_ShowText (page, '(x1, y1)');
+    HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1);
+    HPDF_Page_ShowText (page, '(x2, y2)');
+    HPDF_Page_MoveTextPos (page, x3 - x2, y3 - y2);
+    HPDF_Page_ShowText (page, '(x3, y3)');
+    HPDF_Page_EndText (page);
+
+    HPDF_Page_SetDash (page, @DASH_MODE1, 1, 1);
+
+    HPDF_Page_SetLineWidth (page, 0.5);
+    HPDF_Page_MoveTo (page, x0, y0);
+    HPDF_Page_LineTo (page, x1, y1);
+    HPDF_Page_Stroke (page);
+    HPDF_Page_MoveTo (page, x2, y2);
+    HPDF_Page_LineTo (page, x3, y3);
+    HPDF_Page_Stroke (page);
+
+    HPDF_Page_SetDash (page, nil, 0, 0);
+
+    HPDF_Page_SetLineWidth (page, 1.5);
+    HPDF_Page_MoveTo (page, x0, y0);
+    HPDF_Page_CurveTo (page, x1, y1, x2, y2, x3, y3);
+    HPDF_Page_Stroke (page);
+
+    {* save the document to a file *}
+    HPDF_SaveToFile (pdf, PChar(fname));
+
+  except
+    on e: Exception do
+    begin
+      Writeln (e.message);
+      HPDF_Free (pdf);
+      Halt (1);
+    end;
+  end;
+
+  {* clean up *}
+  HPDF_Free (pdf);
+end;
+
+begin
+  make_pdf;
+end.
+

+ 26 - 0
pdf.mod/libharu/bindings/delphi/README.delphi

@@ -0,0 +1,26 @@
+To use this interface, built Haru as a shared-library (DLL) or use binary 
+package for win32(libharu_x_x_x_dll_win32.zip).
+
+There are some example programs in this directory. The steps to run the 
+demonstration programs is as follows. 
+
+1. Build libharu as a shared library and copy libhpdf.dll to "if\delphi"
+   directory. (Or expand binary package for win32(libharu_x_x_x_dll_win32.zip) 
+   and copy libhpdf.dll to "if\delphi" directory.)
+
+2. Compile and run demo programs. 
+
+   a)Delphi
+     Open XXXX.dpr and run it.
+
+   b)Free Pascal
+     Compile demo programs using '-Mdelphi' option as follows.
+
+     fpc -Mdelphi LineDemo.dpr
+     LineDemo.exe
+
+
+NOTE:
+libhpdf.dll is required to run the program which uses delphi/fpc interface for 
+libharu.
+

+ 872 - 0
pdf.mod/libharu/bindings/delphi/hpdf.pas

@@ -0,0 +1,872 @@
+{*
+ * << Haru Free PDF Library 2.0.6 >> -- hpdf.pas
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ *}
+
+unit hpdf;
+
+interface
+
+uses
+  SysUtils, hpdf_types;
+
+const
+  LIBHPDF_DLL = 'libhpdf.dll';
+
+{*
+  NOTE:
+
+  if you want to use Haru with Kylix/FreePascal on Linux,
+  change "libhpdf.dll" to "libhpdf.so" and change "stdcall" to "cdecl"
+  (This file and hpdf_types.pas)
+
+*}
+
+type
+  HPDF_HANDLE = Pointer;
+  HPDF_Doc = HPDF_HANDLE;
+  HPDF_Page = HPDF_HANDLE;
+  HPDF_Pages = HPDF_HANDLE;
+  HPDF_Stream = HPDF_HANDLE;
+  HPDF_Image = HPDF_HANDLE;
+  HPDF_Font = HPDF_HANDLE;
+  HPDF_Outline = HPDF_HANDLE;
+  HPDF_Encoder = HPDF_HANDLE;
+  HPDF_Destination = HPDF_HANDLE;
+  HPDF_XObject = HPDF_HANDLE;
+  HPDF_Annotation = HPDF_HANDLE;
+  HPDF_ExtGState = HPDF_HANDLE;
+  HPDF_CHAR = PChar;
+  HPDF_STATUS = Cardinal;
+
+function HPDF_NewEx (user_error_fn: THPDF_ErrorFunc;
+        user_alloc_fn: THPDF_AllocFunc; user_free_fn: THPDF_FreeFunc;
+        mem_pool_buf_size: HPDF_UINT; user_data: Pointer): HPDF_Doc;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_New (user_error_fn: THPDF_ErrorFunc; user_data: Pointer): HPDF_Doc;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetErrorHandler (pdf: HPDF_Doc; user_error_fn: THPDF_ErrorFunc):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+procedure HPDF_Free (pdf: HPDF_Doc); stdcall external LIBHPDF_DLL;
+
+
+function HPDF_NewDoc (pdf: HPDF_Doc): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+procedure HPDF_FreeDoc (pdf: HPDF_Doc); stdcall external LIBHPDF_DLL;
+
+
+function HPDF_HasDoc (pdf: HPDF_Doc): HPDF_BOOL; stdcall external LIBHPDF_DLL;
+
+
+procedure HPDF_FreeDocAll (pdf: HPDF_Doc); stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SaveToStream (pdf: HPDF_Doc): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_GetStreamSize (pdf: HPDF_Doc): HPDF_UINT32;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_ReadFromStream (pdf: HPDF_Doc; buf: HPDF_PBYTE; 
+         size: HPDF_PUINT): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_ResetStream (pdf: HPDF_Doc): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SaveToFile (pdf: HPDF_Doc; const file_name: HPDF_PCHAR): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_GetError (pdf: HPDF_Doc): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+procedure HPDF_ResetError (pdf: HPDF_Doc); stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetPagesConfiguration (pdf: HPDF_Doc; page_per_pages: HPDF_UINT):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_GetPageByIndex (pdf: HPDF_Doc; index: HPDF_UINT): HPDF_Page;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_GetPageLayout (pdf: HPDF_Doc): THPDF_PageLayout;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetPageLayout (pdf: HPDF_Doc; layout: THPDF_PageLayout): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_GetPageMode (pdf: HPDF_Doc): THPDF_PageMode;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetPageMode (pdf: HPDF_Doc; mode: THPDF_PageMode): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetOpenAction (pdf: HPDF_Doc; open_action: HPDF_Destination):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_GetViewerPreference (pdf: HPDF_Doc): HPDF_UINT;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetViewerPreference (pdf: HPDF_Doc; value: HPDF_UINT): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_GetCurrentPage (pdf: HPDF_Doc): HPDF_Page;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_AddPage (pdf: HPDF_Doc): HPDF_Page; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_InsertPage (pdf: HPDF_Doc; page: HPDF_Page): HPDF_Page;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetWidth (page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetHeight (page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetSize (page: HPDF_Page; size: THPDF_PageSizes;
+        direction: THPDF_PageDirection): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetRotate (page: HPDF_Page; angle: HPDF_UINT16): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+function HPDF_Page_SetZoom (page: HPDF_Page; zoom: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+function HPDF_GetFont (pdf: HPDF_Doc; const font_name: HPDF_PCHAR;
+        const encoding_name: HPDF_PCHAR): HPDF_Font; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_LoadType1FontFromFile (pdf: HPDF_Doc; afmfilename: HPDF_PCHAR;
+        pfmfilename: HPDF_PCHAR): HPDF_PCHAR; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_LoadTTFontFromFile (pdf: HPDF_Doc; const file_name: HPDF_PCHAR;
+        embedding: HPDF_BOOL): HPDF_PCHAR; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_LoadTTFontFromFile2 (pdf: HPDF_Doc; const file_name: HPDF_PCHAR;
+        index: HPDF_UINT; embedding: HPDF_BOOL): HPDF_CHAR;
+         stdcall external LIBHPDF_DLL;
+
+function HPDF_AddPageLabel (pdf: HPDF_Doc; page_num: HPDF_UINT;
+        style: THPDF_PageNumStyle; first_page: HPDF_UINT; const prefix: HPDF_PCHAR):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_UseJPFonts (pdf: HPDF_Doc): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_UseKRFonts (pdf: HPDF_Doc): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_UseCNSFonts (pdf: HPDF_Doc): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_UseCNTFonts (pdf: HPDF_Doc): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_CreateOutline (pdf: HPDF_Doc; parent: HPDF_Outline;
+        const title: HPDF_PCHAR; encoder: HPDF_Encoder): HPDF_Outline;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Outline_SetOpened (outline: HPDF_Outline; opened: HPDF_BOOL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Outline_SetDestination (outline: HPDF_Outline;
+        dst: HPDF_Destination): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_CreateDestination (page: HPDF_Page): HPDF_Destination;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Destination_SetXYZ (dst: HPDF_Destination; left: HPDF_REAL;
+        top: HPDF_REAL; zoom: HPDF_REAL): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Destination_SetFit (dst: HPDF_Destination): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Destination_SetFitH (dst: HPDF_Destination; top: HPDF_REAL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Destination_SetFitV (dst: HPDF_Destination; left: HPDF_REAL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Destination_SetFitR (dst: HPDF_Destination; left: HPDF_REAL;
+        bottom: HPDF_REAL; right: HPDF_REAL; top: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Destination_SetFitB (dst: HPDF_Destination): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Destination_SetFitBH (dst: HPDF_Destination; top: HPDF_REAL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Destination_SetFitBV (dst: HPDF_Destination; left: HPDF_REAL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_GetEncoder (pdf: HPDF_Doc; const encoding_name: HPDF_PCHAR):
+        HPDF_Encoder; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_GetCurrentEncoder (pdf: HPDF_Doc): HPDF_Encoder;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetCurrentEncoder (pdf: HPDF_Doc; const encoding_name: HPDF_PCHAR):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Encoder_GetType (encoder: HPDF_Encoder): THPDF_EncoderType;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Encoder_GetByteType (encoder: HPDF_Encoder; const text: HPDF_PCHAR;
+        index: HPDF_UINT): THPDF_ByteType; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Encoder_GetUnicode (encoder: HPDF_Encoder; code: HPDF_UINT16):
+        HPDF_UNICODE; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Encoder_GetWritingMode (encoder: HPDF_Encoder): THPDF_EncoderType;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_UseJPEncodings (pdf: HPDF_Doc): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_UseKREncodings (pdf: HPDF_Doc): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_UseCNSEncodings (pdf: HPDF_Doc): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_UseCNTEncodings (pdf: HPDF_Doc): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_CreateTextAnnot (page: HPDF_Page; rect: THPDF_Rect;
+        const text: HPDF_PCHAR; encoder: HPDF_Encoder): HPDF_Annotation;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_CreateLinkAnnot (page: HPDF_Page; rect: THPDF_Rect;
+        dst: HPDF_Destination): HPDF_Annotation; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_CreateURILinkAnnot (page: HPDF_Page; rect: THPDF_Rect;
+        const uri: HPDF_PCHAR): HPDF_Annotation; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_LinkAnnot_SetHighlightMode (annot: HPDF_Annotation;
+        mode: THPDF_AnnotHighlightMode): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_LinkAnnot_SetBorderStyle (annot: HPDF_Annotation; width: HPDF_REAL;
+        dash_on: HPDF_UINT16; dash_off: HPDF_UINT16): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_TextAnnot_SetIcon (annot: HPDF_Annotation; icon: THPDF_AnnotIcon):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_TextAnnot_SetOpened (annot: HPDF_Annotation; opened: HPDF_BOOL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_LoadPngImageFromFile (pdf: HPDF_Doc; filename: HPDF_PCHAR):
+        HPDF_Image; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_LoadPngImageFromFile2 (pdf: HPDF_Doc; filename: HPDF_PCHAR):
+        HPDF_Image; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_LoadJpegImageFromFile (pdf: HPDF_Doc; filename: HPDF_PCHAR):
+        HPDF_Image; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_LoadRawImageFromFile (pdf: HPDF_Doc; filename: HPDF_PCHAR;
+        width: HPDF_UINT; height: HPDF_UINT; color_space: THPDF_ColorSpace):
+        HPDF_Image; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_LoadRawImageFromMem (pdf: HPDF_Doc; const buf: HPDF_PBYTE;
+        width: HPDF_UINT; height: HPDF_UINT; color_space: THPDF_ColorSpace;
+        bits_per_component: HPDF_UINT): HPDF_Image; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Image_GetSize2 (image: HPDF_Image; size: PHPDF_Point): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Image_GetSize (image: HPDF_Image): THPDF_Point;
+
+
+function HPDF_Image_GetWidth (image: HPDF_Image): HPDF_UINT;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Image_GetHeight (image: HPDF_Image): HPDF_UINT;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Image_GetBitsPerComponent (image: HPDF_Image): HPDF_UINT;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Image_GetColorSpace (image: HPDF_Image): HPDF_PCHAR;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Image_SetColorMask (image: HPDF_Image; rmin: HPDF_UINT;
+        rmax: HPDF_UINT; gmin: HPDF_UINT; gmax: HPDF_UINT; bmin: HPDF_UINT;
+        bmax: HPDF_UINT): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Image_SetMaskImage (image: HPDF_Image; mask_image: HPDF_Image):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetInfoAttr (pdf: HPDF_Doc; info_type: THPDF_InfoType;
+        const value: HPDF_PCHAR): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_GetInfoAttr (pdf: HPDF_Doc; info_type: THPDF_InfoType): HPDF_PCHAR;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetInfoDateAttr (pdf: HPDF_Doc; info_type: THPDF_InfoType; value: THPDF_Date):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetPassword (pdf: HPDF_Doc; const owner_passwd: HPDF_PCHAR;
+        const user_passwd: HPDF_PCHAR): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetPermission (pdf: HPDF_Doc; permission: HPDF_UINT): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetEncryptionMode (pdf: HPDF_Doc; mode: THPDF_EncryptMode;
+        key_len: HPDF_UINT): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_SetCompressionMode (pdf: HPDF_Doc; mode: HPDF_UINT): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_TextWidth (page: HPDF_Page; const text: HPDF_PCHAR): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_MeasureText (page: HPDF_Page; const text: HPDF_PCHAR;
+        width: HPDF_REAL; wordwrap: HPDF_BOOL; real_width: HPDF_PREAL): HPDF_UINT;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetWidth (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetHeight (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetGMode (page: HPDF_Page): HPDF_UINT16;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetCurrentPos2 (page: HPDF_Page; pos: PHPDF_Point): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+function HPDF_Page_GetCurrentPos (page: HPDF_Page): THPDF_Point;
+
+
+function HPDF_Page_GetCurrentTextPos2 (page: HPDF_Page; pos: PHPDF_Point): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+function HPDF_Page_GetCurrentTextPos (page: HPDF_Page): THPDF_Point;
+
+
+function HPDF_Page_GetCurrentFont (page: HPDF_Page): HPDF_Font;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Font_GetFontName (font: HPDF_Font): HPDF_PCHAR;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Font_GetEncodingName (font: HPDF_Font): HPDF_PCHAR;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Font_GetUnicodeWidth (font: HPDF_Font; code: HPDF_UNICODE): HPDF_INT;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Font_GetBBox (font: HPDF_Font): THPDF_Rect;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Font_GetAscent (font: HPDF_Font): HPDF_INT;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Font_GetDescent (font: HPDF_Font): HPDF_INT;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Font_GetXHeight (font: HPDF_Font): HPDF_UINT;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Font_GetCapHeight (font: HPDF_Font): HPDF_UINT;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Font_TextWidth  (font: HPDF_Font; const text: PChar; len: HPDF_UINT): THPDF_TextWidth;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Font_MeasureText (font: HPDF_Font; const text: PChar; len: HPDF_UINT;
+         width: HPDF_REAL; font_size: HPDF_REAL; char_space: HPDF_REAL; 
+         word_space: HPDF_REAL; wordwrap: HPDF_BOOL; real_width: HPDF_PREAL) : HPDF_UINT;
+         stdcall external LIBHPDF_DLL;
+
+function HPDF_CreateExtGState  (pdf: HPDF_Doc) : HPDF_ExtGState;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_ExtGState_SetAlphaStroke  (ext_gstate: HPDF_ExtGState; 
+         value: HPDF_REAL) : HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_ExtGState_SetAlphaFill  (ext_gstate: HPDF_ExtGState; 
+         value: HPDF_REAL) : HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_ExtGState_SetBlendMode  (ext_gstate: HPDF_ExtGState; 
+         mode: THPDF_BlendMode) : HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetCurrentFontSize (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetTransMatrix (page: HPDF_Page): THPDF_TransMatrix;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetLineWidth (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetLineCap (page: HPDF_Page): THPDF_LineCap;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetLineJoin (page: HPDF_Page): THPDF_LineJoin;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetMiterLimit (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetDash (page: HPDF_Page): THPDF_DashMode;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetFlat (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetCharSpace (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetWordSpace (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetHorizontalScalling (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetTextLeading (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetTextRenderingMode (page: HPDF_Page): THPDF_TextRenderingMode;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetTextRaise (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetRGBFill (page: HPDF_Page): THPDF_RGBColor;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetRGBStroke (page: HPDF_Page): THPDF_RGBColor;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetCMYKFill (page: HPDF_Page): THPDF_CMYKColor;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetCMYKStroke (page: HPDF_Page): THPDF_CMYKColor;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetGrayFill (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetGrayStroke (page: HPDF_Page): HPDF_REAL;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetStrokingColorSpace (page: HPDF_Page): THPDF_ColorSpace;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetFillingColorSpace (page: HPDF_Page): THPDF_ColorSpace;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetTextMatrix (page: HPDF_Page): THPDF_TransMatrix;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GetGStateDepth (page: HPDF_Page): HPDF_UINT;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetLineWidth (page: HPDF_Page; line_width: HPDF_REAL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetLineCap (page: HPDF_Page; line_cap: THPDF_LineCap):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetLineJoin (page: HPDF_Page; line_join: THPDF_LineJoin):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetMiterLimit (page: HPDF_Page; miter_limit: HPDF_REAL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetDash (page: HPDF_Page; ptn: HPDF_PUINT16; num_param: HPDF_UINT;
+        phase: HPDF_UINT): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetFlat (page: HPDF_Page; flatness: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetExtGState (page: HPDF_Page; ext_gstate: HPDF_ExtGState): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GSave (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_GRestore (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_Concat (page: HPDF_Page; a: HPDF_REAL; b: HPDF_REAL; c: HPDF_REAL;
+        d: HPDF_REAL; x: HPDF_REAL; y: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_MoveTo (page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_LineTo (page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_CurveTo (page: HPDF_Page; x1: HPDF_REAL; y1: HPDF_REAL;
+        x2: HPDF_REAL; y2: HPDF_REAL; x3: HPDF_REAL; y3: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_CurveTo2 (page: HPDF_Page; x2: HPDF_REAL; y2: HPDF_REAL;
+        x3: HPDF_REAL; y3: HPDF_REAL): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_CurveTo3 (page: HPDF_Page; x1: HPDF_REAL; y1: HPDF_REAL;
+        x3: HPDF_REAL; y3: HPDF_REAL): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_ClosePath (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_Rectangle (page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL;
+        width: HPDF_REAL; height: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_Stroke (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_ClosePathStroke (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_Fill (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_Eofill (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_FillStroke (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_EofillStroke (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_ClosePathFillStroke (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_ClosePathEofillStroke (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_EndPath (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_Clip (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_Eoclip (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_BeginText (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_EndText (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetCharSpace (page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetWordSpace (page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetHorizontalScalling (page: HPDF_Page; value: HPDF_REAL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetTextLeading (page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetFontAndSize (page: HPDF_Page; font: HPDF_Font;
+        size: HPDF_REAL): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetTextRenderingMode (page: HPDF_Page;
+        mode: THPDF_TextRenderingMode): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetTextRaise (page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_MoveTextPos (page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_MoveTextPos2 (page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetTextMatrix (page: HPDF_Page; a: HPDF_REAL; b: HPDF_REAL; 
+        c: HPDF_REAL; d: HPDF_REAL; x: HPDF_REAL; y: HPDF_REAL):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_MoveToNextLine (page: HPDF_Page): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_ShowText (page: HPDF_Page; const text: HPDF_PCHAR): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_ShowTextNextLine (page: HPDF_Page; const text: HPDF_PCHAR):
+        HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_ShowTextNextLineEx (page: HPDF_Page; word_space: HPDF_REAL;
+        char_space: HPDF_REAL; const text: HPDF_PCHAR): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetGrayFill (page: HPDF_Page; gray: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetGrayStroke (page: HPDF_Page; gray: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetRGBFill (page: HPDF_Page; r: HPDF_REAL; g: HPDF_REAL;
+        b: HPDF_REAL): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetRGBStroke (page: HPDF_Page; r: HPDF_REAL; g: HPDF_REAL;
+        b: HPDF_REAL): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetCMYKFill (page: HPDF_Page; c: HPDF_REAL; m: HPDF_REAL;
+        y: HPDF_REAL; k: HPDF_REAL): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetCMYKStroke (page: HPDF_Page; c: HPDF_REAL; m: HPDF_REAL;
+        y: HPDF_REAL; k: HPDF_REAL): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_ExecuteXObject (page: HPDF_Page; obj: HPDF_XObject): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_DrawImage (page: HPDF_Page; image: HPDF_Image; x: HPDF_REAL;
+        y: HPDF_REAL; width: HPDF_REAL; height: HPDF_REAL): HPDF_STATUS;
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_Circle (page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL;
+        ray: HPDF_REAL): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_Arc (page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL; ray: HPDF_REAL;
+        ang1: HPDF_REAL; ang2: HPDF_REAL): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+function HPDF_Page_Ellipse (page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL;
+        xray: HPDF_REAL; yray: HPDF_REAL): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_TextOut (page: HPDF_Page; xpos: HPDF_REAL; ypos: HPDF_REAL;
+         const text: HPDF_PCHAR): HPDF_STATUS; stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_TextRect  (page: HPDF_Page; left: HPDF_REAL; top: HPDF_REAL;
+        right: HPDF_REAL; bottom: HPDF_REAL; const text: HPDF_PCHAR; 
+        align: THPDF_TextAlignment; len: HPDF_PUINT): HPDF_STATUS; 
+         stdcall external LIBHPDF_DLL;
+
+
+function HPDF_Page_SetSlideShow  (page: HPDF_Page; sstype: THPDF_TransitionStyle; 
+        disp_time: HPDF_REAL; trans_time: HPDF_REAL): HPDF_STATUS; 
+         stdcall external LIBHPDF_DLL;
+
+implementation
+
+function HPDF_Page_GetCurrentPos (page: HPDF_Page): THPDF_Point;
+var
+  pos: THPDF_Point;
+begin
+  HPDF_Page_GetCurrentPos2 (page, @pos);
+  result := pos;
+end;
+
+function HPDF_Page_GetCurrentTextPos (page: HPDF_Page): THPDF_Point;
+var
+  pos: THPDF_Point;
+begin
+  HPDF_Page_GetCurrentTextPos2 (page, @pos);
+  result := pos;
+end;
+
+function HPDF_Image_GetSize (image: HPDF_Image): THPDF_Point;
+var
+  size: THPDF_Point;
+begin
+  HPDF_Image_GetSize2 (image, @size);
+  result := size;
+end;
+
+
+end.
+

+ 547 - 0
pdf.mod/libharu/bindings/delphi/hpdf_consts.pas

@@ -0,0 +1,547 @@
+{*
+ * << Haru Free PDF Library 2.0.3 >> -- hpdf.pas
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ *}
+
+unit hpdf_consts;
+
+interface
+
+uses
+  hpdf_types;
+
+const
+  HPDF_TRUE = 1;
+  HPDF_FALSE = 0;
+
+  HPDF_OK = 0;
+  HPDF_NOERROR = 0;
+
+{*----- default values -------------------------------------------------------*}
+
+{* buffer size which is required when we convert to character string. *}
+  HPDF_TMP_BUF_SIZ = 256;
+  HPDF_SHORT_BUF_SIZ = 32;
+  HPDF_REAL_LEN = 11;
+  HPDF_INT_LEN = 11;
+  HPDF_TEXT_DEFAULT_LEN = 256;
+  HPDF_UNICODE_HEADER_LEN = 2;
+  HPDF_DATE_TIME_STR_LEN = 23;
+
+{* length of each item defined in PDF *}
+  HPDF_BYTE_OFFSET_LEN = 10;
+  HPDF_OBJ_ID_LEN = 7;
+  HPDF_GEN_NO_LEN = 5;
+
+{* default value of Graphic State *}
+  HPDF_DEF_FONT: string = 'Helvetica';
+  HPDF_DEF_PAGE_LAYOUT = HPDF_PAGE_LAYOUT_SINGLE;
+  HPDF_DEF_PAGE_MODE = HPDF_PAGE_MODE_USE_NONE;
+  HPDF_DEF_WORDSPACE= 0;
+  HPDF_DEF_CHARSPACE= 0;
+  HPDF_DEF_FONTSIZE = 10;
+  HPDF_DEF_HSCALING = 100;
+  HPDF_DEF_LEADING= 0;
+  HPDF_DEF_RENDERING_MODE = HPDF_FILL;
+  HPDF_DEF_RAISE= 0;
+  HPDF_DEF_LINEWIDTH = 1;
+  HPDF_DEF_LINECAP =  HPDF_BUTT_END;
+  HPDF_DEF_LINEJOIN = HPDF_MITER_JOIN;
+  HPDF_DEF_MITERLIMIT = 10;
+  HPDF_DEF_FLATNESS = 1;
+  HPDF_DEF_PAGE_NUM = 1;
+
+  HPDF_BS_DEF_WIDTH = 1;
+
+{* default page-size *}
+  HPDF_DEF_PAGE_WIDTH = 595.276;
+  HPDF_DEF_PAGE_HEIGHT = 841.89;
+
+  HPDF_VERSION_TEXT: string = '2.0.3';
+
+{*---------------------------------------------------------------------------*}
+{*----- compression mode ----------------------------------------------------*}
+
+  HPDF_COMP_NONE = $00;
+  HPDF_COMP_TEXT = $01;
+  HPDF_COMP_IMAGE = $02;
+  HPDF_COMP_METADATA = $04;
+  HPDF_COMP_ALL = $0F;
+{*  HPDF_COMP_BEST_COMPRESS = $10;
+ *  HPDF_COMP_BEST_SPEED = $20;
+ *}
+  HPDF_COMP_MASK = $FF;
+
+{*----------------------------------------------------------------------------*}
+{*----- permission flags (only Revision 2 is supported)-----------------------*}
+
+  HPDF_ENABLE_READ = 0;
+  HPDF_ENABLE_PRINT = 4;
+  HPDF_ENABLE_EDIT_ALL = 8;
+  HPDF_ENABLE_COPY = 16;
+  HPDF_ENABLE_EDIT = 32;
+
+
+{*----------------------------------------------------------------------------*}
+{*------ viewer preferences definitions --------------------------------------*}
+
+  HPDF_HIDE_TOOLBAR = 1;
+  HPDF_HIDE_MENUBAR = 2;
+  HPDF_HIDE_WINDOW_UI = 4;
+  HPDF_FIT_WINDOW = 8;
+  HPDF_CENTER_WINDOW = 16;
+
+
+{*---------------------------------------------------------------------------*}
+{*------ limitation of object implementation (PDF1.4) -----------------------*}
+
+  HPDF_LIMIT_MAX_INT = 2147483647;
+  HPDF_LIMIT_MIN_INT = -2147483647;
+
+  HPDF_LIMIT_MAX_REAL = 32767;
+  HPDF_LIMIT_MIN_REAL = -32767;
+
+  HPDF_LIMIT_MAX_STRING_LEN = 65535;
+  HPDF_LIMIT_MAX_NAME_LEN = 127;
+
+  HPDF_LIMIT_MAX_ARRAY = 8191;
+  HPDF_LIMIT_MAX_DICT_ELEMENT = 4095;
+  HPDF_LIMIT_MAX_XREF_ELEMENT = 8388607;
+  HPDF_LIMIT_MAX_GSTATE = 28;
+  HPDF_LIMIT_MAX_DEVICE_N = 8;
+  HPDF_LIMIT_MAX_DEVICE_N_V15 = 32;
+  HPDF_LIMIT_MAX_CID = 65535;
+  HPDF_MAX_GENERATION_NUM = 65535;
+
+  HPDF_MIN_PAGE_HEIGHT = 3;
+  HPDF_MIN_PAGE_WIDTH = 3;
+  HPDF_MAX_PAGE_HEIGHT = 14400;
+  HPDF_MAX_PAGE_WIDTH = 14400;
+  HPDF_MIN_MAGNIFICATION_FACTOR = 8;
+  HPDF_MAX_MAGNIFICATION_FACTOR = 3200;
+
+{*---------------------------------------------------------------------------*}
+{*------ limitation of various properties -----------------------------------*}
+
+  HPDF_MIN_PAGE_SIZE = 3;
+  HPDF_MAX_PAGE_SIZE = 14400;
+  HPDF_MIN_HORIZONTALSCALING = 10;
+  HPDF_MAX_HORIZONTALSCALING = 300;
+  HPDF_MIN_WORDSPACE = -30;
+  HPDF_MAX_WORDSPACE = 300;
+  HPDF_MIN_CHARSPACE = -30;
+  HPDF_MAX_CHARSPACE = 300;
+  HPDF_MAX_FONTSIZE = 300;
+  HPDF_MAX_ZOOMSIZE = 10;
+  HPDF_MAX_LEADING = 300;
+  HPDF_MAX_LINEWIDTH = 100;
+  HPDF_MAX_DASH_PATTERN = 100;
+
+{*----------------------------------------------------------------------------*}
+{*----- country code definition ----------------------------------------------*}
+
+  HPDF_COUNTRY_AF: string = 'AF';    {* AFGHANISTAN *}
+  HPDF_COUNTRY_AL: string = 'AL';    {* ALBANIA *}
+  HPDF_COUNTRY_DZ: string = 'DZ';    {* ALGERIA *}
+  HPDF_COUNTRY_AS: string = 'AS';    {* AMERICAN SAMOA *}
+  HPDF_COUNTRY_AD: string = 'AD';    {* ANDORRA *}
+  HPDF_COUNTRY_AO: string = 'AO';    {* ANGOLA *}
+  HPDF_COUNTRY_AI: string = 'AI';    {* ANGUILLA *}
+  HPDF_COUNTRY_AQ: string = 'AQ';    {* ANTARCTICA *}
+  HPDF_COUNTRY_AG: string = 'AG';    {* ANTIGUA AND BARBUDA *}
+  HPDF_COUNTRY_AR: string = 'AR';    {* ARGENTINA *}
+  HPDF_COUNTRY_AM: string = 'AM';    {* ARMENIA *}
+  HPDF_COUNTRY_AW: string = 'AW';    {* ARUBA *}
+  HPDF_COUNTRY_AU: string = 'AU';    {* AUSTRALIA *}
+  HPDF_COUNTRY_AT: string = 'AT';    {* AUSTRIA *}
+  HPDF_COUNTRY_AZ: string = 'AZ';    {* AZERBAIJAN *}
+  HPDF_COUNTRY_BS: string = 'BS';    {* BAHAMAS *}
+  HPDF_COUNTRY_BH: string = 'BH';    {* BAHRAIN *}
+  HPDF_COUNTRY_BD: string = 'BD';    {* BANGLADESH *}
+  HPDF_COUNTRY_BB: string = 'BB';    {* BARBADOS *}
+  HPDF_COUNTRY_BY: string = 'BY';    {* BELARUS *}
+  HPDF_COUNTRY_BE: string = 'BE';    {* BELGIUM *}
+  HPDF_COUNTRY_BZ: string = 'BZ';    {* BELIZE *}
+  HPDF_COUNTRY_BJ: string = 'BJ';    {* BENIN *}
+  HPDF_COUNTRY_BM: string = 'BM';    {* BERMUDA *}
+  HPDF_COUNTRY_BT: string = 'BT';    {* BHUTAN *}
+  HPDF_COUNTRY_BO: string = 'BO';    {* BOLIVIA *}
+  HPDF_COUNTRY_BA: string = 'BA';    {* BOSNIA AND HERZEGOWINA *}
+  HPDF_COUNTRY_BW: string = 'BW';    {* BOTSWANA *}
+  HPDF_COUNTRY_BV: string = 'BV';    {* BOUVET ISLAND *}
+  HPDF_COUNTRY_BR: string = 'BR';    {* BRAZIL *}
+  HPDF_COUNTRY_IO: string = 'IO';    {* BRITISH INDIAN OCEAN TERRITORY *}
+  HPDF_COUNTRY_BN: string = 'BN';    {* BRUNEI DARUSSALAM *}
+  HPDF_COUNTRY_BG: string = 'BG';    {* BULGARIA *}
+  HPDF_COUNTRY_BF: string = 'BF';    {* BURKINA FASO *}
+  HPDF_COUNTRY_BI: string = 'BI';    {* BURUNDI *}
+  HPDF_COUNTRY_KH: string = 'KH';    {* CAMBODIA *}
+  HPDF_COUNTRY_CM: string = 'CM';    {* CAMEROON *}
+  HPDF_COUNTRY_CA: string = 'CA';    {* CANADA *}
+  HPDF_COUNTRY_CV: string = 'CV';    {* CAPE VERDE *}
+  HPDF_COUNTRY_KY: string = 'KY';    {* CAYMAN ISLANDS *}
+  HPDF_COUNTRY_CF: string = 'CF';    {* CENTRAL AFRICAN REPUBLIC *}
+  HPDF_COUNTRY_TD: string = 'TD';    {* CHAD *}
+  HPDF_COUNTRY_CL: string = 'CL';    {* CHILE *}
+  HPDF_COUNTRY_CN: string = 'CN';    {* CHINA *}
+  HPDF_COUNTRY_CX: string = 'CX';    {* CHRISTMAS ISLAND *}
+  HPDF_COUNTRY_CC: string = 'CC';    {* COCOS (KEELING) ISLANDS *}
+  HPDF_COUNTRY_CO: string = 'CO';    {* COLOMBIA *}
+  HPDF_COUNTRY_KM: string = 'KM';    {* COMOROS *}
+  HPDF_COUNTRY_CG: string = 'CG';    {* CONGO *}
+  HPDF_COUNTRY_CK: string = 'CK';    {* COOK ISLANDS *}
+  HPDF_COUNTRY_CR: string = 'CR';    {* COSTA RICA *}
+  HPDF_COUNTRY_CI: string = 'CI';    {* COTE D'IVOIRE *}
+  HPDF_COUNTRY_HR: string = 'HR';    {* CROATIA (local name: Hrvatska) *}
+  HPDF_COUNTRY_CU: string = 'CU';    {* CUBA *}
+  HPDF_COUNTRY_CY: string = 'CY';    {* CYPRUS *}
+  HPDF_COUNTRY_CZ: string = 'CZ';    {* CZECH REPUBLIC *}
+  HPDF_COUNTRY_DK: string = 'DK';    {* DENMARK *}
+  HPDF_COUNTRY_DJ: string = 'DJ';    {* DJIBOUTI *}
+  HPDF_COUNTRY_DM: string = 'DM';    {* DOMINICA *}
+  HPDF_COUNTRY_DO: string = 'DO';    {* DOMINICAN REPUBLIC *}
+  HPDF_COUNTRY_TP: string = 'TP';    {* EAST TIMOR *}
+  HPDF_COUNTRY_EC: string = 'EC';    {* ECUADOR *}
+  HPDF_COUNTRY_EG: string = 'EG';    {* EGYPT *}
+  HPDF_COUNTRY_SV: string = 'SV';    {* EL SALVADOR *}
+  HPDF_COUNTRY_GQ: string = 'GQ';    {* EQUATORIAL GUINEA *}
+  HPDF_COUNTRY_ER: string = 'ER';    {* ERITREA *}
+  HPDF_COUNTRY_EE: string = 'EE';    {* ESTONIA *}
+  HPDF_COUNTRY_ET: string = 'ET';    {* ETHIOPIA *}
+  HPDF_COUNTRY_FK: string = 'FK';    {* FALKLAND ISLANDS (MALVINAS) *}
+  HPDF_COUNTRY_FO: string = 'FO';    {* FAROE ISLANDS *}
+  HPDF_COUNTRY_FJ: string = 'FJ';    {* FIJI *}
+  HPDF_COUNTRY_FI: string = 'FI';    {* FINLAND *}
+  HPDF_COUNTRY_FR: string = 'FR';    {* FRANCE *}
+  HPDF_COUNTRY_FX: string = 'FX';    {* FRANCE, METROPOLITAN *}
+  HPDF_COUNTRY_GF: string = 'GF';    {* FRENCH GUIANA *}
+  HPDF_COUNTRY_PF: string = 'PF';    {* FRENCH POLYNESIA *}
+  HPDF_COUNTRY_TF: string = 'TF';    {* FRENCH SOUTHERN TERRITORIES *}
+  HPDF_COUNTRY_GA: string = 'GA';    {* GABON *}
+  HPDF_COUNTRY_GM: string = 'GM';    {* GAMBIA *}
+  HPDF_COUNTRY_GE: string = 'GE';    {* GEORGIA *}
+  HPDF_COUNTRY_DE: string = 'DE';    {* GERMANY *}
+  HPDF_COUNTRY_GH: string = 'GH';    {* GHANA *}
+  HPDF_COUNTRY_GI: string = 'GI';    {* GIBRALTAR *}
+  HPDF_COUNTRY_GR: string = 'GR';    {* GREECE *}
+  HPDF_COUNTRY_GL: string = 'GL';    {* GREENLAND *}
+  HPDF_COUNTRY_GD: string = 'GD';    {* GRENADA *}
+  HPDF_COUNTRY_GP: string = 'GP';    {* GUADELOUPE *}
+  HPDF_COUNTRY_GU: string = 'GU';    {* GUAM *}
+  HPDF_COUNTRY_GT: string = 'GT';    {* GUATEMALA *}
+  HPDF_COUNTRY_GN: string = 'GN';    {* GUINEA *}
+  HPDF_COUNTRY_GW: string = 'GW';    {* GUINEA-BISSAU *}
+  HPDF_COUNTRY_GY: string = 'GY';    {* GUYANA *}
+  HPDF_COUNTRY_HT: string = 'HT';    {* HAITI *}
+  HPDF_COUNTRY_HM: string = 'HM';    {* HEARD AND MC DONALD ISLANDS *}
+  HPDF_COUNTRY_HN: string = 'HN';    {* HONDURAS *}
+  HPDF_COUNTRY_HK: string = 'HK';    {* HONG KONG *}
+  HPDF_COUNTRY_HU: string = 'HU';    {* HUNGARY *}
+  HPDF_COUNTRY_IS: string = 'IS';    {* ICELAND *}
+  HPDF_COUNTRY_IN: string = 'IN';    {* INDIA *}
+  HPDF_COUNTRY_ID: string = 'ID';    {* INDONESIA *}
+  HPDF_COUNTRY_IR: string = 'IR';    {* IRAN (ISLAMIC REPUBLIC OF) *}
+  HPDF_COUNTRY_IQ: string = 'IQ';    {* IRAQ *}
+  HPDF_COUNTRY_IE: string = 'IE';    {* IRELAND *}
+  HPDF_COUNTRY_IL: string = 'IL';    {* ISRAEL *}
+  HPDF_COUNTRY_IT: string = 'IT';    {* ITALY *}
+  HPDF_COUNTRY_JM: string = 'JM';    {* JAMAICA *}
+  HPDF_COUNTRY_JP: string = 'JP';    {* JAPAN *}
+  HPDF_COUNTRY_JO: string = 'JO';    {* JORDAN *}
+  HPDF_COUNTRY_KZ: string = 'KZ';    {* KAZAKHSTAN *}
+  HPDF_COUNTRY_KE: string = 'KE';    {* KENYA *}
+  HPDF_COUNTRY_KI: string = 'KI';    {* KIRIBATI *}
+  HPDF_COUNTRY_KP: string = 'KP';    {* KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF *}
+  HPDF_COUNTRY_KR: string = 'KR';    {* KOREA, REPUBLIC OF *}
+  HPDF_COUNTRY_KW: string = 'KW';    {* KUWAIT *}
+  HPDF_COUNTRY_KG: string = 'KG';    {* KYRGYZSTAN *}
+  HPDF_COUNTRY_LA: string = 'LA';    {* LAO PEOPLE'S DEMOCRATIC REPUBLIC *}
+  HPDF_COUNTRY_LV: string = 'LV';    {* LATVIA *}
+  HPDF_COUNTRY_LB: string = 'LB';    {* LEBANON *}
+  HPDF_COUNTRY_LS: string = 'LS';    {* LESOTHO *}
+  HPDF_COUNTRY_LR: string = 'LR';    {* LIBERIA *}
+  HPDF_COUNTRY_LY: string = 'LY';    {* LIBYAN ARAB JAMAHIRIYA *}
+  HPDF_COUNTRY_LI: string = 'LI';    {* LIECHTENSTEIN *}
+  HPDF_COUNTRY_LT: string = 'LT';    {* LITHUANIA *}
+  HPDF_COUNTRY_LU: string = 'LU';    {* LUXEMBOURG *}
+  HPDF_COUNTRY_MO: string = 'MO';    {* MACAU *}
+  HPDF_COUNTRY_MK: string = 'MK';    {* MACEDONIA,THE FORMER YUGOSLAV REPUBLIC OF *}
+  HPDF_COUNTRY_MG: string = 'MG';    {* MADAGASCAR *}
+  HPDF_COUNTRY_MW: string = 'MW';    {* MALAWI *}
+  HPDF_COUNTRY_MY: string = 'MY';    {* MALAYSIA *}
+  HPDF_COUNTRY_MV: string = 'MV';    {* MALDIVES *}
+  HPDF_COUNTRY_ML: string = 'ML';    {* MALI *}
+  HPDF_COUNTRY_MT: string = 'MT';    {* MALTA *}
+  HPDF_COUNTRY_MH: string = 'MH';    {* MARSHALL ISLANDS *}
+  HPDF_COUNTRY_MQ: string = 'MQ';    {* MARTINIQUE *}
+  HPDF_COUNTRY_MR: string = 'MR';    {* MAURITANIA *}
+  HPDF_COUNTRY_MU: string = 'MU';    {* MAURITIUS *}
+  HPDF_COUNTRY_YT: string = 'YT';    {* MAYOTTE *}
+  HPDF_COUNTRY_MX: string = 'MX';    {* MEXICO *}
+  HPDF_COUNTRY_FM: string = 'FM';    {* MICRONESIA, FEDERATED STATES OF *}
+  HPDF_COUNTRY_MD: string = 'MD';    {* MOLDOVA, REPUBLIC OF *}
+  HPDF_COUNTRY_MC: string = 'MC';    {* MONACO *}
+  HPDF_COUNTRY_MN: string = 'MN';    {* MONGOLIA *}
+  HPDF_COUNTRY_MS: string = 'MS';    {* MONTSERRAT *}
+  HPDF_COUNTRY_MA: string = 'MA';    {* MOROCCO *}
+  HPDF_COUNTRY_MZ: string = 'MZ';    {* MOZAMBIQUE *}
+  HPDF_COUNTRY_MM: string = 'MM';    {* MYANMAR *}
+  HPDF_COUNTRY_NA: string = 'NA';    {* NAMIBIA *}
+  HPDF_COUNTRY_NR: string = 'NR';    {* NAURU *}
+  HPDF_COUNTRY_NP: string = 'NP';    {* NEPAL *}
+  HPDF_COUNTRY_NL: string = 'NL';    {* NETHERLANDS *}
+  HPDF_COUNTRY_AN: string = 'AN';    {* NETHERLANDS ANTILLES *}
+  HPDF_COUNTRY_NC: string = 'NC';    {* NEW CALEDONIA *}
+  HPDF_COUNTRY_NZ: string = 'NZ';    {* NEW ZEALAND *}
+  HPDF_COUNTRY_NI: string = 'NI';    {* NICARAGUA *}
+  HPDF_COUNTRY_NE: string = 'NE';    {* NIGER *}
+  HPDF_COUNTRY_NG: string = 'NG';    {* NIGERIA *}
+  HPDF_COUNTRY_NU: string = 'NU';    {* NIUE *}
+  HPDF_COUNTRY_NF: string = 'NF';    {* NORFOLK ISLAND *}
+  HPDF_COUNTRY_MP: string = 'MP';    {* NORTHERN MARIANA ISLANDS *}
+  HPDF_COUNTRY_NO: string = 'NO';    {* NORWAY *}
+  HPDF_COUNTRY_OM: string = 'OM';    {* OMAN *}
+  HPDF_COUNTRY_PK: string = 'PK';    {* PAKISTAN *}
+  HPDF_COUNTRY_PW: string = 'PW';    {* PALAU *}
+  HPDF_COUNTRY_PA: string = 'PA';    {* PANAMA *}
+  HPDF_COUNTRY_PG: string = 'PG';    {* PAPUA NEW GUINEA *}
+  HPDF_COUNTRY_PY: string = 'PY';    {* PARAGUAY *}
+  HPDF_COUNTRY_PE: string = 'PE';    {* PERU *}
+  HPDF_COUNTRY_PH: string = 'PH';    {* PHILIPPINES *}
+  HPDF_COUNTRY_PN: string = 'PN';    {* PITCAIRN *}
+  HPDF_COUNTRY_PL: string = 'PL';    {* POLAND *}
+  HPDF_COUNTRY_PT: string = 'PT';    {* PORTUGAL *}
+  HPDF_COUNTRY_PR: string = 'PR';    {* PUERTO RICO *}
+  HPDF_COUNTRY_QA: string = 'QA';    {* QATAR *}
+  HPDF_COUNTRY_RE: string = 'RE';    {* REUNION *}
+  HPDF_COUNTRY_RO: string = 'RO';    {* ROMANIA *}
+  HPDF_COUNTRY_RU: string = 'RU';    {* RUSSIAN FEDERATION *}
+  HPDF_COUNTRY_RW: string = 'RW';    {* RWANDA *}
+  HPDF_COUNTRY_KN: string = 'KN';    {* SAINT KITTS AND NEVIS *}
+  HPDF_COUNTRY_LC: string = 'LC';    {* SAINT LUCIA *}
+  HPDF_COUNTRY_VC: string = 'VC';    {* SAINT VINCENT AND THE GRENADINES *}
+  HPDF_COUNTRY_WS: string = 'WS';    {* SAMOA *}
+  HPDF_COUNTRY_SM: string = 'SM';    {* SAN MARINO *}
+  HPDF_COUNTRY_ST: string = 'ST';    {* SAO TOME AND PRINCIPE *}
+  HPDF_COUNTRY_SA: string = 'SA';    {* SAUDI ARABIA *}
+  HPDF_COUNTRY_SN: string = 'SN';    {* SENEGAL *}
+  HPDF_COUNTRY_SC: string = 'SC';    {* SEYCHELLES *}
+  HPDF_COUNTRY_SL: string = 'SL';    {* SIERRA LEONE *}
+  HPDF_COUNTRY_SG: string = 'SG';    {* SINGAPORE *}
+  HPDF_COUNTRY_SK: string = 'SK';    {* SLOVAKIA (Slovak Republic) *}
+  HPDF_COUNTRY_SI: string = 'SI';    {* SLOVENIA *}
+  HPDF_COUNTRY_SB: string = 'SB';    {* SOLOMON ISLANDS *}
+  HPDF_COUNTRY_SO: string = 'SO';    {* SOMALIA *}
+  HPDF_COUNTRY_ZA: string = 'ZA';    {* SOUTH AFRICA *}
+  HPDF_COUNTRY_ES: string = 'ES';    {* SPAIN *}
+  HPDF_COUNTRY_LK: string = 'LK';    {* SRI LANKA *}
+  HPDF_COUNTRY_SH: string = 'SH';    {* ST. HELENA *}
+  HPDF_COUNTRY_PM: string = 'PM';    {* ST. PIERRE AND MIQUELON *}
+  HPDF_COUNTRY_SD: string = 'SD';    {* SUDAN *}
+  HPDF_COUNTRY_SR: string = 'SR';    {* SURINAME *}
+  HPDF_COUNTRY_SJ: string = 'SJ';    {* SVALBARD AND JAN MAYEN ISLANDS *}
+  HPDF_COUNTRY_SZ: string = 'SZ';    {* SWAZILAND *}
+  HPDF_COUNTRY_SE: string = 'SE';    {* SWEDEN *}
+  HPDF_COUNTRY_CH: string = 'CH';    {* SWITZERLAND *}
+  HPDF_COUNTRY_SY: string = 'SY';    {* SYRIAN ARAB REPUBLIC *}
+  HPDF_COUNTRY_TW: string = 'TW';    {* TAIWAN, PROVINCE OF CHINA *}
+  HPDF_COUNTRY_TJ: string = 'TJ';    {* TAJIKISTAN *}
+  HPDF_COUNTRY_TZ: string = 'TZ';    {* TANZANIA, UNITED REPUBLIC OF *}
+  HPDF_COUNTRY_TH: string = 'TH';    {* THAILAND *}
+  HPDF_COUNTRY_TG: string = 'TG';    {* TOGO *}
+  HPDF_COUNTRY_TK: string = 'TK';    {* TOKELAU *}
+  HPDF_COUNTRY_TO: string = 'TO';    {* TONGA *}
+  HPDF_COUNTRY_TT: string = 'TT';    {* TRINIDAD AND TOBAGO *}
+  HPDF_COUNTRY_TN: string = 'TN';    {* TUNISIA *}
+  HPDF_COUNTRY_TR: string = 'TR';    {* TURKEY *}
+  HPDF_COUNTRY_TM: string = 'TM';    {* TURKMENISTAN *}
+  HPDF_COUNTRY_TC: string = 'TC';    {* TURKS AND CAICOS ISLANDS *}
+  HPDF_COUNTRY_TV: string = 'TV';    {* TUVALU *}
+  HPDF_COUNTRY_UG: string = 'UG';    {* UGANDA *}
+  HPDF_COUNTRY_UA: string = 'UA';    {* UKRAINE *}
+  HPDF_COUNTRY_AE: string = 'AE';    {* UNITED ARAB EMIRATES *}
+  HPDF_COUNTRY_GB: string = 'GB';    {* UNITED KINGDOM *}
+  HPDF_COUNTRY_US: string = 'US';    {* UNITED STATES *}
+  HPDF_COUNTRY_UM: string = 'UM';    {* UNITED STATES MINOR OUTLYING ISLANDS *}
+  HPDF_COUNTRY_UY: string = 'UY';    {* URUGUAY *}
+  HPDF_COUNTRY_UZ: string = 'UZ';    {* UZBEKISTAN *}
+  HPDF_COUNTRY_VU: string = 'VU';    {* VANUATU *}
+  HPDF_COUNTRY_VA: string = 'VA';    {* VATICAN CITY STATE (HOLY SEE) *}
+  HPDF_COUNTRY_VE: string = 'VE';    {* VENEZUELA *}
+  HPDF_COUNTRY_VN: string = 'VN';    {* VIET NAM *}
+  HPDF_COUNTRY_VG: string = 'VG';    {* VIRGIN ISLANDS (BRITISH) *}
+  HPDF_COUNTRY_VI: string = 'VI';    {* VIRGIN ISLANDS (U.S.) *}
+  HPDF_COUNTRY_WF: string = 'WF';    {* WALLIS AND FUTUNA ISLANDS *}
+  HPDF_COUNTRY_EH: string = 'EH';    {* WESTERN SAHARA *}
+  HPDF_COUNTRY_YE: string = 'YE';    {* YEMEN *}
+  HPDF_COUNTRY_YU: string = 'YU';    {* YUGOSLAVIA *}
+  HPDF_COUNTRY_ZR: string = 'ZR';    {* ZAIRE *}
+  HPDF_COUNTRY_ZM: string = 'ZM';    {* ZAMBIA *}
+  HPDF_COUNTRY_ZW: string = 'ZW';    {* ZIMBABWE *}
+
+{*----------------------------------------------------------------------------*}
+{*----- lang code definition -------------------------------------------------*}
+
+  HPDF_LANG_AA: string = 'aa';    {* Afar *}
+  HPDF_LANG_AB: string = 'ab';    {* Abkhazian *}
+  HPDF_LANG_AF: string = 'af';    {* Afrikaans *}
+  HPDF_LANG_AM: string = 'am';    {* Amharic *}
+  HPDF_LANG_AR: string = 'ar';    {* Arabic *}
+  HPDF_LANG_AS: string = 'as';    {* Assamese *}
+  HPDF_LANG_AY: string = 'ay';    {* Aymara *}
+  HPDF_LANG_AZ: string = 'az';    {* Azerbaijani *}
+  HPDF_LANG_BA: string = 'ba';    {* Bashkir *}
+  HPDF_LANG_BE: string = 'be';    {* Byelorussian *}
+  HPDF_LANG_BG: string = 'bg';    {* Bulgarian *}
+  HPDF_LANG_BH: string = 'bh';    {* Bihari *}
+  HPDF_LANG_BI: string = 'bi';    {* Bislama *}
+  HPDF_LANG_BN: string = 'bn';    {* Bengali Bangla *}
+  HPDF_LANG_BO: string = 'bo';    {* Tibetan *}
+  HPDF_LANG_BR: string = 'br';    {* Breton *}
+  HPDF_LANG_CA: string = 'ca';    {* Catalan *}
+  HPDF_LANG_CO: string = 'co';    {* Corsican *}
+  HPDF_LANG_CS: string = 'cs';    {* Czech *}
+  HPDF_LANG_CY: string = 'cy';    {* Welsh *}
+  HPDF_LANG_DA: string = 'da';    {* Danish *}
+  HPDF_LANG_DE: string = 'de';    {* German *}
+  HPDF_LANG_DZ: string = 'dz';    {* Bhutani *}
+  HPDF_LANG_EL: string = 'el';    {* Greek *}
+  HPDF_LANG_EN: string = 'en';    {* English *}
+  HPDF_LANG_EO: string = 'eo';    {* Esperanto *}
+  HPDF_LANG_ES: string = 'es';    {* Spanish *}
+  HPDF_LANG_ET: string = 'et';    {* Estonian *}
+  HPDF_LANG_EU: string = 'eu';    {* Basque *}
+  HPDF_LANG_FA: string = 'fa';    {* Persian *}
+  HPDF_LANG_FI: string = 'fi';    {* Finnish *}
+  HPDF_LANG_FJ: string = 'fj';    {* Fiji *}
+  HPDF_LANG_FO: string = 'fo';    {* Faeroese *}
+  HPDF_LANG_FR: string = 'fr';    {* French *}
+  HPDF_LANG_FY: string = 'fy';    {* Frisian *}
+  HPDF_LANG_GA: string = 'ga';    {* Irish *}
+  HPDF_LANG_GD: string = 'gd';    {* Scots Gaelic *}
+  HPDF_LANG_GL: string = 'gl';    {* Galician *}
+  HPDF_LANG_GN: string = 'gn';    {* Guarani *}
+  HPDF_LANG_GU: string = 'gu';    {* Gujarati *}
+  HPDF_LANG_HA: string = 'ha';    {* Hausa *}
+  HPDF_LANG_HI: string = 'hi';    {* Hindi *}
+  HPDF_LANG_HR: string = 'hr';    {* Croatian *}
+  HPDF_LANG_HU: string = 'hu';    {* Hungarian *}
+  HPDF_LANG_HY: string = 'hy';    {* Armenian *}
+  HPDF_LANG_IA: string = 'ia';    {* Interlingua *}
+  HPDF_LANG_IE: string = 'ie';    {* Interlingue *}
+  HPDF_LANG_IK: string = 'ik';    {* Inupiak *}
+  HPDF_LANG_IN: string = 'in';    {* Indonesian *}
+  HPDF_LANG_IS: string = 'is';    {* Icelandic *}
+  HPDF_LANG_IT: string = 'it';    {* Italian *}
+  HPDF_LANG_IW: string = 'iw';    {* Hebrew *}
+  HPDF_LANG_JA: string = 'ja';    {* Japanese *}
+  HPDF_LANG_JI: string = 'ji';    {* Yiddish *}
+  HPDF_LANG_JW: string = 'jw';    {* Javanese *}
+  HPDF_LANG_KA: string = 'ka';    {* Georgian *}
+  HPDF_LANG_KK: string = 'kk';    {* Kazakh *}
+  HPDF_LANG_KL: string = 'kl';    {* Greenlandic *}
+  HPDF_LANG_KM: string = 'km';    {* Cambodian *}
+  HPDF_LANG_KN: string = 'kn';    {* Kannada *}
+  HPDF_LANG_KO: string = 'ko';    {* Korean *}
+  HPDF_LANG_KS: string = 'ks';    {* Kashmiri *}
+  HPDF_LANG_KU: string = 'ku';    {* Kurdish *}
+  HPDF_LANG_KY: string = 'ky';    {* Kirghiz *}
+  HPDF_LANG_LA: string = 'la';    {* Latin *}
+  HPDF_LANG_LN: string = 'ln';    {* Lingala *}
+  HPDF_LANG_LO: string = 'lo';    {* Laothian *}
+  HPDF_LANG_LT: string = 'lt';    {* Lithuanian *}
+  HPDF_LANG_LV: string = 'lv';    {* Latvian,Lettish *}
+  HPDF_LANG_MG: string = 'mg';    {* Malagasy *}
+  HPDF_LANG_MI: string = 'mi';    {* Maori *}
+  HPDF_LANG_MK: string = 'mk';    {* Macedonian *}
+  HPDF_LANG_ML: string = 'ml';    {* Malayalam *}
+  HPDF_LANG_MN: string = 'mn';    {* Mongolian *}
+  HPDF_LANG_MO: string = 'mo';    {* Moldavian *}
+  HPDF_LANG_MR: string = 'mr';    {* Marathi *}
+  HPDF_LANG_MS: string = 'ms';    {* Malay *}
+  HPDF_LANG_MT: string = 'mt';    {* Maltese *}
+  HPDF_LANG_MY: string = 'my';    {* Burmese *}
+  HPDF_LANG_NA: string = 'na';    {* Nauru *}
+  HPDF_LANG_NE: string = 'ne';    {* Nepali *}
+  HPDF_LANG_NL: string = 'nl';    {* Dutch *}
+  HPDF_LANG_NO: string = 'no';    {* Norwegian *}
+  HPDF_LANG_OC: string = 'oc';    {* Occitan *}
+  HPDF_LANG_OM: string = 'om';    {* (Afan)Oromo *}
+  HPDF_LANG_OR: string = 'or';    {* Oriya *}
+  HPDF_LANG_PA: string = 'pa';    {* Punjabi *}
+  HPDF_LANG_PL: string = 'pl';    {* Polish *}
+  HPDF_LANG_PS: string = 'ps';    {* Pashto,Pushto *}
+  HPDF_LANG_PT: string = 'pt';    {* Portuguese  *}
+  HPDF_LANG_QU: string = 'qu';    {* Quechua *}
+  HPDF_LANG_RM: string = 'rm';    {* Rhaeto-Romance *}
+  HPDF_LANG_RN: string = 'rn';    {* Kirundi *}
+  HPDF_LANG_RO: string = 'ro';    {* Romanian *}
+  HPDF_LANG_RU: string = 'ru';    {* Russian *}
+  HPDF_LANG_RW: string = 'rw';    {* Kinyarwanda *}
+  HPDF_LANG_SA: string = 'sa';    {* Sanskrit *}
+  HPDF_LANG_SD: string = 'sd';    {* Sindhi *}
+  HPDF_LANG_SG: string = 'sg';    {* Sangro *}
+  HPDF_LANG_SH: string = 'sh';    {* Serbo-Croatian *}
+  HPDF_LANG_SI: string = 'si';    {* Singhalese *}
+  HPDF_LANG_SK: string = 'sk';    {* Slovak *}
+  HPDF_LANG_SL: string = 'sl';    {* Slovenian *}
+  HPDF_LANG_SM: string = 'sm';    {* Samoan *}
+  HPDF_LANG_SN: string = 'sn';    {* Shona *}
+  HPDF_LANG_SO: string = 'so';    {* Somali *}
+  HPDF_LANG_SQ: string = 'sq';    {* Albanian *}
+  HPDF_LANG_SR: string = 'sr';    {* Serbian *}
+  HPDF_LANG_SS: string = 'ss';    {* Siswati *}
+  HPDF_LANG_ST: string = 'st';    {* Sesotho *}
+  HPDF_LANG_SU: string = 'su';    {* Sundanese *}
+  HPDF_LANG_SV: string = 'sv';    {* Swedish *}
+  HPDF_LANG_SW: string = 'sw';    {* Swahili *}
+  HPDF_LANG_TA: string = 'ta';    {* Tamil *}
+  HPDF_LANG_TE: string = 'te';    {* Tegulu *}
+  HPDF_LANG_TG: string = 'tg';    {* Tajik *}
+  HPDF_LANG_TH: string = 'th';    {* Thai *}
+  HPDF_LANG_TI: string = 'ti';    {* Tigrinya *}
+  HPDF_LANG_TK: string = 'tk';    {* Turkmen *}
+  HPDF_LANG_TL: string = 'tl';    {* Tagalog *}
+  HPDF_LANG_TN: string = 'tn';    {* Setswanato Tonga *}
+  HPDF_LANG_TR: string = 'tr';    {* Turkish *}
+  HPDF_LANG_TS: string = 'ts';    {* Tsonga *}
+  HPDF_LANG_TT: string = 'tt';    {* Tatar *}
+  HPDF_LANG_TW: string = 'tw';    {* Twi *}
+  HPDF_LANG_UK: string = 'uk';    {* Ukrainian *}
+  HPDF_LANG_UR: string = 'ur';    {* Urdu *}
+  HPDF_LANG_UZ: string = 'uz';    {* Uzbek *}
+  HPDF_LANG_VI: string = 'vi';    {* Vietnamese *}
+  HPDF_LANG_VO: string = 'vo';    {* Volapuk *}
+  HPDF_LANG_WO: string = 'wo';    {* Wolof *}
+  HPDF_LANG_XH: string = 'xh';    {* Xhosa *}
+  HPDF_LANG_YO: string = 'yo';    {* Yoruba *}
+  HPDF_LANG_ZH: string = 'zh';    {* Chinese *}
+  HPDF_LANG_ZU: string = 'zu';    {* Zulu *}
+
+
+{*----------------------------------------------------------------------------*}
+{*----- Graphics mode --------------------------------------------------------*}
+
+  HPDF_GMODE_PAGE_DESCRIPTION = $0001;
+  HPDF_GMODE_PATH_OBJECT = $0002;
+  HPDF_GMODE_TEXT_OBJECT = $0004;
+  HPDF_GMODE_CLIPPING_PATH = $0008;
+  HPDF_GMODE_SHADING = $0010;
+  HPDF_GMODE_INLINE_IMAGE =  $0020;
+  HPDF_GMODE_EXTERNAL_OBJECT = $0040;
+
+{*----------------------------------------------------------------------------*}
+
+implementation
+
+end.
+

+ 463 - 0
pdf.mod/libharu/bindings/delphi/hpdf_types.pas

@@ -0,0 +1,463 @@
+{*
+ * << Haru Free PDF Library 2.0.6 >> -- hpdf_types.pas
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ *}
+
+unit hpdf_types;
+
+interface
+
+uses
+  SysUtils;
+
+type
+
+{*----------------------------------------------------------------------------*}
+{*----- type definition ------------------------------------------------------*}
+
+
+{*  native OS integer types *}
+  HPDF_INT = Integer;
+  HPDF_UINT = Cardinal;
+  HPDF_PUINT = ^Cardinal;
+
+{*  32bit integer types
+ *}
+  HPDF_INT32 = Longint;
+  HPDF_UINT32 = Longword;
+  HPDF_PUINT32 = ^Longword;
+
+
+{*  16bit integer types
+ *}
+  HPDF_INT16 = SmallInt;
+  HPDF_UINT16 = Word;
+  HPDF_PUINT16 = ^Word;
+
+
+
+{*  8bit integer types
+ *}
+  HPDF_INT8 = Shortint;
+  HPDF_UINT8 = Byte;
+
+
+{*  8bit character types
+ *}
+  HPDF_CHAR = char;
+
+
+{*  8bit binary types
+ *}
+  HPDF_BYTE = Byte;
+  HPDF_PBYTE = ^Byte;
+
+
+{*  float type (32bit IEEE754)
+ *}
+  HPDF_REAL = Single;
+  HPDF_PREAL = ^HPDF_REAL;
+
+
+{*  double type (64bit IEEE754)
+ *}
+  HPDF_DOUBLE = Double;
+
+
+{*  boolean type (0: False, 1: True)
+ *}
+  HPDF_BOOL = Integer;
+
+
+{*  error-no type (32bit unsigned integer)
+ *}
+  HPDF_STATUS = Cardinal;
+
+
+{*  character-code type (16bit)
+ *}
+  HPDF_CID = Word;
+  HPDF_UNICODE = Word;
+
+{*  null terminated character *}
+  HPDF_PCHAR = PChar;
+
+
+{*  HPDF_Box struct
+ *}
+  THPDF_Box = packed record
+    left: HPDF_REAL;
+    bottom: HPDF_REAL;
+    right: HPDF_REAL;
+    top: HPDF_REAL;
+  end;
+
+
+{*  HPDF_Point struct
+ *}
+  THPDF_Point = packed record
+    x: HPDF_REAL;
+    y: HPDF_REAL;
+  end;
+  PHPDF_Point = ^THPDF_Point;
+
+
+{*  HPDF_Rect struct
+ *}
+  THPDF_Rect = packed record
+    left: HPDF_REAL;
+    bottom: HPDF_REAL;
+    right: HPDF_REAL;
+    top: HPDF_REAL;
+  end;
+
+
+{* HPDF_Date struct
+ *}
+  THPDF_Date = packed record
+    year: HPDF_INT;
+    month: HPDF_INT;
+    day: HPDF_INT;
+    hour: HPDF_INT;
+    minutes: HPDF_INT;
+    seconds: HPDF_INT;
+    ind: HPDF_CHAR;
+    off_hour: HPDF_INT;
+    off_minutes: HPDF_INT;
+  end;
+
+
+  THPDF_InfoType = (
+    HPDF_INFO_CREATION_DATE,
+    HPDF_INFO_MOD_DATE,
+    HPDF_INFO_AUTHOR,
+    HPDF_INFO_CREATOR,
+    HPDF_INFO_PRODUCER,
+    HPDF_INFO_TITLE,
+    HPDF_INFO_SUBJECT,
+    HPDF_INFO_KEYWORDS,
+    HPDF_INFO_EOF
+  );
+
+
+  THPDF_EncryptMode = (
+    HPDF_ENCRYPT_R2,
+    HPDF_ENCRYPT_R3
+  );
+
+
+
+
+{*---------------------------------------------------------------------------*}
+{*------ text width struct --------------------------------------------------*}
+
+  THPDF_TextWidth = packed record
+    numchars: HPDF_UINT;
+    numwords: HPDF_UINT;   {* don't use this value. *}
+    width: HPDF_UINT;
+    numspace: HPDF_UINT;
+  end;
+
+
+{*---------------------------------------------------------------------------*}
+{*------ dash mode ----------------------------------------------------------*}
+
+  THPDF_DashMode = packed record
+    ptn: array[0..7] of HPDF_UINT16;
+    num_ptn: HPDF_UINT16;
+    phase: HPDF_UINT16;
+  end;
+
+
+{*---------------------------------------------------------------------------*}
+{*----- HPDF_TransMatrix struct ---------------------------------------------*}
+
+  THPDF_TransMatrix = packed record
+    a: HPDF_REAL;
+    b: HPDF_REAL;
+    c: HPDF_REAL;
+    d: HPDF_REAL;
+    x: HPDF_REAL;
+    y: HPDF_REAL;
+  end;
+
+
+{*---------------------------------------------------------------------------*}
+
+  THPDF_ColorSpace = (
+    HPDF_CS_DEVICE_GRAY,
+    HPDF_CS_DEVICE_RGB,
+    HPDF_CS_DEVICE_CMYK,
+    HPDF_CS_CAL_GRAY,
+    HPDF_CS_CAL_RGB,
+    HPDF_CS_LAB,
+    HPDF_CS_ICC_BASED,
+    HPDF_CS_SEPARATION,
+    HPDF_CS_DEVICE_N,
+    HPDF_CS_INDEXED,
+    HPDF_CS_PATTERN,
+    HPDF_CS_EOF
+  );
+
+{*---------------------------------------------------------------------------*}
+{*----- HPDF_RGBColor struct ------------------------------------------------*}
+
+  THPDF_RGBColor = packed record
+    r: HPDF_REAL;
+    g: HPDF_REAL;
+    b: HPDF_REAL;
+  end;
+
+{*---------------------------------------------------------------------------*}
+{*----- HPDF_CMYKColor struct -----------------------------------------------*}
+
+  THPDF_CMYKColor = packed record
+    c: HPDF_REAL;
+    m: HPDF_REAL;
+    y: HPDF_REAL;
+    k: HPDF_REAL;
+  end;
+
+{*---------------------------------------------------------------------------*}
+{*------ The line cap style -------------------------------------------------*}
+
+  THPDF_LineCap = (
+    HPDF_BUTT_END,
+    HPDF_ROUND_END,
+    HPDF_PROJECTING_SQUARE_END
+  );
+
+{*----------------------------------------------------------------------------*}
+{*------ The line join style -------------------------------------------------*}
+
+  THPDF_LineJoin = (
+    HPDF_MITER_JOIN,
+    HPDF_ROUND_JOIN,
+    HPDF_BEVEL_JOIN
+  );
+
+{*----------------------------------------------------------------------------*}
+{*------ The text rendering mode ---------------------------------------------*}
+
+  THPDF_TextRenderingMode = (
+    HPDF_FILL,
+    HPDF_STROKE,
+    HPDF_FILL_THEN_STROKE,
+    HPDF_INVISIBLE,
+    HPDF_FILL_CLIPPING,
+    HPDF_STROKE_CLIPPING,
+    HPDF_FILL_STROKE_CLIPPING,
+    HPDF_CLIPPING,
+    HPDF_RENDERING_MODE_EOF
+  );
+
+
+  THPDF_WritingMode = (
+    HPDF_WMODE_HORIZONTAL,
+    HPDF_WMODE_VERTICAL
+  );
+
+
+  THPDF_PageLayout = (
+    HPDF_PAGE_LAYOUT_SINGLE,
+    HPDF_PAGE_LAYOUT_ONE_COLUMN,
+    HPDF_PAGE_LAYOUT_TWO_COLUMN_LEFT,
+    HPDF_PAGE_LAYOUT_TWO_COLUMN_RIGHT
+  );
+
+
+  THPDF_PageMode = (
+    HPDF_PAGE_MODE_USE_NONE,
+    HPDF_PAGE_MODE_USE_OUTLINE,
+    HPDF_PAGE_MODE_USE_THUMBS,
+    HPDF_PAGE_MODE_FULL_SCREEN
+{*  HPDF_PAGE_MODE_USE_OC,
+    HPDF_PAGE_MODE_USE_ATTACHMENTS
+ *}
+  );
+
+
+  THPDF_PageNumStyle = (
+    HPDF_PAGE_NUM_STYLE_DECIMAL,
+    HPDF_PAGE_NUM_STYLE_UPPER_ROMAN,
+    HPDF_PAGE_NUM_STYLE_LOWER_ROMAN,
+    HPDF_PAGE_NUM_STYLE_UPPER_LETTERS,
+    HPDF_PAGE_NUM_STYLE_LOWER_LETTERS
+  );
+
+
+  THPDF_DestinationType = (
+    HPDF_XYZ,
+    HPDF_FIT,
+    HPDF_FIT_H,
+    HPDF_FIT_V,
+    HPDF_FIT_R,
+    HPDF_FIT_B,
+    HPDF_FIT_BH,
+    HPDF_FIT_BV,
+    HPDF_DST_EOF
+  );
+
+
+  THPDF_AnnotType = (
+    HPDF_ANNOT_TEXT_NOTES,
+    HPDF_ANNOT_LINK,
+    HPDF_ANNOT_SOUND,
+    HPDF_ANNOT_FREE_TEXT,
+    HPDF_ANNOT_STAMP,
+    HPDF_ANNOT_SQUARE,
+    HPDF_ANNOT_CIRCLE,
+    HPDF_ANNOT_STRIKE_OUT,
+    HPDF_ANNOT_HIGHTLIGHT,
+    HPDF_ANNOT_UNDERLINE,
+    HPDF_ANNOT_INK,
+    HPDF_ANNOT_FILE_ATTACHMENT,
+    HPDF_ANNOT_POPUP
+  );
+
+
+  THPDF_AnnotFlgs = (
+    HPDF_ANNOT_INVISIBLE,
+    HPDF_ANNOT_HIDDEN,
+    HPDF_ANNOT_PRINT,
+    HPDF_ANNOT_NOZOOM,
+    HPDF_ANNOT_NOROTATE,
+    HPDF_ANNOT_NOVIEW,
+    HPDF_ANNOT_READONLY
+  );
+
+
+  THPDF_AnnotHighlightMode = (
+    HPDF_ANNOT_NO_HIGHTLIGHT,
+    HPDF_ANNOT_INVERT_BOX,
+    HPDF_ANNOT_INVERT_BORDER,
+    HPDF_ANNOT_DOWN_APPEARANCE
+  );
+
+
+  THPDF_AnnotIcon = (
+    HPDF_ANNOT_ICON_COMMENT,
+    HPDF_ANNOT_ICON_KEY,
+    HPDF_ANNOT_ICON_NOTE,
+    HPDF_ANNOT_ICON_HELP,
+    HPDF_ANNOT_ICON_NEW_PARAGRAPH,
+    HPDF_ANNOT_ICON_PARAGRAPH,
+    HPDF_ANNOT_ICON_INSERT
+  );
+
+
+{*----------------------------------------------------------------------------*}
+{*------ border stype --------------------------------------------------------*}
+
+  THPDF_BSSubtype = (
+    HPDF_BS_SOLID,
+    HPDF_BS_DASHED,
+    HPDF_BS_BEVELED,
+    HPDF_BS_INSET,
+    HPDF_BS_UNDERLINED
+  );
+
+
+  THPDF_PageSizes = (
+    HPDF_PAGE_SIZE_LETTER,
+    HPDF_PAGE_SIZE_LEGAL,
+    HPDF_PAGE_SIZE_A3,
+    HPDF_PAGE_SIZE_A4,
+    HPDF_PAGE_SIZE_A5,
+    HPDF_PAGE_SIZE_B5,
+    HPDF_PAGE_SIZE_EXECUTIVE,
+    HPDF_PAGE_SIZE_US4x6,
+    HPDF_PAGE_SIZE_US4x8,
+    HPDF_PAGE_SIZE_US5x7,
+    HPDF_PAGE_SIZE_COMM10
+  );
+
+
+  THPDF_PageDirection = (
+    HPDF_PAGE_PORTRAIT,
+    HPDF_PAGE_LANDSCAPE
+  );
+
+
+  THPDF_EncoderType = (
+    HPDF_ENCODER_TYPE_SINGLE_BYTE,
+    HPDF_ENCODER_TYPE_DOUBLE_BYTE,
+    HPDF_ENCODER_TYPE_UNINITIALIZED,
+    HPDF_ENCODER_UNKNOWN
+  );
+
+
+  THPDF_ByteType = (
+    HPDF_BYTE_TYPE_SINGLE,
+    HPDF_BYTE_TYPE_LEAD,
+    HPDF_BYTE_TYPE_TRAIL,
+    HPDF_BYTE_TYPE_UNKNOWN
+  );
+
+
+  THPDF_TextAlignment = (
+    HPDF_TALIGN_LEFT,
+    HPDF_TALIGN_RIGHT,
+    HPDF_TALIGN_CENTER,
+    HPDF_TALIGN_JUSTIFY
+  );
+
+
+  THPDF_BlendMode = (
+    HPDF_BM_NORMAL,
+    HPDF_BM_MULTIPLY,
+    HPDF_BM_SCREEN,
+    HPDF_BM_OVERLAY,
+    HPDF_BM_DARKEN,
+    HPDF_BM_LIGHTEN,
+    HPDF_BM_COLOR_DODGE,
+    HPDF_BM_COLOR_BUM,
+    HPDF_BM_HARD_LIGHT,
+    HPDF_BM_SOFT_LIGHT,
+    HPDF_BM_DIFFERENCE,
+    HPDF_BM_EXCLUSHON,
+    HPDF_BM_EOF
+  );
+
+
+  THPDF_TransitionStyle = (
+    HPDF_TS_WIPE_RIGHT,
+    HPDF_TS_WIPE_UP,
+    HPDF_TS_WIPE_LEFT,
+    HPDF_TS_WIPE_DOWN,
+    HPDF_TS_BARN_DOORS_HORIZONTAL_OUT,
+    HPDF_TS_BARN_DOORS_HORIZONTAL_IN,
+    HPDF_TS_BARN_DOORS_VERTICAL_OUT,
+    HPDF_TS_BARN_DOORS_VERTICAL_IN,
+    HPDF_TS_BOX_OUT,
+    HPDF_TS_BOX_IN,
+    HPDF_TS_BLINDS_HORIZONTAL,
+    HPDF_TS_BLINDS_VERTICAL,
+    HPDF_TS_DISSOLVE,
+    HPDF_TS_GLITTER_RIGHT,
+    HPDF_TS_GLITTER_DOWN,
+    HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT,
+    HPDF_TS_REPLACE,
+    HPDF_TS_EOF
+  );
+
+
+THPDF_ErrorFunc = procedure (error_no: HPDF_STATUS; detail_no: HPDF_STATUS;
+                user_data: Pointer); stdcall;
+
+THPDF_AllocFunc = procedure (size: Cardinal); stdcall;
+
+THPDF_FreeFunc = procedure (aptr: Pointer); stdcall;
+
+implementation
+
+end.

+ 25 - 0
pdf.mod/libharu/bindings/freebasic/README.freebasic

@@ -0,0 +1,25 @@
+To use this interface, you need to build Haru as a static library (.a) or use 
+the binary package for win32.
+
+There is an example program in this directory. 
+The steps to run the demonstration program are as follows:
+
+1. Build libHaru as a static library and copy libhpdf.a to your source 
+   directory.
+   If you want to build libhpdf on win32 platforms you need either
+   MinGW/MSYS or Cygwin.
+ 
+2. Put the include (.bi) files in your source directory.
+
+3. Compile and run the demo program.
+
+   a) compile with: fbc hpdftest.bas
+   b) run with:     hpdftest.exe (on win32) or ./hpdftest (on linux)
+
+
+For more information see: http://www.freebasic.net/forum/viewtopic.php?t=9014
+
+
+NOTE:
+libhpdf.a is required to run the program which uses the FreeBasic interface for
+libHaru.

+ 217 - 0
pdf.mod/libharu/bindings/freebasic/hpdf.bi

@@ -0,0 +1,217 @@
+''
+''
+'' hpdf -- header translated with help of SWIG FB wrapper
+''
+'' NOTICE: This file is part of the FreeBASIC Compiler package and can't
+''         be included in other distributions without authorization.
+''
+''
+#ifndef __hpdf_bi__
+#define __hpdf_bi__
+
+#inclib "hpdf"  
+
+
+'extern "c" 
+declare function HPDF_GetVersion cdecl alias "HPDF_GetVersion" () as zstring ptr
+declare function HPDF_NewEx cdecl alias "HPDF_NewEx" (byval user_error_fn as HPDF_Error_Handler, byval user_alloc_fn as HPDF_Alloc_Func, byval user_free_fn as HPDF_Free_Func, byval mem_pool_buf_size as HPDF_UINT, byval user_data as any ptr) as HPDF_Doc
+declare function HPDF_New cdecl alias "HPDF_New" (byval user_error_fn as HPDF_Error_Handler, byval user_data as any ptr) as HPDF_Doc
+declare function HPDF_SetErrorHandler cdecl alias "HPDF_SetErrorHandler" (byval pdf as HPDF_Doc, byval user_error_fn as HPDF_Error_Handler) as HPDF_STATUS
+declare sub HPDF_Free cdecl alias "HPDF_Free" (byval pdf as HPDF_Doc)
+declare function HPDF_NewDoc cdecl alias "HPDF_NewDoc" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare sub HPDF_FreeDoc cdecl alias "HPDF_FreeDoc" (byval pdf as HPDF_Doc)
+declare function HPDF_HasDoc cdecl alias "HPDF_HasDoc" (byval pdf as HPDF_Doc) as HPDF_BOOL
+declare sub HPDF_FreeDocAll cdecl alias "HPDF_FreeDocAll" (byval pdf as HPDF_Doc)
+declare function HPDF_SaveToStream cdecl alias "HPDF_SaveToStream" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare function HPDF_GetStreamSize cdecl alias "HPDF_GetStreamSize" (byval pdf as HPDF_Doc) as HPDF_UINT32
+declare function HPDF_ReadFromStream cdecl alias "HPDF_ReadFromStream" (byval pdf as HPDF_Doc, byval buf as HPDF_BYTE ptr, byval size as HPDF_UINT32 ptr) as HPDF_STATUS
+declare function HPDF_ResetStream cdecl alias "HPDF_ResetStream" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare function HPDF_SaveToFile cdecl alias "HPDF_SaveToFile" (byval pdf as HPDF_Doc, byval file_name as zstring ptr) as HPDF_STATUS
+declare function HPDF_GetError cdecl alias "HPDF_GetError" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare function HPDF_GetErrorDetail cdecl alias "HPDF_GetErrorDetail" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare sub HPDF_ResetError cdecl alias "HPDF_ResetError" (byval pdf as HPDF_Doc)
+declare function HPDF_SetPagesConfiguration cdecl alias "HPDF_SetPagesConfiguration" (byval pdf as HPDF_Doc, byval page_per_pages as HPDF_UINT) as HPDF_STATUS
+declare function HPDF_GetPageByIndex cdecl alias "HPDF_GetPageByIndex" (byval pdf as HPDF_Doc, byval index as HPDF_UINT) as HPDF_Page
+declare function HPDF_GetPageLayout cdecl alias "HPDF_GetPageLayout" (byval pdf as HPDF_Doc) as HPDF_PageLayout
+declare function HPDF_SetPageLayout cdecl alias "HPDF_SetPageLayout" (byval pdf as HPDF_Doc, byval layout as HPDF_PageLayout) as HPDF_STATUS
+declare function HPDF_GetPageMode cdecl alias "HPDF_GetPageMode" (byval pdf as HPDF_Doc) as HPDF_PageMode
+declare function HPDF_SetPageMode cdecl alias "HPDF_SetPageMode" (byval pdf as HPDF_Doc, byval mode as HPDF_PageMode) as HPDF_STATUS
+declare function HPDF_GetViewerPreference cdecl alias "HPDF_GetViewerPreference" (byval pdf as HPDF_Doc) as HPDF_UINT
+declare function HPDF_SetViewerPreference cdecl alias "HPDF_SetViewerPreference" (byval pdf as HPDF_Doc, byval value as HPDF_UINT) as HPDF_STATUS
+declare function HPDF_SetOpenAction cdecl alias "HPDF_SetOpenAction" (byval pdf as HPDF_Doc, byval open_action as HPDF_Destination) as HPDF_STATUS
+declare function HPDF_GetCurrentPage cdecl alias "HPDF_GetCurrentPage" (byval pdf as HPDF_Doc) as HPDF_Page
+declare function HPDF_AddPage cdecl alias "HPDF_AddPage" (byval pdf as HPDF_Doc) as HPDF_Page
+declare function HPDF_InsertPage cdecl alias "HPDF_InsertPage" (byval pdf as HPDF_Doc, byval page as HPDF_Page) as HPDF_Page
+declare function HPDF_Page_SetWidth cdecl alias "HPDF_Page_SetWidth" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetHeight cdecl alias "HPDF_Page_SetHeight" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetSize cdecl alias "HPDF_Page_SetSize" (byval page as HPDF_Page, byval size as HPDF_PageSizes, byval direction as HPDF_PageDirection) as HPDF_STATUS
+declare function HPDF_Page_SetRotate cdecl alias "HPDF_Page_SetRotate" (byval page as HPDF_Page, byval angle as HPDF_UINT16) as HPDF_STATUS
+declare function HPDF_GetFont cdecl alias "HPDF_GetFont" (byval pdf as HPDF_Doc, byval font_name as zstring ptr, byval encoding_name as zstring ptr) as HPDF_Font
+declare function HPDF_LoadType1FontFromFile cdecl alias "HPDF_LoadType1FontFromFile" (byval pdf as HPDF_Doc, byval afm_file_name as zstring ptr, byval data_file_name as zstring ptr) as zstring ptr
+declare function HPDF_LoadTTFontFromFile cdecl alias "HPDF_LoadTTFontFromFile" (byval pdf as HPDF_Doc, byval file_name as zstring ptr, byval embedding as HPDF_BOOL) as zstring ptr
+declare function HPDF_LoadTTFontFromFile2 cdecl alias "HPDF_LoadTTFontFromFile2" (byval pdf as HPDF_Doc, byval file_name as zstring ptr, byval index as HPDF_UINT, byval embedding as HPDF_BOOL) as zstring ptr
+declare function HPDF_AddPageLabel cdecl alias "HPDF_AddPageLabel" (byval pdf as HPDF_Doc, byval page_num as HPDF_UINT, byval style as HPDF_PageNumStyle, byval first_page as HPDF_UINT, byval prefix as zstring ptr) as HPDF_STATUS
+declare function HPDF_UseJPFonts cdecl alias "HPDF_UseJPFonts" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare function HPDF_UseKRFonts cdecl alias "HPDF_UseKRFonts" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare function HPDF_UseCNSFonts cdecl alias "HPDF_UseCNSFonts" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare function HPDF_UseCNTFonts cdecl alias "HPDF_UseCNTFonts" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare function HPDF_CreateOutline cdecl alias "HPDF_CreateOutline" (byval pdf as HPDF_Doc, byval parent as HPDF_Outline, byval title as zstring ptr, byval encoder as HPDF_Encoder) as HPDF_Outline
+declare function HPDF_Outline_SetOpened cdecl alias "HPDF_Outline_SetOpened" (byval outline as HPDF_Outline, byval opened as HPDF_BOOL) as HPDF_STATUS
+declare function HPDF_Outline_SetDestination cdecl alias "HPDF_Outline_SetDestination" (byval outline as HPDF_Outline, byval dst as HPDF_Destination) as HPDF_STATUS
+declare function HPDF_Page_CreateDestination cdecl alias "HPDF_Page_CreateDestination" (byval page as HPDF_Page) as HPDF_Destination
+declare function HPDF_Destination_SetXYZ cdecl alias "HPDF_Destination_SetXYZ" (byval dst as HPDF_Destination, byval left as HPDF_REAL, byval top as HPDF_REAL, byval zoom as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Destination_SetFit cdecl alias "HPDF_Destination_SetFit" (byval dst as HPDF_Destination) as HPDF_STATUS
+declare function HPDF_Destination_SetFitH cdecl alias "HPDF_Destination_SetFitH" (byval dst as HPDF_Destination, byval top as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Destination_SetFitV cdecl alias "HPDF_Destination_SetFitV" (byval dst as HPDF_Destination, byval left as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Destination_SetFitR cdecl alias "HPDF_Destination_SetFitR" (byval dst as HPDF_Destination, byval left as HPDF_REAL, byval bottom as HPDF_REAL, byval right as HPDF_REAL, byval top as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Destination_SetFitB cdecl alias "HPDF_Destination_SetFitB" (byval dst as HPDF_Destination) as HPDF_STATUS
+declare function HPDF_Destination_SetFitBH cdecl alias "HPDF_Destination_SetFitBH" (byval dst as HPDF_Destination, byval top as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Destination_SetFitBV cdecl alias "HPDF_Destination_SetFitBV" (byval dst as HPDF_Destination, byval left as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_GetEncoder cdecl alias "HPDF_GetEncoder" (byval pdf as HPDF_Doc, byval encoding_name as zstring ptr) as HPDF_Encoder
+declare function HPDF_GetCurrentEncoder cdecl alias "HPDF_GetCurrentEncoder" (byval pdf as HPDF_Doc) as HPDF_Encoder
+declare function HPDF_SetCurrentEncoder cdecl alias "HPDF_SetCurrentEncoder" (byval pdf as HPDF_Doc, byval encoding_name as zstring ptr) as HPDF_STATUS
+declare function HPDF_Encoder_GetType cdecl alias "HPDF_Encoder_GetType" (byval encoder as HPDF_Encoder) as HPDF_EncoderType
+declare function HPDF_Encoder_GetByteType cdecl alias "HPDF_Encoder_GetByteType" (byval encoder as HPDF_Encoder, byval text as zstring ptr, byval index as HPDF_UINT) as HPDF_ByteType
+declare function HPDF_Encoder_GetUnicode cdecl alias "HPDF_Encoder_GetUnicode" (byval encoder as HPDF_Encoder, byval code as HPDF_UINT16) as HPDF_UNICODE
+declare function HPDF_Encoder_GetWritingMode cdecl alias "HPDF_Encoder_GetWritingMode" (byval encoder as HPDF_Encoder) as HPDF_WritingMode
+declare function HPDF_UseJPEncodings cdecl alias "HPDF_UseJPEncodings" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare function HPDF_UseKREncodings cdecl alias "HPDF_UseKREncodings" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare function HPDF_UseCNSEncodings cdecl alias "HPDF_UseCNSEncodings" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare function HPDF_UseCNTEncodings cdecl alias "HPDF_UseCNTEncodings" (byval pdf as HPDF_Doc) as HPDF_STATUS
+declare function HPDF_Page_CreateTextAnnot cdecl alias "HPDF_Page_CreateTextAnnot" (byval page as HPDF_Page, byval rect as HPDF_Rect, byval text as zstring ptr, byval encoder as HPDF_Encoder) as HPDF_Annotation
+declare function HPDF_Page_CreateLinkAnnot cdecl alias "HPDF_Page_CreateLinkAnnot" (byval page as HPDF_Page, byval rect as HPDF_Rect, byval dst as HPDF_Destination) as HPDF_Annotation
+declare function HPDF_Page_CreateURILinkAnnot cdecl alias "HPDF_Page_CreateURILinkAnnot" (byval page as HPDF_Page, byval rect as HPDF_Rect, byval uri as zstring ptr) as HPDF_Annotation
+declare function HPDF_LinkAnnot_SetHighlightMode cdecl alias "HPDF_LinkAnnot_SetHighlightMode" (byval annot as HPDF_Annotation, byval mode as HPDF_AnnotHighlightMode) as HPDF_STATUS
+declare function HPDF_LinkAnnot_SetBorderStyle cdecl alias "HPDF_LinkAnnot_SetBorderStyle" (byval annot as HPDF_Annotation, byval width as HPDF_REAL, byval dash_on as HPDF_UINT16, byval dash_off as HPDF_UINT16) as HPDF_STATUS
+declare function HPDF_TextAnnot_SetIcon cdecl alias "HPDF_TextAnnot_SetIcon" (byval annot as HPDF_Annotation, byval icon as HPDF_AnnotIcon) as HPDF_STATUS
+declare function HPDF_TextAnnot_SetOpened cdecl alias "HPDF_TextAnnot_SetOpened" (byval annot as HPDF_Annotation, byval opened as HPDF_BOOL) as HPDF_STATUS
+declare function HPDF_LoadPngImageFromFile cdecl alias "HPDF_LoadPngImageFromFile" (byval pdf as HPDF_Doc, byval filename as zstring ptr) as HPDF_Image
+declare function HPDF_LoadPngImageFromFile2 cdecl alias "HPDF_LoadPngImageFromFile2" (byval pdf as HPDF_Doc, byval filename as zstring ptr) as HPDF_Image
+declare function HPDF_LoadJpegImageFromFile cdecl alias "HPDF_LoadJpegImageFromFile" (byval pdf as HPDF_Doc, byval filename as zstring ptr) as HPDF_Image
+declare function HPDF_LoadRawImageFromFile cdecl alias "HPDF_LoadRawImageFromFile" (byval pdf as HPDF_Doc, byval filename as zstring ptr, byval width as HPDF_UINT, byval height as HPDF_UINT, byval color_space as HPDF_ColorSpace) as HPDF_Image
+declare function HPDF_LoadRawImageFromMem cdecl alias "HPDF_LoadRawImageFromMem" (byval pdf as HPDF_Doc, byval buf as HPDF_BYTE ptr, byval width as HPDF_UINT, byval height as HPDF_UINT, byval color_space as HPDF_ColorSpace, byval bits_per_component as HPDF_UINT) as HPDF_Image
+declare function HPDF_Image_GetSize cdecl alias "HPDF_Image_GetSize" (byval image as HPDF_Image) as HPDF_Point
+declare function HPDF_Image_GetSize2 cdecl alias "HPDF_Image_GetSize2" (byval image as HPDF_Image, byval size as HPDF_Point ptr) as HPDF_STATUS
+declare function HPDF_Image_GetWidth cdecl alias "HPDF_Image_GetWidth" (byval image as HPDF_Image) as HPDF_UINT
+declare function HPDF_Image_GetHeight cdecl alias "HPDF_Image_GetHeight" (byval image as HPDF_Image) as HPDF_UINT
+declare function HPDF_Image_GetBitsPerComponent cdecl alias "HPDF_Image_GetBitsPerComponent" (byval image as HPDF_Image) as HPDF_UINT
+declare function HPDF_Image_GetColorSpace cdecl alias "HPDF_Image_GetColorSpace" (byval image as HPDF_Image) as zstring ptr
+declare function HPDF_Image_SetColorMask cdecl alias "HPDF_Image_SetColorMask" (byval image as HPDF_Image, byval rmin as HPDF_UINT, byval rmax as HPDF_UINT, byval gmin as HPDF_UINT, byval gmax as HPDF_UINT, byval bmin as HPDF_UINT, byval bmax as HPDF_UINT) as HPDF_STATUS
+declare function HPDF_Image_SetMaskImage cdecl alias "HPDF_Image_SetMaskImage" (byval image as HPDF_Image, byval mask_image as HPDF_Image) as HPDF_STATUS
+declare function HPDF_SetInfoAttr cdecl alias "HPDF_SetInfoAttr" (byval pdf as HPDF_Doc, byval type as HPDF_InfoType, byval value as zstring ptr) as HPDF_STATUS
+declare function HPDF_GetInfoAttr cdecl alias "HPDF_GetInfoAttr" (byval pdf as HPDF_Doc, byval type as HPDF_InfoType) as zstring ptr
+declare function HPDF_SetInfoDateAttr cdecl alias "HPDF_SetInfoDateAttr" (byval pdf as HPDF_Doc, byval type as HPDF_InfoType, byval value as HPDF_Date) as HPDF_STATUS
+declare function HPDF_SetPassword cdecl alias "HPDF_SetPassword" (byval pdf as HPDF_Doc, byval owner_passwd as zstring ptr, byval user_passwd as zstring ptr) as HPDF_STATUS
+declare function HPDF_SetPermission cdecl alias "HPDF_SetPermission" (byval pdf as HPDF_Doc, byval permission as HPDF_UINT) as HPDF_STATUS
+declare function HPDF_SetEncryptionMode cdecl alias "HPDF_SetEncryptionMode" (byval pdf as HPDF_Doc, byval mode as HPDF_EncryptMode, byval key_len as HPDF_UINT) as HPDF_STATUS
+declare function HPDF_SetCompressionMode cdecl alias "HPDF_SetCompressionMode" (byval pdf as HPDF_Doc, byval mode as HPDF_UINT) as HPDF_STATUS
+declare function HPDF_Font_GetFontName cdecl alias "HPDF_Font_GetFontName" (byval font as HPDF_Font) as zstring ptr
+declare function HPDF_Font_GetEncodingName cdecl alias "HPDF_Font_GetEncodingName" (byval font as HPDF_Font) as zstring ptr
+declare function HPDF_Font_GetUnicodeWidth cdecl alias "HPDF_Font_GetUnicodeWidth" (byval font as HPDF_Font, byval code as HPDF_UNICODE) as HPDF_INT
+declare function HPDF_Font_GetBBox cdecl alias "HPDF_Font_GetBBox" (byval font as HPDF_Font) as HPDF_Box
+declare function HPDF_Font_GetAscent cdecl alias "HPDF_Font_GetAscent" (byval font as HPDF_Font) as HPDF_INT
+declare function HPDF_Font_GetDescent cdecl alias "HPDF_Font_GetDescent" (byval font as HPDF_Font) as HPDF_INT
+declare function HPDF_Font_GetXHeight cdecl alias "HPDF_Font_GetXHeight" (byval font as HPDF_Font) as HPDF_UINT
+declare function HPDF_Font_GetCapHeight cdecl alias "HPDF_Font_GetCapHeight" (byval font as HPDF_Font) as HPDF_UINT
+declare function HPDF_Font_TextWidth cdecl alias "HPDF_Font_TextWidth" (byval font as HPDF_Font, byval text as HPDF_BYTE ptr, byval len as HPDF_UINT) as HPDF_TextWidth
+declare function HPDF_Font_MeasureText cdecl alias "HPDF_Font_MeasureText" (byval font as HPDF_Font, byval text as HPDF_BYTE ptr, byval len as HPDF_UINT, byval width as HPDF_REAL, byval font_size as HPDF_REAL, byval char_space as HPDF_REAL, byval word_space as HPDF_REAL, byval wordwrap as HPDF_BOOL, byval real_width as HPDF_REAL ptr) as HPDF_UINT
+declare function HPDF_CreateExtGState cdecl alias "HPDF_CreateExtGState" (byval pdf as HPDF_Doc) as HPDF_ExtGState
+declare function HPDF_ExtGState_SetAlphaStroke cdecl alias "HPDF_ExtGState_SetAlphaStroke" (byval ext_gstate as HPDF_ExtGState, byval value as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_ExtGState_SetAlphaFill cdecl alias "HPDF_ExtGState_SetAlphaFill" (byval ext_gstate as HPDF_ExtGState, byval value as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_ExtGState_SetBlendMode cdecl alias "HPDF_ExtGState_SetBlendMode" (byval ext_gstate as HPDF_ExtGState, byval mode as HPDF_BlendMode) as HPDF_STATUS
+declare function HPDF_Page_TextWidth cdecl alias "HPDF_Page_TextWidth" (byval page as HPDF_Page, byval text as zstring ptr) as HPDF_REAL
+declare function HPDF_Page_MeasureText cdecl alias "HPDF_Page_MeasureText" (byval page as HPDF_Page, byval text as zstring ptr, byval width as HPDF_REAL, byval wordwrap as HPDF_BOOL, byval real_width as HPDF_REAL ptr) as HPDF_UINT
+declare function HPDF_Page_GetWidth cdecl alias "HPDF_Page_GetWidth" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetHeight cdecl alias "HPDF_Page_GetHeight" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetGMode cdecl alias "HPDF_Page_GetGMode" (byval page as HPDF_Page) as HPDF_UINT16
+declare function HPDF_Page_GetCurrentPos cdecl alias "HPDF_Page_GetCurrentPos" (byval page as HPDF_Page) as HPDF_Point
+declare function HPDF_Page_GetCurrentPos2 cdecl alias "HPDF_Page_GetCurrentPos2" (byval page as HPDF_Page, byval pos as HPDF_Point ptr) as HPDF_STATUS
+declare function HPDF_Page_GetCurrentTextPos cdecl alias "HPDF_Page_GetCurrentTextPos" (byval page as HPDF_Page) as HPDF_Point
+declare function HPDF_Page_GetCurrentTextPos2 cdecl alias "HPDF_Page_GetCurrentTextPos2" (byval page as HPDF_Page, byval pos as HPDF_Point ptr) as HPDF_STATUS
+declare function HPDF_Page_GetCurrentFont cdecl alias "HPDF_Page_GetCurrentFont" (byval page as HPDF_Page) as HPDF_Font
+declare function HPDF_Page_GetCurrentFontSize cdecl alias "HPDF_Page_GetCurrentFontSize" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetTransMatrix cdecl alias "HPDF_Page_GetTransMatrix" (byval page as HPDF_Page) as HPDF_TransMatrix
+declare function HPDF_Page_GetLineWidth cdecl alias "HPDF_Page_GetLineWidth" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetLineCap cdecl alias "HPDF_Page_GetLineCap" (byval page as HPDF_Page) as HPDF_LineCap
+declare function HPDF_Page_GetLineJoin cdecl alias "HPDF_Page_GetLineJoin" (byval page as HPDF_Page) as HPDF_LineJoin
+declare function HPDF_Page_GetMiterLimit cdecl alias "HPDF_Page_GetMiterLimit" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetDash cdecl alias "HPDF_Page_GetDash" (byval page as HPDF_Page) as HPDF_DashMode
+declare function HPDF_Page_GetFlat cdecl alias "HPDF_Page_GetFlat" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetCharSpace cdecl alias "HPDF_Page_GetCharSpace" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetWordSpace cdecl alias "HPDF_Page_GetWordSpace" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetHorizontalScalling cdecl alias "HPDF_Page_GetHorizontalScalling" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetTextLeading cdecl alias "HPDF_Page_GetTextLeading" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetTextRenderingMode cdecl alias "HPDF_Page_GetTextRenderingMode" (byval page as HPDF_Page) as HPDF_TextRenderingMode
+declare function HPDF_Page_GetTextRaise cdecl alias "HPDF_Page_GetTextRaise" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetTextRise cdecl alias "HPDF_Page_GetTextRise" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetRGBFill cdecl alias "HPDF_Page_GetRGBFill" (byval page as HPDF_Page) as HPDF_RGBColor
+declare function HPDF_Page_GetRGBStroke cdecl alias "HPDF_Page_GetRGBStroke" (byval page as HPDF_Page) as HPDF_RGBColor
+declare function HPDF_Page_GetCMYKFill cdecl alias "HPDF_Page_GetCMYKFill" (byval page as HPDF_Page) as HPDF_CMYKColor
+declare function HPDF_Page_GetCMYKStroke cdecl alias "HPDF_Page_GetCMYKStroke" (byval page as HPDF_Page) as HPDF_CMYKColor
+declare function HPDF_Page_GetGrayFill cdecl alias "HPDF_Page_GetGrayFill" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetGrayStroke cdecl alias "HPDF_Page_GetGrayStroke" (byval page as HPDF_Page) as HPDF_REAL
+declare function HPDF_Page_GetStrokingColorSpace cdecl alias "HPDF_Page_GetStrokingColorSpace" (byval page as HPDF_Page) as HPDF_ColorSpace
+declare function HPDF_Page_GetFillingColorSpace cdecl alias "HPDF_Page_GetFillingColorSpace" (byval page as HPDF_Page) as HPDF_ColorSpace
+declare function HPDF_Page_GetTextMatrix cdecl alias "HPDF_Page_GetTextMatrix" (byval page as HPDF_Page) as HPDF_TransMatrix
+declare function HPDF_Page_GetGStateDepth cdecl alias "HPDF_Page_GetGStateDepth" (byval page as HPDF_Page) as HPDF_UINT
+declare function HPDF_Page_SetLineWidth cdecl alias "HPDF_Page_SetLineWidth" (byval page as HPDF_Page, byval line_width as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetLineCap cdecl alias "HPDF_Page_SetLineCap" (byval page as HPDF_Page, byval line_cap as HPDF_LineCap) as HPDF_STATUS
+declare function HPDF_Page_SetLineJoin cdecl alias "HPDF_Page_SetLineJoin" (byval page as HPDF_Page, byval line_join as HPDF_LineJoin) as HPDF_STATUS
+declare function HPDF_Page_SetMiterLimit cdecl alias "HPDF_Page_SetMiterLimit" (byval page as HPDF_Page, byval miter_limit as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetDash cdecl alias "HPDF_Page_SetDash" (byval page as HPDF_Page, byval dash_ptn as HPDF_UINT16 ptr, byval num_param as HPDF_UINT, byval phase as HPDF_UINT) as HPDF_STATUS
+declare function HPDF_Page_SetFlat cdecl alias "HPDF_Page_SetFlat" (byval page as HPDF_Page, byval flatness as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetExtGState cdecl alias "HPDF_Page_SetExtGState" (byval page as HPDF_Page, byval ext_gstate as HPDF_ExtGState) as HPDF_STATUS
+declare function HPDF_Page_GSave cdecl alias "HPDF_Page_GSave" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_GRestore cdecl alias "HPDF_Page_GRestore" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_Concat cdecl alias "HPDF_Page_Concat" (byval page as HPDF_Page, byval a as HPDF_REAL, byval b as HPDF_REAL, byval c as HPDF_REAL, byval d as HPDF_REAL, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_MoveTo cdecl alias "HPDF_Page_MoveTo" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_LineTo cdecl alias "HPDF_Page_LineTo" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_CurveTo cdecl alias "HPDF_Page_CurveTo" (byval page as HPDF_Page, byval x1 as HPDF_REAL, byval y1 as HPDF_REAL, byval x2 as HPDF_REAL, byval y2 as HPDF_REAL, byval x3 as HPDF_REAL, byval y3 as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_CurveTo2 cdecl alias "HPDF_Page_CurveTo2" (byval page as HPDF_Page, byval x2 as HPDF_REAL, byval y2 as HPDF_REAL, byval x3 as HPDF_REAL, byval y3 as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_CurveTo3 cdecl alias "HPDF_Page_CurveTo3" (byval page as HPDF_Page, byval x1 as HPDF_REAL, byval y1 as HPDF_REAL, byval x3 as HPDF_REAL, byval y3 as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_ClosePath cdecl alias "HPDF_Page_ClosePath" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_Rectangle cdecl alias "HPDF_Page_Rectangle" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL, byval width as HPDF_REAL, byval height as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_Stroke cdecl alias "HPDF_Page_Stroke" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_ClosePathStroke cdecl alias "HPDF_Page_ClosePathStroke" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_Fill cdecl alias "HPDF_Page_Fill" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_Eofill cdecl alias "HPDF_Page_Eofill" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_FillStroke cdecl alias "HPDF_Page_FillStroke" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_EofillStroke cdecl alias "HPDF_Page_EofillStroke" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_ClosePathFillStroke cdecl alias "HPDF_Page_ClosePathFillStroke" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_ClosePathEofillStroke cdecl alias "HPDF_Page_ClosePathEofillStroke" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_EndPath cdecl alias "HPDF_Page_EndPath" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_Clip cdecl alias "HPDF_Page_Clip" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_Eoclip cdecl alias "HPDF_Page_Eoclip" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_BeginText cdecl alias "HPDF_Page_BeginText" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_EndText cdecl alias "HPDF_Page_EndText" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_SetCharSpace cdecl alias "HPDF_Page_SetCharSpace" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetWordSpace cdecl alias "HPDF_Page_SetWordSpace" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetHorizontalScalling cdecl alias "HPDF_Page_SetHorizontalScalling" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetTextLeading cdecl alias "HPDF_Page_SetTextLeading" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetFontAndSize cdecl alias "HPDF_Page_SetFontAndSize" (byval page as HPDF_Page, byval font as HPDF_Font, byval size as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetTextRenderingMode cdecl alias "HPDF_Page_SetTextRenderingMode" (byval page as HPDF_Page, byval mode as HPDF_TextRenderingMode) as HPDF_STATUS
+declare function HPDF_Page_SetTextRise cdecl alias "HPDF_Page_SetTextRise" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetTextRaise cdecl alias "HPDF_Page_SetTextRaise" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_MoveTextPos cdecl alias "HPDF_Page_MoveTextPos" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_MoveTextPos2 cdecl alias "HPDF_Page_MoveTextPos2" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetTextMatrix cdecl alias "HPDF_Page_SetTextMatrix" (byval page as HPDF_Page, byval a as HPDF_REAL, byval b as HPDF_REAL, byval c as HPDF_REAL, byval d as HPDF_REAL, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_MoveToNextLine cdecl alias "HPDF_Page_MoveToNextLine" (byval page as HPDF_Page) as HPDF_STATUS
+declare function HPDF_Page_ShowText cdecl alias "HPDF_Page_ShowText" (byval page as HPDF_Page, byval text as zstring ptr) as HPDF_STATUS
+declare function HPDF_Page_ShowTextNextLine cdecl alias "HPDF_Page_ShowTextNextLine" (byval page as HPDF_Page, byval text as zstring ptr) as HPDF_STATUS
+declare function HPDF_Page_ShowTextNextLineEx cdecl alias "HPDF_Page_ShowTextNextLineEx" (byval page as HPDF_Page, byval word_space as HPDF_REAL, byval char_space as HPDF_REAL, byval text as zstring ptr) as HPDF_STATUS
+declare function HPDF_Page_SetGrayFill cdecl alias "HPDF_Page_SetGrayFill" (byval page as HPDF_Page, byval gray as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetGrayStroke cdecl alias "HPDF_Page_SetGrayStroke" (byval page as HPDF_Page, byval gray as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetRGBFill cdecl alias "HPDF_Page_SetRGBFill" (byval page as HPDF_Page, byval r as HPDF_REAL, byval g as HPDF_REAL, byval b as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetRGBStroke cdecl alias "HPDF_Page_SetRGBStroke" (byval page as HPDF_Page, byval r as HPDF_REAL, byval g as HPDF_REAL, byval b as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetCMYKFill cdecl alias "HPDF_Page_SetCMYKFill" (byval page as HPDF_Page, byval c as HPDF_REAL, byval m as HPDF_REAL, byval y as HPDF_REAL, byval k as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_SetCMYKStroke cdecl alias "HPDF_Page_SetCMYKStroke" (byval page as HPDF_Page, byval c as HPDF_REAL, byval m as HPDF_REAL, byval y as HPDF_REAL, byval k as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_ExecuteXObject cdecl alias "HPDF_Page_ExecuteXObject" (byval page as HPDF_Page, byval obj as HPDF_XObject) as HPDF_STATUS
+declare function HPDF_Page_DrawImage cdecl alias "HPDF_Page_DrawImage" (byval page as HPDF_Page, byval image as HPDF_Image, byval x as HPDF_REAL, byval y as HPDF_REAL, byval width as HPDF_REAL, byval height as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_Circle cdecl alias "HPDF_Page_Circle" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL, byval ray as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_Ellipse cdecl alias "HPDF_Page_Ellipse" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL, byval xray as HPDF_REAL, byval yray as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_Arc cdecl alias "HPDF_Page_Arc" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL, byval ray as HPDF_REAL, byval ang1 as HPDF_REAL, byval ang2 as HPDF_REAL) as HPDF_STATUS
+declare function HPDF_Page_TextOut cdecl alias "HPDF_Page_TextOut" (byval page as HPDF_Page, byval xpos as HPDF_REAL, byval ypos as HPDF_REAL, byval text as zstring ptr) as HPDF_STATUS
+declare function HPDF_Page_TextRect cdecl alias "HPDF_Page_TextRect" (byval page as HPDF_Page, byval left as HPDF_REAL, byval top as HPDF_REAL, byval right as HPDF_REAL, byval bottom as HPDF_REAL, byval text as zstring ptr, byval align as HPDF_TextAlignment, byval len as HPDF_UINT ptr) as HPDF_STATUS
+declare function HPDF_Page_SetSlideShow cdecl alias "HPDF_Page_SetSlideShow" (byval page as HPDF_Page, byval type as HPDF_TransitionStyle, byval disp_time as HPDF_REAL, byval trans_time as HPDF_REAL) as HPDF_STATUS
+'end extern
+#endif

+ 473 - 0
pdf.mod/libharu/bindings/freebasic/hpdf_consts.bi

@@ -0,0 +1,473 @@
+''
+''
+'' hpdf_consts -- header translated with help of SWIG FB wrapper
+''
+'' NOTICE: This file is part of the FreeBASIC Compiler package and can't
+''         be included in other distributions without authorization.
+''
+''
+#ifndef __hpdf_consts_bi__
+#define __hpdf_consts_bi__
+
+#define HPDF_TRUE 1
+#define HPDF_FALSE 0
+#define HPDF_OK 0
+#define HPDF_NOERROR 0
+#define HPDF_TMP_BUF_SIZ 512
+#define HPDF_SHORT_BUF_SIZ 32
+#define HPDF_REAL_LEN 11
+#define HPDF_INT_LEN 11
+#define HPDF_TEXT_DEFAULT_LEN 256
+#define HPDF_UNICODE_HEADER_LEN 2
+#define HPDF_DATE_TIME_STR_LEN 23
+#define HPDF_BYTE_OFFSET_LEN 10
+#define HPDF_OBJ_ID_LEN 7
+#define HPDF_GEN_NO_LEN 5
+#define HPDF_DEF_FONT "Helvetica"
+#define HPDF_DEF_WORDSPACE 0
+#define HPDF_DEF_CHARSPACE 0
+#define HPDF_DEF_FONTSIZE 10
+#define HPDF_DEF_HSCALING 100
+#define HPDF_DEF_LEADING 0
+#define HPDF_DEF_RISE 0
+#define HPDF_DEF_RAISE 0
+#define HPDF_DEF_LINEWIDTH 1
+#define HPDF_DEF_MITERLIMIT 10
+#define HPDF_DEF_FLATNESS 1
+#define HPDF_DEF_PAGE_NUM 1
+#define HPDF_BS_DEF_WIDTH 1
+#define HPDF_DEF_PAGE_WIDTH 595.276F
+#define HPDF_DEF_PAGE_HEIGHT 841.89F
+#define HPDF_VERSION_TEXT "2.0.8"
+#define HPDF_COMP_NONE &h00
+#define HPDF_COMP_TEXT &h01
+#define HPDF_COMP_IMAGE &h02
+#define HPDF_COMP_METADATA &h04
+#define HPDF_COMP_ALL &h0F
+#define HPDF_COMP_MASK &hFF
+#define HPDF_ENABLE_READ 0
+#define HPDF_ENABLE_PRINT 4
+#define HPDF_ENABLE_EDIT_ALL 8
+#define HPDF_ENABLE_COPY 16
+#define HPDF_ENABLE_EDIT 32
+#define HPDF_HIDE_TOOLBAR 1
+#define HPDF_HIDE_MENUBAR 2
+#define HPDF_HIDE_WINDOW_UI 4
+#define HPDF_FIT_WINDOW 8
+#define HPDF_CENTER_WINDOW 16
+#define HPDF_LIMIT_MAX_INT 2147483647
+#define HPDF_LIMIT_MIN_INT -2147483647
+#define HPDF_LIMIT_MAX_REAL 32767
+#define HPDF_LIMIT_MIN_REAL -32767
+#define HPDF_LIMIT_MAX_STRING_LEN 65535
+#define HPDF_LIMIT_MAX_NAME_LEN 127
+#define HPDF_LIMIT_MAX_ARRAY 8191
+#define HPDF_LIMIT_MAX_DICT_ELEMENT 4095
+#define HPDF_LIMIT_MAX_XREF_ELEMENT 8388607
+#define HPDF_LIMIT_MAX_GSTATE 28
+#define HPDF_LIMIT_MAX_DEVICE_N 8
+#define HPDF_LIMIT_MAX_DEVICE_N_V15 32
+#define HPDF_LIMIT_MAX_CID 65535
+#define HPDF_MAX_GENERATION_NUM 65535
+#define HPDF_MIN_PAGE_HEIGHT 3
+#define HPDF_MIN_PAGE_WIDTH 3
+#define HPDF_MAX_PAGE_HEIGHT 14400
+#define HPDF_MAX_PAGE_WIDTH 14400
+#define HPDF_MIN_MAGNIFICATION_FACTOR 8
+#define HPDF_MAX_MAGNIFICATION_FACTOR 3200
+#define HPDF_MIN_PAGE_SIZE 3
+#define HPDF_MAX_PAGE_SIZE 14400
+#define HPDF_MIN_HORIZONTALSCALING 10
+#define HPDF_MAX_HORIZONTALSCALING 300
+#define HPDF_MIN_WORDSPACE -30
+#define HPDF_MAX_WORDSPACE 300
+#define HPDF_MIN_CHARSPACE -30
+#define HPDF_MAX_CHARSPACE 300
+#define HPDF_MAX_FONTSIZE 300
+#define HPDF_MAX_ZOOMSIZE 10
+#define HPDF_MAX_LEADING 300
+#define HPDF_MAX_LINEWIDTH 100
+#define HPDF_MAX_DASH_PATTERN 100
+#define HPDF_MAX_JWW_NUM 128
+#define HPDF_COUNTRY_AF "AF"
+#define HPDF_COUNTRY_AL "AL"
+#define HPDF_COUNTRY_DZ "DZ"
+#define HPDF_COUNTRY_AS "AS"
+#define HPDF_COUNTRY_AD "AD"
+#define HPDF_COUNTRY_AO "AO"
+#define HPDF_COUNTRY_AI "AI"
+#define HPDF_COUNTRY_AQ "AQ"
+#define HPDF_COUNTRY_AG "AG"
+#define HPDF_COUNTRY_AR "AR"
+#define HPDF_COUNTRY_AM "AM"
+#define HPDF_COUNTRY_AW "AW"
+#define HPDF_COUNTRY_AU "AU"
+#define HPDF_COUNTRY_AT "AT"
+#define HPDF_COUNTRY_AZ "AZ"
+#define HPDF_COUNTRY_BS "BS"
+#define HPDF_COUNTRY_BH "BH"
+#define HPDF_COUNTRY_BD "BD"
+#define HPDF_COUNTRY_BB "BB"
+#define HPDF_COUNTRY_BY "BY"
+#define HPDF_COUNTRY_BE "BE"
+#define HPDF_COUNTRY_BZ "BZ"
+#define HPDF_COUNTRY_BJ "BJ"
+#define HPDF_COUNTRY_BM "BM"
+#define HPDF_COUNTRY_BT "BT"
+#define HPDF_COUNTRY_BO "BO"
+#define HPDF_COUNTRY_BA "BA"
+#define HPDF_COUNTRY_BW "BW"
+#define HPDF_COUNTRY_BV "BV"
+#define HPDF_COUNTRY_BR "BR"
+#define HPDF_COUNTRY_IO "IO"
+#define HPDF_COUNTRY_BN "BN"
+#define HPDF_COUNTRY_BG "BG"
+#define HPDF_COUNTRY_BF "BF"
+#define HPDF_COUNTRY_BI "BI"
+#define HPDF_COUNTRY_KH "KH"
+#define HPDF_COUNTRY_CM "CM"
+#define HPDF_COUNTRY_CA "CA"
+#define HPDF_COUNTRY_CV "CV"
+#define HPDF_COUNTRY_KY "KY"
+#define HPDF_COUNTRY_CF "CF"
+#define HPDF_COUNTRY_TD "TD"
+#define HPDF_COUNTRY_CL "CL"
+#define HPDF_COUNTRY_CN "CN"
+#define HPDF_COUNTRY_CX "CX"
+#define HPDF_COUNTRY_CC "CC"
+#define HPDF_COUNTRY_CO "CO"
+#define HPDF_COUNTRY_KM "KM"
+#define HPDF_COUNTRY_CG "CG"
+#define HPDF_COUNTRY_CK "CK"
+#define HPDF_COUNTRY_CR "CR"
+#define HPDF_COUNTRY_CI "CI"
+#define HPDF_COUNTRY_HR "HR"
+#define HPDF_COUNTRY_CU "CU"
+#define HPDF_COUNTRY_CY "CY"
+#define HPDF_COUNTRY_CZ "CZ"
+#define HPDF_COUNTRY_DK "DK"
+#define HPDF_COUNTRY_DJ "DJ"
+#define HPDF_COUNTRY_DM "DM"
+#define HPDF_COUNTRY_DO "DO"
+#define HPDF_COUNTRY_TP "TP"
+#define HPDF_COUNTRY_EC "EC"
+#define HPDF_COUNTRY_EG "EG"
+#define HPDF_COUNTRY_SV "SV"
+#define HPDF_COUNTRY_GQ "GQ"
+#define HPDF_COUNTRY_ER "ER"
+#define HPDF_COUNTRY_EE "EE"
+#define HPDF_COUNTRY_ET "ET"
+#define HPDF_COUNTRY_FK "FK"
+#define HPDF_COUNTRY_FO "FO"
+#define HPDF_COUNTRY_FJ "FJ"
+#define HPDF_COUNTRY_FI "FI"
+#define HPDF_COUNTRY_FR "FR"
+#define HPDF_COUNTRY_FX "FX"
+#define HPDF_COUNTRY_GF "GF"
+#define HPDF_COUNTRY_PF "PF"
+#define HPDF_COUNTRY_TF "TF"
+#define HPDF_COUNTRY_GA "GA"
+#define HPDF_COUNTRY_GM "GM"
+#define HPDF_COUNTRY_GE "GE"
+#define HPDF_COUNTRY_DE "DE"
+#define HPDF_COUNTRY_GH "GH"
+#define HPDF_COUNTRY_GI "GI"
+#define HPDF_COUNTRY_GR "GR"
+#define HPDF_COUNTRY_GL "GL"
+#define HPDF_COUNTRY_GD "GD"
+#define HPDF_COUNTRY_GP "GP"
+#define HPDF_COUNTRY_GU "GU"
+#define HPDF_COUNTRY_GT "GT"
+#define HPDF_COUNTRY_GN "GN"
+#define HPDF_COUNTRY_GW "GW"
+#define HPDF_COUNTRY_GY "GY"
+#define HPDF_COUNTRY_HT "HT"
+#define HPDF_COUNTRY_HM "HM"
+#define HPDF_COUNTRY_HN "HN"
+#define HPDF_COUNTRY_HK "HK"
+#define HPDF_COUNTRY_HU "HU"
+#define HPDF_COUNTRY_IS "IS"
+#define HPDF_COUNTRY_IN "IN"
+#define HPDF_COUNTRY_ID "ID"
+#define HPDF_COUNTRY_IR "IR"
+#define HPDF_COUNTRY_IQ "IQ"
+#define HPDF_COUNTRY_IE "IE"
+#define HPDF_COUNTRY_IL "IL"
+#define HPDF_COUNTRY_IT "IT"
+#define HPDF_COUNTRY_JM "JM"
+#define HPDF_COUNTRY_JP "JP"
+#define HPDF_COUNTRY_JO "JO"
+#define HPDF_COUNTRY_KZ "KZ"
+#define HPDF_COUNTRY_KE "KE"
+#define HPDF_COUNTRY_KI "KI"
+#define HPDF_COUNTRY_KP "KP"
+#define HPDF_COUNTRY_KR "KR"
+#define HPDF_COUNTRY_KW "KW"
+#define HPDF_COUNTRY_KG "KG"
+#define HPDF_COUNTRY_LA "LA"
+#define HPDF_COUNTRY_LV "LV"
+#define HPDF_COUNTRY_LB "LB"
+#define HPDF_COUNTRY_LS "LS"
+#define HPDF_COUNTRY_LR "LR"
+#define HPDF_COUNTRY_LY "LY"
+#define HPDF_COUNTRY_LI "LI"
+#define HPDF_COUNTRY_LT "LT"
+#define HPDF_COUNTRY_LU "LU"
+#define HPDF_COUNTRY_MO "MO"
+#define HPDF_COUNTRY_MK "MK"
+#define HPDF_COUNTRY_MG "MG"
+#define HPDF_COUNTRY_MW "MW"
+#define HPDF_COUNTRY_MY "MY"
+#define HPDF_COUNTRY_MV "MV"
+#define HPDF_COUNTRY_ML "ML"
+#define HPDF_COUNTRY_MT "MT"
+#define HPDF_COUNTRY_MH "MH"
+#define HPDF_COUNTRY_MQ "MQ"
+#define HPDF_COUNTRY_MR "MR"
+#define HPDF_COUNTRY_MU "MU"
+#define HPDF_COUNTRY_YT "YT"
+#define HPDF_COUNTRY_MX "MX"
+#define HPDF_COUNTRY_FM "FM"
+#define HPDF_COUNTRY_MD "MD"
+#define HPDF_COUNTRY_MC "MC"
+#define HPDF_COUNTRY_MN "MN"
+#define HPDF_COUNTRY_MS "MS"
+#define HPDF_COUNTRY_MA "MA"
+#define HPDF_COUNTRY_MZ "MZ"
+#define HPDF_COUNTRY_MM "MM"
+#define HPDF_COUNTRY_NA "NA"
+#define HPDF_COUNTRY_NR "NR"
+#define HPDF_COUNTRY_NP "NP"
+#define HPDF_COUNTRY_NL "NL"
+#define HPDF_COUNTRY_AN "AN"
+#define HPDF_COUNTRY_NC "NC"
+#define HPDF_COUNTRY_NZ "NZ"
+#define HPDF_COUNTRY_NI "NI"
+#define HPDF_COUNTRY_NE "NE"
+#define HPDF_COUNTRY_NG "NG"
+#define HPDF_COUNTRY_NU "NU"
+#define HPDF_COUNTRY_NF "NF"
+#define HPDF_COUNTRY_MP "MP"
+#define HPDF_COUNTRY_NO "NO"
+#define HPDF_COUNTRY_OM "OM"
+#define HPDF_COUNTRY_PK "PK"
+#define HPDF_COUNTRY_PW "PW"
+#define HPDF_COUNTRY_PA "PA"
+#define HPDF_COUNTRY_PG "PG"
+#define HPDF_COUNTRY_PY "PY"
+#define HPDF_COUNTRY_PE "PE"
+#define HPDF_COUNTRY_PH "PH"
+#define HPDF_COUNTRY_PN "PN"
+#define HPDF_COUNTRY_PL "PL"
+#define HPDF_COUNTRY_PT "PT"
+#define HPDF_COUNTRY_PR "PR"
+#define HPDF_COUNTRY_QA "QA"
+#define HPDF_COUNTRY_RE "RE"
+#define HPDF_COUNTRY_RO "RO"
+#define HPDF_COUNTRY_RU "RU"
+#define HPDF_COUNTRY_RW "RW"
+#define HPDF_COUNTRY_KN "KN"
+#define HPDF_COUNTRY_LC "LC"
+#define HPDF_COUNTRY_VC "VC"
+#define HPDF_COUNTRY_WS "WS"
+#define HPDF_COUNTRY_SM "SM"
+#define HPDF_COUNTRY_ST "ST"
+#define HPDF_COUNTRY_SA "SA"
+#define HPDF_COUNTRY_SN "SN"
+#define HPDF_COUNTRY_SC "SC"
+#define HPDF_COUNTRY_SL "SL"
+#define HPDF_COUNTRY_SG "SG"
+#define HPDF_COUNTRY_SK "SK"
+#define HPDF_COUNTRY_SI "SI"
+#define HPDF_COUNTRY_SB "SB"
+#define HPDF_COUNTRY_SO "SO"
+#define HPDF_COUNTRY_ZA "ZA"
+#define HPDF_COUNTRY_ES "ES"
+#define HPDF_COUNTRY_LK "LK"
+#define HPDF_COUNTRY_SH "SH"
+#define HPDF_COUNTRY_PM "PM"
+#define HPDF_COUNTRY_SD "SD"
+#define HPDF_COUNTRY_SR "SR"
+#define HPDF_COUNTRY_SJ "SJ"
+#define HPDF_COUNTRY_SZ "SZ"
+#define HPDF_COUNTRY_SE "SE"
+#define HPDF_COUNTRY_CH "CH"
+#define HPDF_COUNTRY_SY "SY"
+#define HPDF_COUNTRY_TW "TW"
+#define HPDF_COUNTRY_TJ "TJ"
+#define HPDF_COUNTRY_TZ "TZ"
+#define HPDF_COUNTRY_TH "TH"
+#define HPDF_COUNTRY_TG "TG"
+#define HPDF_COUNTRY_TK "TK"
+#define HPDF_COUNTRY_TO "TO"
+#define HPDF_COUNTRY_TT "TT"
+#define HPDF_COUNTRY_TN "TN"
+#define HPDF_COUNTRY_TR "TR"
+#define HPDF_COUNTRY_TM "TM"
+#define HPDF_COUNTRY_TC "TC"
+#define HPDF_COUNTRY_TV "TV"
+#define HPDF_COUNTRY_UG "UG"
+#define HPDF_COUNTRY_UA "UA"
+#define HPDF_COUNTRY_AE "AE"
+#define HPDF_COUNTRY_GB "GB"
+#define HPDF_COUNTRY_US "US"
+#define HPDF_COUNTRY_UM "UM"
+#define HPDF_COUNTRY_UY "UY"
+#define HPDF_COUNTRY_UZ "UZ"
+#define HPDF_COUNTRY_VU "VU"
+#define HPDF_COUNTRY_VA "VA"
+#define HPDF_COUNTRY_VE "VE"
+#define HPDF_COUNTRY_VN "VN"
+#define HPDF_COUNTRY_VG "VG"
+#define HPDF_COUNTRY_VI "VI"
+#define HPDF_COUNTRY_WF "WF"
+#define HPDF_COUNTRY_EH "EH"
+#define HPDF_COUNTRY_YE "YE"
+#define HPDF_COUNTRY_YU "YU"
+#define HPDF_COUNTRY_ZR "ZR"
+#define HPDF_COUNTRY_ZM "ZM"
+#define HPDF_COUNTRY_ZW "ZW"
+#define HPDF_LANG_AA "aa"
+#define HPDF_LANG_AB "ab"
+#define HPDF_LANG_AF "af"
+#define HPDF_LANG_AM "am"
+#define HPDF_LANG_AR "ar"
+#define HPDF_LANG_AS "as"
+#define HPDF_LANG_AY "ay"
+#define HPDF_LANG_AZ "az"
+#define HPDF_LANG_BA "ba"
+#define HPDF_LANG_BE "be"
+#define HPDF_LANG_BG "bg"
+#define HPDF_LANG_BH "bh"
+#define HPDF_LANG_BI "bi"
+#define HPDF_LANG_BN "bn"
+#define HPDF_LANG_BO "bo"
+#define HPDF_LANG_BR "br"
+#define HPDF_LANG_CA "ca"
+#define HPDF_LANG_CO "co"
+#define HPDF_LANG_CS "cs"
+#define HPDF_LANG_CY "cy"
+#define HPDF_LANG_DA "da"
+#define HPDF_LANG_DE "de"
+#define HPDF_LANG_DZ "dz"
+#define HPDF_LANG_EL "el"
+#define HPDF_LANG_EN "en"
+#define HPDF_LANG_EO "eo"
+#define HPDF_LANG_ES "es"
+#define HPDF_LANG_ET "et"
+#define HPDF_LANG_EU "eu"
+#define HPDF_LANG_FA "fa"
+#define HPDF_LANG_FI "fi"
+#define HPDF_LANG_FJ "fj"
+#define HPDF_LANG_FO "fo"
+#define HPDF_LANG_FR "fr"
+#define HPDF_LANG_FY "fy"
+#define HPDF_LANG_GA "ga"
+#define HPDF_LANG_GD "gd"
+#define HPDF_LANG_GL "gl"
+#define HPDF_LANG_GN "gn"
+#define HPDF_LANG_GU "gu"
+#define HPDF_LANG_HA "ha"
+#define HPDF_LANG_HI "hi"
+#define HPDF_LANG_HR "hr"
+#define HPDF_LANG_HU "hu"
+#define HPDF_LANG_HY "hy"
+#define HPDF_LANG_IA "ia"
+#define HPDF_LANG_IE "ie"
+#define HPDF_LANG_IK "ik"
+#define HPDF_LANG_IN "in"
+#define HPDF_LANG_IS "is"
+#define HPDF_LANG_IT "it"
+#define HPDF_LANG_IW "iw"
+#define HPDF_LANG_JA "ja"
+#define HPDF_LANG_JI "ji"
+#define HPDF_LANG_JW "jw"
+#define HPDF_LANG_KA "ka"
+#define HPDF_LANG_KK "kk"
+#define HPDF_LANG_KL "kl"
+#define HPDF_LANG_KM "km"
+#define HPDF_LANG_KN "kn"
+#define HPDF_LANG_KO "ko"
+#define HPDF_LANG_KS "ks"
+#define HPDF_LANG_KU "ku"
+#define HPDF_LANG_KY "ky"
+#define HPDF_LANG_LA "la"
+#define HPDF_LANG_LN "ln"
+#define HPDF_LANG_LO "lo"
+#define HPDF_LANG_LT "lt"
+#define HPDF_LANG_LV "lv"
+#define HPDF_LANG_MG "mg"
+#define HPDF_LANG_MI "mi"
+#define HPDF_LANG_MK "mk"
+#define HPDF_LANG_ML "ml"
+#define HPDF_LANG_MN "mn"
+#define HPDF_LANG_MO "mo"
+#define HPDF_LANG_MR "mr"
+#define HPDF_LANG_MS "ms"
+#define HPDF_LANG_MT "mt"
+#define HPDF_LANG_MY "my"
+#define HPDF_LANG_NA "na"
+#define HPDF_LANG_NE "ne"
+#define HPDF_LANG_NL "nl"
+#define HPDF_LANG_NO "no"
+#define HPDF_LANG_OC "oc"
+#define HPDF_LANG_OM "om"
+#define HPDF_LANG_OR "or"
+#define HPDF_LANG_PA "pa"
+#define HPDF_LANG_PL "pl"
+#define HPDF_LANG_PS "ps"
+#define HPDF_LANG_PT "pt"
+#define HPDF_LANG_QU "qu"
+#define HPDF_LANG_RM "rm"
+#define HPDF_LANG_RN "rn"
+#define HPDF_LANG_RO "ro"
+#define HPDF_LANG_RU "ru"
+#define HPDF_LANG_RW "rw"
+#define HPDF_LANG_SA "sa"
+#define HPDF_LANG_SD "sd"
+#define HPDF_LANG_SG "sg"
+#define HPDF_LANG_SH "sh"
+#define HPDF_LANG_SI "si"
+#define HPDF_LANG_SK "sk"
+#define HPDF_LANG_SL "sl"
+#define HPDF_LANG_SM "sm"
+#define HPDF_LANG_SN "sn"
+#define HPDF_LANG_SO "so"
+#define HPDF_LANG_SQ "sq"
+#define HPDF_LANG_SR "sr"
+#define HPDF_LANG_SS "ss"
+#define HPDF_LANG_ST "st"
+#define HPDF_LANG_SU "su"
+#define HPDF_LANG_SV "sv"
+#define HPDF_LANG_SW "sw"
+#define HPDF_LANG_TA "ta"
+#define HPDF_LANG_TE "te"
+#define HPDF_LANG_TG "tg"
+#define HPDF_LANG_TH "th"
+#define HPDF_LANG_TI "ti"
+#define HPDF_LANG_TK "tk"
+#define HPDF_LANG_TL "tl"
+#define HPDF_LANG_TN "tn"
+#define HPDF_LANG_TR "tr"
+#define HPDF_LANG_TS "ts"
+#define HPDF_LANG_TT "tt"
+#define HPDF_LANG_TW "tw"
+#define HPDF_LANG_UK "uk"
+#define HPDF_LANG_UR "ur"
+#define HPDF_LANG_UZ "uz"
+#define HPDF_LANG_VI "vi"
+#define HPDF_LANG_VO "vo"
+#define HPDF_LANG_WO "wo"
+#define HPDF_LANG_XH "xh"
+#define HPDF_LANG_YO "yo"
+#define HPDF_LANG_ZH "zh"
+#define HPDF_LANG_ZU "zu"
+#define HPDF_GMODE_PAGE_DESCRIPTION &h0001
+#define HPDF_GMODE_PATH_OBJECT &h0002
+#define HPDF_GMODE_TEXT_OBJECT &h0004
+#define HPDF_GMODE_CLIPPING_PATH &h0008
+#define HPDF_GMODE_SHADING &h0010
+#define HPDF_GMODE_INLINE_IMAGE &h0020
+#define HPDF_GMODE_EXTERNAL_OBJECT &h0040
+
+#endif

+ 415 - 0
pdf.mod/libharu/bindings/freebasic/hpdf_types.bi

@@ -0,0 +1,415 @@
+''
+''
+'' hpdf_types -- header translated with help of SWIG FB wrapper
+''
+'' NOTICE: This file is part of the FreeBASIC Compiler package and can't
+''         be included in other distributions without authorization.
+''
+''
+#ifndef __hpdf_types_bi__
+#define __hpdf_types_bi__
+
+
+Type HPDF_HANDLE As Any Ptr
+Type HPDF_Doc As HPDF_HANDLE
+Type HPDF_Page As HPDF_HANDLE
+Type HPDF_Pages As HPDF_HANDLE
+Type HPDF_Stream As HPDF_HANDLE
+Type HPDF_Image As HPDF_HANDLE
+Type HPDF_Font As HPDF_HANDLE
+Type HPDF_Outline As HPDF_HANDLE
+Type HPDF_Encoder As HPDF_HANDLE
+Type HPDF_Destination As HPDF_HANDLE
+Type HPDF_XObject As HPDF_HANDLE
+Type HPDF_Annotation As HPDF_HANDLE
+Type HPDF_ExtGState As HPDF_HANDLE
+
+
+type HPDF_INT as integer
+type HPDF_UINT as uinteger
+type HPDF_INT32 as integer
+type HPDF_UINT32 as uinteger
+type HPDF_INT16 as short
+type HPDF_UINT16 as ushort
+type HPDF_INT8 as byte
+type HPDF_UINT8 as ubyte
+type HPDF_BYTE as ubyte
+type HPDF_REAL as single
+type HPDF_DOUBLE as double
+type HPDF_BOOL as integer
+type HPDF_STATUS as uinteger
+type HPDF_CID as HPDF_UINT16
+type HPDF_UNICODE as HPDF_UINT16
+
+type _HPDF_Point
+	x as HPDF_REAL
+	y as HPDF_REAL
+end type
+
+type HPDF_Point as _HPDF_Point
+
+type _HPDF_Rect
+	left as HPDF_REAL
+	bottom as HPDF_REAL
+	right as HPDF_REAL
+	top as HPDF_REAL
+end type
+
+type HPDF_Rect as _HPDF_Rect
+type HPDF_Box as _HPDF_Rect
+
+type _HPDF_Date
+	year as HPDF_INT
+	month as HPDF_INT
+	day as HPDF_INT
+	hour as HPDF_INT
+	minutes as HPDF_INT
+	seconds as HPDF_INT
+	ind as byte
+	off_hour as HPDF_INT
+	off_minutes as HPDF_INT
+end type
+
+type HPDF_Date as _HPDF_Date
+
+enum _HPDF_InfoType
+	HPDF_INFO_CREATION_DATE = 0
+	HPDF_INFO_MOD_DATE
+	HPDF_INFO_AUTHOR
+	HPDF_INFO_CREATOR
+	HPDF_INFO_PRODUCER
+	HPDF_INFO_TITLE
+	HPDF_INFO_SUBJECT
+	HPDF_INFO_KEYWORDS
+	HPDF_INFO_EOF
+end enum
+
+type HPDF_InfoType as _HPDF_InfoType
+
+enum _HPDF_PdfVer
+	HPDF_VER_12 = 0
+	HPDF_VER_13
+	HPDF_VER_14
+	HPDF_VER_15
+	HPDF_VER_16
+	HPDF_VER_EOF
+end enum
+
+type HPDF_PDFVer as _HPDF_PdfVer
+
+enum _HPDF_EncryptMode
+	HPDF_ENCRYPT_R2 = 2
+	HPDF_ENCRYPT_R3 = 3
+end enum
+
+type HPDF_EncryptMode as _HPDF_EncryptMode
+type HPDF_Error_Handler as sub cdecl(byval as HPDF_STATUS, byval as HPDF_STATUS, byval as any ptr)
+type HPDF_Alloc_Func as sub cdecl(byval as HPDF_UINT)
+type HPDF_Free_Func as sub cdecl(byval as any ptr)
+
+type _HPDF_TextWidth
+	numchars as HPDF_UINT
+	numwords as HPDF_UINT
+	width as HPDF_UINT
+	numspace as HPDF_UINT
+end type
+
+type HPDF_TextWidth as _HPDF_TextWidth
+
+type _HPDF_DashMode
+	ptn(0 to 8-1) as HPDF_UINT16
+	num_ptn as HPDF_UINT
+	phase as HPDF_UINT
+end type
+
+type HPDF_DashMode as _HPDF_DashMode
+
+type _HPDF_TransMatrix
+	a as HPDF_REAL
+	b as HPDF_REAL
+	c as HPDF_REAL
+	d as HPDF_REAL
+	x as HPDF_REAL
+	y as HPDF_REAL
+end type
+
+type HPDF_TransMatrix as _HPDF_TransMatrix
+
+enum _HPDF_ColorSpace
+	HPDF_CS_DEVICE_GRAY = 0
+	HPDF_CS_DEVICE_RGB
+	HPDF_CS_DEVICE_CMYK
+	HPDF_CS_CAL_GRAY
+	HPDF_CS_CAL_RGB
+	HPDF_CS_LAB
+	HPDF_CS_ICC_BASED
+	HPDF_CS_SEPARATION
+	HPDF_CS_DEVICE_N
+	HPDF_CS_INDEXED
+	HPDF_CS_PATTERN
+	HPDF_CS_EOF
+end enum
+
+type HPDF_ColorSpace as _HPDF_ColorSpace
+
+type _HPDF_RGBColor
+	r as HPDF_REAL
+	g as HPDF_REAL
+	b as HPDF_REAL
+end type
+
+type HPDF_RGBColor as _HPDF_RGBColor
+
+type _HPDF_CMYKColor
+	c as HPDF_REAL
+	m as HPDF_REAL
+	y as HPDF_REAL
+	k as HPDF_REAL
+end type
+
+type HPDF_CMYKColor as _HPDF_CMYKColor
+
+enum _HPDF_LineCap
+	HPDF_BUTT_END = 0
+	HPDF_ROUND_END
+	HPDF_PROJECTING_SQUARE_END
+	HPDF_LINECAP_EOF
+end enum
+
+type HPDF_LineCap as _HPDF_LineCap
+
+enum _HPDF_LineJoin
+	HPDF_MITER_JOIN = 0
+	HPDF_ROUND_JOIN
+	HPDF_BEVEL_JOIN
+	HPDF_LINEJOIN_EOF
+end enum
+
+type HPDF_LineJoin as _HPDF_LineJoin
+
+enum _HPDF_TextRenderingMode
+	HPDF_FILL = 0
+	HPDF_STROKE
+	HPDF_FILL_THEN_STROKE
+	HPDF_INVISIBLE
+	HPDF_FILL_CLIPPING
+	HPDF_STROKE_CLIPPING
+	HPDF_FILL_STROKE_CLIPPING
+	HPDF_CLIPPING
+	HPDF_RENDERING_MODE_EOF
+end enum
+
+type HPDF_TextRenderingMode as _HPDF_TextRenderingMode
+
+enum _HPDF_WritingMode
+	HPDF_WMODE_HORIZONTAL = 0
+	HPDF_WMODE_VERTICAL
+	HPDF_WMODE_EOF
+end enum
+
+type HPDF_WritingMode as _HPDF_WritingMode
+
+enum _HPDF_PageLayout
+	HPDF_PAGE_LAYOUT_SINGLE = 0
+	HPDF_PAGE_LAYOUT_ONE_COLUMN
+	HPDF_PAGE_LAYOUT_TWO_COLUMN_LEFT
+	HPDF_PAGE_LAYOUT_TWO_COLUMN_RIGHT
+	HPDF_PAGE_LAYOUT_EOF
+end enum
+
+type HPDF_PageLayout as _HPDF_PageLayout
+
+enum _HPDF_PageMode
+	HPDF_PAGE_MODE_USE_NONE = 0
+	HPDF_PAGE_MODE_USE_OUTLINE
+	HPDF_PAGE_MODE_USE_THUMBS
+	HPDF_PAGE_MODE_FULL_SCREEN
+	HPDF_PAGE_MODE_EOF
+end enum
+
+type HPDF_PageMode as _HPDF_PageMode
+
+enum _HPDF_PageNumStyle
+	HPDF_PAGE_NUM_STYLE_DECIMAL = 0
+	HPDF_PAGE_NUM_STYLE_UPPER_ROMAN
+	HPDF_PAGE_NUM_STYLE_LOWER_ROMAN
+	HPDF_PAGE_NUM_STYLE_UPPER_LETTERS
+	HPDF_PAGE_NUM_STYLE_LOWER_LETTERS
+	HPDF_PAGE_NUM_STYLE_EOF
+end enum
+
+type HPDF_PageNumStyle as _HPDF_PageNumStyle
+
+enum _HPDF_DestinationType
+	HPDF_XYZ = 0
+	HPDF_FIT
+	HPDF_FIT_H
+	HPDF_FIT_V
+	HPDF_FIT_R
+	HPDF_FIT_B
+	HPDF_FIT_BH
+	HPDF_FIT_BV
+	HPDF_DST_EOF
+end enum
+
+type HPDF_DestinationType as _HPDF_DestinationType
+
+enum _HPDF_AnnotType
+	HPDF_ANNOT_TEXT_NOTES
+	HPDF_ANNOT_LINK
+	HPDF_ANNOT_SOUND
+	HPDF_ANNOT_FREE_TEXT
+	HPDF_ANNOT_STAMP
+	HPDF_ANNOT_SQUARE
+	HPDF_ANNOT_CIRCLE
+	HPDF_ANNOT_STRIKE_OUT
+	HPDF_ANNOT_HIGHTLIGHT
+	HPDF_ANNOT_UNDERLINE
+	HPDF_ANNOT_INK
+	HPDF_ANNOT_FILE_ATTACHMENT
+	HPDF_ANNOT_POPUP
+end enum
+
+type HPDF_AnnotType as _HPDF_AnnotType
+
+enum _HPDF_AnnotFlgs
+	HPDF_ANNOT_INVISIBLE
+	HPDF_ANNOT_HIDDEN
+	HPDF_ANNOT_PRINT
+	HPDF_ANNOT_NOZOOM
+	HPDF_ANNOT_NOROTATE
+	HPDF_ANNOT_NOVIEW
+	HPDF_ANNOT_READONLY
+end enum
+
+type HPDF_AnnotFlgs as _HPDF_AnnotFlgs
+
+enum _HPDF_AnnotHighlightMode
+	HPDF_ANNOT_NO_HIGHTLIGHT = 0
+	HPDF_ANNOT_INVERT_BOX
+	HPDF_ANNOT_INVERT_BORDER
+	HPDF_ANNOT_DOWN_APPEARANCE
+	HPDF_ANNOT_HIGHTLIGHT_MODE_EOF
+end enum
+
+type HPDF_AnnotHighlightMode as _HPDF_AnnotHighlightMode
+
+enum _HPDF_AnnotIcon
+	HPDF_ANNOT_ICON_COMMENT = 0
+	HPDF_ANNOT_ICON_KEY
+	HPDF_ANNOT_ICON_NOTE
+	HPDF_ANNOT_ICON_HELP
+	HPDF_ANNOT_ICON_NEW_PARAGRAPH
+	HPDF_ANNOT_ICON_PARAGRAPH
+	HPDF_ANNOT_ICON_INSERT
+	HPDF_ANNOT_ICON_EOF
+end enum
+
+type HPDF_AnnotIcon as _HPDF_AnnotIcon
+
+enum _HPDF_BSSubtype
+	HPDF_BS_SOLID
+	HPDF_BS_DASHED
+	HPDF_BS_BEVELED
+	HPDF_BS_INSET
+	HPDF_BS_UNDERLINED
+end enum
+
+type HPDF_BSSubtype as _HPDF_BSSubtype
+
+enum _HPDF_BlendMode
+	HPDF_BM_NORMAL
+	HPDF_BM_MULTIPLY
+	HPDF_BM_SCREEN
+	HPDF_BM_OVERLAY
+	HPDF_BM_DARKEN
+	HPDF_BM_LIGHTEN
+	HPDF_BM_COLOR_DODGE
+	HPDF_BM_COLOR_BUM
+	HPDF_BM_HARD_LIGHT
+	HPDF_BM_SOFT_LIGHT
+	HPDF_BM_DIFFERENCE
+	HPDF_BM_EXCLUSHON
+	HPDF_BM_EOF
+end enum
+
+type HPDF_BlendMode as _HPDF_BlendMode
+
+enum _HPDF_TransitionStyle
+	HPDF_TS_WIPE_RIGHT = 0
+	HPDF_TS_WIPE_UP
+	HPDF_TS_WIPE_LEFT
+	HPDF_TS_WIPE_DOWN
+	HPDF_TS_BARN_DOORS_HORIZONTAL_OUT
+	HPDF_TS_BARN_DOORS_HORIZONTAL_IN
+	HPDF_TS_BARN_DOORS_VERTICAL_OUT
+	HPDF_TS_BARN_DOORS_VERTICAL_IN
+	HPDF_TS_BOX_OUT
+	HPDF_TS_BOX_IN
+	HPDF_TS_BLINDS_HORIZONTAL
+	HPDF_TS_BLINDS_VERTICAL
+	HPDF_TS_DISSOLVE
+	HPDF_TS_GLITTER_RIGHT
+	HPDF_TS_GLITTER_DOWN
+	HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT
+	HPDF_TS_REPLACE
+	HPDF_TS_EOF
+end enum
+
+type HPDF_TransitionStyle as _HPDF_TransitionStyle
+
+enum _HPDF_PageSizes
+	HPDF_PAGE_SIZE_LETTER = 0
+	HPDF_PAGE_SIZE_LEGAL
+	HPDF_PAGE_SIZE_A3
+	HPDF_PAGE_SIZE_A4
+	HPDF_PAGE_SIZE_A5
+	HPDF_PAGE_SIZE_B4
+	HPDF_PAGE_SIZE_B5
+	HPDF_PAGE_SIZE_EXECUTIVE
+	HPDF_PAGE_SIZE_US4x6
+	HPDF_PAGE_SIZE_US4x8
+	HPDF_PAGE_SIZE_US5x7
+	HPDF_PAGE_SIZE_COMM10
+	HPDF_PAGE_SIZE_EOF
+end enum
+
+type HPDF_PageSizes as _HPDF_PageSizes
+
+enum _HPDF_PageDirection
+	HPDF_PAGE_PORTRAIT = 0
+	HPDF_PAGE_LANDSCAPE
+end enum
+
+type HPDF_PageDirection as _HPDF_PageDirection
+
+enum _HPDF_EncoderType
+	HPDF_ENCODER_TYPE_SINGLE_BYTE
+	HPDF_ENCODER_TYPE_DOUBLE_BYTE
+	HPDF_ENCODER_TYPE_UNINITIALIZED
+	HPDF_ENCODER_UNKNOWN
+end enum
+
+type HPDF_EncoderType as _HPDF_EncoderType
+
+enum _HPDF_ByteType
+	HPDF_BYTE_TYPE_SINGLE = 0
+	HPDF_BYTE_TYPE_LEAD
+	HPDF_BYTE_TYPE_TRAIL
+	HPDF_BYTE_TYPE_UNKNOWN
+end enum
+
+type HPDF_ByteType as _HPDF_ByteType
+
+enum _HPDF_TextAlignment
+	HPDF_TALIGN_LEFT = 0
+	HPDF_TALIGN_RIGHT
+	HPDF_TALIGN_CENTER
+	HPDF_TALIGN_JUSTIFY
+end enum
+
+type HPDF_TextAlignment as _HPDF_TextAlignment
+
+
+
+#endif

+ 154 - 0
pdf.mod/libharu/bindings/freebasic/hpdftest.bas

@@ -0,0 +1,154 @@
+'****************************************************************************** 
+'*  Program name: hpdftest
+'*  Version:      0.1
+'*
+'*  Author:       Copyright (c) 2008 Klaus Siebke
+'*                Siebke Unternehmensberatung
+'*                URL http://www.siebke.com
+'*
+'*  Description:
+'*  -----------
+'*
+'*  Program to test the creation of a PDF file using the Haru Free PDF Library
+'*  for more details see: http://www.freebasic.net/forum/viewtopic.php?t=9014
+'*
+'*  License:
+'*  -------
+'*
+'*  Permission to use, copy, modify, distribute and sell this software
+'*  and its documentation for any purpose is hereby granted without fee,
+'*  provided that the above copyright notice appear in all copies and
+'*  that both that copyright notice and this permission notice appear
+'*  in supporting documentation.
+'*  It is provided "as is" without express or implied warranty.
+'*
+'*
+'*  External libraries used by the program:
+'*  --------------------------------------
+'*
+'*  << Haru Free PDF Library 2.0.8 >>
+'*  URL http://libharu.org/
+'*  Copyright (c) 1999-2006 Takeshi Kanno
+'*
+'****************************************************************************** 
+
+#include "crt/errno.bi"
+#include "zlib.bi"       
+
+'****************************************************************************** 
+'* Includes for Haru Free PDF Library 
+'****************************************************************************** 
+#ifndef __mod_hpdf_bi__
+#define __mod_hpdf_bi__
+#include once "hpdf_consts.bi"
+#include once "hpdf_types.bi"
+#include once "hpdf.bi"
+#endif
+
+'****************************************************************************** 
+'* Declarations of subroutines and functions
+'****************************************************************************** 
+declare sub error_handler cdecl (byval error_no as HPDF_STATUS, byval detail_no as HPDF_STATUS, byval user_data as any ptr )
+
+'****************************************************************************** 
+'* Constants
+'****************************************************************************** 
+#define NULL 0 
+const page_title = "PDF test document"
+
+'****************************************************************************** 
+'* Variables
+'****************************************************************************** 
+dim shared pdf          as HPDF_Doc 'ptr 
+dim shared fname        as string * 256   
+dim shared page         as HPDF_Page
+dim shared def_font     as HPDF_Font
+dim shared txt_font     as HPDF_Font
+dim shared tw           as HPDF_REAL
+dim shared doc_height   as HPDF_REAL
+dim shared doc_width    as HPDF_REAL 
+dim shared i            as HPDF_UINT
+'dim shared errno        as HPDF_STATUS ptr
+dim shared detno        as HPDF_STATUS ptr
+dim shared userdat      as any ptr
+
+
+'****************************************************************************** 
+'* Begin of main program
+'****************************************************************************** 
+
+'let's go ... (initialize hpdf)
+pdf = HPDF_New(@error_handler, NULL)
+
+
+'add a new page object
+page = HPDF_AddPage (pdf)
+
+'specify the document size
+doc_height = HPDF_Page_GetHeight (page)
+doc_width = HPDF_Page_GetWidth (page)
+
+'print a frame
+HPDF_Page_SetLineWidth (page, .5)
+HPDF_Page_Rectangle (page, 50, 50, doc_width - 100, doc_height - 110)
+HPDF_Page_Stroke (page)
+
+'print the title of the page (with positioning center) with font Helvetica
+def_font = HPDF_GetFont (pdf, "Helvetica", NULL)
+HPDF_Page_SetFontAndSize (page, def_font, 24)
+tw = HPDF_Page_TextWidth (page, page_title)
+HPDF_Page_BeginText (page)
+HPDF_Page_TextOut (page, (doc_width - tw) / 2, doc_height - 50, page_title)
+HPDF_Page_EndText (page)
+
+'print some text inside the frame 
+HPDF_Page_BeginText (page)
+
+'first line with font Times Roman 14
+txt_font = HPDF_GetFont (pdf, "Times-Roman", NULL)
+HPDF_Page_MoveTextPos (page, 60, doc_height - 105)
+HPDF_Page_SetFontAndSize (page, txt_font, 14)
+HPDF_Page_ShowText (page, "This is a first line")
+
+'second line with font Courier 12
+txt_font = HPDF_GetFont (pdf, "Courier", NULL)
+HPDF_Page_MoveTextPos (page, 0, -20)
+HPDF_Page_SetFontAndSize (page, txt_font, 12)
+HPDF_Page_ShowText (page, "This is a second line")
+
+'third line with font Symbol 16
+txt_font = HPDF_GetFont (pdf, "Symbol", NULL)
+HPDF_Page_MoveTextPos (page, 0, -20)
+HPDF_Page_SetFontAndSize (page, txt_font, 16)
+HPDF_Page_ShowText (page, "Here are some symbols")
+
+'fourth line with font Helvetica 14
+txt_font = HPDF_GetFont (pdf, "Helvetica", NULL)
+HPDF_Page_MoveTextPos (page, 0, -20)
+HPDF_Page_SetFontAndSize (page, txt_font, 14)
+HPDF_Page_ShowText (page, "This is arial")
+
+
+HPDF_Page_EndText (page)
+
+'save the document
+HPDF_SaveToFile (pdf, "mydoc.pdf")
+
+'clean up
+HPDF_Free (pdf)
+
+'****************************************************************************** 
+'* End of main program
+'****************************************************************************** 
+
+
+sub error_handler cdecl (byval error_no as HPDF_STATUS, byval detail_no as HPDF_STATUS, byval user_data as any ptr) 
+'****************************************************************************** 
+'* Error handler
+'****************************************************************************** 
+' do something here ... 
+  print "error_no: ", error_no
+  print "detail_no:", detail_no
+  print "data:     ", user_data
+
+end sub

+ 9 - 0
pdf.mod/libharu/bindings/oberon-2/README.oberon-2

@@ -0,0 +1,9 @@
+This is an Oberon-2 (www.excelsior-usa.com/xds.html) binding for libharu.
+
+It tested on Windows, but should work on Linux as well.
+
+Copy libhpdf.dll to this folder and run build.bat, then run test.exe.
+
+PTS55F.ttf is a part of 'PT Sans' font.
+http://www.fontstock.com/public/PTSans.zip
+http://fonts.ru/public

+ 2 - 0
pdf.mod/libharu/bindings/oberon-2/build.bat

@@ -0,0 +1,2 @@
+xlib /implib libhpdf.lib libhpdf.dll
+xc =p test.prj

+ 1255 - 0
pdf.mod/libharu/bindings/oberon-2/hpdf.ob2

@@ -0,0 +1,1255 @@
+<*+CHANGESYM*>
+<*+M2EXTENSIONS*>
+<*+O2EXTENSIONS*>
+(*
+#
+#  URL http://libharu.org/
+#
+#  Copyright 2000-2006 (c) Takeshi Kanno
+#  Copyright 2007-2009 (c) Antony Dovgal et al.
+#
+#  Copyright 2012 (c) Dmitry Solomennikov
+#  Oberon-2 language binding to libhpdf.dll
+#
+*)
+
+MODULE hpdf;
+
+IMPORT 
+  Windows, SYSTEM;
+
+(*
+  NOTE:
+
+  if you want to use Haru with Kylix/FreePascal on Linux,
+  change "libhpdf.dll" to "libhpdf.so" and change "stdcall" to "cdecl"
+  (This file and hpdf_types.pas)
+
+*)
+
+TYPE
+  HPDF_HANDLE      * = Windows.PVOID;
+  HPDF_Doc         * = HPDF_HANDLE;
+  HPDF_Page        * = HPDF_HANDLE;
+  HPDF_Pages       * = HPDF_HANDLE;
+  HPDF_Stream      * = HPDF_HANDLE;
+  HPDF_Image       * = HPDF_HANDLE;
+  HPDF_Font        * = HPDF_HANDLE;
+  HPDF_Outline     * = HPDF_HANDLE;
+  HPDF_Encoder     * = HPDF_HANDLE;
+  HPDF_Destination * = HPDF_HANDLE;
+  HPDF_XObject     * = HPDF_HANDLE;
+  HPDF_Annotation  * = HPDF_HANDLE;
+  HPDF_ExtGState   * = HPDF_HANDLE;
+--  HPDF_CHAR        = Windows.PSTR;
+  --HPDF_STATUS      = Windows.UINT;
+
+(*----------------------------------------------------------------------------*)
+(*----- type definition ------------------------------------------------------*)
+
+
+(*  native OS integer types *)
+  HPDF_INT   * = Windows.LONG;
+  HPDF_UINT  * = Windows.UINT;
+  HPDF_PUINT * = Windows.PUINT;
+
+(*
+  32bit integer types
+*)
+  HPDF_INT32 * = Windows.LONG;
+  HPDF_UINT32 * = Windows.ULONG;
+  HPDF_PUINT32 * = Windows.PULONG;
+
+
+(*
+  16bit integer types
+ *)
+  HPDF_INT16 * = Windows.SHORT;
+  HPDF_UINT16 * = Windows.USHORT;
+  HPDF_PUINT16 * = POINTER TO ARRAY OF HPDF_UINT16;
+
+
+
+(*
+  8bit integer types
+*)
+  HPDF_INT8  * = Windows.INT8;
+  HPDF_UINT8 * = Windows.CARD8;
+
+
+(*
+  8bit character types
+*)
+  HPDF_CHAR * = Windows.PSTR;
+
+(*
+  8bit binary types
+*)
+  HPDF_BYTE * = Windows.BYTE;
+  HPDF_PBYTE * = Windows.PBYTE;
+
+
+(*
+  float type (32bit IEEE754)
+*)
+  HPDF_REAL * = Windows.FLOAT;
+--  HPDF_PREAL * = ^HPDF_REAL;
+
+
+(*  
+  double type (64bit IEEE754)
+ *)
+  HPDF_DOUBLE * = LONGREAL;
+
+
+(*  
+  boolean type (0: False, 1: True)
+ *)
+  HPDF_BOOL * = Windows.BOOL;
+
+
+(*  
+  error-no type (32bit unsigned integer)
+ *)
+  HPDF_STATUS * = Windows.UINT;
+
+
+(*  
+  character-code type (16bit)
+ *)
+  HPDF_CID * = Windows.WCHAR;
+  HPDF_UNICODE * = Windows.WCHAR;
+
+(*  
+  null terminated character *)
+  HPDF_PCHAR * = Windows.PSTR;
+
+
+(*  
+  HPDF_Box struct
+ *)
+  THPDF_Box * = RECORD
+    left: HPDF_REAL;
+    bottom: HPDF_REAL;
+    right: HPDF_REAL;
+    top: HPDF_REAL;
+  END;
+
+
+(*  
+  HPDF_Point struct
+ *)
+  PHPDF_Point * = POINTER ["StdCall"] TO THPDF_Point;
+  THPDF_Point * = RECORD
+    x: HPDF_REAL;
+    y: HPDF_REAL;
+  END;
+
+
+(*  
+  HPDF_Rect struct
+ *)
+  THPDF_Rect * = RECORD
+    left: HPDF_REAL;
+    bottom: HPDF_REAL;
+    right: HPDF_REAL;
+    top: HPDF_REAL;
+  END;
+
+
+(* 
+  HPDF_Date struct
+ *)
+  THPDF_Date * = RECORD
+    year: HPDF_INT;
+    month: HPDF_INT;
+    day: HPDF_INT;
+    hour: HPDF_INT;
+    minutes: HPDF_INT;
+    seconds: HPDF_INT;
+    ind: HPDF_CHAR;
+    off_hour: HPDF_INT;
+    off_minutes: HPDF_INT;
+  END;
+
+(*---------------------------------------------------------------------------*)
+(*------ text width struct --------------------------------------------------*)
+
+  THPDF_TextWidth * = RECORD
+    numchars: HPDF_UINT;
+    numwords: HPDF_UINT;   (* don't use this value. *)
+    width: HPDF_UINT;
+    numspace: HPDF_UINT;
+  END;
+
+(*---------------------------------------------------------------------------*)
+(*------ dash mode ----------------------------------------------------------*)
+
+  THPDF_DashMode * = RECORD ["StdCall"]
+    ptn: ARRAY 8 OF HPDF_UINT16;
+    num_ptn: HPDF_UINT16;
+    phase: HPDF_UINT16;
+  END;
+
+
+(*---------------------------------------------------------------------------*)
+(*----- HPDF_TransMatrix struct ---------------------------------------------*)
+
+  THPDF_TransMatrix * = RECORD
+    a: HPDF_REAL;
+    b: HPDF_REAL;
+    c: HPDF_REAL;
+    d: HPDF_REAL;
+    x: HPDF_REAL;
+    y: HPDF_REAL;
+  END;
+
+(*---------------------------------------------------------------------------*)
+(*----- HPDF_RGBColor struct ------------------------------------------------*)
+
+  THPDF_RGBColor * = RECORD
+    r: HPDF_REAL;
+    g: HPDF_REAL;
+    b: HPDF_REAL;
+  END;
+
+(*---------------------------------------------------------------------------*)
+(*----- HPDF_CMYKColor struct -----------------------------------------------*)
+
+  THPDF_CMYKColor * = RECORD
+    c: HPDF_REAL;
+    m: HPDF_REAL;
+    y: HPDF_REAL;
+    k: HPDF_REAL;
+  END;
+
+
+TYPE
+  THPDF_ColorSpace * = Windows.UINT;
+CONST
+  HPDF_CS_DEVICE_GRAY                * = 0;
+  HPDF_CS_DEVICE_RGB                 * = 1;
+  HPDF_CS_DEVICE_CMYK                * = 2;
+  HPDF_CS_CAL_GRAY                   * = 3;
+  HPDF_CS_CAL_RGB                    * = 4;
+  HPDF_CS_LAB                        * = 5;
+  HPDF_CS_ICC_BASED                  * = 6;
+  HPDF_CS_SEPARATION                 * = 7;
+  HPDF_CS_DEVICE_N                   * = 8;
+  HPDF_CS_INDEXED                    * = 9;
+  HPDF_CS_PATTERN                    * = 10;
+  HPDF_CS_EOF                        * = 11;
+
+(*----------------------------------------------------------------------------*)
+(*------ The line cap style --------------------------------------------------*)
+TYPE
+  THPDF_LineCap * = Windows.UINT;
+CONST
+  HPDF_BUTT_END                      * = 0;
+  HPDF_ROUND_END                     * = 1;
+  HPDF_PROJECTING_SQUARE_END         * = 2;
+  HPDF_LINECAP_EOF                   * = 3;
+
+(*----------------------------------------------------------------------------*)
+(*------ The line join style -------------------------------------------------*)
+TYPE
+  THPDF_LineJoin * = Windows.UINT;
+CONST
+  HPDF_MITER_JOIN                    * = 0;
+  HPDF_ROUND_JOIN                    * = 1;
+  HPDF_BEVEL_JOIN                    * = 2;
+  HPDF_LINEJOIN_EOF                  * = 3;
+
+(*----------------------------------------------------------------------------*)
+(*------ The text rendering mode ---------------------------------------------*)
+TYPE
+  THPDF_TextRenderingMode * = Windows.UINT;
+CONST
+  HPDF_FILL                          * = 0;
+  HPDF_STROKE                        * = 1;
+  HPDF_FILL_THEN_STROKE              * = 2;
+  HPDF_INVISIBLE                     * = 3;
+  HPDF_FILL_CLIPPING                 * = 4;
+  HPDF_STROKE_CLIPPING               * = 5;
+  HPDF_FILL_STROKE_CLIPPING          * = 6;
+  HPDF_CLIPPING                      * = 7;
+  HPDF_RENDERING_MODE_EOF            * = 8;
+
+TYPE
+  THPDF_WritingMode * = Windows.UINT;
+CONST
+  HPDF_WMODE_HORIZONTAL              * = 0;
+  HPDF_WMODE_VERTICAL                * = 1;
+  HPDF_WMODE_EOF                     * = 2;
+
+
+
+TYPE
+  THPDF_PageLayout * = Windows.UINT;
+CONST
+  HPDF_PAGE_LAYOUT_SINGLE            * = 0;
+  HPDF_PAGE_LAYOUT_ONE_COLUMN        * = 1;
+  HPDF_PAGE_LAYOUT_TWO_COLUMN_LEFT   * = 2;
+  HPDF_PAGE_LAYOUT_TWO_COLUMN_RIGHT  * = 3;
+  HPDF_PAGE_LAYOUT_EOF               * = 4;
+
+TYPE
+  THPDF_PageMode= Windows.UINT;
+CONST
+  HPDF_PAGE_MODE_USE_NONE            * = 0;
+  HPDF_PAGE_MODE_USE_OUTLINE         * = 1;
+  HPDF_PAGE_MODE_USE_THUMBS          * = 2;
+  HPDF_PAGE_MODE_FULL_SCREEN         * = 3;
+(*  HPDF_PAGE_MODE_USE_OC              * =4
+  HPDF_PAGE_MODE_USE_ATTACHMENTS     * = 4;
+' *)
+  HPDF_PAGE_MODE_EOF                 * = 4;
+
+TYPE
+  THPDF_PageNumStyle= Windows.UINT;
+CONST
+  HPDF_PAGE_NUM_STYLE_DECIMAL        * = 0;
+  HPDF_PAGE_NUM_STYLE_UPPER_ROMAN    * = 1;
+  HPDF_PAGE_NUM_STYLE_LOWER_ROMAN    * = 2;
+  HPDF_PAGE_NUM_STYLE_UPPER_LETTERS  * = 3;
+  HPDF_PAGE_NUM_STYLE_LOWER_LETTERS  * = 4;
+  HPDF_PAGE_NUM_STYLE_EOF            * = 5;
+
+TYPE
+  THPDF_DestinationType= Windows.UINT;
+CONST
+  HPDF_XYZ                           * = 0;
+  HPDF_FIT                           * = 1;
+  HPDF_FIT_H                         * = 2;
+  HPDF_FIT_V                         * = 3;
+  HPDF_FIT_R                         * = 4;
+  HPDF_FIT_B                         * = 5;
+  HPDF_FIT_BH                        * = 6;
+  HPDF_FIT_BV                        * = 7;
+  HPDF_DST_EOF                       * = 8;
+
+TYPE
+  THPDF_AnnotType= Windows.UINT;
+CONST
+  HPDF_ANNOT_TEXT_NOTES              * = 1;
+  HPDF_ANNOT_LINK                    * = 2;
+  HPDF_ANNOT_SOUND                   * = 3;
+  HPDF_ANNOT_FREE_TEXT               * = 4;
+  HPDF_ANNOT_STAMP                   * = 5;
+  HPDF_ANNOT_SQUARE                  * = 6;
+  HPDF_ANNOT_CIRCLE                  * = 7;
+  HPDF_ANNOT_STRIKE_OUT              * = 8;
+  HPDF_ANNOT_HIGHTLIGHT              * = 9;
+  HPDF_ANNOT_UNDERLINE               * = 10;
+  HPDF_ANNOT_INK                     * = 11;
+  HPDF_ANNOT_FILE_ATTACHMENT         * = 12;
+  HPDF_ANNOT_POPUP                   * = 13;
+
+TYPE
+  THPDF_AnnotFlgs= Windows.UINT;
+CONST
+  HPDF_ANNOT_INVISIBLE               * = 1;
+  HPDF_ANNOT_HIDDEN                  * = 2;
+  HPDF_ANNOT_PRINT                   * = 3;
+  HPDF_ANNOT_NOZOOM                  * = 4;
+  HPDF_ANNOT_NOROTATE                * = 5;
+  HPDF_ANNOT_NOVIEW                  * = 6;
+  HPDF_ANNOT_READONLY                * = 7;
+
+TYPE
+  THPDF_AnnotHighlightMode= Windows.UINT;
+CONST
+  HPDF_ANNOT_NO_HIGHTLIGHT           * = 0;
+  HPDF_ANNOT_INVERT_BOX              * = 1;
+  HPDF_ANNOT_INVERT_BORDER           * = 2;
+  HPDF_ANNOT_DOWN_APPEARANCE         * = 3;
+  HPDF_ANNOT_HIGHTLIGHT_MODE_EOF     * = 4;
+
+TYPE
+  THPDF_AnnotIcon= Windows.UINT;
+CONST
+  HPDF_ANNOT_ICON_COMMENT            * = 0;
+  HPDF_ANNOT_ICON_KEY                * = 1;
+  HPDF_ANNOT_ICON_NOTE               * = 2;
+  HPDF_ANNOT_ICON_HELP               * = 3;
+  HPDF_ANNOT_ICON_NEW_PARAGRAPH      * = 4;
+  HPDF_ANNOT_ICON_PARAGRAPH          * = 5;
+  HPDF_ANNOT_ICON_INSERT             * = 6;
+  HPDF_ANNOT_ICON_EOF                * = 7;
+
+(*----------------------------------------------------------------------------*)
+(*------ border stype --------------------------------------------------------*)
+TYPE
+  THPDF_BSSubtype= Windows.UINT;
+CONST
+  HPDF_BS_SOLID                      * = 1;
+  HPDF_BS_DASHED                     * = 2;
+  HPDF_BS_BEVELED                    * = 3;
+  HPDF_BS_INSET                      * = 4;
+  HPDF_BS_UNDERLINED                 * = 5;
+
+TYPE
+  THPDF_PageSizes= Windows.UINT;
+CONST
+  HPDF_PAGE_SIZE_LETTER              * = 0;
+  HPDF_PAGE_SIZE_LEGAL               * = 1;
+  HPDF_PAGE_SIZE_A3                  * = 2;
+  HPDF_PAGE_SIZE_A4                  * = 3;
+  HPDF_PAGE_SIZE_A5                  * = 4;
+  HPDF_PAGE_SIZE_B4                  * = 5;
+  HPDF_PAGE_SIZE_B5                  * = 6;
+  HPDF_PAGE_SIZE_EXECUTIVE           * = 7;
+  HPDF_PAGE_SIZE_US4x6               * = 8;
+  HPDF_PAGE_SIZE_US4x8               * = 9;
+  HPDF_PAGE_SIZE_US5x7               * = 10;
+  HPDF_PAGE_SIZE_COMM10              * = 11;
+  HPDF_PAGE_SIZE_EOF                 * = 12;
+
+TYPE
+  THPDF_PageDirection= Windows.UINT;
+CONST
+  HPDF_PAGE_PORTRAIT                 * = 0;
+  HPDF_PAGE_LANDSCAPE                * = 1;
+
+TYPE
+  THPDF_EncoderType= Windows.UINT;
+CONST
+  HPDF_ENCODER_TYPE_SINGLE_BYTE      * = 1;
+  HPDF_ENCODER_TYPE_DOUBLE_BYTE      * = 2;
+  HPDF_ENCODER_TYPE_UNINITIALIZED    * = 3;
+  HPDF_ENCODER_UNKNOWN               * = 4;
+
+TYPE
+  THPDF_ByteType= Windows.UINT;
+CONST
+  HPDF_BYTE_TYPE_SINGLE              * = 0;
+  HPDF_BYTE_TYPE_LEAD                * = 1;
+  HPDF_BYTE_TYPE_TRAIL               * = 2;
+  HPDF_BYTE_TYPE_UNKNOWN             * = 3;
+
+TYPE
+  THPDF_TextAlignment= Windows.UINT;
+CONST
+  HPDF_TALIGN_LEFT                   * = 0;
+  HPDF_TALIGN_RIGHT                  * = 1;
+  HPDF_TALIGN_CENTER                 * = 2;
+  HPDF_TALIGN_JUSTIFY                * = 3;
+TYPE
+  THPDF_InfoType * = Windows.UINT;
+CONST
+    (* date-time type parameters *)
+    HPDF_INFO_CREATION_DATE          * = 0;
+    HPDF_INFO_MOD_DATE               * = 1;
+
+    (* string type parameters *)
+    HPDF_INFO_AUTHOR                 * = 2;
+    HPDF_INFO_CREATOR                * = 3;
+    HPDF_INFO_PRODUCER               * = 4;
+    HPDF_INFO_TITLE                  * = 5;
+    HPDF_INFO_SUBJECT                * = 6;
+    HPDF_INFO_KEYWORDS               * = 7;
+    HPDF_INFO_EOF                    * = 8;
+
+TYPE
+  THPDF_EncryptMode = Windows.UINT;
+CONST
+  HPDF_ENCRYPT_R2 * = 2;
+  HPDF_ENCRYPT_R3 * = 3;
+
+TYPE
+  THPDF_TransitionStyle * = Windows.UINT;
+CONST
+  HPDF_TS_WIPE_RIGHT                       * = 0;
+  HPDF_TS_WIPE_UP                          * = 1;
+  HPDF_TS_WIPE_LEFT                        * = 2;
+  HPDF_TS_WIPE_DOWN                        * = 3;
+  HPDF_TS_BARN_DOORS_HORIZONTAL_OUT        * = 4;
+  HPDF_TS_BARN_DOORS_HORIZONTAL_IN         * = 5;
+  HPDF_TS_BARN_DOORS_VERTICAL_OUT          * = 6;
+  HPDF_TS_BARN_DOORS_VERTICAL_IN           * = 7;
+  HPDF_TS_BOX_OUT                          * = 8;
+  HPDF_TS_BOX_IN                           * = 9;
+  HPDF_TS_BLINDS_HORIZONTAL                * = 10;
+  HPDF_TS_BLINDS_VERTICAL                  * = 11;
+  HPDF_TS_DISSOLVE                         * = 12;
+  HPDF_TS_GLITTER_RIGHT                    * = 13;
+  HPDF_TS_GLITTER_DOWN                     * = 14;
+  HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT * = 15;
+  HPDF_TS_REPLACE                          * = 16;
+  HPDF_TS_EOF                              * = 17;
+
+TYPE
+  THPDF_BlendMode * = Windows.UINT;
+CONST
+  HPDF_BM_NORMAL      * = 0;
+  HPDF_BM_MULTIPLY    * = 1;
+  HPDF_BM_SCREEN      * = 2;
+  HPDF_BM_OVERLAY     * = 3;
+  HPDF_BM_DARKEN      * = 4;
+  HPDF_BM_LIGHTEN     * = 5;
+  HPDF_BM_COLOR_DODGE * = 6;
+  HPDF_BM_COLOR_BUM   * = 7;
+  HPDF_BM_HARD_LIGHT  * = 8;
+  HPDF_BM_SOFT_LIGHT  * = 9;
+  HPDF_BM_DIFFERENCE  * = 10;
+  HPDF_BM_EXCLUSHON   * = 11;
+  HPDF_BM_EOF         * = 12;
+
+
+CONST
+  HPDF_TRUE                    * = TRUE;
+  HPDF_FALSE                   * = FALSE;
+
+  HPDF_OK                      * = 0;
+  HPDF_NOERROR                 * = 0;
+
+(*----- default values -------------------------------------------------------*)
+
+(* buffer size which is required when we convert to character string. *)
+  HPDF_TMP_BUF_SIZ             * = 256;
+  HPDF_SHORT_BUF_SIZ           * = 32;
+  HPDF_REAL_LEN                * = 11;
+  HPDF_INT_LEN                 * = 11;
+  HPDF_TEXT_DEFAULT_LEN        * = 256;
+  HPDF_UNICODE_HEADER_LEN      * = 2;
+  HPDF_DATE_TIME_STR_LEN       * = 23;
+
+(* length of each item defined in PDF *)
+  HPDF_BYTE_OFFSET_LEN         * = 10;
+  HPDF_OBJ_ID_LEN              * = 7;
+  HPDF_GEN_NO_LEN              * = 5;
+
+(* default value of Graphic State *)
+  HPDF_DEF_FONT                * = 'Helvetica';
+  HPDF_DEF_PAGE_LAYOUT         * = HPDF_PAGE_LAYOUT_SINGLE;
+  HPDF_DEF_PAGE_MODE           * = HPDF_PAGE_MODE_USE_NONE;
+  HPDF_DEF_WORDSPACE           * = 0;
+  HPDF_DEF_CHARSPACE           * = 0;
+  HPDF_DEF_FONTSIZE            * = 10;
+  HPDF_DEF_HSCALING            * = 100;
+  HPDF_DEF_LEADING             * = 0;
+  HPDF_DEF_RENDERING_MODE      * = HPDF_FILL;
+  HPDF_DEF_RAISE               * = 0;
+  HPDF_DEF_LINEWIDTH           * = 1;
+  HPDF_DEF_LINECAP             * =  HPDF_BUTT_END;
+  HPDF_DEF_LINEJOIN            * = HPDF_MITER_JOIN;
+  HPDF_DEF_MITERLIMIT          * = 10;
+  HPDF_DEF_FLATNESS            * = 1;
+  HPDF_DEF_PAGE_NUM            * = 1;
+
+  HPDF_BS_DEF_WIDTH            * = 1;
+
+(* default page-size *)
+  HPDF_DEF_PAGE_WIDTH          * = 595.276;
+  HPDF_DEF_PAGE_HEIGHT         * = 841.89;
+
+  HPDF_VERSION_TEXT            * = '2.0.3';
+
+(*---------------------------------------------------------------------------*)
+(*----- compression mode ----------------------------------------------------*)
+TYPE
+  TCompressionMode* = SYSTEM.SET32;
+CONST
+  HPDF_COMP_NONE               * = TCompressionMode { };
+  HPDF_COMP_TEXT               * = TCompressionMode {0};
+  HPDF_COMP_IMAGE              * = TCompressionMode {1};
+  HPDF_COMP_METADATA           * = TCompressionMode {2};
+  HPDF_COMP_ALL                * = TCompressionMode {0..3};
+(*  HPDF_COMP_BEST_COMPRESS    * = $10;
+ *  HPDF_COMP_BEST_SPEED       * = $20;
+ *)
+  HPDF_COMP_MASK               * = TCompressionMode {0..7};
+
+(*----------------------------------------------------------------------------*)
+(*----- permission flags (only Revision 2 is supported)-----------------------*)
+
+  HPDF_ENABLE_READ             * = 0;
+  HPDF_ENABLE_PRINT            * = 4;
+  HPDF_ENABLE_EDIT_ALL         * = 8;
+  HPDF_ENABLE_COPY             * = 16;
+  HPDF_ENABLE_EDIT             * = 32;
+
+
+(*----------------------------------------------------------------------------*)
+(*------ viewer preferences definitions --------------------------------------*)
+
+  HPDF_HIDE_TOOLBAR            * = 1;
+  HPDF_HIDE_MENUBAR            * = 2;
+  HPDF_HIDE_WINDOW_UI          * = 4;
+  HPDF_FIT_WINDOW              * = 8;
+  HPDF_CENTER_WINDOW           * = 16;
+
+
+(*---------------------------------------------------------------------------*)
+(*------ limitation of object implementation (PDF1.4) -----------------------*)
+
+  HPDF_LIMIT_MAX_INT           * = 2147483647;
+  HPDF_LIMIT_MIN_INT           * = -2147483647;
+
+  HPDF_LIMIT_MAX_REAL          * = 32767;
+  HPDF_LIMIT_MIN_REAL          * = -32767;
+
+  HPDF_LIMIT_MAX_STRING_LEN    * = 65535;
+  HPDF_LIMIT_MAX_NAME_LEN      * = 127;
+
+  HPDF_LIMIT_MAX_ARRAY         * = 8191;
+  HPDF_LIMIT_MAX_DICT_ELEMENT  * = 4095;
+  HPDF_LIMIT_MAX_XREF_ELEMENT  * = 8388607;
+  HPDF_LIMIT_MAX_GSTATE        * = 28;
+  HPDF_LIMIT_MAX_DEVICE_N      * = 8;
+  HPDF_LIMIT_MAX_DEVICE_N_V15  * = 32;
+  HPDF_LIMIT_MAX_CID           * = 65535;
+  HPDF_MAX_GENERATION_NUM      * = 65535;
+
+  HPDF_MIN_PAGE_HEIGHT         * = 3;
+  HPDF_MIN_PAGE_WIDTH          * = 3;
+  HPDF_MAX_PAGE_HEIGHT         * = 14400;
+  HPDF_MAX_PAGE_WIDTH          * = 14400;
+  HPDF_MIN_MAGNIFICATION_FACTOR* = 8;
+  HPDF_MAX_MAGNIFICATION_FACTOR* = 3200;
+
+(*---------------------------------------------------------------------------*)
+(*------ limitation of various properties -----------------------------------*)
+
+  HPDF_MIN_PAGE_SIZE           * = 3;
+  HPDF_MAX_PAGE_SIZE           * = 14400;
+  HPDF_MIN_HORIZONTALSCALING   * = 10;
+  HPDF_MAX_HORIZONTALSCALING   * = 300;
+  HPDF_MIN_WORDSPACE           * = -30;
+  HPDF_MAX_WORDSPACE           * = 300;
+  HPDF_MIN_CHARSPACE           * = -30;
+  HPDF_MAX_CHARSPACE           * = 300;
+  HPDF_MAX_FONTSIZE            * = 300;
+  HPDF_MAX_ZOOMSIZE            * = 10;
+  HPDF_MAX_LEADING             * = 300;
+  HPDF_MAX_LINEWIDTH           * = 100;
+  HPDF_MAX_DASH_PATTERN        * = 100;
+
+(*----------------------------------------------------------------------------*)
+(*----- country code definition ----------------------------------------------*)
+
+  HPDF_COUNTRY_AF              * = 'AF';    (* AFGHANISTAN *)
+  HPDF_COUNTRY_AL              * = 'AL';    (* ALBANIA *)
+  HPDF_COUNTRY_DZ              * = 'DZ';    (* ALGERIA *)
+  HPDF_COUNTRY_AS              * = 'AS';    (* AMERICAN SAMOA *)
+  HPDF_COUNTRY_AD              * = 'AD';    (* ANDORRA *)
+  HPDF_COUNTRY_AO              * = 'AO';    (* ANGOLA *)
+  HPDF_COUNTRY_AI              * = 'AI';    (* ANGUILLA *)
+  HPDF_COUNTRY_AQ              * = 'AQ';    (* ANTARCTICA *)
+  HPDF_COUNTRY_AG              * = 'AG';    (* ANTIGUA AND BARBUDA *)
+  HPDF_COUNTRY_AR              * = 'AR';    (* ARGENTINA *)
+  HPDF_COUNTRY_AM              * = 'AM';    (* ARMENIA *)
+  HPDF_COUNTRY_AW              * = 'AW';    (* ARUBA *)
+  HPDF_COUNTRY_AU              * = 'AU';    (* AUSTRALIA *)
+  HPDF_COUNTRY_AT              * = 'AT';    (* AUSTRIA *)
+  HPDF_COUNTRY_AZ              * = 'AZ';    (* AZERBAIJAN *)
+  HPDF_COUNTRY_BS              * = 'BS';    (* BAHAMAS *)
+  HPDF_COUNTRY_BH              * = 'BH';    (* BAHRAIN *)
+  HPDF_COUNTRY_BD              * = 'BD';    (* BANGLADESH *)
+  HPDF_COUNTRY_BB              * = 'BB';    (* BARBADOS *)
+  HPDF_COUNTRY_BY              * = 'BY';    (* BELARUS *)
+  HPDF_COUNTRY_BE              * = 'BE';    (* BELGIUM *)
+  HPDF_COUNTRY_BZ              * = 'BZ';    (* BELIZE *)
+  HPDF_COUNTRY_BJ              * = 'BJ';    (* BENIN *)
+  HPDF_COUNTRY_BM              * = 'BM';    (* BERMUDA *)
+  HPDF_COUNTRY_BT              * = 'BT';    (* BHUTAN *)
+  HPDF_COUNTRY_BO              * = 'BO';    (* BOLIVIA *)
+  HPDF_COUNTRY_BA              * = 'BA';    (* BOSNIA AND HERZEGOWINA *)
+  HPDF_COUNTRY_BW              * = 'BW';    (* BOTSWANA *)
+  HPDF_COUNTRY_BV              * = 'BV';    (* BOUVET ISLAND *)
+  HPDF_COUNTRY_BR              * = 'BR';    (* BRAZIL *)
+  HPDF_COUNTRY_IO              * = 'IO';    (* BRITISH INDIAN OCEAN TERRITORY *)
+  HPDF_COUNTRY_BN              * = 'BN';    (* BRUNEI DARUSSALAM *)
+  HPDF_COUNTRY_BG              * = 'BG';    (* BULGARIA *)
+  HPDF_COUNTRY_BF              * = 'BF';    (* BURKINA FASO *)
+  HPDF_COUNTRY_BI              * = 'BI';    (* BURUNDI *)
+  HPDF_COUNTRY_KH              * = 'KH';    (* CAMBODIA *)
+  HPDF_COUNTRY_CM              * = 'CM';    (* CAMEROON *)
+  HPDF_COUNTRY_CA              * = 'CA';    (* CANADA *)
+  HPDF_COUNTRY_CV              * = 'CV';    (* CAPE VERDE *)
+  HPDF_COUNTRY_KY              * = 'KY';    (* CAYMAN ISLANDS *)
+  HPDF_COUNTRY_CF              * = 'CF';    (* CENTRAL AFRICAN REPUBLIC *)
+  HPDF_COUNTRY_TD              * = 'TD';    (* CHAD *)
+  HPDF_COUNTRY_CL              * = 'CL';    (* CHILE *)
+  HPDF_COUNTRY_CN              * = 'CN';    (* CHINA *)
+  HPDF_COUNTRY_CX              * = 'CX';    (* CHRISTMAS ISLAND *)
+  HPDF_COUNTRY_CC              * = 'CC';    (* COCOS (KEELING) ISLANDS *)
+  HPDF_COUNTRY_CO              * = 'CO';    (* COLOMBIA *)
+  HPDF_COUNTRY_KM              * = 'KM';    (* COMOROS *)
+  HPDF_COUNTRY_CG              * = 'CG';    (* CONGO *)
+  HPDF_COUNTRY_CK              * = 'CK';    (* COOK ISLANDS *)
+  HPDF_COUNTRY_CR              * = 'CR';    (* COSTA RICA *)
+  HPDF_COUNTRY_CI              * = 'CI';    (* COTE D'IVOIRE *)
+  HPDF_COUNTRY_HR              * = 'HR';    (* CROATIA (local name: Hrvatska) *)
+  HPDF_COUNTRY_CU              * = 'CU';    (* CUBA *)
+  HPDF_COUNTRY_CY              * = 'CY';    (* CYPRUS *)
+  HPDF_COUNTRY_CZ              * = 'CZ';    (* CZECH REPUBLIC *)
+  HPDF_COUNTRY_DK              * = 'DK';    (* DENMARK *)
+  HPDF_COUNTRY_DJ              * = 'DJ';    (* DJIBOUTI *)
+  HPDF_COUNTRY_DM              * = 'DM';    (* DOMINICA *)
+  HPDF_COUNTRY_DO              * = 'DO';    (* DOMINICAN REPUBLIC *)
+  HPDF_COUNTRY_TP              * = 'TP';    (* EAST TIMOR *)
+  HPDF_COUNTRY_EC              * = 'EC';    (* ECUADOR *)
+  HPDF_COUNTRY_EG              * = 'EG';    (* EGYPT *)
+  HPDF_COUNTRY_SV              * = 'SV';    (* EL SALVADOR *)
+  HPDF_COUNTRY_GQ              * = 'GQ';    (* EQUATORIAL GUINEA *)
+  HPDF_COUNTRY_ER              * = 'ER';    (* ERITREA *)
+  HPDF_COUNTRY_EE              * = 'EE';    (* ESTONIA *)
+  HPDF_COUNTRY_ET              * = 'ET';    (* ETHIOPIA *)
+  HPDF_COUNTRY_FK              * = 'FK';    (* FALKLAND ISLANDS (MALVINAS) *)
+  HPDF_COUNTRY_FO              * = 'FO';    (* FAROE ISLANDS *)
+  HPDF_COUNTRY_FJ              * = 'FJ';    (* FIJI *)
+  HPDF_COUNTRY_FI              * = 'FI';    (* FINLAND *)
+  HPDF_COUNTRY_FR              * = 'FR';    (* FRANCE *)
+  HPDF_COUNTRY_FX              * = 'FX';    (* FRANCE, METROPOLITAN *)
+  HPDF_COUNTRY_GF              * = 'GF';    (* FRENCH GUIANA *)
+  HPDF_COUNTRY_PF              * = 'PF';    (* FRENCH POLYNESIA *)
+  HPDF_COUNTRY_TF              * = 'TF';    (* FRENCH SOUTHERN TERRITORIES *)
+  HPDF_COUNTRY_GA              * = 'GA';    (* GABON *)
+  HPDF_COUNTRY_GM              * = 'GM';    (* GAMBIA *)
+  HPDF_COUNTRY_GE              * = 'GE';    (* GEORGIA *)
+  HPDF_COUNTRY_DE              * = 'DE';    (* GERMANY *)
+  HPDF_COUNTRY_GH              * = 'GH';    (* GHANA *)
+  HPDF_COUNTRY_GI              * = 'GI';    (* GIBRALTAR *)
+  HPDF_COUNTRY_GR              * = 'GR';    (* GREECE *)
+  HPDF_COUNTRY_GL              * = 'GL';    (* GREENLAND *)
+  HPDF_COUNTRY_GD              * = 'GD';    (* GRENADA *)
+  HPDF_COUNTRY_GP              * = 'GP';    (* GUADELOUPE *)
+  HPDF_COUNTRY_GU              * = 'GU';    (* GUAM *)
+  HPDF_COUNTRY_GT              * = 'GT';    (* GUATEMALA *)
+  HPDF_COUNTRY_GN              * = 'GN';    (* GUINEA *)
+  HPDF_COUNTRY_GW              * = 'GW';    (* GUINEA-BISSAU *)
+  HPDF_COUNTRY_GY              * = 'GY';    (* GUYANA *)
+  HPDF_COUNTRY_HT              * = 'HT';    (* HAITI *)
+  HPDF_COUNTRY_HM              * = 'HM';    (* HEARD AND MC DONALD ISLANDS *)
+  HPDF_COUNTRY_HN              * = 'HN';    (* HONDURAS *)
+  HPDF_COUNTRY_HK              * = 'HK';    (* HONG KONG *)
+  HPDF_COUNTRY_HU              * = 'HU';    (* HUNGARY *)
+  HPDF_COUNTRY_IS              * = 'IS';    (* ICELAND *)
+  HPDF_COUNTRY_IN              * = 'IN';    (* INDIA *)
+  HPDF_COUNTRY_ID              * = 'ID';    (* INDONESIA *)
+  HPDF_COUNTRY_IR              * = 'IR';    (* IRAN (ISLAMIC REPUBLIC OF) *)
+  HPDF_COUNTRY_IQ              * = 'IQ';    (* IRAQ *)
+  HPDF_COUNTRY_IE              * = 'IE';    (* IRELAND *)
+  HPDF_COUNTRY_IL              * = 'IL';    (* ISRAEL *)
+  HPDF_COUNTRY_IT              * = 'IT';    (* ITALY *)
+  HPDF_COUNTRY_JM              * = 'JM';    (* JAMAICA *)
+  HPDF_COUNTRY_JP              * = 'JP';    (* JAPAN *)
+  HPDF_COUNTRY_JO              * = 'JO';    (* JORDAN *)
+  HPDF_COUNTRY_KZ              * = 'KZ';    (* KAZAKHSTAN *)
+  HPDF_COUNTRY_KE              * = 'KE';    (* KENYA *)
+  HPDF_COUNTRY_KI              * = 'KI';    (* KIRIBATI *)
+  HPDF_COUNTRY_KP              * = 'KP';    (* KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF *)
+  HPDF_COUNTRY_KR              * = 'KR';    (* KOREA, REPUBLIC OF *)
+  HPDF_COUNTRY_KW              * = 'KW';    (* KUWAIT *)
+  HPDF_COUNTRY_KG              * = 'KG';    (* KYRGYZSTAN *)
+  HPDF_COUNTRY_LA              * = 'LA';    (* LAO PEOPLE'S DEMOCRATIC REPUBLIC *)
+  HPDF_COUNTRY_LV              * = 'LV';    (* LATVIA *)
+  HPDF_COUNTRY_LB              * = 'LB';    (* LEBANON *)
+  HPDF_COUNTRY_LS              * = 'LS';    (* LESOTHO *)
+  HPDF_COUNTRY_LR              * = 'LR';    (* LIBERIA *)
+  HPDF_COUNTRY_LY              * = 'LY';    (* LIBYAN ARAB JAMAHIRIYA *)
+  HPDF_COUNTRY_LI              * = 'LI';    (* LIECHTENSTEIN *)
+  HPDF_COUNTRY_LT              * = 'LT';    (* LITHUANIA *)
+  HPDF_COUNTRY_LU              * = 'LU';    (* LUXEMBOURG *)
+  HPDF_COUNTRY_MO              * = 'MO';    (* MACAU *)
+  HPDF_COUNTRY_MK              * = 'MK';    (* MACEDONIA,THE FORMER YUGOSLAV REPUBLIC OF *)
+  HPDF_COUNTRY_MG              * = 'MG';    (* MADAGASCAR *)
+  HPDF_COUNTRY_MW              * = 'MW';    (* MALAWI *)
+  HPDF_COUNTRY_MY              * = 'MY';    (* MALAYSIA *)
+  HPDF_COUNTRY_MV              * = 'MV';    (* MALDIVES *)
+  HPDF_COUNTRY_ML              * = 'ML';    (* MALI *)
+  HPDF_COUNTRY_MT              * = 'MT';    (* MALTA *)
+  HPDF_COUNTRY_MH              * = 'MH';    (* MARSHALL ISLANDS *)
+  HPDF_COUNTRY_MQ              * = 'MQ';    (* MARTINIQUE *)
+  HPDF_COUNTRY_MR              * = 'MR';    (* MAURITANIA *)
+  HPDF_COUNTRY_MU              * = 'MU';    (* MAURITIUS *)
+  HPDF_COUNTRY_YT              * = 'YT';    (* MAYOTTE *)
+  HPDF_COUNTRY_MX              * = 'MX';    (* MEXICO *)
+  HPDF_COUNTRY_FM              * = 'FM';    (* MICRONESIA, FEDERATED STATES OF *)
+  HPDF_COUNTRY_MD              * = 'MD';    (* MOLDOVA, REPUBLIC OF *)
+  HPDF_COUNTRY_MC              * = 'MC';    (* MONACO *)
+  HPDF_COUNTRY_MN              * = 'MN';    (* MONGOLIA *)
+  HPDF_COUNTRY_MS              * = 'MS';    (* MONTSERRAT *)
+  HPDF_COUNTRY_MA              * = 'MA';    (* MOROCCO *)
+  HPDF_COUNTRY_MZ              * = 'MZ';    (* MOZAMBIQUE *)
+  HPDF_COUNTRY_MM              * = 'MM';    (* MYANMAR *)
+  HPDF_COUNTRY_NA              * = 'NA';    (* NAMIBIA *)
+  HPDF_COUNTRY_NR              * = 'NR';    (* NAURU *)
+  HPDF_COUNTRY_NP              * = 'NP';    (* NEPAL *)
+  HPDF_COUNTRY_NL              * = 'NL';    (* NETHERLANDS *)
+  HPDF_COUNTRY_AN              * = 'AN';    (* NETHERLANDS ANTILLES *)
+  HPDF_COUNTRY_NC              * = 'NC';    (* NEW CALEDONIA *)
+  HPDF_COUNTRY_NZ              * = 'NZ';    (* NEW ZEALAND *)
+  HPDF_COUNTRY_NI              * = 'NI';    (* NICARAGUA *)
+  HPDF_COUNTRY_NE              * = 'NE';    (* NIGER *)
+  HPDF_COUNTRY_NG              * = 'NG';    (* NIGERIA *)
+  HPDF_COUNTRY_NU              * = 'NU';    (* NIUE *)
+  HPDF_COUNTRY_NF              * = 'NF';    (* NORFOLK ISLAND *)
+  HPDF_COUNTRY_MP              * = 'MP';    (* NORTHERN MARIANA ISLANDS *)
+  HPDF_COUNTRY_NO              * = 'NO';    (* NORWAY *)
+  HPDF_COUNTRY_OM              * = 'OM';    (* OMAN *)
+  HPDF_COUNTRY_PK              * = 'PK';    (* PAKISTAN *)
+  HPDF_COUNTRY_PW              * = 'PW';    (* PALAU *)
+  HPDF_COUNTRY_PA              * = 'PA';    (* PANAMA *)
+  HPDF_COUNTRY_PG              * = 'PG';    (* PAPUA NEW GUINEA *)
+  HPDF_COUNTRY_PY              * = 'PY';    (* PARAGUAY *)
+  HPDF_COUNTRY_PE              * = 'PE';    (* PERU *)
+  HPDF_COUNTRY_PH              * = 'PH';    (* PHILIPPINES *)
+  HPDF_COUNTRY_PN              * = 'PN';    (* PITCAIRN *)
+  HPDF_COUNTRY_PL              * = 'PL';    (* POLAND *)
+  HPDF_COUNTRY_PT              * = 'PT';    (* PORTUGAL *)
+  HPDF_COUNTRY_PR              * = 'PR';    (* PUERTO RICO *)
+  HPDF_COUNTRY_QA              * = 'QA';    (* QATAR *)
+  HPDF_COUNTRY_RE              * = 'RE';    (* REUNION *)
+  HPDF_COUNTRY_RO              * = 'RO';    (* ROMANIA *)
+  HPDF_COUNTRY_RU              * = 'RU';    (* RUSSIAN FEDERATION *)
+  HPDF_COUNTRY_RW              * = 'RW';    (* RWANDA *)
+  HPDF_COUNTRY_KN              * = 'KN';    (* SAINT KITTS AND NEVIS *)
+  HPDF_COUNTRY_LC              * = 'LC';    (* SAINT LUCIA *)
+  HPDF_COUNTRY_VC              * = 'VC';    (* SAINT VINCENT AND THE GRENADINES *)
+  HPDF_COUNTRY_WS              * = 'WS';    (* SAMOA *)
+  HPDF_COUNTRY_SM              * = 'SM';    (* SAN MARINO *)
+  HPDF_COUNTRY_ST              * = 'ST';    (* SAO TOME AND PRINCIPE *)
+  HPDF_COUNTRY_SA              * = 'SA';    (* SAUDI ARABIA *)
+  HPDF_COUNTRY_SN              * = 'SN';    (* SENEGAL *)
+  HPDF_COUNTRY_SC              * = 'SC';    (* SEYCHELLES *)
+  HPDF_COUNTRY_SL              * = 'SL';    (* SIERRA LEONE *)
+  HPDF_COUNTRY_SG              * = 'SG';    (* SINGAPORE *)
+  HPDF_COUNTRY_SK              * = 'SK';    (* SLOVAKIA (Slovak Republic) *)
+  HPDF_COUNTRY_SI              * = 'SI';    (* SLOVENIA *)
+  HPDF_COUNTRY_SB              * = 'SB';    (* SOLOMON ISLANDS *)
+  HPDF_COUNTRY_SO              * = 'SO';    (* SOMALIA *)
+  HPDF_COUNTRY_ZA              * = 'ZA';    (* SOUTH AFRICA *)
+  HPDF_COUNTRY_ES              * = 'ES';    (* SPAIN *)
+  HPDF_COUNTRY_LK              * = 'LK';    (* SRI LANKA *)
+  HPDF_COUNTRY_SH              * = 'SH';    (* ST. HELENA *)
+  HPDF_COUNTRY_PM              * = 'PM';    (* ST. PIERRE AND MIQUELON *)
+  HPDF_COUNTRY_SD              * = 'SD';    (* SUDAN *)
+  HPDF_COUNTRY_SR              * = 'SR';    (* SURINAME *)
+  HPDF_COUNTRY_SJ              * = 'SJ';    (* SVALBARD AND JAN MAYEN ISLANDS *)
+  HPDF_COUNTRY_SZ              * = 'SZ';    (* SWAZILAND *)
+  HPDF_COUNTRY_SE              * = 'SE';    (* SWEDEN *)
+  HPDF_COUNTRY_CH              * = 'CH';    (* SWITZERLAND *)
+  HPDF_COUNTRY_SY              * = 'SY';    (* SYRIAN ARAB REPUBLIC *)
+  HPDF_COUNTRY_TW              * = 'TW';    (* TAIWAN, PROVINCE OF CHINA *)
+  HPDF_COUNTRY_TJ              * = 'TJ';    (* TAJIKISTAN *)
+  HPDF_COUNTRY_TZ              * = 'TZ';    (* TANZANIA, UNITED REPUBLIC OF *)
+  HPDF_COUNTRY_TH              * = 'TH';    (* THAILAND *)
+  HPDF_COUNTRY_TG              * = 'TG';    (* TOGO *)
+  HPDF_COUNTRY_TK              * = 'TK';    (* TOKELAU *)
+  HPDF_COUNTRY_TO              * = 'TO';    (* TONGA *)
+  HPDF_COUNTRY_TT              * = 'TT';    (* TRINIDAD AND TOBAGO *)
+  HPDF_COUNTRY_TN              * = 'TN';    (* TUNISIA *)
+  HPDF_COUNTRY_TR              * = 'TR';    (* TURKEY *)
+  HPDF_COUNTRY_TM              * = 'TM';    (* TURKMENISTAN *)
+  HPDF_COUNTRY_TC              * = 'TC';    (* TURKS AND CAICOS ISLANDS *)
+  HPDF_COUNTRY_TV              * = 'TV';    (* TUVALU *)
+  HPDF_COUNTRY_UG              * = 'UG';    (* UGANDA *)
+  HPDF_COUNTRY_UA              * = 'UA';    (* UKRAINE *)
+  HPDF_COUNTRY_AE              * = 'AE';    (* UNITED ARAB EMIRATES *)
+  HPDF_COUNTRY_GB              * = 'GB';    (* UNITED KINGDOM *)
+  HPDF_COUNTRY_US              * = 'US';    (* UNITED STATES *)
+  HPDF_COUNTRY_UM              * = 'UM';    (* UNITED STATES MINOR OUTLYING ISLANDS *)
+  HPDF_COUNTRY_UY              * = 'UY';    (* URUGUAY *)
+  HPDF_COUNTRY_UZ              * = 'UZ';    (* UZBEKISTAN *)
+  HPDF_COUNTRY_VU              * = 'VU';    (* VANUATU *)
+  HPDF_COUNTRY_VA              * = 'VA';    (* VATICAN CITY STATE (HOLY SEE) *)
+  HPDF_COUNTRY_VE              * = 'VE';    (* VENEZUELA *)
+  HPDF_COUNTRY_VN              * = 'VN';    (* VIET NAM *)
+  HPDF_COUNTRY_VG              * = 'VG';    (* VIRGIN ISLANDS (BRITISH) *)
+  HPDF_COUNTRY_VI              * = 'VI';    (* VIRGIN ISLANDS (U.S.) *)
+  HPDF_COUNTRY_WF              * = 'WF';    (* WALLIS AND FUTUNA ISLANDS *)
+  HPDF_COUNTRY_EH              * = 'EH';    (* WESTERN SAHARA *)
+  HPDF_COUNTRY_YE              * = 'YE';    (* YEMEN *)
+  HPDF_COUNTRY_YU              * = 'YU';    (* YUGOSLAVIA *)
+  HPDF_COUNTRY_ZR              * = 'ZR';    (* ZAIRE *)
+  HPDF_COUNTRY_ZM              * = 'ZM';    (* ZAMBIA *)
+  HPDF_COUNTRY_ZW              * = 'ZW';    (* ZIMBABWE *)
+
+(*----------------------------------------------------------------------------*)
+(*----- lang code definition -------------------------------------------------*)
+
+  HPDF_LANG_AA                 * = 'aa';    (* Afar *)
+  HPDF_LANG_AB                 * = 'ab';    (* Abkhazian *)
+  HPDF_LANG_AF                 * = 'af';    (* Afrikaans *)
+  HPDF_LANG_AM                 * = 'am';    (* Amharic *)
+  HPDF_LANG_AR                 * = 'ar';    (* Arabic *)
+  HPDF_LANG_AS                 * = 'as';    (* Assamese *)
+  HPDF_LANG_AY                 * = 'ay';    (* Aymara *)
+  HPDF_LANG_AZ                 * = 'az';    (* Azerbaijani *)
+  HPDF_LANG_BA                 * = 'ba';    (* Bashkir *)
+  HPDF_LANG_BE                 * = 'be';    (* Byelorussian *)
+  HPDF_LANG_BG                 * = 'bg';    (* Bulgarian *)
+  HPDF_LANG_BH                 * = 'bh';    (* Bihari *)
+  HPDF_LANG_BI                 * = 'bi';    (* Bislama *)
+  HPDF_LANG_BN                 * = 'bn';    (* Bengali Bangla *)
+  HPDF_LANG_BO                 * = 'bo';    (* Tibetan *)
+  HPDF_LANG_BR                 * = 'br';    (* Breton *)
+  HPDF_LANG_CA                 * = 'ca';    (* Catalan *)
+  HPDF_LANG_CO                 * = 'co';    (* Corsican *)
+  HPDF_LANG_CS                 * = 'cs';    (* Czech *)
+  HPDF_LANG_CY                 * = 'cy';    (* Welsh *)
+  HPDF_LANG_DA                 * = 'da';    (* Danish *)
+  HPDF_LANG_DE                 * = 'de';    (* German *)
+  HPDF_LANG_DZ                 * = 'dz';    (* Bhutani *)
+  HPDF_LANG_EL                 * = 'el';    (* Greek *)
+  HPDF_LANG_EN                 * = 'en';    (* English *)
+  HPDF_LANG_EO                 * = 'eo';    (* Esperanto *)
+  HPDF_LANG_ES                 * = 'es';    (* Spanish *)
+  HPDF_LANG_ET                 * = 'et';    (* Estonian *)
+  HPDF_LANG_EU                 * = 'eu';    (* Basque *)
+  HPDF_LANG_FA                 * = 'fa';    (* Persian *)
+  HPDF_LANG_FI                 * = 'fi';    (* Finnish *)
+  HPDF_LANG_FJ                 * = 'fj';    (* Fiji *)
+  HPDF_LANG_FO                 * = 'fo';    (* Faeroese *)
+  HPDF_LANG_FR                 * = 'fr';    (* French *)
+  HPDF_LANG_FY                 * = 'fy';    (* Frisian *)
+  HPDF_LANG_GA                 * = 'ga';    (* Irish *)
+  HPDF_LANG_GD                 * = 'gd';    (* Scots Gaelic *)
+  HPDF_LANG_GL                 * = 'gl';    (* Galician *)
+  HPDF_LANG_GN                 * = 'gn';    (* Guarani *)
+  HPDF_LANG_GU                 * = 'gu';    (* Gujarati *)
+  HPDF_LANG_HA                 * = 'ha';    (* Hausa *)
+  HPDF_LANG_HI                 * = 'hi';    (* Hindi *)
+  HPDF_LANG_HR                 * = 'hr';    (* Croatian *)
+  HPDF_LANG_HU                 * = 'hu';    (* Hungarian *)
+  HPDF_LANG_HY                 * = 'hy';    (* Armenian *)
+  HPDF_LANG_IA                 * = 'ia';    (* Interlingua *)
+  HPDF_LANG_IE                 * = 'ie';    (* Interlingue *)
+  HPDF_LANG_IK                 * = 'ik';    (* Inupiak *)
+  HPDF_LANG_IN                 * = 'in';    (* Indonesian *)
+  HPDF_LANG_IS                 * = 'is';    (* Icelandic *)
+  HPDF_LANG_IT                 * = 'it';    (* Italian *)
+  HPDF_LANG_IW                 * = 'iw';    (* Hebrew *)
+  HPDF_LANG_JA                 * = 'ja';    (* Japanese *)
+  HPDF_LANG_JI                 * = 'ji';    (* Yiddish *)
+  HPDF_LANG_JW                 * = 'jw';    (* Javanese *)
+  HPDF_LANG_KA                 * = 'ka';    (* Georgian *)
+  HPDF_LANG_KK                 * = 'kk';    (* Kazakh *)
+  HPDF_LANG_KL                 * = 'kl';    (* Greenlandic *)
+  HPDF_LANG_KM                 * = 'km';    (* Cambodian *)
+  HPDF_LANG_KN                 * = 'kn';    (* Kannada *)
+  HPDF_LANG_KO                 * = 'ko';    (* Korean *)
+  HPDF_LANG_KS                 * = 'ks';    (* Kashmiri *)
+  HPDF_LANG_KU                 * = 'ku';    (* Kurdish *)
+  HPDF_LANG_KY                 * = 'ky';    (* Kirghiz *)
+  HPDF_LANG_LA                 * = 'la';    (* Latin *)
+  HPDF_LANG_LN                 * = 'ln';    (* Lingala *)
+  HPDF_LANG_LO                 * = 'lo';    (* Laothian *)
+  HPDF_LANG_LT                 * = 'lt';    (* Lithuanian *)
+  HPDF_LANG_LV                 * = 'lv';    (* Latvian,Lettish *)
+  HPDF_LANG_MG                 * = 'mg';    (* Malagasy *)
+  HPDF_LANG_MI                 * = 'mi';    (* Maori *)
+  HPDF_LANG_MK                 * = 'mk';    (* Macedonian *)
+  HPDF_LANG_ML                 * = 'ml';    (* Malayalam *)
+  HPDF_LANG_MN                 * = 'mn';    (* Mongolian *)
+  HPDF_LANG_MO                 * = 'mo';    (* Moldavian *)
+  HPDF_LANG_MR                 * = 'mr';    (* Marathi *)
+  HPDF_LANG_MS                 * = 'ms';    (* Malay *)
+  HPDF_LANG_MT                 * = 'mt';    (* Maltese *)
+  HPDF_LANG_MY                 * = 'my';    (* Burmese *)
+  HPDF_LANG_NA                 * = 'na';    (* Nauru *)
+  HPDF_LANG_NE                 * = 'ne';    (* Nepali *)
+  HPDF_LANG_NL                 * = 'nl';    (* Dutch *)
+  HPDF_LANG_NO                 * = 'no';    (* Norwegian *)
+  HPDF_LANG_OC                 * = 'oc';    (* Occitan *)
+  HPDF_LANG_OM                 * = 'om';    (* (Afan)Oromo *)
+  HPDF_LANG_OR                 * = 'or';    (* Oriya *)
+  HPDF_LANG_PA                 * = 'pa';    (* Punjabi *)
+  HPDF_LANG_PL                 * = 'pl';    (* Polish *)
+  HPDF_LANG_PS                 * = 'ps';    (* Pashto,Pushto *)
+  HPDF_LANG_PT                 * = 'pt';    (* Portuguese  *)
+  HPDF_LANG_QU                 * = 'qu';    (* Quechua *)
+  HPDF_LANG_RM                 * = 'rm';    (* Rhaeto-Romance *)
+  HPDF_LANG_RN                 * = 'rn';    (* Kirundi *)
+  HPDF_LANG_RO                 * = 'ro';    (* Romanian *)
+  HPDF_LANG_RU                 * = 'ru';    (* Russian *)
+  HPDF_LANG_RW                 * = 'rw';    (* Kinyarwanda *)
+  HPDF_LANG_SA                 * = 'sa';    (* Sanskrit *)
+  HPDF_LANG_SD                 * = 'sd';    (* Sindhi *)
+  HPDF_LANG_SG                 * = 'sg';    (* Sangro *)
+  HPDF_LANG_SH                 * = 'sh';    (* Serbo-Croatian *)
+  HPDF_LANG_SI                 * = 'si';    (* Singhalese *)
+  HPDF_LANG_SK                 * = 'sk';    (* Slovak *)
+  HPDF_LANG_SL                 * = 'sl';    (* Slovenian *)
+  HPDF_LANG_SM                 * = 'sm';    (* Samoan *)
+  HPDF_LANG_SN                 * = 'sn';    (* Shona *)
+  HPDF_LANG_SO                 * = 'so';    (* Somali *)
+  HPDF_LANG_SQ                 * = 'sq';    (* Albanian *)
+  HPDF_LANG_SR                 * = 'sr';    (* Serbian *)
+  HPDF_LANG_SS                 * = 'ss';    (* Siswati *)
+  HPDF_LANG_ST                 * = 'st';    (* Sesotho *)
+  HPDF_LANG_SU                 * = 'su';    (* Sundanese *)
+  HPDF_LANG_SV                 * = 'sv';    (* Swedish *)
+  HPDF_LANG_SW                 * = 'sw';    (* Swahili *)
+  HPDF_LANG_TA                 * = 'ta';    (* Tamil *)
+  HPDF_LANG_TE                 * = 'te';    (* Tegulu *)
+  HPDF_LANG_TG                 * = 'tg';    (* Tajik *)
+  HPDF_LANG_TH                 * = 'th';    (* Thai *)
+  HPDF_LANG_TI                 * = 'ti';    (* Tigrinya *)
+  HPDF_LANG_TK                 * = 'tk';    (* Turkmen *)
+  HPDF_LANG_TL                 * = 'tl';    (* Tagalog *)
+  HPDF_LANG_TN                 * = 'tn';    (* Setswanato Tonga *)
+  HPDF_LANG_TR                 * = 'tr';    (* Turkish *)
+  HPDF_LANG_TS                 * = 'ts';    (* Tsonga *)
+  HPDF_LANG_TT                 * = 'tt';    (* Tatar *)
+  HPDF_LANG_TW                 * = 'tw';    (* Twi *)
+  HPDF_LANG_UK                 * = 'uk';    (* Ukrainian *)
+  HPDF_LANG_UR                 * = 'ur';    (* Urdu *)
+  HPDF_LANG_UZ                 * = 'uz';    (* Uzbek *)
+  HPDF_LANG_VI                 * = 'vi';    (* Vietnamese *)
+  HPDF_LANG_VO                 * = 'vo';    (* Volapuk *)
+  HPDF_LANG_WO                 * = 'wo';    (* Wolof *)
+  HPDF_LANG_XH                 * = 'xh';    (* Xhosa *)
+  HPDF_LANG_YO                 * = 'yo';    (* Yoruba *)
+  HPDF_LANG_ZH                 * = 'zh';    (* Chinese *)
+  HPDF_LANG_ZU                 * = 'zu';    (* Zulu *)
+
+
+(*----------------------------------------------------------------------------*)
+(*----- Graphis mode ---------------------------------------------------------*)
+CONST
+  HPDF_GMODE_PAGE_DESCRIPTION  * = {0};
+  HPDF_GMODE_PATH_OBJECT       * = {1};
+  HPDF_GMODE_TEXT_OBJECT       * = {2};
+  HPDF_GMODE_CLIPPING_PATH     * = {3};
+  HPDF_GMODE_SHADING           * = {4};
+  HPDF_GMODE_INLINE_IMAGE      * = {5};
+  HPDF_GMODE_EXTERNAL_OBJECT   * = {6};
+
+
+TYPE
+  THPDF_ErrorFunc * = PROCEDURE ["StdCall"] (error_no: HPDF_STATUS; detail_no: HPDF_STATUS; user_data: Windows.PVOID); 
+  THPDF_AllocFunc * = PROCEDURE ["StdCall"] (size: Windows.UINT); 
+  THPDF_FreeFunc  * = PROCEDURE ["StdCall"] (aptr: Windows.PVOID);
+
+  (*
+  THPDF_ErrorFunc * = PROCEDURE ["StdCall"] (HPDF_STATUS, HPDF_STATUS, Windows.PVOID); 
+  THPDF_AllocFunc * = PROCEDURE ["StdCall"] (Windows.UINT); 
+  THPDF_FreeFunc  * = PROCEDURE ["StdCall"] (Windows.PVOID); *)
+
+PROCEDURE ["StdCall"] / HPDF_NewEx*(user_error_fn: THPDF_ErrorFunc; user_alloc_fn: THPDF_AllocFunc; user_free_fn: THPDF_FreeFunc; mem_pool_buf_size: HPDF_UINT; user_data: Windows.PVOID): HPDF_Doc;
+PROCEDURE ["StdCall"] / HPDF_New*(user_error_fn: THPDF_ErrorFunc; user_data: Windows.PVOID): HPDF_Doc;
+PROCEDURE ["StdCall"] / HPDF_SetErrorHandler*(pdf: HPDF_Doc; user_error_fn: THPDF_ErrorFunc): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Free*(pdf: HPDF_Doc); 
+PROCEDURE ["StdCall"] / HPDF_NewDoc*(pdf: HPDF_Doc): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_FreeDoc*(pdf: HPDF_Doc); 
+PROCEDURE ["StdCall"] / HPDF_HasDoc*(pdf: HPDF_Doc): HPDF_BOOL; 
+PROCEDURE ["StdCall"] / HPDF_FreeDocAll*(pdf: HPDF_Doc); 
+PROCEDURE ["StdCall"] / HPDF_SaveToStream*(pdf: HPDF_Doc): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_GetStreamSize*(pdf: HPDF_Doc): HPDF_UINT32;
+PROCEDURE ["StdCall"] / HPDF_ReadFromStream*(pdf: HPDF_Doc; buf: HPDF_PBYTE; size: HPDF_PUINT): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_ResetStream*(pdf: HPDF_Doc): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_SaveToFile*(pdf: HPDF_Doc; file_name: HPDF_PCHAR): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_GetError*(pdf: HPDF_Doc): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_ResetError*(pdf: HPDF_Doc); 
+PROCEDURE ["StdCall"] / HPDF_SetPagesConfiguration*(pdf: HPDF_Doc; page_per_pages: HPDF_UINT): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_GetPageByIndex*(pdf: HPDF_Doc; index: HPDF_UINT): HPDF_Page;
+PROCEDURE ["StdCall"] / HPDF_GetPageLayout*(pdf: HPDF_Doc): THPDF_PageLayout;
+PROCEDURE ["StdCall"] / HPDF_SetPageLayout*(pdf: HPDF_Doc; layout: THPDF_PageLayout): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_GetPageMode*(pdf: HPDF_Doc): THPDF_PageMode;
+PROCEDURE ["StdCall"] / HPDF_SetPageMode*(pdf: HPDF_Doc; mode: THPDF_PageMode): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_SetOpenAction*(pdf: HPDF_Doc; open_action: HPDF_Destination): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_GetViewerPreference*(pdf: HPDF_Doc): HPDF_UINT;
+PROCEDURE ["StdCall"] / HPDF_SetViewerPreference*(pdf: HPDF_Doc; value: HPDF_UINT): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_GetCurrentPage*(pdf: HPDF_Doc): HPDF_Page;
+PROCEDURE ["StdCall"] / HPDF_AddPage*(pdf: HPDF_Doc): HPDF_Page; 
+PROCEDURE ["StdCall"] / HPDF_InsertPage*(pdf: HPDF_Doc; page: HPDF_Page): HPDF_Page;
+PROCEDURE ["StdCall"] / HPDF_Page_SetWidth*(page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_SetHeight*(page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_SetSize*(page: HPDF_Page; size: THPDF_PageSizes; direction: THPDF_PageDirection): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetRotate*(page: HPDF_Page; angle: HPDF_UINT16): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_GetFont*(pdf: HPDF_Doc; font_name: HPDF_PCHAR; encoding_name: HPDF_PCHAR): HPDF_Font; 
+PROCEDURE ["StdCall"] / HPDF_LoadType1FontFromFile*(pdf: HPDF_Doc; afmfilename: HPDF_PCHAR; pfmfilename: HPDF_PCHAR): HPDF_PCHAR; 
+PROCEDURE ["StdCall"] / HPDF_LoadTTFontFromFile*(pdf: HPDF_Doc; file_name: HPDF_PCHAR; embedding: HPDF_BOOL): HPDF_PCHAR; 
+PROCEDURE ["StdCall"] / HPDF_LoadTTFontFromFile2*(pdf: HPDF_Doc; file_name: HPDF_PCHAR; index: HPDF_UINT; embedding: HPDF_BOOL): HPDF_CHAR;
+PROCEDURE ["StdCall"] / HPDF_AddPageLabel*(pdf: HPDF_Doc; page_num: HPDF_UINT; style: THPDF_PageNumStyle; first_page: HPDF_UINT; prefix: HPDF_PCHAR): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_UseJPFonts*(pdf: HPDF_Doc): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_UseKRFonts*(pdf: HPDF_Doc): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_UseCNSFonts*(pdf: HPDF_Doc): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_UseCNTFonts*(pdf: HPDF_Doc): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_CreateOutline*(pdf: HPDF_Doc; parent: HPDF_Outline; title: HPDF_PCHAR; encoder: HPDF_Encoder): HPDF_Outline;
+PROCEDURE ["StdCall"] / HPDF_Outline_SetOpened*(outline: HPDF_Outline; opened: HPDF_BOOL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Outline_SetDestination*(outline: HPDF_Outline; dst: HPDF_Destination): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_CreateDestination*(page: HPDF_Page): HPDF_Destination;
+PROCEDURE ["StdCall"] / HPDF_Destination_SetXYZ*(dst: HPDF_Destination; left: HPDF_REAL; top: HPDF_REAL; zoom: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Destination_SetFit*(dst: HPDF_Destination): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Destination_SetFitH*(dst: HPDF_Destination; top: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Destination_SetFitV*(dst: HPDF_Destination; left: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Destination_SetFitR*(dst: HPDF_Destination; left: HPDF_REAL; bottom: HPDF_REAL; right: HPDF_REAL; top: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Destination_SetFitB*(dst: HPDF_Destination): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Destination_SetFitBH*(dst: HPDF_Destination; top: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Destination_SetFitBV*(dst: HPDF_Destination; left: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_GetEncoder*(pdf: HPDF_Doc; encoding_name: HPDF_PCHAR): HPDF_Encoder; 
+PROCEDURE ["StdCall"] / HPDF_GetCurrentEncoder*(pdf: HPDF_Doc): HPDF_Encoder;
+PROCEDURE ["StdCall"] / HPDF_SetCurrentEncoder*(pdf: HPDF_Doc; encoding_name: HPDF_PCHAR): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Encoder_GetType*(encoder: HPDF_Encoder): THPDF_EncoderType;
+PROCEDURE ["StdCall"] / HPDF_Encoder_GetByteType*(encoder: HPDF_Encoder; text: HPDF_PCHAR; index: HPDF_UINT): THPDF_ByteType; 
+PROCEDURE ["StdCall"] / HPDF_Encoder_GetUnicode*(encoder: HPDF_Encoder; code: HPDF_UINT16): HPDF_UNICODE; 
+PROCEDURE ["StdCall"] / HPDF_Encoder_GetWritingMode*(encoder: HPDF_Encoder): THPDF_EncoderType;
+PROCEDURE ["StdCall"] / HPDF_UseJPEncodings*(pdf: HPDF_Doc): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_UseKREncodings*(pdf: HPDF_Doc): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_UseCNSEncodings*(pdf: HPDF_Doc): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_UseCNTEncodings*(pdf: HPDF_Doc): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_CreateTextAnnot*(page: HPDF_Page; rect: THPDF_Rect;text: HPDF_PCHAR; encoder: HPDF_Encoder): HPDF_Annotation;
+PROCEDURE ["StdCall"] / HPDF_Page_CreateLinkAnnot*(page: HPDF_Page; rect: THPDF_Rect; dst: HPDF_Destination): HPDF_Annotation;
+PROCEDURE ["StdCall"] / HPDF_Page_CreateURILinkAnnot*(page: HPDF_Page; rect: THPDF_Rect; uri: HPDF_PCHAR): HPDF_Annotation; 
+PROCEDURE ["StdCall"] / HPDF_LinkAnnot_SetHighlightMode*(annot: HPDF_Annotation; mode: THPDF_AnnotHighlightMode): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_LinkAnnot_SetBorderStyle*(annot: HPDF_Annotation; width: HPDF_REAL; dash_on: HPDF_UINT16; dash_off: HPDF_UINT16): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_TextAnnot_SetIcon*(annot: HPDF_Annotation; icon: THPDF_AnnotIcon): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_TextAnnot_SetOpened*(annot: HPDF_Annotation; opened: HPDF_BOOL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_LoadPngImageFromFile*(pdf: HPDF_Doc; filename: HPDF_PCHAR): HPDF_Image; 
+PROCEDURE ["StdCall"] / HPDF_LoadPngImageFromFile2*(pdf: HPDF_Doc; filename: HPDF_PCHAR): HPDF_Image; 
+PROCEDURE ["StdCall"] / HPDF_LoadJpegImageFromFile*(pdf: HPDF_Doc; filename: HPDF_PCHAR): HPDF_Image; 
+PROCEDURE ["StdCall"] / HPDF_LoadRawImageFromFile*(pdf: HPDF_Doc; filename: HPDF_PCHAR; width: HPDF_UINT; height: HPDF_UINT; color_space: THPDF_ColorSpace): HPDF_Image; 
+PROCEDURE ["StdCall"] / HPDF_LoadRawImageFromMem*(pdf: HPDF_Doc; buf: HPDF_PBYTE; width: HPDF_UINT; height: HPDF_UINT; color_space: THPDF_ColorSpace; bits_per_component: HPDF_UINT): HPDF_Image; 
+PROCEDURE ["StdCall"] / HPDF_Image_GetSize2*(image: HPDF_Image; VAR size: THPDF_Point): HPDF_STATUS;
+--PROCEDURE ["StdCall"] / HPDF_Image_GetSize*(image: HPDF_Image): THPDF_Point;
+PROCEDURE ["StdCall"] / HPDF_Image_GetWidth*(image: HPDF_Image): HPDF_UINT;
+PROCEDURE ["StdCall"] / HPDF_Image_GetHeight*(image: HPDF_Image): HPDF_UINT;
+PROCEDURE ["StdCall"] / HPDF_Image_GetBitsPerComponent*(image: HPDF_Image): HPDF_UINT;
+PROCEDURE ["StdCall"] / HPDF_Image_GetColorSpace*(image: HPDF_Image): HPDF_PCHAR;
+PROCEDURE ["StdCall"] / HPDF_Image_SetColorMask*(image: HPDF_Image; rmin: HPDF_UINT; rmax: HPDF_UINT; gmin: HPDF_UINT; gmax: HPDF_UINT; bmin: HPDF_UINT; bmax: HPDF_UINT): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Image_SetMaskImage*(image: HPDF_Image; mask_image: HPDF_Image): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_SetInfoAttr*(pdf: HPDF_Doc; info_type: THPDF_InfoType; value: HPDF_PCHAR): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_GetInfoAttr*(pdf: HPDF_Doc; info_type: THPDF_InfoType): HPDF_PCHAR;
+PROCEDURE ["StdCall"] / HPDF_SetInfoDateAttr*(pdf: HPDF_Doc; info_type: THPDF_InfoType; value: THPDF_Date): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_SetPassword*(pdf: HPDF_Doc; owner_passwd: HPDF_PCHAR; user_passwd: HPDF_PCHAR): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_SetPermission*(pdf: HPDF_Doc; permission: HPDF_UINT): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_SetEncryptionMode*(pdf: HPDF_Doc; mode: THPDF_EncryptMode; key_len: HPDF_UINT): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_SetCompressionMode*(pdf: HPDF_Doc; mode: TCompressionMode): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_TextWidth*(page: HPDF_Page; text: HPDF_PCHAR): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_MeasureText*(page: HPDF_Page; text: HPDF_PCHAR; width: HPDF_REAL; wordwrap: HPDF_BOOL; VAR real_width: HPDF_REAL): HPDF_UINT;
+PROCEDURE ["StdCall"] / HPDF_Page_GetWidth*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetHeight*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetGMode*(page: HPDF_Page): HPDF_UINT16;
+PROCEDURE ["StdCall"] / HPDF_Page_GetCurrentPos2*(page: HPDF_Page; VAR pos: THPDF_Point): HPDF_STATUS;
+--PROCEDURE ["StdCall"] / HPDF_Page_GetCurrentPos*(page: HPDF_Page): THPDF_Point;
+PROCEDURE ["StdCall"] / HPDF_Page_GetCurrentTextPos2*(page: HPDF_Page; VAR pos: THPDF_Point): HPDF_STATUS;
+--PROCEDURE ["StdCall"] / HPDF_Page_GetCurrentTextPos*(page: HPDF_Page): THPDF_Point;
+PROCEDURE ["StdCall"] / HPDF_Page_GetCurrentFont*(page: HPDF_Page): HPDF_Font;
+PROCEDURE ["StdCall"] / HPDF_Font_GetFontName*(font: HPDF_Font): HPDF_PCHAR;
+PROCEDURE ["StdCall"] / HPDF_Font_GetEncodingName*(font: HPDF_Font): HPDF_PCHAR;
+PROCEDURE ["StdCall"] / HPDF_Font_GetUnicodeWidth*(font: HPDF_Font; code: HPDF_UNICODE): HPDF_INT;
+PROCEDURE ["StdCall"] / HPDF_Font_GetBBox*(font: HPDF_Font): THPDF_Rect;
+PROCEDURE ["StdCall"] / HPDF_Font_GetAscent*(font: HPDF_Font): HPDF_INT;
+PROCEDURE ["StdCall"] / HPDF_Font_GetDescent*(font: HPDF_Font): HPDF_INT;
+PROCEDURE ["StdCall"] / HPDF_Font_GetXHeight*(font: HPDF_Font): HPDF_UINT;
+PROCEDURE ["StdCall"] / HPDF_Font_GetCapHeight*(font: HPDF_Font): HPDF_UINT;
+PROCEDURE ["StdCall"] / HPDF_Font_TextWidth*(font: HPDF_Font; text: HPDF_PCHAR; len: HPDF_UINT): THPDF_TextWidth;
+PROCEDURE ["StdCall"] / HPDF_Font_MeasureText*(font: HPDF_Font; text: HPDF_PCHAR; len: HPDF_UINT; width: HPDF_REAL; font_size: HPDF_REAL; char_space: HPDF_REAL;  word_space: HPDF_REAL; wordwrap: HPDF_BOOL; VAR real_width: HPDF_REAL) : HPDF_UINT;
+PROCEDURE ["StdCall"] / HPDF_CreateExtGState*(pdf: HPDF_Doc) : HPDF_ExtGState;
+PROCEDURE ["StdCall"] / HPDF_ExtGState_SetAlphaStroke*(ext_gstate: HPDF_ExtGState; value: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_ExtGState_SetAlphaFill*(ext_gstate: HPDF_ExtGState; value: HPDF_REAL) : HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_ExtGState_SetBlendMode*(ext_gstate: HPDF_ExtGState; mode: THPDF_BlendMode) : HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_GetCurrentFontSize*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetTransMatrix*(page: HPDF_Page): THPDF_TransMatrix;
+PROCEDURE ["StdCall"] / HPDF_Page_GetLineWidth*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetLineCap*(page: HPDF_Page): THPDF_LineCap;
+PROCEDURE ["StdCall"] / HPDF_Page_GetLineJoin*(page: HPDF_Page): THPDF_LineJoin;
+PROCEDURE ["StdCall"] / HPDF_Page_GetMiterLimit*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetDash*(page: HPDF_Page): THPDF_DashMode;
+PROCEDURE ["StdCall"] / HPDF_Page_GetFlat*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetCharSpace*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetWordSpace*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetHorizontalScalling*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetTextLeading*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetTextRenderingMode*(page: HPDF_Page): THPDF_TextRenderingMode;
+PROCEDURE ["StdCall"] / HPDF_Page_GetTextRaise*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetRGBFill*(page: HPDF_Page): THPDF_RGBColor;
+PROCEDURE ["StdCall"] / HPDF_Page_GetRGBStroke*(page: HPDF_Page): THPDF_RGBColor;
+PROCEDURE ["StdCall"] / HPDF_Page_GetCMYKFill*(page: HPDF_Page): THPDF_CMYKColor;
+PROCEDURE ["StdCall"] / HPDF_Page_GetCMYKStroke*(page: HPDF_Page): THPDF_CMYKColor;
+PROCEDURE ["StdCall"] / HPDF_Page_GetGrayFill*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetGrayStroke*(page: HPDF_Page): HPDF_REAL;
+PROCEDURE ["StdCall"] / HPDF_Page_GetStrokingColorSpace*(page: HPDF_Page): THPDF_ColorSpace;
+PROCEDURE ["StdCall"] / HPDF_Page_GetFillingColorSpace*(page: HPDF_Page): THPDF_ColorSpace;
+PROCEDURE ["StdCall"] / HPDF_Page_GetTextMatrix*(page: HPDF_Page): THPDF_TransMatrix;
+PROCEDURE ["StdCall"] / HPDF_Page_GetGStateDepth*(page: HPDF_Page): HPDF_UINT;
+PROCEDURE ["StdCall"] / HPDF_Page_SetLineWidth*(page: HPDF_Page; line_width: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetLineCap*(page: HPDF_Page; line_cap: THPDF_LineCap): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetLineJoin*(page: HPDF_Page; line_join: THPDF_LineJoin): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetMiterLimit*(page: HPDF_Page; miter_limit: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetDash*(page: HPDF_Page; ptn: HPDF_PUINT16; num_param: HPDF_UINT; phase: HPDF_UINT): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_SetFlat*(page: HPDF_Page; flatness: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_SetExtGState*(page: HPDF_Page; ext_gstate: HPDF_ExtGState): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_GSave*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_GRestore*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_Concat*(page: HPDF_Page; a: HPDF_REAL; b: HPDF_REAL; c: HPDF_REAL; d: HPDF_REAL; x: HPDF_REAL; y: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_MoveTo*(page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_LineTo*(page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_CurveTo*(page: HPDF_Page; x1: HPDF_REAL; y1: HPDF_REAL; x2: HPDF_REAL; y2: HPDF_REAL; x3: HPDF_REAL; y3: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_CurveTo2*(page: HPDF_Page; x2: HPDF_REAL; y2: HPDF_REAL; x3: HPDF_REAL; y3: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_CurveTo3*(page: HPDF_Page; x1: HPDF_REAL; y1: HPDF_REAL; x3: HPDF_REAL; y3: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_ClosePath*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_Rectangle*(page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL; width: HPDF_REAL; height: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_Stroke*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_ClosePathStroke*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_Fill*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_Eofill*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_FillStroke*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_EofillStroke*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_ClosePathFillStroke*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_ClosePathEofillStroke*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_EndPath*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_Clip*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_Eoclip*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_BeginText*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_EndText*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_SetCharSpace*(page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_SetWordSpace*(page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_SetHorizontalScalling*(page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetTextLeading*(page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_SetFontAndSize*(page: HPDF_Page; font: HPDF_Font; size: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetTextRenderingMode*(page: HPDF_Page; mode: THPDF_TextRenderingMode): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetTextRaise*(page: HPDF_Page; value: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_MoveTextPos*(page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_MoveTextPos2*(page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetTextMatrix*(page: HPDF_Page; a: HPDF_REAL; b: HPDF_REAL; c: HPDF_REAL; d: HPDF_REAL; x: HPDF_REAL; y: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_MoveToNextLine*(page: HPDF_Page): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_ShowText*(page: HPDF_Page; text: HPDF_PCHAR): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_ShowTextNextLine*(page: HPDF_Page; text: HPDF_PCHAR): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_ShowTextNextLineEx*(page: HPDF_Page; word_space: HPDF_REAL; char_space: HPDF_REAL; text: HPDF_PCHAR): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_SetGrayFill*(page: HPDF_Page; gray: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_SetGrayStroke*(page: HPDF_Page; gray: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_SetRGBFill*(page: HPDF_Page; r: HPDF_REAL; g: HPDF_REAL;b: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetRGBStroke*(page: HPDF_Page; r: HPDF_REAL; g: HPDF_REAL;b: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetCMYKFill*(page: HPDF_Page; c: HPDF_REAL; m: HPDF_REAL; y: HPDF_REAL; k: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetCMYKStroke*(page: HPDF_Page; c: HPDF_REAL; m: HPDF_REAL; y: HPDF_REAL; k: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_ExecuteXObject*(page: HPDF_Page; obj: HPDF_XObject): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_DrawImage*(page: HPDF_Page; image: HPDF_Image; x: HPDF_REAL; y: HPDF_REAL; width: HPDF_REAL; height: HPDF_REAL): HPDF_STATUS;
+PROCEDURE ["StdCall"] / HPDF_Page_Circle*(page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL; ray: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_Arc*(page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL; ray: HPDF_REAL; ang1: HPDF_REAL; ang2: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_Ellipse*(page: HPDF_Page; x: HPDF_REAL; y: HPDF_REAL; xray: HPDF_REAL; yray: HPDF_REAL): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_TextOut*(page: HPDF_Page; xpos: HPDF_REAL; ypos: HPDF_REAL; text: HPDF_PCHAR): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_TextRect*(page: HPDF_Page; left: HPDF_REAL; top: HPDF_REAL; right: HPDF_REAL; bottom: HPDF_REAL; text: HPDF_PCHAR; align: THPDF_TextAlignment; len: HPDF_PUINT): HPDF_STATUS; 
+PROCEDURE ["StdCall"] / HPDF_Page_SetSlideShow*(page: HPDF_Page; sstype: THPDF_TransitionStyle; disp_time: HPDF_REAL; trans_time: HPDF_REAL): HPDF_STATUS; 
+         
+
+PROCEDURE HPDF_Page_GetCurrentPos*(page: HPDF_Page): THPDF_Point;
+VAR
+  pos: THPDF_Point;
+BEGIN
+  HPDF_Page_GetCurrentPos2(page, pos);
+  RETURN pos;
+END HPDF_Page_GetCurrentPos;
+
+PROCEDURE HPDF_Page_GetCurrentTextPos*(page: HPDF_Page): THPDF_Point;
+VAR
+  pos: THPDF_Point;
+BEGIN
+  HPDF_Page_GetCurrentTextPos2(page, pos);
+  RETURN pos;
+END HPDF_Page_GetCurrentTextPos;
+
+PROCEDURE HPDF_Image_GetSize*(image: HPDF_Image): THPDF_Point;
+VAR 
+  size: THPDF_Point;
+BEGIN
+  HPDF_Image_GetSize2(image, size);
+  RETURN size;
+END HPDF_Image_GetSize;
+
+END hpdf.
+

+ 338 - 0
pdf.mod/libharu/bindings/oberon-2/test.ob2

@@ -0,0 +1,338 @@
+<*+CHANGESYM*>
+<*+M2EXTENSIONS*>
+<*+O2EXTENSIONS*>
+<*+MAIN*>
+MODULE test;
+
+IMPORT
+  Out,
+  SYSTEM,
+  w := Windows,
+  h := hpdf;
+
+PROCEDURE ["StdCall"] ErrorProc(error_no: h.HPDF_STATUS; detail_no: h.HPDF_STATUS; <*+WOFF301*>user_data: w.PVOID<*-WOFF301*>);
+BEGIN
+  Out.String("ERROR: ");
+  Out.Int(error_no,  1);
+  Out.String(" - ");
+  Out.Int(detail_no, 1);
+  Out.Ln;
+  HALT(1);
+END ErrorProc;
+
+PROCEDURE draw_line (page: h.HPDF_Page; x: h.HPDF_REAL; y: h.HPDF_REAL; text: h.HPDF_PCHAR);
+BEGIN
+  h.HPDF_Page_BeginText(page);
+  h.HPDF_Page_MoveTextPos(page, x, y - 10);
+  h.HPDF_Page_ShowText(page, text);
+  h.HPDF_Page_EndText(page);
+
+  h.HPDF_Page_MoveTo(page, x, y - 15);
+  h.HPDF_Page_LineTo(page, x + 220, y - 15);
+  h.HPDF_Page_Stroke(page);
+END draw_line;
+
+PROCEDURE draw_line2 (page: h.HPDF_Page; x: h.HPDF_REAL; y: h.HPDF_REAL; text: h.HPDF_PCHAR);
+BEGIN
+  h.HPDF_Page_BeginText(page);
+  h.HPDF_Page_MoveTextPos(page, x, y);
+  h.HPDF_Page_ShowText(page, text);
+  h.HPDF_Page_EndText(page);
+
+  h.HPDF_Page_MoveTo(page, x + 30, y - 25);
+  h.HPDF_Page_LineTo(page, x + 160, y - 25);
+  h.HPDF_Page_Stroke(page);
+END draw_line2;
+
+PROCEDURE draw_rect (page: h.HPDF_Page; x: h.HPDF_REAL; y: h.HPDF_REAL; text: h.HPDF_PCHAR);
+BEGIN
+  h.HPDF_Page_BeginText(page);
+  h.HPDF_Page_MoveTextPos(page, x, y - 10);
+  h.HPDF_Page_ShowText(page, text);
+  h.HPDF_Page_EndText(page);
+
+  h.HPDF_Page_Rectangle(page, x, y - 40, 220, 25);
+--  h.HPDF_Page_Rectangle(page, x, y - 40, 100, 100);
+END draw_rect;
+
+
+VAR
+  pdf:  h.HPDF_Doc;
+  font: h.HPDF_Font;
+  page: h.HPDF_Page;
+
+  x, y,
+  x0, y0,
+  x1, y1,
+  x2, y2,
+  x3, y3,
+  tw: h.HPDF_REAL;
+  ffilename: h.HPDF_PCHAR;
+CONST
+  page_title = 'Äåìîíñòðàöèÿ øòðèõîâ';
+  fname      = 'LineDemo.pdf';
+
+  DASH_MODE1 = ARRAY OF h.HPDF_UINT16          {3};
+  DASH_MODE2 = ARRAY OF h.HPDF_UINT16       {7, 3};
+  DASH_MODE3 = ARRAY OF h.HPDF_UINT16 {8, 7, 2, 7};
+
+BEGIN
+  pdf := h.HPDF_New(ErrorProc, NIL);
+
+  IF pdf = NIL THEN
+    Out.String("error: cannot create PdfDoc object"); Out.Ln();
+    HALT(1);
+  END;
+
+
+    h.HPDF_SetCompressionMode(pdf, h.HPDF_COMP_ALL);
+
+    ffilename := h.HPDF_LoadTTFontFromFile(pdf, w.GetPSTR('PTS55F.ttf'), TRUE);
+    (* create default-font *)
+    font := h.HPDF_GetFont(pdf, ffilename, w.GetPSTR('CP1251'));
+    (* add a new page object. *)
+    page := h.HPDF_AddPage(pdf);
+
+    (* print the lines of the page. *)
+    h.HPDF_Page_SetLineWidth(page, 1);
+    x := h.HPDF_Page_GetWidth(page) - 100;
+    y := h.HPDF_Page_GetHeight(page) - 110;
+    h.HPDF_Page_Rectangle(page, 50, 50, x, y);
+    h.HPDF_Page_Stroke(page);
+
+    (* print the title of the page (with positioning center). *)
+    h.HPDF_Page_SetFontAndSize(page, font, 24);
+    tw := h.HPDF_Page_TextWidth(page, w.GetPSTR(page_title));
+    h.HPDF_Page_BeginText(page);
+
+    x := (h.HPDF_Page_GetWidth(page) - tw) / 2;
+    y := h.HPDF_Page_GetHeight(page) - 50;
+    h.HPDF_Page_MoveTextPos (page, x, y);
+
+    h.HPDF_Page_ShowText (page, w.GetPSTR(page_title));
+    h.HPDF_Page_EndText (page);
+
+    h.HPDF_Page_SetFontAndSize (page, font, 10);
+
+    (* Draw verious widths of lines. *)
+    h.HPDF_Page_SetLineWidth (page, 0);
+    draw_line (page, 60, 770, w.GetPSTR('òîëùèíà ëèíèè := 0'));
+
+    h.HPDF_Page_SetLineWidth (page, 1.0);
+    draw_line (page, 60, 740, w.GetPSTR('òîëùèíà ëèíèè := 1.0'));
+
+    h.HPDF_Page_SetLineWidth (page, 2.0);
+    draw_line (page, 60, 710, w.GetPSTR('òîëùèíà ëèíèè := 2.0'));
+
+    (* Line dash pattern *)
+    h.HPDF_Page_SetLineWidth (page, 1.0);
+
+    h.HPDF_Page_SetDash (page, SYSTEM.REF(DASH_MODE1), 1, 1);
+    draw_line (page, 60, 680, w.GetPSTR('dash_ptn=[3], ôàçû=1 -- 2 âêë, 3 âûêë, 3 âêë...'));
+
+    h.HPDF_Page_SetDash (page, SYSTEM.REF(DASH_MODE2), 2, 2);
+    draw_line (page, 60, 650, w.GetPSTR('dash_ptn=[7, 3], phase=2 -- 5 âêë 3 âûêë, 7 âêë,...'));
+
+    h.HPDF_Page_SetDash (page, SYSTEM.REF(DASH_MODE3), 4, 0);
+    draw_line (page, 60, 620, w.GetPSTR('dash_ptn=[8, 7, 2, 7], ôàçû=0'));
+
+    h.HPDF_Page_SetDash (page, NIL, 0, 0);
+
+    h.HPDF_Page_SetLineWidth (page, 30);
+    h.HPDF_Page_SetRGBStroke (page, 0.0, 0.5, 0.0);
+
+    (* Line Cap Style *)
+    h.HPDF_Page_SetLineCap (page, h.HPDF_BUTT_END);
+    draw_line2 (page, 60, 570, w.GetPSTR('PDF_BUTT_END'));
+
+    h.HPDF_Page_SetLineCap (page, h.HPDF_ROUND_END);
+    draw_line2 (page, 60, 505, w.GetPSTR('PDF_ROUND_END'));
+
+    h.HPDF_Page_SetLineCap (page, h.HPDF_PROJECTING_SQUARE_END);
+    draw_line2 (page, 60, 440, w.GetPSTR('PDF_PROJECTING_SCUARE_END'));
+
+    (* Line Join Style *)
+    h.HPDF_Page_SetLineWidth (page, 30);
+    h.HPDF_Page_SetRGBStroke (page, 0.0, 0.0, 0.5);
+
+    h.HPDF_Page_SetLineJoin (page, h.HPDF_MITER_JOIN);
+    h.HPDF_Page_MoveTo (page, 120, 300);
+    h.HPDF_Page_LineTo (page, 160, 340);
+    h.HPDF_Page_LineTo (page, 200, 300);
+    h.HPDF_Page_Stroke (page);
+
+    h.HPDF_Page_BeginText (page);
+    h.HPDF_Page_MoveTextPos (page, 60, 360);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('PDF_MITER_JOIN'));
+    h.HPDF_Page_EndText (page);
+
+    h.HPDF_Page_SetLineJoin (page, h.HPDF_ROUND_JOIN);
+    h.HPDF_Page_MoveTo (page, 120, 195);
+    h.HPDF_Page_LineTo (page, 160, 235);
+    h.HPDF_Page_LineTo (page, 200, 195);
+    h.HPDF_Page_Stroke (page);
+
+    h.HPDF_Page_BeginText (page);
+    h.HPDF_Page_MoveTextPos (page, 60, 255);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('PDF_ROUND_JOIN'));
+    h.HPDF_Page_EndText (page);
+
+    h.HPDF_Page_SetLineJoin (page, h.HPDF_BEVEL_JOIN);
+    h.HPDF_Page_MoveTo (page, 120, 90);
+    h.HPDF_Page_LineTo (page, 160, 130);
+    h.HPDF_Page_LineTo (page, 200, 90);
+    h.HPDF_Page_Stroke (page);
+
+    h.HPDF_Page_BeginText (page);
+    h.HPDF_Page_MoveTextPos (page, 60, 150);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('PDF_BEVEL_JOIN'));
+    h.HPDF_Page_EndText (page);
+
+    (* Draw Rectangle *)
+    h.HPDF_Page_SetLineWidth (page, 2);
+    h.HPDF_Page_SetRGBStroke (page, 0, 0, 0);
+    h.HPDF_Page_SetRGBFill (page, 0.75, 0.0, 0.0);
+
+    draw_rect (page, 300, 770, w.GetPSTR('Øòðèõ'));
+    h.HPDF_Page_Stroke (page);
+
+    draw_rect (page, 300, 720, w.GetPSTR('Çàïîëíåíèå'));
+    h.HPDF_Page_Fill (page);
+
+    draw_rect (page, 300, 670, w.GetPSTR('Çàïîëíåíèå, ïîòîì øòðèõ'));
+    h.HPDF_Page_FillStroke (page);
+
+    (* Clip Rect *)
+    h.HPDF_Page_GSave (page);  (* Save the current graphic state *)
+    draw_rect (page, 300, 620, w.GetPSTR('Ïðÿìîóãîëüíèê îòñå÷åíèÿ'));
+    h.HPDF_Page_Clip (page);
+    h.HPDF_Page_Stroke (page);
+    h.HPDF_Page_SetFontAndSize (page, font, 13);
+
+    h.HPDF_Page_BeginText (page);
+    h.HPDF_Page_MoveTextPos (page, 290, 600);
+    h.HPDF_Page_SetTextLeading (page, 12);
+    h.HPDF_Page_ShowText         (page, w.GetPSTR('Îòñå÷åíèå Îòñå÷åíèå Îòñå÷åíèå Îòñå÷åíèå'));
+    h.HPDF_Page_ShowTextNextLine (page, w.GetPSTR('Îòñå÷åíèå Îòñå÷åíèå Îòñå÷åíèå Îòñå÷åíèå'));
+    h.HPDF_Page_ShowTextNextLine (page, w.GetPSTR('Îòñå÷åíèå Îòñå÷åíèå Îòñå÷åíèå Îòñå÷åíèå'));
+    h.HPDF_Page_EndText (page);
+    h.HPDF_Page_GRestore (page);
+
+    x0 := 330;
+    y0 := 440;
+    x1 := 430;
+    y1 := 530;
+    x2 := 480;
+    y2 := 470;
+    x3 := 480;
+    y3 := 90;
+
+    (* Curve Example(CurveTo2) *)
+    h.HPDF_Page_SetRGBFill (page, 0, 0, 0);
+
+    h.HPDF_Page_BeginText (page);
+    h.HPDF_Page_MoveTextPos (page, 300, 540);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('CurveTo2(x1, y1, x2. y2)'));
+    h.HPDF_Page_EndText (page);
+
+    h.HPDF_Page_BeginText (page);
+    h.HPDF_Page_MoveTextPos (page, x0 + 5, y0 - 5);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('Òåêóùàÿ òî÷êà'));
+    h.HPDF_Page_MoveTextPos (page, x1 - x0, y1 - y0);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('(x1, y1)'));
+    h.HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('(x2, y2)'));
+    h.HPDF_Page_EndText (page);
+
+    h.HPDF_Page_SetDash (page, NIL, 0, 0);
+
+    h.HPDF_Page_SetLineWidth (page, 0.5);
+    h.HPDF_Page_MoveTo (page, x1, y1);
+    h.HPDF_Page_LineTo (page, x2, y2);
+    h.HPDF_Page_Stroke (page);
+
+    h.HPDF_Page_SetDash (page, NIL, 0, 0);
+
+    h.HPDF_Page_SetLineWidth (page, 1.5);
+
+    h.HPDF_Page_MoveTo (page, x0, y0);
+    h.HPDF_Page_CurveTo2 (page, x1, y1, x2, y2);
+    h.HPDF_Page_Stroke (page);
+
+    (* Curve Example(CurveTo3) *)
+    y0 := y0 - 150;
+    y1 := y1 - 150;
+    y2 := y2 - 150;
+
+    h.HPDF_Page_BeginText (page);
+    h.HPDF_Page_MoveTextPos (page, 300, 390);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('CurveTo3(x1, y1, x2. y2)'));
+    h.HPDF_Page_EndText (page);
+
+    h.HPDF_Page_BeginText (page);
+    h.HPDF_Page_MoveTextPos (page, x0 + 5, y0 - 5);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('Òåêóùàÿ òî÷êà'));
+    h.HPDF_Page_MoveTextPos (page, x1 - x0, y1 - y0);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('(x1, y1)'));
+    h.HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('(x2, y2)'));
+    h.HPDF_Page_EndText (page);
+
+    h.HPDF_Page_SetDash (page, SYSTEM.REF(DASH_MODE1), 1, 1);
+
+    h.HPDF_Page_SetLineWidth (page, 0.5);
+    h.HPDF_Page_MoveTo (page, x0, y0);
+    h.HPDF_Page_LineTo (page, x1, y1);
+    h.HPDF_Page_Stroke (page);
+
+    h.HPDF_Page_SetDash (page, NIL, 0, 0);
+
+    h.HPDF_Page_SetLineWidth (page, 1.5);
+    h.HPDF_Page_MoveTo (page, x0, y0);
+    h.HPDF_Page_CurveTo3 (page, x1, y1, x2, y2);
+    h.HPDF_Page_Stroke (page);
+
+    (* Curve Example(CurveTo) *)
+    y0 := y0 - 150;
+    y1 := y1 - 160;
+    y2 := y2 - 130;
+    x2 := x2 + 10;
+
+    h.HPDF_Page_BeginText (page);
+    h.HPDF_Page_MoveTextPos (page, 300, 240);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('CurveTo(x1, y1, x2. y2, x3, y3)'));
+    h.HPDF_Page_EndText (page);
+
+    h.HPDF_Page_BeginText (page);
+    h.HPDF_Page_MoveTextPos (page, x0 + 5, y0 - 5);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('Òåêóùàÿ òî÷êà'));
+    h.HPDF_Page_MoveTextPos (page, x1 - x0, y1 - y0);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('(x1, y1)'));
+    h.HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1);
+    h.HPDF_Page_ShowText (page, w.GetPSTR('(x2, y2)'));
+    h.HPDF_Page_MoveTextPos (page, x3 - x2, y3 - y2);
+    h.HPDF_Page_ShowText (page, '(x3, y3)');
+    h.HPDF_Page_EndText (page);
+
+    h.HPDF_Page_SetDash (page, SYSTEM.REF(DASH_MODE1), 1, 1);
+
+    h.HPDF_Page_SetLineWidth (page, 0.5);
+    h.HPDF_Page_MoveTo (page, x0, y0);
+    h.HPDF_Page_LineTo (page, x1, y1);
+    h.HPDF_Page_Stroke (page);
+    h.HPDF_Page_MoveTo (page, x2, y2);
+    h.HPDF_Page_LineTo (page, x3, y3);
+    h.HPDF_Page_Stroke (page);
+
+    h.HPDF_Page_SetDash (page, NIL, 0, 0);
+
+    h.HPDF_Page_SetLineWidth (page, 1.5);
+    h.HPDF_Page_MoveTo (page, x0, y0);
+    h.HPDF_Page_CurveTo (page, x1, y1, x2, y2, x3, y3);
+    h.HPDF_Page_Stroke (page);
+
+    (* save the document to a file *)
+    h.HPDF_SaveToFile (pdf, w.GetPSTR(fname));
+
+  
+END test.

+ 10 - 0
pdf.mod/libharu/bindings/oberon-2/test.prj

@@ -0,0 +1,10 @@
+-IMPLIB+
+-CHANGESYM+
+-USEDLL+
+-GUI-
+-HEAPLIMIT=96000000
+-COMPILERHEAP=48000000
+
+!module hpdf.ob2
+!module test.ob2
+!module libhpdf.lib

+ 36 - 0
pdf.mod/libharu/bindings/python/History.txt

@@ -0,0 +1,36 @@
+(GMT+8)
+
+2008.01.19 first release
+version '2.0.8'
+1. All of the C API is usable
+
+2. known problems
+1) demo\text_demo.py, there are 2 bugs
+one, Traceback (most recent call last):
+  File "H:\libharu-2.0.8\pyharu\demo\text_demo.py", line 357, in <module>
+    main()
+  File "H:\libharu-2.0.8\pyharu\demo\text_demo.py", line 208, in main
+    "RenderingMode=PDF_FILL")
+  File "H:\libharu-2.0.8\pyharu\demo\text_demo.py", line 62, in show_description
+    c = HPDF_Page_GetRGBFill (page)
+ValueError: Procedure called with not enough arguments (4 bytes missing) or wrong calling convention
+
+Often, that msg happens when we load a Cdll with Windll method, vice versa. But why here?
+
+two, if I comment out "c = HPDF_Page_GetRGBFill (page)", the yieled pdf has a unexpected layout
+
+2) ttfont_demo.C and ttfont_demo.py, in other words, that is the problem with haru
+ttfont_demo.exe  .\ttfont\PenguinAttack.ttf -E
+ttfont_demo.exe  .\ttfont\PenguinAttack.ttf
+no characters appear
+
+ttfont_demo.exe  c:\winnt\fonts\arial.ttf -E
+many rectangles appear
+
+ttfont_demo.exe  c:\winnt\fonts\arial.ttf -E
+no characters appear
+
+3) try to make_rawimage.exe, fails. So that maybe the problem in haru too.
+make_rawimage.py fails too
+python H:\libharu-2.0.8\pyharu\demo\make_rawimage.py png_demo.pdf 11.pdf
+ERROR: Invalid PNG image format., detail_no=0          <==crazy haru

+ 125 - 0
pdf.mod/libharu/bindings/python/README.python

@@ -0,0 +1,125 @@
+1. What is pyharu?
+Pyharu is a pure python interface to haru(Haru Free PDF Library,
+http://libharu.org/). All of the C API is usable.
+No OO interface yet, but maybe in the feature, or you can write one by
+yourself and send me to be included in pyharu ;)
+Pyharu runs on different python versions, and even in different OS
+without recompilation.
+
+2. How to install?
+1) To use pyharu, ctypes is needed , which is included since python 2.5.
+But you have to install or compile by yourself in case you use python 2.3 or 2.4.
+You can find details on ctypes website: http://python.net/crew/theller/ctypes
+
+2) To use this interface, built Haru as a shared-library (DLL on windows,
+so on linux). The binary package for win32(libharu_x_x_x_dll_win32.zip)
+from official website DOES NOT work with this interface, so I included
+my home-made one with PNG and zlib feature enabled.
+The function in correct DLL looks like "HPDF_Page_GetTextRaise",
+but NOT "HPDF_Page_GetTextRaise@4".
+
+3) copy haru directory (including all files in it) to a directory, where is
+in python's sys.path, for example d:\python\lib\site-packages
+
+4) put libhpdf.dll(libhpdf.so) under a directory which is in environment
+variant PATH, or put it in haru\dll\. I prefer to the last solution.
+5) that is all
+
+3. How to use?
+1) Currently, pyharu supplies only the api that is similar to the C api, so
+please read the haru document for API details.
+2) All the example programs in haru C src has been ported, and you can find
+them in demo directory. These demonstration programs are helpful too.
+If you want to run them, you should copy the directories under libharu-xxx\demo\
+to here
+3) To run a python program, just type
+python png_demo.py
+
+4. difference between C API and pyharu API
+the following python functions has a same form as their C brothers.
+But they returns 3 value( actually, aTuple).
+
+return of func, point.x, point.y=HPDF_Image_GetSize2 (HPDF_Image image, HPDF_Point *size)
+return of func, pos.x, pos.y=HPDF_Page_GetCurrentPos2 (HPDF_Page page, HPDF_Point *pos)
+return of func, pos.x, pos.y=HPDF_Page_GetCurrentTextPos2 (HPDF_Page page, HPDF_Point *pos)
+
+And in fact, you don't need to pass the 2nd parameter to function:
+return of func, point.x, point.y=HPDF_Image_GetSize2 (HPDF_Image image)
+return of func, pos.x, pos.y=HPDF_Page_GetCurrentPos2 (HPDF_Page page)
+return of func, pos.x, pos.y=HPDF_Page_GetCurrentTextPos2 (HPDF_Page page)
+
+5. known problems
+1) demo\text_demo.py, there are 2 bugs
+one, Traceback (most recent call last):
+  File "H:\libharu-2.0.8\pyharu\demo\text_demo.py", line 357, in <module>
+    main()
+  File "H:\libharu-2.0.8\pyharu\demo\text_demo.py", line 208, in main
+    "RenderingMode=PDF_FILL")
+  File "H:\libharu-2.0.8\pyharu\demo\text_demo.py", line 62, in show_description
+    c = HPDF_Page_GetRGBFill (page)
+ValueError: Procedure called with not enough arguments (4 bytes missing) or wrong calling convention
+
+Often, that msg happens when we load a Cdll with Windll method, vice versa. But why here?
+
+two, if I comment out "c = HPDF_Page_GetRGBFill (page)", the yieled pdf has a unexpected layout
+
+2) ttfont_demo.C and ttfont_demo.py, in other words, that is the problem with haru
+ttfont_demo.exe  .\ttfont\PenguinAttack.ttf -E
+ttfont_demo.exe  .\ttfont\PenguinAttack.ttf
+no characters appear
+
+ttfont_demo.exe  c:\winnt\fonts\arial.ttf -E
+many rectangles appear
+
+ttfont_demo.exe  c:\winnt\fonts\arial.ttf -E
+no characters appear
+
+3) try to make_rawimage.exe, fails. So that maybe the problem in haru too.
+make_rawimage.py fails too
+python H:\libharu-2.0.8\pyharu\demo\make_rawimage.py png_demo.pdf 11.pdf
+ERROR: Invalid PNG image format., detail_no=0          <==crazy haru
+
+6. I don't use linux, but this interface should run linux without modification.
+If I am wrong, please tell me. Thanks.
+But first of all, you should make sure that you have installed correct
+dynamic link lib(libhpdf.dll or libhpdf.so), please read part 2.4
+
+7. How to update?
+Please go to http://groups.google.com/group/pythoncia for the new version.
+But that is only necessary when haru's API(not the implement of API) has
+changed- I mean 'change or rename', but not 'add new function'
+If haru does not change its API, but improve internal functions or fix
+some internal bugs, what you only need to do is to overwrite the old DLL/so
+on your PC with the new one.
+
+8. What does the pyharu version number means?
+Well, I just use the version number of haru that I am using.
+That helps me to remember my development progress.
+
+9. License
+pyharu has a same license as haru, ie,  ZLIB/LIBPNG License.
+
+The license of pyharu is as follows.
+
+Copyright (C) 2008 Li Jun
+This software is provided 'as-is', without any express or implied warranty.
+
+In no event will the authors be held liable for any damages arising from the
+use of this software.
+
+Permission is granted to anyone to use this software for any purpose,including
+commercial applications, and to alter it and redistribute it freely, subject
+to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not claim
+    that you wrote the original software. If you use this software in a
+    product, an acknowledgment in the product documentation would be
+    appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+    misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+
+A. Discuss and bug report
+http://groups.google.com/group/pythoncia
+Since other projects by me is discussed here, please add [haru] in your post title.

Fichier diff supprimé car celui-ci est trop grand
+ 5 - 0
pdf.mod/libharu/bindings/python/__init__.py


+ 8 - 0
pdf.mod/libharu/bindings/python/c_func.py

@@ -0,0 +1,8 @@
+def printf(format, *optional):
+    #print 'format="%s"' % format
+    #print 'optional="%s"' % optional
+    if len(optional)==1:
+        optional=optional[0]
+    if format.endswith('\n'):
+        format=format[:-1]
+    print format % optional

+ 123 - 0
pdf.mod/libharu/bindings/python/demo/arc_demo.py

@@ -0,0 +1,123 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- arc_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+from grid_sheet import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def main ():
+    global pdf
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    HPDF_Page_SetHeight (page, 220)
+    HPDF_Page_SetWidth (page, 200)
+
+    # draw grid to the page
+    print_grid  (pdf, page)
+
+    # draw pie chart
+    # *
+    # *   A: 45% Red
+    # *   B: 25% Blue
+    # *   C: 15% green
+    # *   D: other yellow
+
+
+    # A
+    HPDF_Page_SetRGBFill (page, 1.0, 0, 0)
+    HPDF_Page_MoveTo (page, 100, 100)
+    HPDF_Page_LineTo (page, 100, 180)
+    HPDF_Page_Arc (page, 100, 100, 80, 0, 360 * 0.45)
+    pos = HPDF_Page_GetCurrentPos (page)
+    HPDF_Page_LineTo (page, 100, 100)
+    HPDF_Page_Fill (page)
+
+    # B
+    HPDF_Page_SetRGBFill (page, 0, 0, 1.0)
+    HPDF_Page_MoveTo (page, 100, 100)
+    HPDF_Page_LineTo (page, pos.x, pos.y)
+    HPDF_Page_Arc (page, 100, 100, 80, 360 * 0.45, 360 * 0.7)
+    pos = HPDF_Page_GetCurrentPos (page)
+    HPDF_Page_LineTo (page, 100, 100)
+    HPDF_Page_Fill (page)
+
+    # C
+    HPDF_Page_SetRGBFill (page, 0, 1.0, 0)
+    HPDF_Page_MoveTo (page, 100, 100)
+    HPDF_Page_LineTo (page, pos.x, pos.y)
+    HPDF_Page_Arc (page, 100, 100, 80, 360 * 0.7, 360 * 0.85)
+    pos = HPDF_Page_GetCurrentPos (page)
+    HPDF_Page_LineTo (page, 100, 100)
+    HPDF_Page_Fill (page)
+
+    # D
+    HPDF_Page_SetRGBFill (page, 1.0, 1.0, 0)
+    HPDF_Page_MoveTo (page, 100, 100)
+    HPDF_Page_LineTo (page, pos.x, pos.y)
+    HPDF_Page_Arc (page, 100, 100, 80, 360 * 0.85, 360)
+    pos = HPDF_Page_GetCurrentPos (page)
+    HPDF_Page_LineTo (page, 100, 100)
+    HPDF_Page_Fill (page)
+
+    # draw center circle
+    HPDF_Page_SetGrayStroke (page, 0)
+    HPDF_Page_SetGrayFill (page, 1)
+    HPDF_Page_Circle (page, 100, 100, 30)
+    HPDF_Page_Fill (page)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 265 - 0
pdf.mod/libharu/bindings/python/demo/character_map.py

@@ -0,0 +1,265 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- character_map.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+## * usage character_map <encoding-name> <low-range-from> <low-range-to>
+## *              <high-range-from> <high-range-to>
+## * ex. character_map 90ms-RKSJ-V 0x80 0x
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+def draw_page(pdf, page, title_font, font, h_byte, l_byte):
+    PAGE_WIDTH = 420
+    CELL_HEIGHT = 20
+    CELL_WIDTH = 20
+
+
+    l_byte = int(l_byte / 16) * 16
+    h_count = 16 - (l_byte / 16)
+    page_height = 40 + 40 + (h_count + 1) * CELL_HEIGHT
+
+    HPDF_Page_SetHeight (page, page_height)
+    HPDF_Page_SetWidth (page, PAGE_WIDTH)
+
+    HPDF_Page_SetFontAndSize (page, title_font, 10)
+
+    ypos = h_count + 1
+    while True:
+        y = (ypos) * CELL_HEIGHT + 40
+
+        HPDF_Page_MoveTo (page, 40, y)
+        HPDF_Page_LineTo (page, 380, y)
+        HPDF_Page_Stroke (page)
+        if (ypos < h_count):
+            buf=[None,None]
+
+            buf[0] = 16 - ypos - 1
+            if (buf[0] < 10):
+                buf[0] += ord('0')
+            else:
+                buf[0] += (ord('A') - 10)
+            buf[1] = 0
+            buf=[i % 256 for i in buf]      #because buf is unsigned char *
+
+            w = HPDF_Page_TextWidth (page, buf)
+            HPDF_Page_BeginText (page)
+            HPDF_Page_MoveTextPos (page, 40 + (20 - w) / 2, y + 5)
+            HPDF_Page_ShowText (page, buf)
+            HPDF_Page_EndText (page)
+
+
+        if (ypos == 0):
+            break
+
+        ypos-=1
+
+
+    for xpos in range(18):
+        y = (h_count + 1) * CELL_HEIGHT + 40
+        x = xpos * CELL_WIDTH + 40
+
+        HPDF_Page_MoveTo (page, x, 40)
+        HPDF_Page_LineTo (page, x, y)
+        HPDF_Page_Stroke (page)
+
+        if (xpos > 0 and xpos <= 16):
+            buf=[None,None]
+
+            buf[0] = xpos - 1
+            if (buf[0] < 10):
+                buf[0] += ord('0')
+            else:
+                buf[0] += (ord('A') - 10)
+            buf[1] = 0
+            buf=[i % 256 for i in buf]      #because buf is unsigned char *
+
+            w = HPDF_Page_TextWidth(page, buf)
+            HPDF_Page_BeginText(page)
+            HPDF_Page_MoveTextPos(page, x + (20 - w) / 2,
+                        h_count * CELL_HEIGHT + 45)
+            HPDF_Page_ShowText(page, buf)
+            HPDF_Page_EndText(page)
+
+
+    HPDF_Page_SetFontAndSize (page, font, 15)
+
+    ypos = h_count
+    while True:
+        y = (ypos - 1) * CELL_HEIGHT + 45
+
+        for xpos in range(16):
+            buf=[None for i in range(3)]
+
+            x = xpos * CELL_WIDTH + 40 + CELL_WIDTH
+
+            buf[0] = h_byte
+            buf[1] = (16 - ypos) * 16 + xpos
+            buf[2] = 0x00
+            buf=[i % 256 for i in buf]      #because buf is unsigned char *
+
+            w = HPDF_Page_TextWidth(page, buf)
+            if (w > 0):
+                HPDF_Page_BeginText(page)
+                HPDF_Page_MoveTextPos(page, x + (20 - w) / 2, y)
+                HPDF_Page_ShowText(page, buf)
+                HPDF_Page_EndText(page)
+
+
+        if (ypos == 0):
+            break
+
+        ypos-=1
+
+
+def main ():
+    global  pdf
+
+    flg=[HPDF_UINT16(0) for i in range(256)]
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    if (len(sys.argv) < 3):
+        printf ("usage: character_map <encoding-name> <font-name>\n")
+        printf ('for example, character_map.py GBK-EUC-H SimHei,Bold')
+        return 1
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+
+    # configure pdf-document (showing outline, compression enabled)
+    HPDF_SetPageMode(pdf, HPDF_PAGE_MODE_USE_OUTLINE)
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+    HPDF_SetPagesConfiguration (pdf, 10)
+
+    HPDF_UseJPEncodings (pdf)
+    HPDF_UseJPFonts (pdf)
+    HPDF_UseKREncodings (pdf)
+    HPDF_UseKRFonts (pdf)
+    HPDF_UseCNSEncodings (pdf)
+    HPDF_UseCNSFonts (pdf)
+    HPDF_UseCNTEncodings (pdf)
+    HPDF_UseCNTFonts (pdf)
+
+    encoder = HPDF_GetEncoder (pdf, sys.argv[1])
+    if (HPDF_Encoder_GetType (encoder) != HPDF_ENCODER_TYPE_DOUBLE_BYTE):
+        printf ("error: %s is not cmap-encoder\n", sys.argv[1])
+        HPDF_Free (pdf)
+        return 1
+
+    font = HPDF_GetFont (pdf, sys.argv[2], sys.argv[1])
+
+    min_l = 255
+    min_h = 256
+    max_l = 0
+    max_h = 0
+
+
+    for i in range(256):
+        for j in range(20, 256):
+            buf=[None, None ,None]
+            code = i * 256 + j
+
+            buf[0] = i
+            buf[1] = j
+            buf[2] = 0
+
+            btype = HPDF_Encoder_GetByteType (encoder, buf, 0)
+            unicode = HPDF_Encoder_GetUnicode (encoder, code)
+
+            if (btype == HPDF_BYTE_TYPE_LEAD and
+                    unicode != 0x25A1):
+                if (min_l > j):
+                    min_l = j
+
+                if (max_l < j):
+                    max_l = j
+
+                if (min_h > i):
+                    min_h = i
+
+                if (max_h < i):
+                    max_h = i
+
+                flg[i] = 1
+
+    printf ("min_h=%04X max_h=%04X min_l=%04X max_l=%04X\n",
+            min_h, max_h, min_l, max_l)
+
+    # create outline root.
+    root = HPDF_CreateOutline (pdf, NULL, sys.argv[1], NULL)
+    HPDF_Outline_SetOpened (root, HPDF_TRUE)
+
+    for i in range(256):
+        if (flg[i]):
+            page = HPDF_AddPage (pdf)
+            title_font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+            buf="0x%04X-0x%04X" %(
+                                  (i * 256 + min_l),
+                                  (i * 256 + max_l)
+                                 )
+
+            outline = HPDF_CreateOutline (pdf, root, buf, NULL)
+            dst = HPDF_Page_CreateDestination (page)
+            HPDF_Outline_SetDestination(outline, dst)
+
+            draw_page (pdf, page, title_font, font, i, min_l)
+
+            buf="%s (%s) 0x%04X-0x%04X" %(
+                        sys.argv[1],
+                        sys.argv[2],
+                        (i * 256 + min_l),
+                        (i * 256 + max_l)
+                        )
+            HPDF_Page_SetFontAndSize (page, title_font, 10)
+            HPDF_Page_BeginText (page)
+            HPDF_Page_MoveTextPos (page, 40, HPDF_Page_GetHeight (page) - 35)
+            HPDF_Page_ShowText (page, buf)
+            HPDF_Page_EndText (page)
+
+    HPDF_SaveToFile (pdf, fname)
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 124 - 0
pdf.mod/libharu/bindings/python/demo/chfont_demo.py

@@ -0,0 +1,124 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- chfont_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+from grid_sheet import *
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+def main ():
+    global  pdf
+
+    if (len(sys.argv) < 4):
+        printf ("chfont_demo <cp936-ttc-font-file-name> "
+                "<cp936-index> <cp932-ttc-font-file-name> <cp932-index>\n")
+        return 1
+
+
+    fname="mbtext/%s"% "cp932.txt"
+    cp932 = open (fname, "rb")
+    if (not cp932):
+        printf ("error: cannot open cp932.txt\n")
+        return 1
+
+    fname= "mbtext/%s" % "cp936.txt"
+    cp936 = open (fname, "rb")
+    if (not cp936):
+        printf ("error: cannot open cp936.txt\n")
+        return 1
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+    HPDF_UseJPEncodings (pdf)
+    HPDF_UseCNSEncodings (pdf)
+
+    fcp936_name = HPDF_LoadTTFontFromFile2 (pdf, sys.argv[1], int(sys.argv[2]),
+            HPDF_TRUE)
+    fcp932_name = HPDF_LoadTTFontFromFile2 (pdf, sys.argv[3], int(sys.argv[4]),
+            HPDF_TRUE)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    HPDF_Page_SetHeight (page, 300)
+    HPDF_Page_SetWidth (page, 550)
+
+    fcp936 = HPDF_GetFont (pdf, fcp936_name, "GBK-EUC-H")
+    fcp932 = HPDF_GetFont (pdf, fcp932_name, "90ms-RKSJ-H")
+
+    print_grid  (pdf, page)
+
+    HPDF_Page_SetTextLeading (page, 20)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 50, 250)
+    HPDF_Page_SetTextLeading (page, 25)
+
+    buf=cp936.read(1024)
+    while buf:
+        HPDF_Page_SetFontAndSize (page, fcp936, 18)
+        buf ='%s\0' % buf
+        HPDF_Page_ShowText (page, buf)
+
+        buf=cp936.read(1024)
+        if buf:
+            HPDF_Page_SetFontAndSize (page, fcp932, 18)
+            buf ='%s\0' % buf
+            HPDF_Page_ShowText (page, buf)
+
+        HPDF_Page_MoveToNextLine (page)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    cp936.close ()
+    cp932.close ()
+
+    return 0
+
+main()

+ 178 - 0
pdf.mod/libharu/bindings/python/demo/cnfont_demo.py

@@ -0,0 +1,178 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- jpfont_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+def main():
+    global pdf
+
+    chinesefonts='''
+SimSun
+SimSun,Bold
+SimSun,Italic
+SimSun,BoldItalic
+SimHei
+SimHei,Bold
+SimHei,Italic
+SimHei,BoldItalic
+'''
+    chinesefonts=chinesefonts.split('\n')
+    chinesefonts=[i for i in chinesefonts if i]
+
+    detail_font=[]
+    PAGE_HEIGHT = 210
+
+    try:
+        f = open ("mbtext/cp936.txt", "rb")
+    except:
+        printf ("error: cannot open 'mbtext/sjis.txt'\n")
+        return 1
+
+    samp_text=f.read(2048)
+    f.close ()
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+
+    # configure pdf-document to be compressed.
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+
+    # declaration for using Japanese font, encoding.
+    HPDF_UseCNSEncodings (pdf)
+    HPDF_UseCNSFonts (pdf)
+
+
+    for i in chinesefonts:
+        detail_font.append( HPDF_GetFont (pdf, i, "GB-EUC-H"))
+
+    # Set page mode to use outlines.
+    HPDF_SetPageMode(pdf, HPDF_PAGE_MODE_USE_OUTLINE)
+
+    # create outline root.
+    root = HPDF_CreateOutline (pdf, NULL, "JP font demo", NULL)
+    HPDF_Outline_SetOpened (root, HPDF_TRUE)
+
+    for i in detail_font:
+
+        # add a new page object.
+        page = HPDF_AddPage (pdf)
+
+        # create outline entry
+        outline = HPDF_CreateOutline (pdf, root,
+                HPDF_Font_GetFontName (i), NULL)
+        dst = HPDF_Page_CreateDestination (page)
+        HPDF_Outline_SetDestination(outline, dst)
+
+        title_font = HPDF_GetFont (pdf, "Helvetica", NULL)
+        HPDF_Page_SetFontAndSize (page, title_font, 10)
+
+        HPDF_Page_BeginText (page)
+
+        # move the position of the text to top of the page.
+        HPDF_Page_MoveTextPos(page, 10, 190)
+        HPDF_Page_ShowText (page, HPDF_Font_GetFontName (i))
+
+        HPDF_Page_SetFontAndSize (page, i, 15)
+        HPDF_Page_MoveTextPos (page, 10, -20)
+        HPDF_Page_ShowText (page, "abcdefghijklmnopqrstuvwxyz")
+        HPDF_Page_MoveTextPos (page, 0, -20)
+        HPDF_Page_ShowText (page, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+        HPDF_Page_MoveTextPos (page, 0, -20)
+        HPDF_Page_ShowText (page, "1234567890")
+        HPDF_Page_MoveTextPos (page, 0, -20)
+
+        HPDF_Page_SetFontAndSize (page, i, 10)
+        HPDF_Page_ShowText (page, samp_text)
+        HPDF_Page_MoveTextPos (page, 0, -18)
+
+        HPDF_Page_SetFontAndSize (page, i, 16)
+        HPDF_Page_ShowText (page, samp_text)
+        HPDF_Page_MoveTextPos (page, 0, -27)
+
+        HPDF_Page_SetFontAndSize (page, i, 23)
+        HPDF_Page_ShowText (page, samp_text)
+        HPDF_Page_MoveTextPos (page, 0, -36)
+
+        HPDF_Page_SetFontAndSize (page, i, 30)
+        HPDF_Page_ShowText (page, samp_text)
+
+        p = HPDF_Page_GetCurrentTextPos (page)
+
+        # finish to print text.
+        HPDF_Page_EndText (page)
+
+        HPDF_Page_SetLineWidth (page, 0.5)
+
+        x_pos = 20
+        for j in range(len (samp_text) // 2):
+            HPDF_Page_MoveTo (page, x_pos, p.y - 10)
+            HPDF_Page_LineTo (page, x_pos, p.y - 12)
+            HPDF_Page_Stroke (page)
+            x_pos = x_pos + 30
+
+        HPDF_Page_SetWidth (page, p.x + 20)
+        HPDF_Page_SetHeight (page, PAGE_HEIGHT)
+
+        HPDF_Page_MoveTo (page, 10, PAGE_HEIGHT - 25)
+        HPDF_Page_LineTo (page, p.x + 10, PAGE_HEIGHT - 25)
+        HPDF_Page_Stroke (page)
+
+        HPDF_Page_MoveTo (page, 10, PAGE_HEIGHT - 85)
+        HPDF_Page_LineTo (page, p.x + 10, PAGE_HEIGHT - 85)
+        HPDF_Page_Stroke (page)
+
+        HPDF_Page_MoveTo (page, 10, p.y - 12)
+        HPDF_Page_LineTo (page, p.x + 10, p.y - 12)
+        HPDF_Page_Stroke (page)
+
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 206 - 0
pdf.mod/libharu/bindings/python/demo/encoding_list.py

@@ -0,0 +1,206 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- encoding_list.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+PAGE_WIDTH = 420
+PAGE_HEIGHT = 400
+CELL_WIDTH = 20
+CELL_HEIGHT = 20
+CELL_HEADER = 10
+
+def draw_graph (page):
+
+    # Draw 16 X 15 cells
+
+    # Draw vertical lines.
+    HPDF_Page_SetLineWidth (page, 0.5)
+
+    for i in range(18):
+        x = i * CELL_WIDTH + 40
+
+        HPDF_Page_MoveTo (page, x, PAGE_HEIGHT - 60)
+        HPDF_Page_LineTo (page, x, 40)
+        HPDF_Page_Stroke (page)
+
+        if (i > 0 and i <= 16):
+            HPDF_Page_BeginText (page)
+            HPDF_Page_MoveTextPos (page, x + 5, PAGE_HEIGHT - 75)
+            buf="%X" %(i - 1)
+            HPDF_Page_ShowText (page, buf)
+            HPDF_Page_EndText (page)
+
+    # Draw horizontal lines.
+    for i in range(16):
+        y = i * CELL_HEIGHT + 40
+
+        HPDF_Page_MoveTo (page, 40, y)
+        HPDF_Page_LineTo (page, PAGE_WIDTH - 40, y)
+        HPDF_Page_Stroke (page)
+
+        if (i < 14):
+            HPDF_Page_BeginText (page)
+            HPDF_Page_MoveTextPos (page, 45, y + 5)
+
+            buf="%X" %( 15 - i)
+            HPDF_Page_ShowText (page, buf)
+            HPDF_Page_EndText (page)
+
+
+def draw_fonts (page):
+    HPDF_Page_BeginText (page)
+
+    # Draw all character from 0x20 to 0xFF to the canvas.
+    for i in range(1,17):
+        for j in range(1,17):
+            buf=[None, None]
+            y = PAGE_HEIGHT - 55 - ((i - 1) * CELL_HEIGHT)
+            x = j * CELL_WIDTH + 50
+
+            buf[1] = 0x00
+
+            buf[0] = (i - 1) * 16 + (j - 1)
+            if (buf[0] >= 32):
+                d  = x - HPDF_Page_TextWidth (page, buf) / 2
+                HPDF_Page_TextOut (page, d, y, buf)
+
+
+    HPDF_Page_EndText (page)
+
+
+
+def main ():
+
+    encodings=[
+            "StandardEncoding",
+            "MacRomanEncoding",
+            "WinAnsiEncoding",
+            "ISO8859-2",
+            "ISO8859-3",
+            "ISO8859-4",
+            "ISO8859-5",
+            "ISO8859-9",
+            "ISO8859-10",
+            "ISO8859-13",
+            "ISO8859-14",
+            "ISO8859-15",
+            "ISO8859-16",
+            "CP1250",
+            "CP1251",
+            "CP1252",
+            "CP1254",
+            "CP1257",
+            "KOI8-R",
+            "Symbol-Set",
+            "ZapfDingbats-Set",
+            NULL
+    ]
+
+    pdf = HPDF_NewEx (error_handler, NULL, NULL, 0, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    # set compression mode
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+
+    # Set page mode to use outlines.
+    HPDF_SetPageMode(pdf, HPDF_PAGE_MODE_USE_OUTLINE)
+
+    # get default font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # load font object
+    font_name = HPDF_LoadType1FontFromFile (pdf, "type1/a010013l.afm",
+            "type1/a010013l.pfb")
+
+    # create outline root.
+    root = HPDF_CreateOutline (pdf, NULL, "Encoding list", NULL)
+    HPDF_Outline_SetOpened (root, HPDF_TRUE)
+
+    i=0
+    while (encodings[i]):
+        page = HPDF_AddPage (pdf)
+
+        HPDF_Page_SetWidth (page, PAGE_WIDTH)
+        HPDF_Page_SetHeight (page, PAGE_HEIGHT)
+
+        outline = HPDF_CreateOutline (pdf, root, encodings[i], NULL)
+        dst = HPDF_Page_CreateDestination (page)
+        HPDF_Destination_SetXYZ(dst, 0, HPDF_Page_GetHeight(page), 1)
+        # HPDF_Destination_SetFitB(dst);
+        HPDF_Outline_SetDestination(outline, dst)
+
+        HPDF_Page_SetFontAndSize (page, font, 15)
+        draw_graph (page)
+
+        HPDF_Page_BeginText (page)
+        HPDF_Page_SetFontAndSize (page, font, 20)
+        HPDF_Page_MoveTextPos (page, 40, PAGE_HEIGHT - 50)
+        HPDF_Page_ShowText (page, encodings[i])
+        HPDF_Page_ShowText (page, " Encoding")
+        HPDF_Page_EndText (page)
+
+        if encodings[i]=="Symbol-Set":
+            font2 = HPDF_GetFont (pdf, "Symbol", NULL)
+        elif encodings[i]=="ZapfDingbats-Set":
+            font2 = HPDF_GetFont (pdf, "ZapfDingbats", NULL)
+        else:
+            font2 = HPDF_GetFont (pdf, font_name, encodings[i])
+
+        HPDF_Page_SetFontAndSize (page, font2, 14)
+        draw_fonts (page)
+
+        i+=1
+
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 85 - 0
pdf.mod/libharu/bindings/python/demo/encryption.py

@@ -0,0 +1,85 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- encryption.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+text = "This is an encrypt document example."
+owner_passwd = "owner"
+user_passwd = "user"
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def main ():
+    global  pdf
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    HPDF_Page_SetSize (page, HPDF_PAGE_SIZE_B5, HPDF_PAGE_LANDSCAPE)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetFontAndSize (page, font, 20)
+    tw = HPDF_Page_TextWidth (page, text)
+    HPDF_Page_MoveTextPos (page, (HPDF_Page_GetWidth (page) - tw) / 2,
+                (HPDF_Page_GetHeight (page)  - 20) / 2)
+    HPDF_Page_ShowText (page, text)
+    HPDF_Page_EndText (page)
+
+    HPDF_SetPassword (pdf, owner_passwd, user_passwd)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 208 - 0
pdf.mod/libharu/bindings/python/demo/ext_gstate_demo.py

@@ -0,0 +1,208 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- ext_gstate_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def draw_circles (page, description, x, y):
+    HPDF_Page_SetLineWidth (page, 1.0)
+    HPDF_Page_SetRGBStroke (page, 0.0, 0.0, 0.0)
+    HPDF_Page_SetRGBFill (page, 1.0, 0.0, 0.0)
+    HPDF_Page_Circle (page, x + 40, y + 40, 40)
+    HPDF_Page_ClosePathFillStroke (page)
+    HPDF_Page_SetRGBFill (page, 0.0, 1.0, 0.0)
+    HPDF_Page_Circle (page, x + 100, y + 40, 40)
+    HPDF_Page_ClosePathFillStroke (page)
+    HPDF_Page_SetRGBFill (page, 0.0, 0.0, 1.0)
+    HPDF_Page_Circle (page, x + 70, y + 74.64, 40)
+    HPDF_Page_ClosePathFillStroke (page)
+
+    HPDF_Page_SetRGBFill (page, 0.0, 0.0, 0.0)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, x + 0.0, y + 130.0, description)
+    HPDF_Page_EndText (page)
+
+
+def main ():
+    global pdf
+
+    PAGE_WIDTH = 600
+    PAGE_HEIGHT = 900
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    hfont = HPDF_GetFont (pdf, "Helvetica-Bold", NULL)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    HPDF_Page_SetFontAndSize (page, hfont, 10)
+
+    HPDF_Page_SetHeight (page, PAGE_HEIGHT)
+    HPDF_Page_SetWidth (page, PAGE_WIDTH)
+
+    # normal
+    HPDF_Page_GSave (page)
+    draw_circles (page, "normal", 40.0, PAGE_HEIGHT - 170)
+    HPDF_Page_GRestore (page)
+
+    # transparency (0.8)
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetAlphaFill (gstate, 0.8)
+    HPDF_ExtGState_SetAlphaStroke (gstate, 0.8)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "alpha fill = 0.8", 230.0, PAGE_HEIGHT - 170)
+    HPDF_Page_GRestore (page)
+
+    # transparency (0.4)
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetAlphaFill (gstate, 0.4)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "alpha fill = 0.4", 420.0, PAGE_HEIGHT - 170)
+    HPDF_Page_GRestore (page)
+
+    # blend-mode=HPDF_BM_MULTIPLY
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_MULTIPLY)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "HPDF_BM_MULTIPLY", 40.0, PAGE_HEIGHT - 340)
+    HPDF_Page_GRestore (page)
+
+    # blend-mode=HPDF_BM_SCREEN
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_SCREEN)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "HPDF_BM_SCREEN", 230.0, PAGE_HEIGHT - 340)
+    HPDF_Page_GRestore (page)
+
+    # blend-mode=HPDF_BM_OVERLAY
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_OVERLAY)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "HPDF_BM_OVERLAY", 420.0, PAGE_HEIGHT - 340)
+    HPDF_Page_GRestore (page)
+
+    # blend-mode=HPDF_BM_DARKEN
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_DARKEN)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "HPDF_BM_DARKEN", 40.0, PAGE_HEIGHT - 510)
+    HPDF_Page_GRestore (page)
+
+    # blend-mode=HPDF_BM_LIGHTEN
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_LIGHTEN)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "HPDF_BM_LIGHTEN", 230.0, PAGE_HEIGHT - 510)
+    HPDF_Page_GRestore (page)
+
+    # blend-mode=HPDF_BM_COLOR_DODGE
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_COLOR_DODGE)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "HPDF_BM_COLOR_DODGE", 420.0, PAGE_HEIGHT - 510)
+    HPDF_Page_GRestore (page)
+
+
+    # blend-mode=HPDF_BM_COLOR_BUM
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_COLOR_BUM)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "HPDF_BM_COLOR_BUM", 40.0, PAGE_HEIGHT - 680)
+    HPDF_Page_GRestore (page)
+
+    # blend-mode=HPDF_BM_HARD_LIGHT
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_HARD_LIGHT)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "HPDF_BM_HARD_LIGHT", 230.0, PAGE_HEIGHT - 680)
+    HPDF_Page_GRestore (page)
+
+    # blend-mode=HPDF_BM_SOFT_LIGHT
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_SOFT_LIGHT)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "HPDF_BM_SOFT_LIGHT", 420.0, PAGE_HEIGHT - 680)
+    HPDF_Page_GRestore (page)
+
+    # blend-mode=HPDF_BM_DIFFERENCE
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_DIFFERENCE)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "HPDF_BM_DIFFERENCE", 40.0, PAGE_HEIGHT - 850)
+    HPDF_Page_GRestore (page)
+
+
+    # blend-mode=HPDF_BM_EXCLUSHON
+    HPDF_Page_GSave (page)
+    gstate = HPDF_CreateExtGState (pdf)
+    HPDF_ExtGState_SetBlendMode (gstate, HPDF_BM_EXCLUSHON)
+    HPDF_Page_SetExtGState (page, gstate)
+    draw_circles (page, "HPDF_BM_EXCLUSHON", 230.0, PAGE_HEIGHT - 850)
+    HPDF_Page_GRestore (page)
+
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 139 - 0
pdf.mod/libharu/bindings/python/demo/font_demo.py

@@ -0,0 +1,139 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- font_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+
+from math import *
+
+
+global pdf
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: error_no=%04X, detail_no=%u\n", error_no,
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+font_list=[
+    "Courier",
+    "Courier-Bold",
+    "Courier-Oblique",
+    "Courier-BoldOblique",
+    "Helvetica",
+    "Helvetica-Bold",
+    "Helvetica-Oblique",
+    "Helvetica-BoldOblique",
+    "Times-Roman",
+    "Times-Bold",
+    "Times-Italic",
+    "Times-BoldItalic",
+    "Symbol",
+    "ZapfDingbats",
+]
+
+def main ():
+    global pdf
+
+    page_title = "Font Demo"
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+
+    # Add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    height = HPDF_Page_GetHeight (page)
+    width = HPDF_Page_GetWidth (page)
+
+    # Print the lines of the page.
+    HPDF_Page_SetLineWidth (page, 1)
+    HPDF_Page_Rectangle (page, 50, 50, width - 100, height - 110)
+    HPDF_Page_Stroke (page)
+
+    # Print the title of the page (with positioning center).
+    def_font = HPDF_GetFont (pdf, "Helvetica", NULL)
+    HPDF_Page_SetFontAndSize (page, def_font, 24)
+
+    tw = HPDF_Page_TextWidth (page, page_title)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, (width - tw) / 2, height - 50, page_title)
+    HPDF_Page_EndText (page)
+
+    # output subtitle.
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetFontAndSize (page, def_font, 16)
+    HPDF_Page_TextOut (page, 60, height - 80, "<Standerd Type1 fonts samples>")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 60, height - 105)
+
+    for i in font_list:
+        samp_text = "abcdefgABCDEFG12345!#$%&+-@?"
+
+        #font_name = HPDF_LoadTTFontFromFile (pdf, "c:/winnt/fonts/arial.ttf", HPDF_TRUE);
+
+        #font_name='arial.ttf'
+        #font = HPDF_GetFont (pdf, font_name, "CP1250");
+
+        #font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+        font = HPDF_GetFont (pdf, i, NULL)
+
+        # print a label of text
+        HPDF_Page_SetFontAndSize (page, def_font, 9)
+        HPDF_Page_ShowText (page, i)
+        HPDF_Page_MoveTextPos (page, 0, -18)
+
+        # print a sample text.
+        HPDF_Page_SetFontAndSize (page, font, 20)
+        HPDF_Page_ShowText (page, samp_text)
+        HPDF_Page_MoveTextPos (page, 0, -20)
+
+
+    HPDF_Page_EndText (page)
+
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 183 - 0
pdf.mod/libharu/bindings/python/demo/grid_sheet.py

@@ -0,0 +1,183 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- grid_sheet.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def print_grid  (pdf, page):
+    height = HPDF_Page_GetHeight (page)
+    width = HPDF_Page_GetWidth (page)
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    HPDF_Page_SetFontAndSize (page, font, 5)
+    HPDF_Page_SetGrayFill (page, 0.5)
+    HPDF_Page_SetGrayStroke (page, 0.8)
+
+    # Draw horizontal lines
+    y = 0
+    while (y < height):
+        if (y % 10 == 0):
+            HPDF_Page_SetLineWidth (page, 0.5)
+        else:
+            if (HPDF_Page_GetLineWidth (page) != 0.25):
+                HPDF_Page_SetLineWidth (page, 0.25)
+
+
+        HPDF_Page_MoveTo (page, 0, y)
+        HPDF_Page_LineTo (page, width, y)
+        HPDF_Page_Stroke (page)
+
+        if (y % 10 == 0 and y > 0):
+            HPDF_Page_SetGrayStroke (page, 0.5)
+
+            HPDF_Page_MoveTo (page, 0, y)
+            HPDF_Page_LineTo (page, 5, y)
+            HPDF_Page_Stroke (page)
+
+            HPDF_Page_SetGrayStroke (page, 0.8)
+
+
+        y += 5
+
+
+
+    # Draw vertical lines
+    x = 0
+    while (x < width):
+        if (x % 10 == 0):
+            HPDF_Page_SetLineWidth (page, 0.5)
+        else:
+            if (HPDF_Page_GetLineWidth (page) != 0.25):
+                HPDF_Page_SetLineWidth (page, 0.25)
+
+
+        HPDF_Page_MoveTo (page, x, 0)
+        HPDF_Page_LineTo (page, x, height)
+        HPDF_Page_Stroke (page)
+
+        if (x % 50 == 0 and x > 0):
+            HPDF_Page_SetGrayStroke (page, 0.5)
+
+            HPDF_Page_MoveTo (page, x, 0)
+            HPDF_Page_LineTo (page, x, 5)
+            HPDF_Page_Stroke (page)
+
+            HPDF_Page_MoveTo (page, x, height)
+            HPDF_Page_LineTo (page, x, height - 5)
+            HPDF_Page_Stroke (page)
+
+            HPDF_Page_SetGrayStroke (page, 0.8)
+
+
+        x += 5
+
+
+    # Draw horizontal text
+    y = 0
+    while (y < height):
+        if (y % 10 == 0 and y > 0):
+
+            HPDF_Page_BeginText (page)
+            HPDF_Page_MoveTextPos (page, 5, y - 2)
+
+            buf="%u" % y
+
+            HPDF_Page_ShowText (page, buf)
+            HPDF_Page_EndText (page)
+
+        y += 5
+
+
+    # Draw vertical text
+    x = 0
+    while (x < width):
+        if (x % 50 == 0 and x > 0):
+
+            HPDF_Page_BeginText (page)
+            HPDF_Page_MoveTextPos (page, x, 5)
+
+            buf="%u" % x
+
+            HPDF_Page_ShowText (page, buf)
+            HPDF_Page_EndText (page)
+
+            HPDF_Page_BeginText (page)
+            HPDF_Page_MoveTextPos (page, x, height - 10)
+            HPDF_Page_ShowText (page, buf)
+            HPDF_Page_EndText (page)
+
+        x += 5
+
+    HPDF_Page_SetGrayFill (page, 0)
+    HPDF_Page_SetGrayStroke (page, 0)
+
+
+def main():
+    global pdf
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    HPDF_Page_SetHeight (page, 600)
+    HPDF_Page_SetWidth (page, 400)
+
+    print_grid  (pdf, page)
+
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+if __name__=='__main__':
+    main()
+
+
+__all__=['print_grid']

+ 224 - 0
pdf.mod/libharu/bindings/python/demo/image_demo.py

@@ -0,0 +1,224 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- image_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+from math import *
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def show_description (page, x, y, text):
+    HPDF_Page_MoveTo (page, x, y - 10)
+    HPDF_Page_LineTo (page, x, y + 10)
+    HPDF_Page_MoveTo (page, x - 10, y)
+    HPDF_Page_LineTo (page, x + 10, y)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_SetFontAndSize (page, HPDF_Page_GetCurrentFont (page), 8)
+    HPDF_Page_SetRGBFill (page, 0, 0, 0)
+
+    HPDF_Page_BeginText (page)
+
+    buf="(x=%d,y=%d)" % (int(x), int(y))
+
+    HPDF_Page_MoveTextPos (page, x - HPDF_Page_TextWidth (page, buf) - 5,
+            y - 10)
+    HPDF_Page_ShowText (page, buf)
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, x - 20, y - 25)
+    HPDF_Page_ShowText (page, text)
+    HPDF_Page_EndText (page)
+
+
+def main ():
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    HPDF_Page_SetWidth (page, 550)
+    HPDF_Page_SetHeight (page, 500)
+
+    dst = HPDF_Page_CreateDestination (page)
+    HPDF_Destination_SetXYZ (dst, 0, HPDF_Page_GetHeight (page), 1)
+    HPDF_SetOpenAction(pdf, dst)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetFontAndSize (page, font, 20)
+    HPDF_Page_MoveTextPos (page, 220, HPDF_Page_GetHeight (page) - 70)
+    HPDF_Page_ShowText (page, "ImageDemo")
+    HPDF_Page_EndText (page)
+
+    # load image file.
+    image = HPDF_LoadPngImageFromFile (pdf, "pngsuite/basn3p02.png")
+
+    # image1 is masked by image2.
+    image1 = HPDF_LoadPngImageFromFile (pdf, "pngsuite/basn3p02.png")
+
+    # image2 is a mask image.
+    image2 = HPDF_LoadPngImageFromFile (pdf, "pngsuite/basn0g01.png")
+
+    # image3 is a RGB-color image. we use this image for color-mask
+    # * demo.
+    image3 = HPDF_LoadPngImageFromFile (pdf, "pngsuite/maskimage.png")
+
+    iw = HPDF_Image_GetWidth (image)
+    ih = HPDF_Image_GetHeight (image)
+
+    HPDF_Page_SetLineWidth (page, 0.5)
+
+    x = 100
+    y = HPDF_Page_GetHeight (page) - 150
+
+    # Draw image to the canvas. (normal-mode with actual size.)
+    HPDF_Page_DrawImage (page, image, x, y, iw, ih)
+
+    show_description (page, x, y, "Actual Size")
+
+    x += 150
+
+    # Scalling image (X direction)
+    HPDF_Page_DrawImage (page, image, x, y, iw * 1.5, ih)
+
+    show_description (page, x, y, "Scalling image (X direction)")
+
+    x += 150
+
+    # Scalling image (Y direction).
+    HPDF_Page_DrawImage (page, image, x, y, iw, ih * 1.5)
+    show_description (page, x, y, "Scalling image (Y direction)")
+
+    x = 100
+    y -= 120
+
+    # Skewing image.
+    angle1 = 10
+    angle2 = 20
+    rad1 = angle1 / 180 * 3.141592
+    rad2 = angle2 / 180 * 3.141592
+
+    HPDF_Page_GSave (page)
+
+    HPDF_Page_Concat (page, iw, tan(rad1) * iw, tan(rad2) * ih, ih, x, y)
+
+    HPDF_Page_ExecuteXObject (page, image)
+    HPDF_Page_GRestore (page)
+
+    show_description (page, x, y, "Skewing image")
+
+    x += 150
+
+    # Rotating image
+    angle = 30;     # rotation of 30 degrees.
+    rad = angle / 180 * 3.141592; # Calculate the radian value.
+
+    HPDF_Page_GSave (page)
+
+    HPDF_Page_Concat (page, iw * cos(rad),
+                iw * sin(rad),
+                ih * -sin(rad),
+                ih * cos(rad),
+                x, y)
+
+    HPDF_Page_ExecuteXObject (page, image)
+    HPDF_Page_GRestore (page)
+
+    show_description (page, x, y, "Rotating image")
+
+    x += 150
+
+    # draw masked image.
+
+    # Set image2 to the mask image of image1
+    HPDF_Image_SetMaskImage (image1, image2)
+
+    HPDF_Page_SetRGBFill (page, 0, 0, 0)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, x - 6, y + 14)
+    HPDF_Page_ShowText (page, "MASKMASK")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_DrawImage (page, image1, x - 3, y - 3, iw + 6, ih + 6)
+
+    show_description (page, x, y, "masked image")
+
+    x = 100
+    y -= 120
+
+    # color mask.
+    HPDF_Page_SetRGBFill (page, 0, 0, 0)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, x - 6, y + 14)
+    HPDF_Page_ShowText (page, "MASKMASK")
+    HPDF_Page_EndText (page)
+
+    HPDF_Image_SetColorMask (image3, 0, 255, 0, 0, 0, 255)
+    HPDF_Page_DrawImage (page, image3, x, y, iw, ih)
+
+    show_description (page, x, y, "Color Mask")
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+
+
+if HPDF_NOPNGLIB:
+    printf("WARNING: if you want to run this demo, \n"
+           "make libhpdf with HPDF_USE_PNGLIB option.\n")
+    sys.exit(1)
+else:
+    main()

+ 111 - 0
pdf.mod/libharu/bindings/python/demo/jpeg_demo.py

@@ -0,0 +1,111 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- jpeg_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+def draw_image (pdf, filename, x, y, text):
+
+    page = HPDF_GetCurrentPage (pdf)
+
+    filename1="images/%s" % filename
+
+    image = HPDF_LoadJpegImageFromFile (pdf, filename1)
+
+    # Draw image to the canvas.
+    HPDF_Page_DrawImage (page, image, x, y, HPDF_Image_GetWidth (image),
+                HPDF_Image_GetHeight (image))
+
+    # Print the text.
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetTextLeading (page, 16)
+    HPDF_Page_MoveTextPos (page, x, y)
+    HPDF_Page_ShowTextNextLine (page, filename)
+    HPDF_Page_ShowTextNextLine (page, text)
+    HPDF_Page_EndText (page)
+
+
+def main():
+    global pdf
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    HPDF_Page_SetWidth (page, 650)
+    HPDF_Page_SetHeight (page, 500)
+
+    dst = HPDF_Page_CreateDestination (page)
+    HPDF_Destination_SetXYZ (dst, 0, HPDF_Page_GetHeight (page), 1)
+    HPDF_SetOpenAction(pdf, dst)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetFontAndSize (page, font, 20)
+    HPDF_Page_MoveTextPos (page, 220, HPDF_Page_GetHeight (page) - 70)
+    HPDF_Page_ShowText (page, "JpegDemo")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetFontAndSize (page, font, 12)
+
+    draw_image (pdf, "rgb.jpg", 70, HPDF_Page_GetHeight (page) - 410,
+                "24bit color image")
+    draw_image (pdf, "gray.jpg", 340, HPDF_Page_GetHeight (page) - 410,
+                "8bit grayscale image")
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 180 - 0
pdf.mod/libharu/bindings/python/demo/jpfont_demo.py

@@ -0,0 +1,180 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- jpfont_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+def main():
+    global pdf
+
+    detail_font=[None  for i in range(16)]
+    PAGE_HEIGHT = 210
+
+    try:
+        f = open ("mbtext/sjis.txt", "rb")
+    except:
+        printf ("error: cannot open 'mbtext/sjis.txt'\n")
+        return 1
+
+    samp_text=f.read(2048)
+    f.close ()
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+
+    # configure pdf-document to be compressed.
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+
+    # declaration for using Japanese font, encoding.
+    HPDF_UseJPEncodings (pdf)
+    HPDF_UseJPFonts (pdf)
+
+    detail_font[0] = HPDF_GetFont (pdf, "MS-Mincyo", "90ms-RKSJ-H")
+    detail_font[1] = HPDF_GetFont (pdf, "MS-Mincyo,Bold", "90ms-RKSJ-H")
+    detail_font[2] = HPDF_GetFont (pdf, "MS-Mincyo,Italic", "90ms-RKSJ-H")
+    detail_font[3] = HPDF_GetFont (pdf, "MS-Mincyo,BoldItalic", "90ms-RKSJ-H")
+    detail_font[4] = HPDF_GetFont (pdf, "MS-PMincyo", "90msp-RKSJ-H")
+    detail_font[5] = HPDF_GetFont (pdf, "MS-PMincyo,Bold", "90msp-RKSJ-H")
+    detail_font[6] = HPDF_GetFont (pdf, "MS-PMincyo,Italic", "90msp-RKSJ-H")
+    detail_font[7] = HPDF_GetFont (pdf, "MS-PMincyo,BoldItalic",
+            "90msp-RKSJ-H")
+    detail_font[8] = HPDF_GetFont (pdf, "MS-Gothic", "90ms-RKSJ-H")
+    detail_font[9] = HPDF_GetFont (pdf, "MS-Gothic,Bold", "90ms-RKSJ-H")
+    detail_font[10] = HPDF_GetFont (pdf, "MS-Gothic,Italic", "90ms-RKSJ-H")
+    detail_font[11] = HPDF_GetFont (pdf, "MS-Gothic,BoldItalic", "90ms-RKSJ-H")
+    detail_font[12] = HPDF_GetFont (pdf, "MS-PGothic", "90msp-RKSJ-H")
+    detail_font[13] = HPDF_GetFont (pdf, "MS-PGothic,Bold", "90msp-RKSJ-H")
+    detail_font[14] = HPDF_GetFont (pdf, "MS-PGothic,Italic", "90msp-RKSJ-H")
+    detail_font[15] = HPDF_GetFont (pdf, "MS-PGothic,BoldItalic",
+            "90msp-RKSJ-H")
+
+    # Set page mode to use outlines.
+    HPDF_SetPageMode(pdf, HPDF_PAGE_MODE_USE_OUTLINE)
+
+    # create outline root.
+    root = HPDF_CreateOutline (pdf, NULL, "JP font demo", NULL)
+    HPDF_Outline_SetOpened (root, HPDF_TRUE)
+
+    for i in range(16):
+
+        # add a new page object.
+        page = HPDF_AddPage (pdf)
+
+        # create outline entry
+        outline = HPDF_CreateOutline (pdf, root,
+                HPDF_Font_GetFontName (detail_font[i]), NULL)
+        dst = HPDF_Page_CreateDestination (page)
+        HPDF_Outline_SetDestination(outline, dst)
+
+        title_font = HPDF_GetFont (pdf, "Helvetica", NULL)
+        HPDF_Page_SetFontAndSize (page, title_font, 10)
+
+        HPDF_Page_BeginText (page)
+
+        # move the position of the text to top of the page.
+        HPDF_Page_MoveTextPos(page, 10, 190)
+        HPDF_Page_ShowText (page, HPDF_Font_GetFontName (detail_font[i]))
+
+        HPDF_Page_SetFontAndSize (page, detail_font[i], 15)
+        HPDF_Page_MoveTextPos (page, 10, -20)
+        HPDF_Page_ShowText (page, "abcdefghijklmnopqrstuvwxyz")
+        HPDF_Page_MoveTextPos (page, 0, -20)
+        HPDF_Page_ShowText (page, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+        HPDF_Page_MoveTextPos (page, 0, -20)
+        HPDF_Page_ShowText (page, "1234567890")
+        HPDF_Page_MoveTextPos (page, 0, -20)
+
+        HPDF_Page_SetFontAndSize (page, detail_font[i], 10)
+        HPDF_Page_ShowText (page, samp_text)
+        HPDF_Page_MoveTextPos (page, 0, -18)
+
+        HPDF_Page_SetFontAndSize (page, detail_font[i], 16)
+        HPDF_Page_ShowText (page, samp_text)
+        HPDF_Page_MoveTextPos (page, 0, -27)
+
+        HPDF_Page_SetFontAndSize (page, detail_font[i], 23)
+        HPDF_Page_ShowText (page, samp_text)
+        HPDF_Page_MoveTextPos (page, 0, -36)
+
+        HPDF_Page_SetFontAndSize (page, detail_font[i], 30)
+        HPDF_Page_ShowText (page, samp_text)
+
+        p = HPDF_Page_GetCurrentTextPos (page)
+
+        # finish to print text.
+        HPDF_Page_EndText (page)
+
+        HPDF_Page_SetLineWidth (page, 0.5)
+
+        x_pos = 20
+        for j in range(len (samp_text) // 2):
+            HPDF_Page_MoveTo (page, x_pos, p.y - 10)
+            HPDF_Page_LineTo (page, x_pos, p.y - 12)
+            HPDF_Page_Stroke (page)
+            x_pos = x_pos + 30
+
+        HPDF_Page_SetWidth (page, p.x + 20)
+        HPDF_Page_SetHeight (page, PAGE_HEIGHT)
+
+        HPDF_Page_MoveTo (page, 10, PAGE_HEIGHT - 25)
+        HPDF_Page_LineTo (page, p.x + 10, PAGE_HEIGHT - 25)
+        HPDF_Page_Stroke (page)
+
+        HPDF_Page_MoveTo (page, 10, PAGE_HEIGHT - 85)
+        HPDF_Page_LineTo (page, p.x + 10, PAGE_HEIGHT - 85)
+        HPDF_Page_Stroke (page)
+
+        HPDF_Page_MoveTo (page, 10, p.y - 12)
+        HPDF_Page_LineTo (page, p.x + 10, p.y - 12)
+        HPDF_Page_Stroke (page)
+
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 346 - 0
pdf.mod/libharu/bindings/python/demo/line_demo.py

@@ -0,0 +1,346 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- line_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def draw_line  (page, x, y, label):
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, x, y - 10)
+    HPDF_Page_ShowText (page, label)
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_MoveTo (page, x, y - 15)
+    HPDF_Page_LineTo (page, x + 220, y - 15)
+    HPDF_Page_Stroke (page)
+
+def draw_line2  (page, x, y, label):
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, x, y)
+    HPDF_Page_ShowText (page, label)
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_MoveTo (page, x + 30, y - 25)
+    HPDF_Page_LineTo (page, x + 160, y - 25)
+    HPDF_Page_Stroke (page)
+
+
+def draw_rect (page,  x, y, label):
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, x, y - 10)
+    HPDF_Page_ShowText (page, label)
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_Rectangle(page, x, y - 40, 220, 25)
+
+def main ():
+    global pdf
+
+    page_title = "Line Example"
+
+    DASH_MODE1= [3]
+    DASH_MODE2= [3, 7]
+    DASH_MODE3= [8, 7, 2, 7]
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    # print the lines of the page.
+    HPDF_Page_SetLineWidth (page, 1)
+    HPDF_Page_Rectangle (page, 50, 50, HPDF_Page_GetWidth(page) - 100,
+                HPDF_Page_GetHeight (page) - 110)
+    HPDF_Page_Stroke (page)
+
+    # print the title of the page (with positioning center).
+    HPDF_Page_SetFontAndSize (page, font, 24)
+    tw = HPDF_Page_TextWidth (page, page_title)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, (HPDF_Page_GetWidth(page) - tw) / 2,
+                HPDF_Page_GetHeight (page) - 50)
+    HPDF_Page_ShowText (page, page_title)
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetFontAndSize (page, font, 10)
+
+    # Draw various widths of lines.
+    HPDF_Page_SetLineWidth (page, 0)
+    draw_line (page, 60, 770, "line width = 0")
+
+    HPDF_Page_SetLineWidth (page, 1.0)
+    draw_line (page, 60, 740, "line width = 1.0")
+
+    HPDF_Page_SetLineWidth (page, 2.0)
+    draw_line (page, 60, 710, "line width = 2.0")
+
+    # Line dash pattern
+    HPDF_Page_SetLineWidth (page, 1.0)
+
+    HPDF_Page_SetDash (page, DASH_MODE1, 1, 1)
+    draw_line (page, 60, 680, "dash_ptn=[3], phase=1 -- "
+                "2 on, 3 off, 3 on...")
+
+    HPDF_Page_SetDash (page, DASH_MODE2, 2, 2)
+    draw_line (page, 60, 650, "dash_ptn=[7, 3], phase=2 -- "
+                "5 on 3 off, 7 on,...")
+
+    HPDF_Page_SetDash (page, DASH_MODE3, 4, 0)
+    draw_line (page, 60, 620, "dash_ptn=[8, 7, 2, 7], phase=0")
+
+    HPDF_Page_SetDash (page, NULL, 0, 0)
+
+    HPDF_Page_SetLineWidth (page, 30)
+    HPDF_Page_SetRGBStroke (page, 0.0, 0.5, 0.0)
+
+    # Line Cap Style
+    HPDF_Page_SetLineCap (page, HPDF_BUTT_END)
+    draw_line2 (page, 60, 570, "PDF_BUTT_END")
+
+    HPDF_Page_SetLineCap (page, HPDF_ROUND_END)
+    draw_line2 (page, 60, 505, "PDF_ROUND_END")
+
+    HPDF_Page_SetLineCap (page, HPDF_PROJECTING_SQUARE_END)
+    draw_line2 (page, 60, 440, "PDF_PROJECTING_SCUARE_END")
+
+    # Line Join Style
+    HPDF_Page_SetLineWidth (page, 30)
+    HPDF_Page_SetRGBStroke (page, 0.0, 0.0, 0.5)
+
+    HPDF_Page_SetLineJoin (page, HPDF_MITER_JOIN)
+    HPDF_Page_MoveTo (page, 120, 300)
+    HPDF_Page_LineTo (page, 160, 340)
+    HPDF_Page_LineTo (page, 200, 300)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 60, 360)
+    HPDF_Page_ShowText (page, "PDF_MITER_JOIN")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetLineJoin (page, HPDF_ROUND_JOIN)
+    HPDF_Page_MoveTo (page, 120, 195)
+    HPDF_Page_LineTo (page, 160, 235)
+    HPDF_Page_LineTo (page, 200, 195)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 60, 255)
+    HPDF_Page_ShowText (page, "PDF_ROUND_JOIN")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetLineJoin (page, HPDF_BEVEL_JOIN)
+    HPDF_Page_MoveTo (page, 120, 90)
+    HPDF_Page_LineTo (page, 160, 130)
+    HPDF_Page_LineTo (page, 200, 90)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 60, 150)
+    HPDF_Page_ShowText (page, "PDF_BEVEL_JOIN")
+    HPDF_Page_EndText (page)
+
+    # Draw Rectangle
+    HPDF_Page_SetLineWidth (page, 2)
+    HPDF_Page_SetRGBStroke (page, 0, 0, 0)
+    HPDF_Page_SetRGBFill (page, 0.75, 0.0, 0.0)
+
+    draw_rect (page, 300, 770, "Stroke")
+    HPDF_Page_Stroke (page)
+
+    draw_rect (page, 300, 720, "Fill")
+    HPDF_Page_Fill (page)
+
+    draw_rect (page, 300, 670, "Fill then Stroke")
+    HPDF_Page_FillStroke (page)
+
+    # Clip Rect
+    HPDF_Page_GSave (page);  # Save the current graphic state
+    draw_rect (page, 300, 620, "Clip Rectangle")
+    HPDF_Page_Clip (page)
+    HPDF_Page_Stroke (page)
+    HPDF_Page_SetFontAndSize (page, font, 13)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 290, 600)
+    HPDF_Page_SetTextLeading (page, 12)
+    HPDF_Page_ShowText (page,
+                "Clip Clip Clip Clip Clip Clipi Clip Clip Clip")
+    HPDF_Page_ShowTextNextLine (page,
+                "Clip Clip Clip Clip Clip Clip Clip Clip Clip")
+    HPDF_Page_ShowTextNextLine (page,
+                "Clip Clip Clip Clip Clip Clip Clip Clip Clip")
+    HPDF_Page_EndText (page)
+    HPDF_Page_GRestore (page)
+
+    # Curve Example(CurveTo2)
+    x = 330
+    y = 440
+    x1 = 430
+    y1 = 530
+    x2 = 480
+    y2 = 470
+    x3 = 480
+    y3 = 90
+
+    HPDF_Page_SetRGBFill (page, 0, 0, 0)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 300, 540)
+    HPDF_Page_ShowText (page, "CurveTo2(x1, y1, x2. y2)")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, x + 5, y - 5)
+    HPDF_Page_ShowText (page, "Current point")
+    HPDF_Page_MoveTextPos (page, x1 - x, y1 - y)
+    HPDF_Page_ShowText (page, "(x1, y1)")
+    HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1)
+    HPDF_Page_ShowText (page, "(x2, y2)")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetDash (page, DASH_MODE1, 1, 0)
+
+    HPDF_Page_SetLineWidth (page, 0.5)
+    HPDF_Page_MoveTo (page, x1, y1)
+    HPDF_Page_LineTo (page, x2, y2)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_SetDash (page, NULL, 0, 0)
+
+    HPDF_Page_SetLineWidth (page, 1.5)
+
+    HPDF_Page_MoveTo (page, x, y)
+    HPDF_Page_CurveTo2 (page, x1, y1, x2, y2)
+    HPDF_Page_Stroke (page)
+
+    # Curve Example(CurveTo3)
+    y -= 150
+    y1 -= 150
+    y2 -= 150
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 300, 390)
+    HPDF_Page_ShowText (page, "CurveTo3(x1, y1, x2. y2)")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, x + 5, y - 5)
+    HPDF_Page_ShowText (page, "Current point")
+    HPDF_Page_MoveTextPos (page, x1 - x, y1 - y)
+    HPDF_Page_ShowText (page, "(x1, y1)")
+    HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1)
+    HPDF_Page_ShowText (page, "(x2, y2)")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetDash (page, DASH_MODE1, 1, 0)
+
+    HPDF_Page_SetLineWidth (page, 0.5)
+    HPDF_Page_MoveTo (page, x, y)
+    HPDF_Page_LineTo (page, x1, y1)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_SetDash (page, NULL, 0, 0)
+
+    HPDF_Page_SetLineWidth (page, 1.5)
+    HPDF_Page_MoveTo (page, x, y)
+    HPDF_Page_CurveTo3 (page, x1, y1, x2, y2)
+    HPDF_Page_Stroke (page)
+
+    # Curve Example(CurveTo)
+    y -= 150
+    y1 -= 160
+    y2 -= 130
+    x2 += 10
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 300, 240)
+    HPDF_Page_ShowText (page, "CurveTo(x1, y1, x2. y2, x3, y3)")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, x + 5, y - 5)
+    HPDF_Page_ShowText (page, "Current point")
+    HPDF_Page_MoveTextPos (page, x1 - x, y1 - y)
+    HPDF_Page_ShowText (page, "(x1, y1)")
+    HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1)
+    HPDF_Page_ShowText (page, "(x2, y2)")
+    HPDF_Page_MoveTextPos (page, x3 - x2, y3 - y2)
+    HPDF_Page_ShowText (page, "(x3, y3)")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetDash (page, DASH_MODE1, 1, 0)
+
+    HPDF_Page_SetLineWidth (page, 0.5)
+    HPDF_Page_MoveTo (page, x, y)
+    HPDF_Page_LineTo (page, x1, y1)
+    HPDF_Page_Stroke (page)
+    HPDF_Page_MoveTo (page, x2, y2)
+    HPDF_Page_LineTo (page, x3, y3)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_SetDash (page, NULL, 0, 0)
+
+    HPDF_Page_SetLineWidth (page, 1.5)
+    HPDF_Page_MoveTo (page, x, y)
+    HPDF_Page_CurveTo (page, x1, y1, x2, y2, x3, y3)
+    HPDF_Page_Stroke (page)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+
+main()

+ 255 - 0
pdf.mod/libharu/bindings/python/demo/link_annotation.py

@@ -0,0 +1,255 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- link_annotation.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+
+def print_page  (page, font, page_num):
+
+    HPDF_Page_SetWidth (page, 200)
+    HPDF_Page_SetHeight (page, 200)
+
+    HPDF_Page_SetFontAndSize (page, font, 20)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 50, 150)
+
+    buf= "Page:%d" % page_num
+
+    HPDF_Page_ShowText (page, buf)
+    HPDF_Page_EndText (page)
+
+def main():
+
+    global pdf
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    page=[None for i in range(9)]
+    rect=HPDF_Rect()
+
+    uri = "http://libharu.org"
+
+
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # create index page
+    index_page = HPDF_AddPage (pdf)
+    HPDF_Page_SetWidth (index_page, 300)
+    HPDF_Page_SetHeight (index_page, 220)
+
+    # Add 7 pages to the document.
+    for i in range(7):
+        page[i] = HPDF_AddPage (pdf)
+        print_page(page[i], font, i + 1)
+
+    HPDF_Page_BeginText (index_page)
+    HPDF_Page_SetFontAndSize (index_page, font, 10)
+    HPDF_Page_MoveTextPos (index_page, 15, 200)
+    HPDF_Page_ShowText (index_page, "Link Annotation Demo")
+    HPDF_Page_EndText (index_page)
+
+    ##
+    # * Create Link-Annotation object on index page.
+    #
+    HPDF_Page_BeginText(index_page)
+    HPDF_Page_SetFontAndSize (index_page, font, 8)
+    HPDF_Page_MoveTextPos (index_page, 20, 180)
+    HPDF_Page_SetTextLeading (index_page, 23)
+
+    # page1 (HPDF_ANNOT_NO_HIGHTLIGHT)
+    tp = HPDF_Page_GetCurrentTextPos (index_page)
+
+    HPDF_Page_ShowText (index_page, "Jump to Page1 (HilightMode=HPDF_ANNOT_NO_HIGHTLIGHT)")
+    rect.left = tp.x - 4
+    rect.bottom = tp.y - 4
+    rect.right = HPDF_Page_GetCurrentTextPos (index_page).x + 4
+    rect.top = tp.y + 10
+
+    HPDF_Page_MoveToNextLine (index_page)
+
+    dst = HPDF_Page_CreateDestination (page[0])
+
+    annot = HPDF_Page_CreateLinkAnnot (index_page, rect, dst)
+
+    HPDF_LinkAnnot_SetHighlightMode (annot, HPDF_ANNOT_NO_HIGHTLIGHT)
+
+
+    # page2 (HPDF_ANNOT_INVERT_BOX)
+    tp = HPDF_Page_GetCurrentTextPos (index_page)
+
+    HPDF_Page_ShowText (index_page, "Jump to Page2 (HilightMode=HPDF_ANNOT_INVERT_BOX)")
+    rect.left = tp.x - 4
+    rect.bottom = tp.y - 4
+    rect.right = HPDF_Page_GetCurrentTextPos (index_page).x + 4
+    rect.top = tp.y + 10
+
+    HPDF_Page_MoveToNextLine (index_page)
+
+    dst = HPDF_Page_CreateDestination (page[1])
+
+    annot = HPDF_Page_CreateLinkAnnot (index_page, rect, dst)
+
+    HPDF_LinkAnnot_SetHighlightMode (annot, HPDF_ANNOT_INVERT_BOX)
+
+
+    # page3 (HPDF_ANNOT_INVERT_BORDER)
+    tp = HPDF_Page_GetCurrentTextPos (index_page)
+
+    HPDF_Page_ShowText (index_page, "Jump to Page3 (HilightMode=HPDF_ANNOT_INVERT_BORDER)")
+    rect.left = tp.x - 4
+    rect.bottom = tp.y - 4
+    rect.right = HPDF_Page_GetCurrentTextPos (index_page).x + 4
+    rect.top = tp.y + 10
+
+    HPDF_Page_MoveToNextLine (index_page)
+
+    dst = HPDF_Page_CreateDestination (page[2])
+
+    annot = HPDF_Page_CreateLinkAnnot (index_page, rect, dst)
+
+    HPDF_LinkAnnot_SetHighlightMode (annot, HPDF_ANNOT_INVERT_BORDER)
+
+
+    # page4 (HPDF_ANNOT_DOWN_APPEARANCE)
+    tp = HPDF_Page_GetCurrentTextPos (index_page)
+
+    HPDF_Page_ShowText (index_page, "Jump to Page4 (HilightMode=HPDF_ANNOT_DOWN_APPEARANCE)")
+    rect.left = tp.x - 4
+    rect.bottom = tp.y - 4
+    rect.right = HPDF_Page_GetCurrentTextPos (index_page).x + 4
+    rect.top = tp.y + 10
+
+    HPDF_Page_MoveToNextLine (index_page)
+
+    dst = HPDF_Page_CreateDestination (page[3])
+
+    annot = HPDF_Page_CreateLinkAnnot (index_page, rect, dst)
+
+    HPDF_LinkAnnot_SetHighlightMode (annot, HPDF_ANNOT_DOWN_APPEARANCE)
+
+
+    # page5 (dash border)
+    tp = HPDF_Page_GetCurrentTextPos (index_page)
+
+    HPDF_Page_ShowText (index_page, "Jump to Page5 (dash border)")
+    rect.left = tp.x - 4
+    rect.bottom = tp.y - 4
+    rect.right = HPDF_Page_GetCurrentTextPos (index_page).x + 4
+    rect.top = tp.y + 10
+
+    HPDF_Page_MoveToNextLine (index_page)
+
+    dst = HPDF_Page_CreateDestination (page[4])
+
+    annot = HPDF_Page_CreateLinkAnnot (index_page, rect, dst)
+
+    HPDF_LinkAnnot_SetBorderStyle (annot, 1, 3, 2)
+
+
+    # page6 (no border)
+    tp = HPDF_Page_GetCurrentTextPos (index_page)
+
+    HPDF_Page_ShowText (index_page, "Jump to Page6 (no border)")
+    rect.left = tp.x - 4
+    rect.bottom = tp.y - 4
+    rect.right = HPDF_Page_GetCurrentTextPos (index_page).x + 4
+    rect.top = tp.y + 10
+
+    HPDF_Page_MoveToNextLine (index_page)
+
+    dst = HPDF_Page_CreateDestination (page[5])
+
+    annot = HPDF_Page_CreateLinkAnnot (index_page, rect, dst)
+
+    HPDF_LinkAnnot_SetBorderStyle (annot, 0, 0, 0)
+
+
+    # page7 (bold border)
+    tp = HPDF_Page_GetCurrentTextPos (index_page)
+
+    HPDF_Page_ShowText (index_page, "Jump to Page7 (bold border)")
+    rect.left = tp.x - 4
+    rect.bottom = tp.y - 4
+    rect.right = HPDF_Page_GetCurrentTextPos (index_page).x + 4
+    rect.top = tp.y + 10
+
+    HPDF_Page_MoveToNextLine (index_page)
+
+    dst = HPDF_Page_CreateDestination (page[6])
+
+    annot = HPDF_Page_CreateLinkAnnot (index_page, rect, dst)
+
+    HPDF_LinkAnnot_SetBorderStyle (annot, 2, 0, 0)
+
+
+    # URI link
+    tp = HPDF_Page_GetCurrentTextPos (index_page)
+
+    HPDF_Page_ShowText (index_page, "URI (")
+    HPDF_Page_ShowText (index_page, uri)
+    HPDF_Page_ShowText (index_page, ")")
+
+    rect.left = tp.x - 4
+    rect.bottom = tp.y - 4
+    rect.right = HPDF_Page_GetCurrentTextPos (index_page).x + 4
+    rect.top = tp.y + 10
+
+    HPDF_Page_CreateURILinkAnnot (index_page, rect, uri)
+
+    HPDF_Page_EndText (index_page)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 85 - 0
pdf.mod/libharu/bindings/python/demo/make_rawimage.py

@@ -0,0 +1,85 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- make_rawimage.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+def main ():
+    global  pdf
+
+    if (len(sys.argv) < 2):
+        printf ("usage: make_rawimage <in-file-name> <out-file-name>\n")
+        return 1
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # load image file.
+    image = HPDF_LoadPngImageFromFile (pdf, sys.argv[1])
+
+    iw = HPDF_Image_GetWidth (image)
+    ih = HPDF_Image_GetHeight (image)
+    bits_per_comp = HPDF_Image_GetBitsPerComponent (image)
+    cs = HPDF_Image_GetColorSpace (image)
+
+    printf ("width=%u\n", iw)
+    printf ("height=%u\n", ih)
+    printf ("bits_per_comp=%u\n", bits_per_comp)
+    printf ("color_space=%s\n", cs)
+
+    # save raw-data to file
+    stream = HPDF_FileWriter_New (pdf.mmgr, sys.argv[2])
+    if (not stream):
+        printf ("cannot open %s\n", sys.argv[2])
+    else:
+        HPDF_Stream_WriteToStream(image.stream, stream, 0, NULL)
+
+    HPDF_Stream_Free (stream)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 127 - 0
pdf.mod/libharu/bindings/python/demo/outline_demo.py

@@ -0,0 +1,127 @@
+#coding=ISO8859-2
+
+###
+## * << Haru Free PDF Library 2.0.0 >> -- outline_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def print_page  (page,  page_num):
+
+    HPDF_Page_SetWidth (page, 800)
+    HPDF_Page_SetHeight (page, 800)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 30, 740)
+
+    buf="Page:%d" % page_num
+
+
+    HPDF_Page_ShowText (page, buf)
+    HPDF_Page_EndText (page)
+
+
+def main():
+    global pdf
+    page=[None for i in range(4)]
+    outline=[None for i in range(4)]
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # Set page mode to use outlines.
+    HPDF_SetPageMode(pdf, HPDF_PAGE_MODE_USE_OUTLINE)
+
+    # Add 3 pages to the document.
+    page[0] = HPDF_AddPage (pdf)
+    HPDF_Page_SetFontAndSize (page[0], font, 30)
+    print_page(page[0], 1)
+
+    page[1] = HPDF_AddPage (pdf)
+    HPDF_Page_SetFontAndSize (page[1], font, 30)
+    print_page(page[1], 2)
+
+    page[2] = HPDF_AddPage (pdf)
+    HPDF_Page_SetFontAndSize (page[2], font, 30)
+    print_page(page[2], 3)
+
+    # create outline root.
+    root = HPDF_CreateOutline (pdf, NULL, "OutlineRoot", NULL)
+    HPDF_Outline_SetOpened (root, HPDF_TRUE)
+
+    outline[0] = HPDF_CreateOutline (pdf, root, "page1", NULL)
+    outline[1] = HPDF_CreateOutline (pdf, root, "page2", NULL)
+
+    # create outline with test which is ISO8859-2 encoding
+    #outline[2] = HPDF_CreateOutline (pdf, root, "ISO8859-2 text 釉罩棕?,
+    #                HPDF_GetEncoder (pdf, "ISO8859-2"))
+
+    # create destination objects on each pages
+    # and link it to outline items.
+
+    dst = HPDF_Page_CreateDestination (page[0])
+    HPDF_Destination_SetXYZ(dst, 0, HPDF_Page_GetHeight(page[0]), 1)
+    HPDF_Outline_SetDestination(outline[0], dst)
+    #HPDF_Catalog_SetOpenAction(dst)
+
+    dst = HPDF_Page_CreateDestination (page[1])
+    HPDF_Destination_SetXYZ(dst, 0, HPDF_Page_GetHeight(page[1]), 1)
+    HPDF_Outline_SetDestination(outline[1], dst)
+
+    dst = HPDF_Page_CreateDestination (page[2])
+    HPDF_Destination_SetXYZ(dst, 0, HPDF_Page_GetHeight(page[2]), 1)
+    HPDF_Outline_SetDestination(outline[2], dst)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 142 - 0
pdf.mod/libharu/bindings/python/demo/outline_demo_jp.py

@@ -0,0 +1,142 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- outline_demo_jp.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+for i in dir():
+    if 'CreateOutLine' in i:
+        print i
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def print_page  (page,  page_num):
+
+    HPDF_Page_SetWidth (page, 200)
+    HPDF_Page_SetHeight (page, 300)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 50, 250)
+
+    buf="Page:%d" % page_num
+
+    HPDF_Page_ShowText (page, buf)
+    HPDF_Page_EndText (page)
+
+def main():
+    global pdf
+
+    page=[None for i in range(4)]
+    outline=[None for i in range(4)]
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    try:
+        f = open ("mbtext/sjis.txt", "rb")
+    except:
+        printf ("error: cannot open 'mbtext/sjis.txt'\n")
+        return 1
+
+
+    SAMP_TXT=f.read(2048)
+    f.close ()
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # declaration for using Japanese encoding.
+    HPDF_UseJPEncodings (pdf)
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # Set page mode to use outlines.
+    HPDF_SetPageMode(pdf, HPDF_PAGE_MODE_USE_OUTLINE)
+
+    # Add 3 pages to the document.
+    page[0] = HPDF_AddPage (pdf)
+    HPDF_Page_SetFontAndSize (page[0], font, 20)
+    print_page(page[0], 1)
+
+    page[1] = HPDF_AddPage (pdf)
+    HPDF_Page_SetFontAndSize (page[1], font, 20)
+    print_page(page[1], 2)
+
+    page[2] = HPDF_AddPage (pdf)
+    HPDF_Page_SetFontAndSize (page[2], font, 20)
+    print_page(page[2], 3)
+
+    # create outline root.
+    root = HPDF_CreateOutLine (pdf, NULL, "OutlineRoot", NULL)
+    HPDF_Outline_SetOpened (root, HPDF_TRUE)
+
+    outline[0] = HPDF_CreateOutLine (pdf, root, "page1", NULL)
+    outline[1] = HPDF_CreateOutLine (pdf, root, "page2", NULL)
+
+    # create outline with test which is  encoding
+    outline[2] = HPDF_CreateOutLine (pdf, root, SAMP_TXT,
+                    HPDF_GetEncoder (pdf, "90ms-RKSJ-H"))
+
+    # create destination objects on each pages
+    # and link it to outline items.
+
+    dst = HPDF_Page_CreateDestination (page[0])
+    HPDF_Destination_SetXYZ(dst, 0, HPDF_Page_GetHeight(page[0]), 1)
+    HPDF_Outline_SetDestination(outline[0], dst)
+    # HPDF_Catalog_SetOpenAction(dst)
+
+    dst = HPDF_Page_CreateDestination (page[1])
+    HPDF_Destination_SetXYZ(dst, 0, HPDF_Page_GetHeight(page[1]), 1)
+    HPDF_Outline_SetDestination(outline[1], dst)
+
+    dst = HPDF_Page_CreateDestination (page[2])
+    HPDF_Destination_SetXYZ(dst, 0, HPDF_Page_GetHeight(page[2]), 1)
+    HPDF_Outline_SetDestination(outline[2], dst)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 86 - 0
pdf.mod/libharu/bindings/python/demo/permission.py

@@ -0,0 +1,86 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- permission.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+text = "User cannot print and copy this document."
+owner_passwd = "owner"
+user_passwd = ""
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def main ():
+    global  pdf
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    HPDF_Page_SetSize (page, HPDF_PAGE_SIZE_B5, HPDF_PAGE_LANDSCAPE)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetFontAndSize (page, font, 20)
+    tw = HPDF_Page_TextWidth (page, text)
+    HPDF_Page_MoveTextPos (page, (HPDF_Page_GetWidth (page) - tw) / 2,
+                (HPDF_Page_GetHeight (page)  - 20) / 2)
+    HPDF_Page_ShowText (page, text)
+    HPDF_Page_EndText (page)
+
+    HPDF_SetPassword (pdf, owner_passwd, user_passwd)
+    HPDF_SetPermission (pdf, HPDF_ENABLE_READ)
+    HPDF_SetEncryptionMode (pdf, HPDF_ENCRYPT_R3, 16)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 143 - 0
pdf.mod/libharu/bindings/python/demo/png_demo.py

@@ -0,0 +1,143 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- png_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+def draw_image (pdf, filename, x, y, text):
+    page = HPDF_GetCurrentPage (pdf)
+
+    filename1= "pngsuite/%s" % filename
+
+    image = HPDF_LoadPngImageFromFile (pdf, filename1)
+
+    # Draw image to the canvas.
+    HPDF_Page_DrawImage (page, image, x, y, HPDF_Image_GetWidth (image),
+                    HPDF_Image_GetHeight (image))
+
+    # Print the text.
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetTextLeading (page, 16)
+    HPDF_Page_MoveTextPos (page, x, y)
+    HPDF_Page_ShowTextNextLine (page, filename)
+    HPDF_Page_ShowTextNextLine (page, text)
+    HPDF_Page_EndText (page)
+
+
+def main():
+    global pdf
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    HPDF_Page_SetWidth (page, 550)
+    HPDF_Page_SetHeight (page, 650)
+
+    dst = HPDF_Page_CreateDestination (page)
+    HPDF_Destination_SetXYZ (dst, 0, HPDF_Page_GetHeight (page), 1)
+    HPDF_SetOpenAction(pdf, dst)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetFontAndSize (page, font, 20)
+    HPDF_Page_MoveTextPos (page, 220, HPDF_Page_GetHeight (page) - 70)
+    HPDF_Page_ShowText (page, "PngDemo")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetFontAndSize (page, font, 12)
+
+    draw_image (pdf, "basn0g01.png", 100, HPDF_Page_GetHeight (page) - 150,
+                "1bit grayscale.")
+    draw_image (pdf, "basn0g02.png", 200, HPDF_Page_GetHeight (page) - 150,
+                "2bit grayscale.")
+    draw_image (pdf, "basn0g04.png", 300, HPDF_Page_GetHeight (page) - 150,
+                "4bit grayscale.")
+    draw_image (pdf, "basn0g08.png", 400, HPDF_Page_GetHeight (page) - 150,
+                "8bit grayscale.")
+
+    draw_image (pdf, "basn2c08.png", 100, HPDF_Page_GetHeight (page) - 250,
+                "8bit color.")
+    draw_image (pdf, "basn2c16.png", 200, HPDF_Page_GetHeight (page) - 250,
+                "16bit color.")
+
+    draw_image (pdf, "basn3p01.png", 100, HPDF_Page_GetHeight (page) - 350,
+                "1bit pallet.")
+    draw_image (pdf, "basn3p02.png", 200, HPDF_Page_GetHeight (page) - 350,
+                "2bit pallet.")
+    draw_image (pdf, "basn3p04.png", 300, HPDF_Page_GetHeight (page) - 350,
+                "4bit pallet.")
+    draw_image (pdf, "basn3p08.png", 400, HPDF_Page_GetHeight (page) - 350,
+                "8bit pallet.")
+
+    draw_image (pdf, "basn4a08.png", 100, HPDF_Page_GetHeight (page) - 450,
+                "8bit alpha.")
+    draw_image (pdf, "basn4a16.png", 200, HPDF_Page_GetHeight (page) - 450,
+                "16bit alpha.")
+
+    draw_image (pdf, "basn6a08.png", 100, HPDF_Page_GetHeight (page) - 550,
+                "8bit alpha.")
+    draw_image (pdf, "basn6a16.png", 200, HPDF_Page_GetHeight (page) - 550,
+                "16bit alpha.")
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+
+if HPDF_NOPNGLIB:
+    printf("WARNING: if you want to run this demo, \n"
+           "make libhpdf with HPDF_USE_PNGLIB option.\n")
+    sys.exit(1)
+else:
+    main()

+ 129 - 0
pdf.mod/libharu/bindings/python/demo/raw_image_demo.py

@@ -0,0 +1,129 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- raw_image_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+RAW_IMAGE_DATA=[
+    0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfc,
+    0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0,
+    0xf3, 0xf3, 0xff, 0xe0, 0xf3, 0xf3, 0xff, 0xc0,
+    0xf3, 0xf3, 0xff, 0x80, 0xf3, 0x33, 0xff, 0x00,
+    0xf3, 0x33, 0xfe, 0x00, 0xf3, 0x33, 0xfc, 0x00,
+    0xf8, 0x07, 0xf8, 0x00, 0xf8, 0x07, 0xf0, 0x00,
+    0xfc, 0xcf, 0xe0, 0x00, 0xfc, 0xcf, 0xc0, 0x00,
+    0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0x00, 0x00,
+    0xff, 0xfe, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00,
+    0xff, 0xf8, 0x0f, 0xe0, 0xff, 0xf0, 0x0f, 0xe0,
+    0xff, 0xe0, 0x0c, 0x30, 0xff, 0xc0, 0x0c, 0x30,
+    0xff, 0x80, 0x0f, 0xe0, 0xff, 0x00, 0x0f, 0xe0,
+    0xfe, 0x00, 0x0c, 0x30, 0xfc, 0x00, 0x0c, 0x30,
+    0xf8, 0x00, 0x0f, 0xe0, 0xf0, 0x00, 0x0f, 0xe0,
+    0xe0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00,
+    0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+]
+
+def main ():
+    global  pdf
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    HPDF_Page_SetWidth (page, 172)
+    HPDF_Page_SetHeight (page, 80)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetFontAndSize (page, font, 20)
+    HPDF_Page_MoveTextPos (page, 220, HPDF_Page_GetHeight (page) - 70)
+    HPDF_Page_ShowText (page, "RawImageDemo")
+    HPDF_Page_EndText (page)
+
+    # load RGB raw-image file.
+    image = HPDF_LoadRawImageFromFile (pdf, "rawimage/32_32_rgb.dat",
+            32, 32, HPDF_CS_DEVICE_RGB)
+
+    x = 20
+    y = 20
+
+    # Draw image to the canvas. (normal-mode with actual size.)
+    HPDF_Page_DrawImage (page, image, x, y, 32, 32)
+
+    # load GrayScale raw-image file.
+    image = HPDF_LoadRawImageFromFile (pdf, "rawimage/32_32_gray.dat",
+            32, 32, HPDF_CS_DEVICE_GRAY)
+
+    x = 70
+    y = 20
+
+    # Draw image to the canvas. (normal-mode with actual size.)
+    HPDF_Page_DrawImage (page, image, x, y, 32, 32)
+
+    # load GrayScale raw-image (1bit) file from memory.
+    image = HPDF_LoadRawImageFromMem (pdf, RAW_IMAGE_DATA, 32, 32,
+                HPDF_CS_DEVICE_GRAY, 1)
+
+    x = 120
+    y = 20
+
+    # Draw image to the canvas. (normal-mode with actual size.)
+    HPDF_Page_DrawImage (page, image, x, y, 32, 32)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 190 - 0
pdf.mod/libharu/bindings/python/demo/slide_show_demo.py

@@ -0,0 +1,190 @@
+###
+## * << Haru Free PDF Library 2.0.6 >> -- slideshow_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+import random
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def print_page  (page, caption, font, style, prev, next):
+    r = random.random()
+    g = random.random()
+    b = random.random()
+
+    rect=HPDF_Rect()
+
+    HPDF_Page_SetWidth (page, 800)
+    HPDF_Page_SetHeight (page, 600)
+
+    HPDF_Page_SetRGBFill (page, r, g, b)
+
+    HPDF_Page_Rectangle (page, 0, 0, 800, 600)
+    HPDF_Page_Fill (page)
+
+    HPDF_Page_SetRGBFill (page, 1.0 - r, 1.0 - g, 1.0 - b)
+
+    HPDF_Page_SetFontAndSize (page, font, 30)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetTextMatrix (page, 0.8, 0.0, 0.0, 1.0, 0.0, 0.0)
+    HPDF_Page_TextOut (page, 50, 530, caption)
+
+    HPDF_Page_SetTextMatrix (page, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0)
+    HPDF_Page_SetFontAndSize (page, font, 20)
+    HPDF_Page_TextOut (page, 55, 300,
+            "Type \"Ctrl+L\" in order to return from full screen mode.")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetSlideShow (page, style, 5.0, 1.0)
+
+    HPDF_Page_SetFontAndSize (page, font, 20)
+
+    if (next):
+        HPDF_Page_BeginText (page)
+        HPDF_Page_TextOut (page, 680, 50, "Next=>")
+        HPDF_Page_EndText (page)
+
+        rect.left = 680
+        rect.right = 750
+        rect.top = 70
+        rect.bottom = 50
+        dst = HPDF_Page_CreateDestination (next)
+        HPDF_Destination_SetFit(dst)
+        annot = HPDF_Page_CreateLinkAnnot (page, rect, dst)
+        HPDF_LinkAnnot_SetBorderStyle (annot, 0, 0, 0)
+        HPDF_LinkAnnot_SetHighlightMode (annot, HPDF_ANNOT_INVERT_BOX)
+
+
+    if (prev):
+        HPDF_Page_BeginText (page)
+        HPDF_Page_TextOut (page, 50, 50, "<=Prev")
+        HPDF_Page_EndText (page)
+
+        rect.left = 50
+        rect.right = 110
+        rect.top = 70
+        rect.bottom = 50
+        dst = HPDF_Page_CreateDestination (prev)
+        HPDF_Destination_SetFit(dst)
+        annot = HPDF_Page_CreateLinkAnnot (page, rect, dst)
+        HPDF_LinkAnnot_SetBorderStyle (annot, 0, 0, 0)
+        HPDF_LinkAnnot_SetHighlightMode (annot, HPDF_ANNOT_INVERT_BOX)
+
+def main():
+    global  pdf
+
+    page=[None for i in range(17)]
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Courier", NULL)
+
+    # Add 17 pages to the document.
+    page[0] = HPDF_AddPage (pdf)
+    page[1] = HPDF_AddPage (pdf)
+    page[2] = HPDF_AddPage (pdf)
+    page[3] = HPDF_AddPage (pdf)
+    page[4] = HPDF_AddPage (pdf)
+    page[5] = HPDF_AddPage (pdf)
+    page[6] = HPDF_AddPage (pdf)
+    page[7] = HPDF_AddPage (pdf)
+    page[8] = HPDF_AddPage (pdf)
+    page[9] = HPDF_AddPage (pdf)
+    page[10] = HPDF_AddPage (pdf)
+    page[11] = HPDF_AddPage (pdf)
+    page[12] = HPDF_AddPage (pdf)
+    page[13] = HPDF_AddPage (pdf)
+    page[14] = HPDF_AddPage (pdf)
+    page[15] = HPDF_AddPage (pdf)
+    page[16] = HPDF_AddPage (pdf)
+
+    print_page(page[0], "HPDF_TS_WIPE_RIGHT", font,
+			HPDF_TS_WIPE_RIGHT, NULL, page[1])
+    print_page(page[1], "HPDF_TS_WIPE_UP", font,
+			HPDF_TS_WIPE_UP, page[0], page[2])
+    print_page(page[2], "HPDF_TS_WIPE_LEFT", font,
+			HPDF_TS_WIPE_LEFT, page[1], page[3])
+    print_page(page[3], "HPDF_TS_WIPE_DOWN", font,
+			HPDF_TS_WIPE_DOWN, page[2], page[4])
+    print_page(page[4], "HPDF_TS_BARN_DOORS_HORIZONTAL_OUT", font,
+			HPDF_TS_BARN_DOORS_HORIZONTAL_OUT, page[3], page[5])
+    print_page(page[5], "HPDF_TS_BARN_DOORS_HORIZONTAL_IN", font,
+			HPDF_TS_BARN_DOORS_HORIZONTAL_IN, page[4], page[6])
+    print_page(page[6], "HPDF_TS_BARN_DOORS_VERTICAL_OUT", font,
+			HPDF_TS_BARN_DOORS_VERTICAL_OUT, page[5], page[7])
+    print_page(page[7], "HPDF_TS_BARN_DOORS_VERTICAL_IN", font,
+			HPDF_TS_BARN_DOORS_VERTICAL_IN, page[6], page[8])
+    print_page(page[8], "HPDF_TS_BOX_OUT", font,
+			HPDF_TS_BOX_OUT, page[7], page[9])
+    print_page(page[9], "HPDF_TS_BOX_IN", font,
+			HPDF_TS_BOX_IN, page[8], page[10])
+    print_page(page[10], "HPDF_TS_BLINDS_HORIZONTAL", font,
+			HPDF_TS_BLINDS_HORIZONTAL, page[9], page[11])
+    print_page(page[11], "HPDF_TS_BLINDS_VERTICAL", font,
+			HPDF_TS_BLINDS_VERTICAL, page[10], page[12])
+    print_page(page[12], "HPDF_TS_DISSOLVE", font,
+			HPDF_TS_DISSOLVE, page[11], page[13])
+    print_page(page[13], "HPDF_TS_GLITTER_RIGHT", font,
+			HPDF_TS_GLITTER_RIGHT, page[12], page[14])
+    print_page(page[14], "HPDF_TS_GLITTER_DOWN", font,
+			HPDF_TS_GLITTER_DOWN, page[13], page[15])
+    print_page(page[15], "HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT", font,
+			HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT, page[14], page[16])
+    print_page(page[16], "HPDF_TS_REPLACE", font,
+			HPDF_TS_REPLACE, page[15], NULL)
+
+
+    HPDF_SetPageMode (pdf, HPDF_PAGE_MODE_FULL_SCREEN)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 167 - 0
pdf.mod/libharu/bindings/python/demo/text_annotation.py

@@ -0,0 +1,167 @@
+#coding=utf-8
+###
+## * << Haru Free PDF Library 2.0.0 >> -- text_annotation.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def main():
+    rect1 =HPDF_Rect(50, 350, 150, 400)
+    rect2 =HPDF_Rect(210, 350, 350, 400)
+    rect3 =HPDF_Rect(50, 250, 150, 300)
+    rect4 =HPDF_Rect(210, 250, 350, 300)
+    rect5 =HPDF_Rect(50, 150, 150, 200)
+    rect6 =HPDF_Rect(210, 150, 350, 200)
+    rect7 =HPDF_Rect(50, 50, 150, 100)
+    rect8 =HPDF_Rect(210, 50, 350, 100)
+
+    global  pdf
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # use Times-Roman font.
+    font = HPDF_GetFont (pdf, "Times-Roman", "WinAnsiEncoding")
+
+    page = HPDF_AddPage (pdf)
+
+    HPDF_Page_SetWidth (page, 400)
+    HPDF_Page_SetHeight (page, 500)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetFontAndSize (page, font, 16)
+    HPDF_Page_MoveTextPos (page, 130, 450)
+    HPDF_Page_ShowText (page, "Annotation Demo")
+    HPDF_Page_EndText (page)
+
+
+    annot = HPDF_Page_CreateTextAnnot (page, rect1, "Annotation with Comment "
+                "Icon. \n This annotation set to be opened initially.",
+                NULL)
+
+    HPDF_TextAnnot_SetIcon (annot, HPDF_ANNOT_ICON_COMMENT)
+    HPDF_TextAnnot_SetOpened (annot, HPDF_TRUE)
+
+    annot = HPDF_Page_CreateTextAnnot (page, rect2,
+                "Annotation with Key Icon", NULL)
+    HPDF_TextAnnot_SetIcon (annot, HPDF_ANNOT_ICON_PARAGRAPH)
+
+    annot = HPDF_Page_CreateTextAnnot (page, rect3,
+                "Annotation with Note Icon", NULL)
+    HPDF_TextAnnot_SetIcon (annot, HPDF_ANNOT_ICON_NOTE)
+
+    annot = HPDF_Page_CreateTextAnnot (page, rect4,
+                "Annotation with Help Icon", NULL)
+    HPDF_TextAnnot_SetIcon (annot, HPDF_ANNOT_ICON_HELP)
+
+    annot = HPDF_Page_CreateTextAnnot (page, rect5,
+                "Annotation with NewParagraph Icon", NULL)
+    HPDF_TextAnnot_SetIcon (annot, HPDF_ANNOT_ICON_NEW_PARAGRAPH)
+
+    annot = HPDF_Page_CreateTextAnnot (page, rect6,
+                "Annotation with Paragraph Icon", NULL)
+    HPDF_TextAnnot_SetIcon (annot, HPDF_ANNOT_ICON_PARAGRAPH)
+
+    annot = HPDF_Page_CreateTextAnnot (page, rect7,
+                "Annotation with Insert Icon", NULL)
+    HPDF_TextAnnot_SetIcon (annot, HPDF_ANNOT_ICON_INSERT)
+
+    encoding = HPDF_GetEncoder (pdf, "ISO8859-2")
+
+    #HPDF_Page_CreateTextAnnot (page, rect8,
+    #            "Annotation with ISO8859 text 釉罩棕?, encoding)
+
+    HPDF_Page_SetFontAndSize (page, font, 11)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, rect1.left + 35, rect1.top - 20)
+    HPDF_Page_ShowText (page, "Comment Icon.")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, rect2.left + 35, rect2.top - 20)
+    HPDF_Page_ShowText (page, "Key Icon")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, rect3.left + 35, rect3.top - 20)
+    HPDF_Page_ShowText (page, "Note Icon.")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, rect4.left + 35, rect4.top - 20)
+    HPDF_Page_ShowText (page, "Help Icon")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, rect5.left + 35, rect5.top - 20)
+    HPDF_Page_ShowText (page, "NewParagraph Icon")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, rect6.left + 35, rect6.top - 20)
+    HPDF_Page_ShowText (page, "Paragraph Icon")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, rect7.left + 35, rect7.top - 20)
+    HPDF_Page_ShowText (page, "Insert Icon")
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, rect8.left + 35, rect8.top - 20)
+    HPDF_Page_ShowText (page, "Text Icon(ISO8859-2 text)")
+    HPDF_Page_EndText (page)
+
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 358 - 0
pdf.mod/libharu/bindings/python/demo/text_demo.py

@@ -0,0 +1,358 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- text_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+from grid_sheet import *
+
+from math import *
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+def show_stripe_pattern  (page, x, y):
+    iy = 0
+
+    while (iy < 50):
+        HPDF_Page_SetRGBStroke (page, 0.0, 0.0, 0.5)
+        HPDF_Page_SetLineWidth (page, 1)
+        HPDF_Page_MoveTo (page, x, y + iy)
+        HPDF_Page_LineTo (page, x + HPDF_Page_TextWidth (page, "ABCabc123"),
+                    y + iy)
+        HPDF_Page_Stroke (page)
+        iy += 3
+
+    HPDF_Page_SetLineWidth (page, 2.5)
+
+
+def show_description  (page, x, y, text):
+    fsize = HPDF_Page_GetCurrentFontSize (page)
+    font = HPDF_Page_GetCurrentFont (page)
+    c = HPDF_Page_GetRGBFill (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetRGBFill (page, 0, 0, 0)
+    HPDF_Page_SetTextRenderingMode (page, HPDF_FILL)
+    HPDF_Page_SetFontAndSize (page, font, 10)
+    HPDF_Page_TextOut (page, x, y - 12, text)
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetFontAndSize (page, font, fsize)
+    HPDF_Page_SetRGBFill (page, c.r, c.g, c.b)
+
+
+
+def main ():
+    global pdf
+
+    page_title = "Text Demo"
+
+
+    samp_text = "abcdefgABCDEFG123!#$%&+-@?"
+    samp_text2 = "The quick brown fox jumps over the lazy dog."
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # set compression mode
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+
+    # create default-font
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    # draw grid to the page
+    print_grid  (pdf, page)
+
+    # print the lines of the page.
+    HPDF_Page_SetLineWidth (page, 1)
+    HPDF_Page_Rectangle (page, 50, 50, HPDF_Page_GetWidth(page) - 100,
+                HPDF_Page_GetHeight (page) - 110)
+    HPDF_Page_Stroke (page)
+
+
+    # print the title of the page (with positioning center).
+    HPDF_Page_SetFontAndSize (page, font, 24)
+    tw = HPDF_Page_TextWidth (page, page_title)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, (HPDF_Page_GetWidth(page) - tw) / 2,
+                HPDF_Page_GetHeight (page) - 50, page_title)
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_MoveTextPos (page, 60, HPDF_Page_GetHeight(page) - 60)
+
+    # font size
+    fsize = 8
+    while (fsize < 60):
+
+        # set style and size of font.
+        HPDF_Page_SetFontAndSize(page, font, fsize)
+
+        # set the position of the text.
+        HPDF_Page_MoveTextPos (page, 0, -5 - fsize)
+
+        # measure the number of characters which included in the page.
+        buf= samp_text
+        length = HPDF_Page_MeasureText (page, samp_text,
+                        HPDF_Page_GetWidth(page) - 120, HPDF_FALSE, NULL)
+
+        # truncate the text.
+        buf='%*s\0' %(int(length), buf)
+
+        HPDF_Page_ShowText (page, buf)
+
+        # print the description.
+        HPDF_Page_MoveTextPos (page, 0, -10)
+        HPDF_Page_SetFontAndSize(page, font, 8)
+        buf="Fontsize=%.0f" %fsize
+        HPDF_Page_ShowText (page, buf)
+
+        fsize *= 1.5
+
+
+    # font color
+    HPDF_Page_SetFontAndSize(page, font, 8)
+    HPDF_Page_MoveTextPos (page, 0, -30)
+    HPDF_Page_ShowText (page, "Font color")
+
+    HPDF_Page_SetFontAndSize (page, font, 18)
+    HPDF_Page_MoveTextPos (page, 0, -20)
+    length = len (samp_text)
+    for i in range(length):
+        buf=[None ,None]
+        r = i / float(length)
+        g = 1 - (i / float(length))
+        buf[0] = samp_text[i]
+        buf[1] = '\0'
+
+        HPDF_Page_SetRGBFill (page, r, g, 0.0)
+        HPDF_Page_ShowText (page, buf)
+
+    HPDF_Page_MoveTextPos (page, 0, -25)
+
+    for i in range(length):
+        buf=[None ,None]
+        r = i / float(length)
+        b = 1 - (i / float(length))
+        buf[0] = samp_text[i]
+        buf[1] = '\0'
+
+        HPDF_Page_SetRGBFill (page, r, 0.0, b)
+        HPDF_Page_ShowText (page, buf)
+
+    HPDF_Page_MoveTextPos (page, 0, -25)
+
+    for i in range(length):
+        buf=[None ,None]
+        b = i / float(length)
+        g = 1 - (i / float(length))
+        buf[0] = samp_text[i]
+        buf[1] = '\0'
+
+        HPDF_Page_SetRGBFill (page, 0.0, g, b)
+        HPDF_Page_ShowText (page, buf)
+
+
+    HPDF_Page_EndText (page)
+
+    ypos = 450
+
+    #
+    # Font rendering mode
+    #
+    HPDF_Page_SetFontAndSize(page, font, 32)
+    HPDF_Page_SetRGBFill (page, 0.5, 0.5, 0.0)
+    HPDF_Page_SetLineWidth (page, 1.5)
+
+     # PDF_FILL
+    show_description (page,  60, ypos,
+                "RenderingMode=PDF_FILL")
+    HPDF_Page_SetTextRenderingMode (page, HPDF_FILL)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, 60, ypos, "ABCabc123")
+    HPDF_Page_EndText (page)
+
+    # PDF_STROKE
+    show_description (page, 60, ypos - 50,
+                "RenderingMode=PDF_STROKE")
+    HPDF_Page_SetTextRenderingMode (page, HPDF_STROKE)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, 60, ypos - 50, "ABCabc123")
+    HPDF_Page_EndText (page)
+
+    # PDF_FILL_THEN_STROKE
+    show_description (page, 60, ypos - 100,
+                "RenderingMode=PDF_FILL_THEN_STROKE")
+    HPDF_Page_SetTextRenderingMode (page, HPDF_FILL_THEN_STROKE)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, 60, ypos - 100, "ABCabc123")
+    HPDF_Page_EndText (page)
+
+    # PDF_FILL_CLIPPING
+    show_description (page, 60, ypos - 150,
+                "RenderingMode=PDF_FILL_CLIPPING")
+    HPDF_Page_GSave (page)
+    HPDF_Page_SetTextRenderingMode (page, HPDF_FILL_CLIPPING)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, 60, ypos - 150, "ABCabc123")
+    HPDF_Page_EndText (page)
+    show_stripe_pattern (page, 60, ypos - 150)
+    HPDF_Page_GRestore (page)
+
+    # PDF_STROKE_CLIPPING
+    show_description (page, 60, ypos - 200,
+                "RenderingMode=PDF_STROKE_CLIPPING")
+    HPDF_Page_GSave (page)
+    HPDF_Page_SetTextRenderingMode (page, HPDF_STROKE_CLIPPING)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, 60, ypos - 200, "ABCabc123")
+    HPDF_Page_EndText (page)
+    show_stripe_pattern (page, 60, ypos - 200)
+    HPDF_Page_GRestore (page)
+
+    # PDF_FILL_STROKE_CLIPPING
+    show_description (page, 60, ypos - 250,
+                "RenderingMode=PDF_FILL_STROKE_CLIPPING")
+    HPDF_Page_GSave (page)
+    HPDF_Page_SetTextRenderingMode (page, HPDF_FILL_STROKE_CLIPPING)
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, 60, ypos - 250, "ABCabc123")
+    HPDF_Page_EndText (page)
+    show_stripe_pattern (page, 60, ypos - 250)
+    HPDF_Page_GRestore (page)
+
+    # Reset text attributes
+    HPDF_Page_SetTextRenderingMode (page, HPDF_FILL)
+    HPDF_Page_SetRGBFill (page, 0, 0, 0)
+    HPDF_Page_SetFontAndSize(page, font, 30)
+
+
+    #
+    # Rotating text
+    #
+    angle1 = 30;                   # A rotation of 30 degrees.
+    rad1 = angle1 / 180 * 3.141592; # Calculate the radian value.
+
+    show_description (page, 320, ypos - 60, "Rotating text")
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetTextMatrix (page, cos(rad1), sin(rad1), -sin(rad1), cos(rad1),
+                330, ypos - 60)
+    HPDF_Page_ShowText (page, "ABCabc123")
+    HPDF_Page_EndText (page)
+
+
+    #
+    # Skewing text.
+    #
+    show_description (page, 320, ypos - 120, "Skewing text")
+    HPDF_Page_BeginText (page)
+
+    angle1 = 10
+    angle2 = 20
+    rad1 = angle1 / 180 * 3.141592
+    rad2 = angle2 / 180 * 3.141592
+
+    HPDF_Page_SetTextMatrix (page, 1, tan(rad1), tan(rad2), 1, 320, ypos - 120)
+    HPDF_Page_ShowText (page, "ABCabc123")
+    HPDF_Page_EndText (page)
+
+
+    #
+    # scaling text (X direction)
+    #
+    show_description (page, 320, ypos - 175, "Scaling text (X direction)")
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetTextMatrix (page, 1.5, 0, 0, 1, 320, ypos - 175)
+    HPDF_Page_ShowText (page, "ABCabc12")
+    HPDF_Page_EndText (page)
+
+
+    #
+    # scaling text (Y direction)
+    #
+    show_description (page, 320, ypos - 250, "Scaling text (Y direction)")
+    HPDF_Page_BeginText (page)
+    HPDF_Page_SetTextMatrix (page, 1, 0, 0, 2, 320, ypos - 250)
+    HPDF_Page_ShowText (page, "ABCabc123")
+    HPDF_Page_EndText (page)
+
+
+    #
+    # char spacing, word spacing
+    #
+
+    show_description (page, 60, 140, "char-spacing 0")
+    show_description (page, 60, 100, "char-spacing 1.5")
+    show_description (page, 60, 60, "char-spacing 1.5, word-spacing 2.5")
+
+    HPDF_Page_SetFontAndSize (page, font, 20)
+    HPDF_Page_SetRGBFill (page, 0.1, 0.3, 0.1)
+
+    ## char-spacing 0
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, 60, 140, samp_text2)
+    HPDF_Page_EndText (page)
+
+    # char-spacing 1.5
+    HPDF_Page_SetCharSpace (page, 1.5)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, 60, 100, samp_text2)
+    HPDF_Page_EndText (page)
+
+    # char-spacing 1.5, word-spacing 3.5
+    HPDF_Page_SetWordSpace (page, 2.5)
+
+    HPDF_Page_BeginText (page)
+    HPDF_Page_TextOut (page, 60, 60, samp_text2)
+    HPDF_Page_EndText (page)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 271 - 0
pdf.mod/libharu/bindings/python/demo/text_demo2.py

@@ -0,0 +1,271 @@
+###
+## * << Alternative PDF Library 1.0.0 >> -- text_demo2.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+
+from grid_sheet import *
+
+from math import *
+
+
+global pdf
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler  (error_no, detail_no, user_data):
+    printf ("ERROR: error_no=%04X, detail_no=%u\n", error_no,
+                detail_no)
+    HPDF_Free (pdf)
+
+
+global no
+no = 0
+
+def PrintText(page):
+    #char buf[512]
+    pos = HPDF_Page_GetCurrentTextPos (page)
+
+    no+=1
+    buf=".[%d]%0.2f %0.2f" %( no, pos.x, pos.y)
+    HPDF_Page_ShowText(page, buf)
+
+
+def main ():
+    global pdf
+
+    rect=HPDF_Rect()
+
+    SAMP_TXT = "The quick brown fox jumps over the lazy dog. "
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+    HPDF_Page_SetSize (page, HPDF_PAGE_SIZE_A5, HPDF_PAGE_PORTRAIT)
+
+    print_grid  (pdf, page)
+
+    page_height = HPDF_Page_GetHeight (page)
+
+    font = HPDF_GetFont (pdf, "Helvetica", NULL)
+    HPDF_Page_SetTextLeading (page, 20)
+
+    # text_rect method
+
+    # HPDF_TALIGN_LEFT
+    rect.left = 25
+    rect.top = 545
+    rect.right = 200
+    rect.bottom = rect.top - 40
+
+    HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
+                rect.top - rect.bottom)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_BeginText (page)
+
+    HPDF_Page_SetFontAndSize (page, font, 10)
+    HPDF_Page_TextOut (page, rect.left, rect.top + 3, "HPDF_TALIGN_LEFT")
+
+    HPDF_Page_SetFontAndSize (page, font, 13)
+    HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
+                SAMP_TXT, HPDF_TALIGN_LEFT, NULL)
+
+    HPDF_Page_EndText (page)
+
+    # HPDF_TALIGN_RIGTH
+    rect.left = 220
+    rect.right = 395
+
+    HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
+                rect.top - rect.bottom)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_BeginText (page)
+
+    HPDF_Page_SetFontAndSize (page, font, 10)
+    HPDF_Page_TextOut (page, rect.left, rect.top + 3, "HPDF_TALIGN_RIGTH")
+
+    HPDF_Page_SetFontAndSize (page, font, 13)
+    HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
+                SAMP_TXT, HPDF_TALIGN_RIGHT, NULL)
+
+    HPDF_Page_EndText (page)
+
+    # HPDF_TALIGN_CENTER
+    rect.left = 25
+    rect.top = 475
+    rect.right = 200
+    rect.bottom = rect.top - 40
+
+    HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
+                rect.top - rect.bottom)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_BeginText (page)
+
+    HPDF_Page_SetFontAndSize (page, font, 10)
+    HPDF_Page_TextOut (page, rect.left, rect.top + 3, "HPDF_TALIGN_CENTER")
+
+    HPDF_Page_SetFontAndSize (page, font, 13)
+    HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
+                SAMP_TXT, HPDF_TALIGN_CENTER, NULL)
+
+    HPDF_Page_EndText (page)
+
+    # HPDF_TALIGN_JUSTIFY
+    rect.left = 220
+    rect.right = 395
+
+    HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
+                rect.top - rect.bottom)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_BeginText (page)
+
+    HPDF_Page_SetFontAndSize (page, font, 10)
+    HPDF_Page_TextOut (page, rect.left, rect.top + 3, "HPDF_TALIGN_JUSTIFY")
+
+    HPDF_Page_SetFontAndSize (page, font, 13)
+    HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
+                SAMP_TXT, HPDF_TALIGN_JUSTIFY, NULL)
+
+    HPDF_Page_EndText (page)
+
+
+
+    # Skewed coordinate system
+    HPDF_Page_GSave (page)
+
+    angle1 = 5
+    angle2 = 10
+    rad1 = angle1 / 180 * 3.141592
+    rad2 = angle2 / 180 * 3.141592
+
+    HPDF_Page_Concat (page, 1, tan(rad1), tan(rad2), 1, 25, 350)
+    rect.left = 0
+    rect.top = 40
+    rect.right = 175
+    rect.bottom = 0
+
+    HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
+                rect.top - rect.bottom)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_BeginText (page)
+
+    HPDF_Page_SetFontAndSize (page, font, 10)
+    HPDF_Page_TextOut (page, rect.left, rect.top + 3, "Skewed coordinate system")
+
+    HPDF_Page_SetFontAndSize (page, font, 13)
+    HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
+                SAMP_TXT, HPDF_TALIGN_LEFT, NULL)
+
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_GRestore (page)
+
+
+    # Rotated coordinate system
+    HPDF_Page_GSave (page)
+
+    angle1 = 5
+    rad1 = angle1 / 180 * 3.141592
+
+    HPDF_Page_Concat (page, cos(rad1), sin(rad1), -sin(rad1), cos(rad1), 220, 350)
+    rect.left = 0
+    rect.top = 40
+    rect.right = 175
+    rect.bottom = 0
+
+    HPDF_Page_Rectangle (page, rect.left, rect.bottom, rect.right - rect.left,
+                rect.top - rect.bottom)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_BeginText (page)
+
+    HPDF_Page_SetFontAndSize (page, font, 10)
+    HPDF_Page_TextOut (page, rect.left, rect.top + 3, "Rotated coordinate system")
+
+    HPDF_Page_SetFontAndSize (page, font, 13)
+    HPDF_Page_TextRect (page, rect.left, rect.top, rect.right, rect.bottom,
+                SAMP_TXT, HPDF_TALIGN_LEFT, NULL)
+
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_GRestore (page)
+
+
+    # text along a circle
+    HPDF_Page_SetGrayStroke (page, 0)
+    HPDF_Page_Circle (page, 210, 190, 145)
+    HPDF_Page_Circle (page, 210, 190, 113)
+    HPDF_Page_Stroke (page)
+
+    angle1 = 360.0 / (len (SAMP_TXT))
+    angle2 = 180
+
+    HPDF_Page_BeginText (page)
+    font = HPDF_GetFont (pdf, "Courier-Bold", NULL)
+    HPDF_Page_SetFontAndSize (page, font, 30)
+
+    for i in range(len (SAMP_TXT)):
+        buf=[None, None]
+
+        rad1 = (angle2 - 90) / 180 * 3.141592
+        rad2 = angle2 / 180 * 3.141592
+
+        x = 210 + cos(rad2) * 122
+        y = 190 + sin(rad2) * 122
+
+        HPDF_Page_SetTextMatrix(page, cos(rad1), sin(rad1), -sin(rad1), cos(rad1), x, y)
+
+        buf[0] = SAMP_TXT[i]
+        buf[1] = chr(0)
+        HPDF_Page_ShowText (page, buf)
+        angle2 -= angle1
+
+    HPDF_Page_EndText (page)
+
+    # save the document to a file
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+
+main()

+ 139 - 0
pdf.mod/libharu/bindings/python/demo/ttfont_demo.py

@@ -0,0 +1,139 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- ttfont_demo.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def main ():
+    global pdf
+
+    SAMP_TXT = "The quick brown fox jumps over the lazy dog."
+
+    if (len(sys.argv) < 2):
+        printf("usage: ttfont_demo [path to font file] "
+                "-E(embedding font).\n")
+        return 1
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+    # Add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    title_font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    if (len(sys.argv) > 2 and sys.argv[2]=="-E"):
+        embed = HPDF_TRUE
+    else:
+        embed = HPDF_FALSE
+
+    detail_font_name = HPDF_LoadTTFontFromFile (pdf, sys.argv[1], embed)
+
+    detail_font = HPDF_GetFont (pdf, detail_font_name, NULL)
+
+    HPDF_Page_SetFontAndSize (page, title_font, 10)
+
+    HPDF_Page_BeginText (page)
+
+    # Move the position of the text to top of the page.
+    HPDF_Page_MoveTextPos(page, 10, 190)
+    HPDF_Page_ShowText (page, detail_font_name)
+
+    if (embed):
+        HPDF_Page_ShowText (page, "(Embedded Subset)")
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 15)
+    HPDF_Page_MoveTextPos (page, 10, -20)
+    HPDF_Page_ShowText (page, "abcdefghijklmnopqrstuvwxyz")
+    HPDF_Page_MoveTextPos (page, 0, -20)
+    HPDF_Page_ShowText (page, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+    HPDF_Page_MoveTextPos (page, 0, -20)
+    HPDF_Page_ShowText (page, "1234567890")
+    HPDF_Page_MoveTextPos (page, 0, -20)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 10)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -18)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 16)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -27)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 23)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -36)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 30)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -36)
+
+    pw = HPDF_Page_TextWidth (page, SAMP_TXT)
+    page_height = 210
+    page_width = pw + 40
+
+    HPDF_Page_SetWidth (page, page_width)
+    HPDF_Page_SetHeight (page, page_height)
+
+    # Finish to print text.
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetLineWidth (page, 0.5)
+
+    HPDF_Page_MoveTo (page, 10, page_height - 25)
+    HPDF_Page_LineTo (page, page_width - 10, page_height - 25)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_MoveTo (page, 10, page_height - 85)
+    HPDF_Page_LineTo (page, page_width - 10, page_height - 85)
+    HPDF_Page_Stroke (page)
+
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 160 - 0
pdf.mod/libharu/bindings/python/demo/ttfont_demo_cn.py

@@ -0,0 +1,160 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- ttfont_demo_jp.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def main ():
+    global  pdf
+
+    if (len(sys.argv) < 2):
+        printf ("ttfont_demo_cn <ttf-font-filename> [-E]\n")
+        printf ("ttfont_demo_cn <ttc-font-filename> <index> [-E]\n")
+        print
+        printf (r"for example, ttfont_demo_cn.py c:\winnt\fonts\simfang.ttf  -E")
+        return 1
+
+    try:
+        f = open ("mbtext/cp936.txt", "rb")
+    except:
+        printf ("error: cannot open 'mbtext/cp936.txt'\n")
+        return 1
+
+
+    SAMP_TXT=f.read(2048)
+    f.close()
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+
+    # declaration for using Japanese encoding.
+    HPDF_UseCNSEncodings (pdf)
+
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+
+    # load ttc file
+    if len(sys.argv) == 4 and sys.argv[3]=="-E":
+        detail_font_name = HPDF_LoadTTFontFromFile2 (pdf, sys.argv[1],
+                int (sys.argv[2]), HPDF_TRUE)
+    elif len(sys.argv) == 3 and sys.argv[2]=="-E":
+        detail_font_name = HPDF_LoadTTFontFromFile (pdf, sys.argv[1], HPDF_TRUE)
+    elif len(sys.argv) == 3:
+        detail_font_name = HPDF_LoadTTFontFromFile2 (pdf, sys.argv[1],
+                int (sys.argv[2]), HPDF_FALSE)
+    else:
+        detail_font_name = HPDF_LoadTTFontFromFile (pdf, sys.argv[1], HPDF_FALSE)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    title_font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    detail_font = HPDF_GetFont (pdf, detail_font_name, "GB-EUC-H")
+
+    HPDF_Page_SetFontAndSize (page, title_font, 10)
+
+    HPDF_Page_BeginText (page)
+
+    # move the position of the text to top of the page.
+    HPDF_Page_MoveTextPos(page, 10, 190)
+    HPDF_Page_ShowText (page, detail_font_name)
+    HPDF_Page_ShowText (page, " (")
+    HPDF_Page_ShowText (page, HPDF_Font_GetEncodingName (detail_font))
+    HPDF_Page_ShowText (page, ")")
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 15)
+    HPDF_Page_MoveTextPos (page, 10, -20)
+    HPDF_Page_ShowText (page, "abcdefghijklmnopqrstuvwxyz")
+    HPDF_Page_MoveTextPos (page, 0, -20)
+    HPDF_Page_ShowText (page, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+    HPDF_Page_MoveTextPos (page, 0, -20)
+    HPDF_Page_ShowText (page, "1234567890")
+    HPDF_Page_MoveTextPos (page, 0, -20)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 10)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -18)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 16)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -27)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 23)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -36)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 30)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -36)
+
+    pw = HPDF_Page_TextWidth (page, SAMP_TXT)
+    page_height = 210
+    page_width = pw + 40
+
+    HPDF_Page_SetWidth (page, page_width)
+    HPDF_Page_SetHeight (page, page_height)
+
+    # finish to print text.
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetLineWidth (page, 0.5)
+
+    HPDF_Page_MoveTo (page, 10, page_height - 25)
+    HPDF_Page_LineTo (page, page_width - 10, page_height - 25)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_MoveTo (page, 10, page_height - 85)
+    HPDF_Page_LineTo (page, page_width - 10, page_height - 85)
+    HPDF_Page_Stroke (page)
+
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 158 - 0
pdf.mod/libharu/bindings/python/demo/ttfont_demo_jp.py

@@ -0,0 +1,158 @@
+###
+## * << Haru Free PDF Library 2.0.0 >> -- ttfont_demo_jp.c
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os, sys
+
+from ctypes import *
+up=2
+def setlibpath(up):
+    import sys
+    path=os.path.normpath(os.path.split(os.path.realpath(__file__))[0]+'\..'*up)
+    if path not in sys.path:
+        sys.path.append(path)
+
+setlibpath(up)
+
+from haru import *
+from haru.c_func import *
+from haru.hpdf_errorcode import *
+
+
+@HPDF_Error_Handler(None, HPDF_UINT, HPDF_UINT, c_void_p)
+def error_handler (error_no, detail_no, user_data):
+    global pdf
+    printf ("ERROR: %s, detail_no=%u\n", error_detail[error_no],
+                detail_no)
+    HPDF_Free (pdf)
+    sys.exit(1)
+
+
+def main ():
+    global  pdf
+
+    if (len(sys.argv) < 2):
+        printf ("ttfont_jp_demo <ttf-font-filename> [-E]\n")
+        printf ("ttfont_jp_demo <ttc-font-filename> <index> [-E]\n")
+        return 1
+
+    try:
+        f = open ("mbtext/sjis.txt", "rb")
+    except:
+        printf ("error: cannot open 'mbtext/sjis.txt'\n")
+        return 1
+
+
+    SAMP_TXT=f.read(2048)
+    f.close()
+
+    fname=os.path.realpath(sys.argv[0])
+    fname=fname[:fname.rfind('.')]+'.pdf'
+
+    pdf = HPDF_New (error_handler, NULL)
+    if (not pdf):
+        printf ("error: cannot create PdfDoc object\n")
+        return 1
+
+
+    # declaration for using Japanese encoding.
+    HPDF_UseJPEncodings (pdf)
+
+    HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL)
+
+    # load ttc file
+    if len(sys.argv) == 4 and sys.argv[3]=="-E":
+        detail_font_name = HPDF_LoadTTFontFromFile2 (pdf, sys.argv[1],
+                int (sys.argv[2]), HPDF_TRUE)
+    elif len(sys.argv) == 3 and sys.argv[2]=="-E":
+        detail_font_name = HPDF_LoadTTFontFromFile (pdf, sys.argv[1], HPDF_TRUE)
+    elif len(sys.argv) == 3:
+        detail_font_name = HPDF_LoadTTFontFromFile2 (pdf, sys.argv[1],
+                int (sys.argv[2]), HPDF_FALSE)
+    else:
+        detail_font_name = HPDF_LoadTTFontFromFile (pdf, sys.argv[1], HPDF_FALSE)
+
+    # add a new page object.
+    page = HPDF_AddPage (pdf)
+
+    title_font = HPDF_GetFont (pdf, "Helvetica", NULL)
+
+    detail_font = HPDF_GetFont (pdf, detail_font_name, "90msp-RKSJ-H")
+
+    HPDF_Page_SetFontAndSize (page, title_font, 10)
+
+    HPDF_Page_BeginText (page)
+
+    # move the position of the text to top of the page.
+    HPDF_Page_MoveTextPos(page, 10, 190)
+    HPDF_Page_ShowText (page, detail_font_name)
+    HPDF_Page_ShowText (page, " (")
+    HPDF_Page_ShowText (page, HPDF_Font_GetEncodingName (detail_font))
+    HPDF_Page_ShowText (page, ")")
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 15)
+    HPDF_Page_MoveTextPos (page, 10, -20)
+    HPDF_Page_ShowText (page, "abcdefghijklmnopqrstuvwxyz")
+    HPDF_Page_MoveTextPos (page, 0, -20)
+    HPDF_Page_ShowText (page, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+    HPDF_Page_MoveTextPos (page, 0, -20)
+    HPDF_Page_ShowText (page, "1234567890")
+    HPDF_Page_MoveTextPos (page, 0, -20)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 10)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -18)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 16)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -27)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 23)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -36)
+
+    HPDF_Page_SetFontAndSize (page, detail_font, 30)
+    HPDF_Page_ShowText (page, SAMP_TXT)
+    HPDF_Page_MoveTextPos (page, 0, -36)
+
+    pw = HPDF_Page_TextWidth (page, SAMP_TXT)
+    page_height = 210
+    page_width = pw + 40
+
+    HPDF_Page_SetWidth (page, page_width)
+    HPDF_Page_SetHeight (page, page_height)
+
+    # finish to print text.
+    HPDF_Page_EndText (page)
+
+    HPDF_Page_SetLineWidth (page, 0.5)
+
+    HPDF_Page_MoveTo (page, 10, page_height - 25)
+    HPDF_Page_LineTo (page, page_width - 10, page_height - 25)
+    HPDF_Page_Stroke (page)
+
+    HPDF_Page_MoveTo (page, 10, page_height - 85)
+    HPDF_Page_LineTo (page, page_width - 10, page_height - 85)
+    HPDF_Page_Stroke (page)
+
+    HPDF_SaveToFile (pdf, fname)
+
+    # clean up
+    HPDF_Free (pdf)
+
+    return 0
+
+main()

+ 2103 - 0
pdf.mod/libharu/bindings/python/hpdf.py

@@ -0,0 +1,2103 @@
+##
+## * << Haru Free PDF Library 2.0.8 >> -- hpdf.h
+## *
+## * URL http://libharu.org/
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+import os
+import sys
+
+import types
+
+def setpath():
+    dllpath='%s/dll' %(os.path.dirname(os.path.realpath(__file__)))
+    if 'PATH' in os.environ:
+        if dllpath not in os.environ['PATH']:
+            os.environ['PATH']='%s;%s' % (dllpath, os.environ['PATH'])
+    else:
+        os.environ['PATH']=dllpath
+setpath()
+
+
+from hpdf_consts import *
+from hpdf_types import *
+
+if os.sys.platform=='win32':
+    harudll='libhpdf.dll'
+    #haru=WinDLL(harudll)
+    haru=CDLL(harudll)
+else:
+    harudll='libhpdf.so'
+    haru=CDLL(harudll)
+
+HPDF_HANDLE=c_void_p
+HPDF_Doc=HPDF_HANDLE
+HPDF_Page=HPDF_HANDLE
+HPDF_Pages=HPDF_HANDLE
+HPDF_Stream=HPDF_HANDLE
+HPDF_Image=HPDF_HANDLE
+HPDF_Font=HPDF_HANDLE
+HPDF_Outline=HPDF_HANDLE
+HPDF_Encoder=HPDF_HANDLE
+HPDF_Destination=HPDF_HANDLE
+HPDF_XObject=HPDF_HANDLE
+HPDF_Annotation=HPDF_HANDLE
+HPDF_ExtGState=HPDF_HANDLE
+
+
+#const char * HPDF_GetVersion (void)
+HPDF_GetVersion=haru.HPDF_GetVersion
+HPDF_GetVersion.restype=c_char_p
+
+
+#HPDF_Doc HPDF_NewEx (HPDF_Error_Handler user_error_fn, HPDF_Alloc_Func user_alloc_fn, HPDF_Free_Func user_free_fn, HPDF_UINT mem_pool_buf_size, void *user_data)
+HPDF_NewEx=haru.HPDF_NewEx
+HPDF_NewEx.restype=HPDF_Doc
+
+
+#HPDF_Doc HPDF_New (HPDF_Error_Handler user_error_fn, void *user_data)
+HPDF_New=haru.HPDF_New
+HPDF_New.restype=HPDF_Doc
+
+
+#HPDF_STATUS HPDF_SetErrorHandler (HPDF_Doc pdf, HPDF_Error_Handler user_error_fn)
+HPDF_SetErrorHandler=haru.HPDF_SetErrorHandler
+HPDF_SetErrorHandler.restype=HPDF_STATUS
+
+
+#void HPDF_Free (HPDF_Doc pdf)
+HPDF_Free=haru.HPDF_Free
+HPDF_Free.restype=None
+
+
+#HPDF_STATUS HPDF_NewDoc (HPDF_Doc pdf)
+HPDF_NewDoc=haru.HPDF_NewDoc
+HPDF_NewDoc.restype=HPDF_STATUS
+
+
+#void HPDF_FreeDoc (HPDF_Doc pdf)
+HPDF_FreeDoc=haru.HPDF_FreeDoc
+HPDF_FreeDoc.restype=None
+
+
+#HPDF_BOOL HPDF_HasDoc (HPDF_Doc pdf)
+HPDF_HasDoc=haru.HPDF_HasDoc
+HPDF_HasDoc.restype=HPDF_BOOL
+
+
+#void HPDF_FreeDocAll (HPDF_Doc pdf)
+HPDF_FreeDocAll=haru.HPDF_FreeDocAll
+HPDF_FreeDocAll.restype=None
+
+
+#HPDF_STATUS HPDF_SaveToStream (HPDF_Doc pdf)
+HPDF_SaveToStream=haru.HPDF_SaveToStream
+HPDF_SaveToStream.restype=HPDF_STATUS
+
+
+#HPDF_UINT32 HPDF_GetStreamSize (HPDF_Doc pdf)
+HPDF_GetStreamSize=haru.HPDF_GetStreamSize
+HPDF_GetStreamSize.restype=HPDF_UINT32
+
+
+#HPDF_STATUS HPDF_ReadFromStream (HPDF_Doc pdf, HPDF_BYTE *buf, HPDF_UINT32 *size)
+_HPDF_ReadFromStream=haru.HPDF_ReadFromStream
+_HPDF_ReadFromStream.restype=HPDF_STATUS
+def HPDF_ReadFromStream(
+                        pdf,    #HPDF_Doc
+                        buf,    #POINTER(HPDF_BYTE)
+                        size,    #POINTER(HPDF_UINT32)
+                       ):
+    if type(buf) in (types.ListType, types.TupleType):
+        size=len(buf)
+        buf=pointer((HPDF_BYTE*size)(*buf))
+    size=HPDF_UINT32(int(size))
+    return _HPDF_ReadFromStream(
+                                pdf,    #HPDF_Doc
+                                buf,    #POINTER(HPDF_BYTE)
+                                size,    #POINTER(HPDF_UINT32)
+                               )
+
+
+#HPDF_STATUS HPDF_ResetStream (HPDF_Doc pdf)
+HPDF_ResetStream=haru.HPDF_ResetStream
+HPDF_ResetStream.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_SaveToFile (HPDF_Doc pdf, const char *file_name)
+HPDF_SaveToFile=haru.HPDF_SaveToFile
+HPDF_SaveToFile.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_GetError (HPDF_Doc pdf)
+HPDF_GetError=haru.HPDF_GetError
+HPDF_GetError.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_GetErrorDetail (HPDF_Doc pdf)
+HPDF_GetErrorDetail=haru.HPDF_GetErrorDetail
+HPDF_GetErrorDetail.restype=HPDF_STATUS
+
+
+#void HPDF_ResetError (HPDF_Doc pdf)
+HPDF_ResetError=haru.HPDF_ResetError
+HPDF_ResetError.restype=None
+
+
+#HPDF_STATUS HPDF_SetPagesConfiguration (HPDF_Doc pdf, HPDF_UINT page_per_pages)
+_HPDF_SetPagesConfiguration=haru.HPDF_SetPagesConfiguration
+_HPDF_SetPagesConfiguration.restype=HPDF_STATUS
+def HPDF_SetPagesConfiguration(
+                               pdf,    #HPDF_Doc
+                               page_per_pages,    #HPDF_UINT
+                              ):
+    page_per_pages=HPDF_UINT(int(page_per_pages))
+    return _HPDF_SetPagesConfiguration(
+                                       pdf,    #HPDF_Doc
+                                       page_per_pages,    #HPDF_UINT
+                                      )
+
+
+#HPDF_Page HPDF_GetPageByIndex (HPDF_Doc pdf, HPDF_UINT index)
+HPDF_GetPageByIndex=haru.HPDF_GetPageByIndex
+HPDF_GetPageByIndex.restype=HPDF_Page
+
+
+#---------------------------------------------------------------------------
+#---------------------------------------------------------------------------
+#HPDF_PageLayout HPDF_GetPageLayout (HPDF_Doc pdf)
+HPDF_GetPageLayout=haru.HPDF_GetPageLayout
+HPDF_GetPageLayout.restype=HPDF_PageLayout
+
+
+#HPDF_STATUS HPDF_SetPageLayout (HPDF_Doc pdf, HPDF_PageLayout layout)
+HPDF_SetPageLayout=haru.HPDF_SetPageLayout
+HPDF_SetPageLayout.restype=HPDF_STATUS
+
+
+#HPDF_PageMode HPDF_GetPageMode (HPDF_Doc pdf)
+HPDF_GetPageMode=haru.HPDF_GetPageMode
+HPDF_GetPageMode.restype=HPDF_PageMode
+
+
+#HPDF_STATUS HPDF_SetPageMode (HPDF_Doc pdf, HPDF_PageMode mode)
+HPDF_SetPageMode=haru.HPDF_SetPageMode
+HPDF_SetPageMode.restype=HPDF_STATUS
+
+
+#HPDF_UINT HPDF_GetViewerPreference (HPDF_Doc pdf)
+HPDF_GetViewerPreference=haru.HPDF_GetViewerPreference
+HPDF_GetViewerPreference.restype=HPDF_UINT
+
+
+#HPDF_STATUS HPDF_SetViewerPreference (HPDF_Doc pdf, HPDF_UINT value)
+HPDF_SetViewerPreference=haru.HPDF_SetViewerPreference
+HPDF_SetViewerPreference.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_SetOpenAction (HPDF_Doc pdf, HPDF_Destination open_action)
+HPDF_SetOpenAction=haru.HPDF_SetOpenAction
+HPDF_SetOpenAction.restype=HPDF_STATUS
+
+
+#---------------------------------------------------------------------------
+#----- page handling -------------------------------------------------------
+
+
+#HPDF_Page HPDF_GetCurrentPage (HPDF_Doc pdf)
+HPDF_GetCurrentPage=haru.HPDF_GetCurrentPage
+HPDF_GetCurrentPage.restype=HPDF_Page
+
+
+#HPDF_Page HPDF_AddPage (HPDF_Doc pdf)
+HPDF_AddPage=haru.HPDF_AddPage
+HPDF_AddPage.restype=HPDF_Page
+
+
+#HPDF_Page HPDF_InsertPage (HPDF_Doc pdf, HPDF_Page page)
+HPDF_InsertPage=haru.HPDF_InsertPage
+HPDF_InsertPage.restype=HPDF_Page
+
+
+#HPDF_STATUS HPDF_Page_SetWidth (HPDF_Page page, HPDF_REAL value)
+_HPDF_Page_SetWidth=haru.HPDF_Page_SetWidth
+_HPDF_Page_SetWidth.restype=HPDF_STATUS
+def HPDF_Page_SetWidth(
+                       page,    #HPDF_Page
+                       value,    #HPDF_REAL
+                      ):
+    value=HPDF_REAL(value)
+    return _HPDF_Page_SetWidth(
+                               page,    #HPDF_Page
+                               value,    #HPDF_REAL
+                              )
+
+
+#HPDF_STATUS HPDF_Page_SetHeight (HPDF_Page page, HPDF_REAL value)
+_HPDF_Page_SetHeight=haru.HPDF_Page_SetHeight
+_HPDF_Page_SetHeight.restype=HPDF_STATUS
+def HPDF_Page_SetHeight(
+                        page,    #HPDF_Page
+                        value,    #HPDF_REAL
+                       ):
+    value=HPDF_REAL(value)
+    return _HPDF_Page_SetHeight(
+                                page,    #HPDF_Page
+                                value,    #HPDF_REAL
+                               )
+
+
+#HPDF_STATUS
+#HPDF_Page_SetSize  (HPDF_Page            page,
+#                    HPDF_PageSizes       size,
+#                    HPDF_PageDirection   direction);
+HPDF_Page_SetSize=haru.HPDF_Page_SetSize
+HPDF_Page_SetSize.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_Page_SetRotate (HPDF_Page page, HPDF_UINT16 angle)
+_HPDF_Page_SetRotate=haru.HPDF_Page_SetRotate
+_HPDF_Page_SetRotate.restype=HPDF_STATUS
+def HPDF_Page_SetRotate(
+                        page,    #HPDF_Page
+                        angle,    #HPDF_UINT16
+                       ):
+    angle=HPDF_UINT16(int(angle))
+    return _HPDF_Page_SetRotate(
+                                page,    #HPDF_Page
+                                angle,    #HPDF_UINT16
+                               )
+
+#---------------------------------------------------------------------------
+#----- font handling -------------------------------------------------------
+
+
+#HPDF_Font HPDF_GetFont (HPDF_Doc pdf, const char *font_name, const char *encoding_name)
+HPDF_GetFont=haru.HPDF_GetFont
+HPDF_GetFont.restype=HPDF_Font
+
+
+#const char* HPDF_LoadType1FontFromFile (HPDF_Doc pdf, const char *afm_file_name, const char *data_file_name)
+HPDF_LoadType1FontFromFile=haru.HPDF_LoadType1FontFromFile
+HPDF_LoadType1FontFromFile.restype=c_char_p
+
+
+#const char* HPDF_LoadTTFontFromFile (HPDF_Doc pdf, const char *file_name, HPDF_BOOL embedding)
+HPDF_LoadTTFontFromFile=haru.HPDF_LoadTTFontFromFile
+HPDF_LoadTTFontFromFile.restype=c_char_p
+
+
+#const char* HPDF_LoadTTFontFromFile2 (HPDF_Doc pdf, const char *file_name, HPDF_UINT index, HPDF_BOOL embedding)
+HPDF_LoadTTFontFromFile2=haru.HPDF_LoadTTFontFromFile2
+HPDF_LoadTTFontFromFile2.restype=c_char_p
+
+
+#HPDF_STATUS HPDF_AddPageLabel (HPDF_Doc pdf, HPDF_UINT page_num, HPDF_PageNumStyle style, HPDF_UINT first_page, const char *prefix)
+_HPDF_AddPageLabel=haru.HPDF_AddPageLabel
+_HPDF_AddPageLabel.restype=HPDF_STATUS
+def HPDF_AddPageLabel(
+                      pdf,    #HPDF_Doc
+                      page_num,    #HPDF_UINT
+                      style,    #HPDF_PageNumStyle
+                      first_page,    #HPDF_UINT
+                      prefix,    #c_char_p
+                     ):
+    page_num, first_page=[HPDF_UINT(int(i))for i in (page_num, first_page)]
+    return _HPDF_AddPageLabel(
+                              pdf,    #HPDF_Doc
+                              page_num,    #HPDF_UINT
+                              style,    #HPDF_PageNumStyle
+                              first_page,    #HPDF_UINT
+                              prefix,    #c_char_p
+                             )
+
+#HPDF_STATUS HPDF_UseJPFonts (HPDF_Doc pdf)
+HPDF_UseJPFonts=haru.HPDF_UseJPFonts
+HPDF_UseJPFonts.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_UseKRFonts (HPDF_Doc pdf)
+HPDF_UseKRFonts=haru.HPDF_UseKRFonts
+HPDF_UseKRFonts.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_UseCNSFonts (HPDF_Doc pdf)
+HPDF_UseCNSFonts=haru.HPDF_UseCNSFonts
+HPDF_UseCNSFonts.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_UseCNTFonts (HPDF_Doc pdf)
+HPDF_UseCNTFonts=haru.HPDF_UseCNTFonts
+HPDF_UseCNTFonts.restype=HPDF_STATUS
+
+
+#--------------------------------------------------------------------------
+#----- outline ------------------------------------------------------------
+
+
+#HPDF_Outline HPDF_CreateOutline (HPDF_Doc pdf, HPDF_Outline parent, const char *title, HPDF_Encoder encoder)
+HPDF_CreateOutline=haru.HPDF_CreateOutline
+HPDF_CreateOutline.restype=HPDF_Outline
+
+
+#HPDF_STATUS HPDF_Outline_SetOpened (HPDF_Outline outline, HPDF_BOOL opened)
+HPDF_Outline_SetOpened=haru.HPDF_Outline_SetOpened
+HPDF_Outline_SetOpened.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_Outline_SetDestination (HPDF_Outline outline, HPDF_Destination dst)
+HPDF_Outline_SetDestination=haru.HPDF_Outline_SetDestination
+HPDF_Outline_SetDestination.restype=HPDF_STATUS
+
+
+#--------------------------------------------------------------------------
+#----- destination --------------------------------------------------------
+#HPDF_Destination HPDF_Page_CreateDestination (HPDF_Page page)
+HPDF_Page_CreateDestination=haru.HPDF_Page_CreateDestination
+HPDF_Page_CreateDestination.restype=HPDF_Destination
+
+
+#HPDF_STATUS HPDF_Destination_SetXYZ (HPDF_Destination dst, HPDF_REAL left, HPDF_REAL top, HPDF_REAL zoom)
+_HPDF_Destination_SetXYZ=haru.HPDF_Destination_SetXYZ
+_HPDF_Destination_SetXYZ.restype=HPDF_STATUS
+def HPDF_Destination_SetXYZ(
+                            dst,    #HPDF_Destination
+                            left,    #HPDF_REAL
+                            top,    #HPDF_REAL
+                            zoom,    #HPDF_REAL
+                           ):
+    left=HPDF_REAL(left)
+    top=HPDF_REAL(top)
+    zoom=HPDF_REAL(zoom)
+    return _HPDF_Destination_SetXYZ(
+                                    dst,    #HPDF_Destination
+                                    left,    #HPDF_REAL
+                                    top,    #HPDF_REAL
+                                    zoom,    #HPDF_REAL
+                                   )
+
+
+#HPDF_STATUS HPDF_Destination_SetFit (HPDF_Destination dst)
+HPDF_Destination_SetFit=haru.HPDF_Destination_SetFit
+HPDF_Destination_SetFit.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_Destination_SetFitH (HPDF_Destination dst, HPDF_REAL top)
+_HPDF_Destination_SetFitH=haru.HPDF_Destination_SetFitH
+_HPDF_Destination_SetFitH.restype=HPDF_STATUS
+def HPDF_Destination_SetFitH(
+                             dst,    #HPDF_Destination
+                             top,    #HPDF_REAL
+                            ):
+    top=HPDF_REAL(top)
+    return _HPDF_Destination_SetFitH(
+                                     dst,    #HPDF_Destination
+                                     top,    #HPDF_REAL
+                                    )
+
+
+#HPDF_STATUS HPDF_Destination_SetFitV (HPDF_Destination dst, HPDF_REAL left)
+_HPDF_Destination_SetFitV=haru.HPDF_Destination_SetFitV
+_HPDF_Destination_SetFitV.restype=HPDF_STATUS
+def HPDF_Destination_SetFitV(
+                             dst,    #HPDF_Destination
+                             left,    #HPDF_REAL
+                            ):
+    left=HPDF_REAL(left)
+    return _HPDF_Destination_SetFitV(
+                                     dst,    #HPDF_Destination
+                                     left,    #HPDF_REAL
+                                    )
+
+
+#HPDF_STATUS HPDF_Destination_SetFitR (HPDF_Destination dst, HPDF_REAL left, HPDF_REAL bottom, HPDF_REAL right, HPDF_REAL top)
+_HPDF_Destination_SetFitR=haru.HPDF_Destination_SetFitR
+_HPDF_Destination_SetFitR.restype=HPDF_STATUS
+def HPDF_Destination_SetFitR(
+                             dst,    #HPDF_Destination
+                             left,    #HPDF_REAL
+                             bottom,    #HPDF_REAL
+                             right,    #HPDF_REAL
+                             top,    #HPDF_REAL
+                            ):
+    left=HPDF_REAL(left)
+    bottom=HPDF_REAL(bottom)
+    right=HPDF_REAL(right)
+    top=HPDF_REAL(top)
+    return _HPDF_Destination_SetFitR(
+                                     dst,    #HPDF_Destination
+                                     left,    #HPDF_REAL
+                                     bottom,    #HPDF_REAL
+                                     right,    #HPDF_REAL
+                                     top,    #HPDF_REAL
+                                    )
+
+
+#HPDF_STATUS HPDF_Destination_SetFitB (HPDF_Destination dst)
+HPDF_Destination_SetFitB=haru.HPDF_Destination_SetFitB
+HPDF_Destination_SetFitB.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_Destination_SetFitBH (HPDF_Destination dst, HPDF_REAL top)
+_HPDF_Destination_SetFitBH=haru.HPDF_Destination_SetFitBH
+_HPDF_Destination_SetFitBH.restype=HPDF_STATUS
+def HPDF_Destination_SetFitBH(
+                              dst,    #HPDF_Destination
+                              top,    #HPDF_REAL
+                             ):
+    top=HPDF_REAL(top)
+    return _HPDF_Destination_SetFitBH(
+                                      dst,    #HPDF_Destination
+                                      top,    #HPDF_REAL
+                                     )
+
+
+#HPDF_STATUS HPDF_Destination_SetFitBV (HPDF_Destination dst, HPDF_REAL left)
+_HPDF_Destination_SetFitBV=haru.HPDF_Destination_SetFitBV
+_HPDF_Destination_SetFitBV.restype=HPDF_STATUS
+def HPDF_Destination_SetFitBV(
+                              dst,    #HPDF_Destination
+                              left,    #HPDF_REAL
+                             ):
+    left=HPDF_REAL(left)
+    return _HPDF_Destination_SetFitBV(
+                                      dst,    #HPDF_Destination
+                                      left,    #HPDF_REAL
+                                     )
+
+
+#--------------------------------------------------------------------------
+#----- encoder ------------------------------------------------------------
+#HPDF_Encoder HPDF_GetEncoder (HPDF_Doc pdf, const char *encoding_name)
+HPDF_GetEncoder=haru.HPDF_GetEncoder
+HPDF_GetEncoder.restype=HPDF_Encoder
+
+
+#HPDF_Encoder HPDF_GetCurrentEncoder (HPDF_Doc pdf)
+HPDF_GetCurrentEncoder=haru.HPDF_GetCurrentEncoder
+HPDF_GetCurrentEncoder.restype=HPDF_Encoder
+
+
+#HPDF_STATUS HPDF_SetCurrentEncoder (HPDF_Doc pdf, const char *encoding_name)
+HPDF_SetCurrentEncoder=haru.HPDF_SetCurrentEncoder
+HPDF_SetCurrentEncoder.restype=HPDF_STATUS
+
+
+#HPDF_EncoderType HPDF_Encoder_GetType (HPDF_Encoder encoder)
+HPDF_Encoder_GetType=haru.HPDF_Encoder_GetType
+HPDF_Encoder_GetType.restype=HPDF_EncoderType
+
+#HPDF_ByteType HPDF_Encoder_GetByteType (HPDF_Encoder encoder, const char *text, HPDF_UINT index)
+_HPDF_Encoder_GetByteType=haru.HPDF_Encoder_GetByteType
+_HPDF_Encoder_GetByteType.restype=HPDF_ByteType
+def HPDF_Encoder_GetByteType(
+                             encoder,       #HPDF_Encoder
+                             text,          #const char *
+                             index          #HPDF_UINT
+                            ):
+    if type(text) in (types.ListType, types.TupleType):
+        if type(text[-1]) != types.StringType:
+            text=[chr(i) for i in text]
+        text=''.join(text)
+    return _HPDF_Encoder_GetByteType(
+                                     encoder,       #HPDF_Encoder
+                                     text,          #const char *
+                                     index          #HPDF_UINT
+                                    )
+
+#HPDF_UNICODE HPDF_Encoder_GetUnicode (HPDF_Encoder encoder, HPDF_UINT16 code)
+HPDF_Encoder_GetUnicode=haru.HPDF_Encoder_GetUnicode
+HPDF_Encoder_GetUnicode.restype=HPDF_UNICODE
+
+
+#HPDF_WritingMode HPDF_Encoder_GetWritingMode (HPDF_Encoder encoder)
+HPDF_Encoder_GetWritingMode=haru.HPDF_Encoder_GetWritingMode
+HPDF_Encoder_GetWritingMode.restype=HPDF_WritingMode
+
+
+#HPDF_STATUS HPDF_UseJPEncodings (HPDF_Doc pdf)
+HPDF_UseJPEncodings=haru.HPDF_UseJPEncodings
+HPDF_UseJPEncodings.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_UseKREncodings (HPDF_Doc pdf)
+HPDF_UseKREncodings=haru.HPDF_UseKREncodings
+HPDF_UseKREncodings.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_UseCNSEncodings (HPDF_Doc pdf)
+HPDF_UseCNSEncodings=haru.HPDF_UseCNSEncodings
+HPDF_UseCNSEncodings.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_UseCNTEncodings (HPDF_Doc pdf)
+HPDF_UseCNTEncodings=haru.HPDF_UseCNTEncodings
+HPDF_UseCNTEncodings.restype=HPDF_STATUS
+
+
+#--------------------------------------------------------------------------
+#----- annotation ---------------------------------------------------------
+#HPDF_Annotation HPDF_Page_CreateTextAnnot (HPDF_Page page, HPDF_Rect rect, const char *text, HPDF_Encoder encoder)
+HPDF_Page_CreateTextAnnot=haru.HPDF_Page_CreateTextAnnot
+HPDF_Page_CreateTextAnnot.restype=HPDF_Annotation
+
+
+#HPDF_Annotation HPDF_Page_CreateLinkAnnot (HPDF_Page page, HPDF_Rect rect, HPDF_Destination dst)
+HPDF_Page_CreateLinkAnnot=haru.HPDF_Page_CreateLinkAnnot
+HPDF_Page_CreateLinkAnnot.restype=HPDF_Annotation
+
+
+#HPDF_Annotation HPDF_Page_CreateURILinkAnnot (HPDF_Page page, HPDF_Rect rect, const char *uri)
+HPDF_Page_CreateURILinkAnnot=haru.HPDF_Page_CreateURILinkAnnot
+HPDF_Page_CreateURILinkAnnot.restype=HPDF_Annotation
+
+
+#HPDF_STATUS HPDF_LinkAnnot_SetHighlightMode (HPDF_Annotation annot, HPDF_AnnotHighlightMode mode)
+HPDF_LinkAnnot_SetHighlightMode=haru.HPDF_LinkAnnot_SetHighlightMode
+HPDF_LinkAnnot_SetHighlightMode.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_LinkAnnot_SetBorderStyle (HPDF_Annotation annot, HPDF_REAL width, HPDF_UINT16 dash_on, HPDF_UINT16 dash_off)
+_HPDF_LinkAnnot_SetBorderStyle=haru.HPDF_LinkAnnot_SetBorderStyle
+_HPDF_LinkAnnot_SetBorderStyle.restype=HPDF_STATUS
+def HPDF_LinkAnnot_SetBorderStyle(
+                                  annot,    #HPDF_Annotation
+                                  width,    #HPDF_REAL
+                                  dash_on,    #HPDF_UINT16
+                                  dash_off,    #HPDF_UINT16
+                                 ):
+    width=HPDF_REAL(width)
+    dash_on=HPDF_UINT16(dash_on)
+    dash_off=HPDF_UINT16(dash_off)
+    return _HPDF_LinkAnnot_SetBorderStyle(
+                                          annot,    #HPDF_Annotation
+                                          width,    #HPDF_REAL
+                                          dash_on,    #HPDF_UINT16
+                                          dash_off,    #HPDF_UINT16
+                                         )
+
+
+#HPDF_STATUS HPDF_TextAnnot_SetIcon (HPDF_Annotation annot, HPDF_AnnotIcon icon)
+HPDF_TextAnnot_SetIcon=haru.HPDF_TextAnnot_SetIcon
+HPDF_TextAnnot_SetIcon.restype=HPDF_STATUS
+
+
+#HPDF_STATUS HPDF_TextAnnot_SetOpened (HPDF_Annotation annot, HPDF_BOOL opened)
+HPDF_TextAnnot_SetOpened=haru.HPDF_TextAnnot_SetOpened
+HPDF_TextAnnot_SetOpened.restype=HPDF_STATUS
+
+
+#--------------------------------------------------------------------------
+#----- image data ---------------------------------------------------------
+#HPDF_Image HPDF_LoadPngImageFromFile (HPDF_Doc pdf, const char *filename)
+HPDF_LoadPngImageFromFile=haru.HPDF_LoadPngImageFromFile
+HPDF_LoadPngImageFromFile.restype=HPDF_Image
+
+
+#HPDF_Image HPDF_LoadPngImageFromFile2 (HPDF_Doc pdf, const char *filename)
+HPDF_LoadPngImageFromFile2=haru.HPDF_LoadPngImageFromFile2
+HPDF_LoadPngImageFromFile2.restype=HPDF_Image
+
+
+#HPDF_Image HPDF_LoadJpegImageFromFile (HPDF_Doc pdf, const char *filename)
+HPDF_LoadJpegImageFromFile=haru.HPDF_LoadJpegImageFromFile
+HPDF_LoadJpegImageFromFile.restype=HPDF_Image
+
+
+#HPDF_Image HPDF_LoadRawImageFromFile (HPDF_Doc pdf, const char *filename, HPDF_UINT width, HPDF_UINT height, HPDF_ColorSpace color_space)
+_HPDF_LoadRawImageFromFile=haru.HPDF_LoadRawImageFromFile
+_HPDF_LoadRawImageFromFile.restype=HPDF_Image
+def HPDF_LoadRawImageFromFile(
+                              pdf,    #HPDF_Doc
+                              filename,    #c_char_p
+                              width,    #HPDF_UINT
+                              height,    #HPDF_UINT
+                              color_space,    #HPDF_ColorSpace
+                             ):
+    width=HPDF_UINT(width)
+    height=HPDF_UINT(height)
+    return _HPDF_LoadRawImageFromFile(
+                                      pdf,    #HPDF_Doc
+                                      filename,    #c_char_p
+                                      width,    #HPDF_UINT
+                                      height,    #HPDF_UINT
+                                      color_space,    #HPDF_ColorSpace
+                                     )
+
+
+#HPDF_Image HPDF_LoadRawImageFromMem (HPDF_Doc pdf, const HPDF_BYTE *buf, HPDF_UINT width, HPDF_UINT height, HPDF_ColorSpace color_space, HPDF_UINT bits_per_component)
+_HPDF_LoadRawImageFromMem=haru.HPDF_LoadRawImageFromMem
+_HPDF_LoadRawImageFromMem.restype=HPDF_Image
+def HPDF_LoadRawImageFromMem(
+                             pdf,    #HPDF_Doc
+                             buf,    #POINTER(HPDF_BYTE)
+                             width,    #HPDF_UINT
+                             height,    #HPDF_UINT
+                             color_space,    #HPDF_ColorSpace
+                             bits_per_component,    #HPDF_UINT
+                            ):
+    if type(buf) in (types.ListType, types.TupleType):
+        size=len(buf)
+        buf=pointer((HPDF_BYTE*size)(*buf))
+        if height in [0, None]:
+            height=size/width
+    width=HPDF_UINT(width)
+    height=HPDF_UINT(height)
+    bits_per_component=HPDF_UINT(bits_per_component)
+    return _HPDF_LoadRawImageFromMem(
+                                     pdf,    #HPDF_Doc
+                                     buf,    #POINTER(HPDF_BYTE)
+                                     width,    #HPDF_UINT
+                                     height,    #HPDF_UINT
+                                     color_space,    #HPDF_ColorSpace
+                                     bits_per_component,    #HPDF_UINT
+                                    )
+
+
+#HPDF_Point HPDF_Image_GetSize (HPDF_Image image)
+HPDF_Image_GetSize=haru.HPDF_Image_GetSize
+HPDF_Image_GetSize.restype=HPDF_Point
+
+
+#HPDF_STATUS HPDF_Image_GetSize2 (HPDF_Image image, HPDF_Point *size)
+_HPDF_Image_GetSize2=haru.HPDF_Image_GetSize2
+_HPDF_Image_GetSize2.restype=HPDF_STATUS
+def HPDF_Image_GetSize2(
+                        image,    #HPDF_Image
+                        size=None,    #POINTER(HPDF_Point)
+                       ):
+    size=HPDF_Point
+    ret= _HPDF_Image_GetSize2(
+                              image,    #HPDF_Image
+                              size,    #POINTER(HPDF_Point)
+                             )
+    return ret, size.x, size.y
+
+
+#HPDF_UINT HPDF_Image_GetWidth (HPDF_Image image)
+HPDF_Image_GetWidth=haru.HPDF_Image_GetWidth
+HPDF_Image_GetWidth.restype=HPDF_UINT
+
+
+#HPDF_UINT HPDF_Image_GetHeight (HPDF_Image image)
+HPDF_Image_GetHeight=haru.HPDF_Image_GetHeight
+HPDF_Image_GetHeight.restype=HPDF_UINT
+
+
+#HPDF_UINT HPDF_Image_GetBitsPerComponent (HPDF_Image image)
+HPDF_Image_GetBitsPerComponent=haru.HPDF_Image_GetBitsPerComponent
+HPDF_Image_GetBitsPerComponent.restype=HPDF_UINT
+
+
+#const char* HPDF_Image_GetColorSpace (HPDF_Image image)
+HPDF_Image_GetColorSpace=haru.HPDF_Image_GetColorSpace
+HPDF_Image_GetColorSpace.restype=c_char_p
+
+
+#HPDF_STATUS HPDF_Image_SetColorMask (HPDF_Image image, HPDF_UINT rmin, HPDF_UINT rmax, HPDF_UINT gmin, HPDF_UINT gmax, HPDF_UINT bmin, HPDF_UINT bmax)
+_HPDF_Image_SetColorMask=haru.HPDF_Image_SetColorMask
+_HPDF_Image_SetColorMask.restype=HPDF_STATUS
+def HPDF_Image_SetColorMask(
+                            image,    #HPDF_Image
+                            rmin,    #HPDF_UINT
+                            rmax,    #HPDF_UINT
+                            gmin,    #HPDF_UINT
+                            gmax,    #HPDF_UINT
+                            bmin,    #HPDF_UINT
+                            bmax,    #HPDF_UINT
+                           ):
+    rmin=HPDF_UINT(rmin)
+    rmax=HPDF_UINT(rmax)
+    gmin=HPDF_UINT(gmin)
+    gmax=HPDF_UINT(gmax)
+    bmin=HPDF_UINT(bmin)
+    bmax=HPDF_UINT(bmax)
+    return _HPDF_Image_SetColorMask(
+                                    image,    #HPDF_Image
+                                    rmin,    #HPDF_UINT
+                                    rmax,    #HPDF_UINT
+                                    gmin,    #HPDF_UINT
+                                    gmax,    #HPDF_UINT
+                                    bmin,    #HPDF_UINT
+                                    bmax,    #HPDF_UINT
+                                   )
+
+
+#HPDF_STATUS HPDF_Image_SetMaskImage (HPDF_Image image, HPDF_Image mask_image)
+HPDF_Image_SetMaskImage=haru.HPDF_Image_SetMaskImage
+HPDF_Image_SetMaskImage.restype=HPDF_STATUS
+
+
+#--------------------------------------------------------------------------
+#----- info dictionary ----------------------------------------------------
+#HPDF_STATUS HPDF_SetInfoAttr (HPDF_Doc pdf, HPDF_InfoType type, const char *value)
+HPDF_SetInfoAttr=haru.HPDF_SetInfoAttr
+HPDF_SetInfoAttr.restype=HPDF_STATUS
+
+
+#const char* HPDF_GetInfoAttr (HPDF_Doc pdf, HPDF_InfoType type)
+HPDF_GetInfoAttr=haru.HPDF_GetInfoAttr
+HPDF_GetInfoAttr.restype=c_char_p
+
+
+#HPDF_STATUS HPDF_SetInfoDateAttr (HPDF_Doc pdf, HPDF_InfoType type, HPDF_Date value)
+HPDF_SetInfoDateAttr=haru.HPDF_SetInfoDateAttr
+HPDF_SetInfoDateAttr.restype=HPDF_STATUS
+
+
+#--------------------------------------------------------------------------
+#----- encryption ---------------------------------------------------------
+#HPDF_STATUS HPDF_SetPassword (HPDF_Doc pdf, const char *owner_passwd, const char *user_passwd)
+HPDF_SetPassword=haru.HPDF_SetPassword
+HPDF_SetPassword.restype=HPDF_STATUS
+
+#HPDF_STATUS HPDF_SetPermission (HPDF_Doc pdf, HPDF_UINT permission)
+_HPDF_SetPermission=haru.HPDF_SetPermission
+_HPDF_SetPermission.restype=HPDF_STATUS
+def HPDF_SetPermission(
+                       pdf,    #HPDF_Doc
+                       permission,    #HPDF_UINT
+                      ):
+    permission=HPDF_UINT(int(permission))
+    return _HPDF_SetPermission(
+                               pdf,    #HPDF_Doc
+                               permission,    #HPDF_UINT
+                              )
+
+
+#HPDF_STATUS HPDF_SetEncryptionMode (HPDF_Doc pdf, HPDF_EncryptMode mode, HPDF_UINT key_len)
+_HPDF_SetEncryptionMode=haru.HPDF_SetEncryptionMode
+_HPDF_SetEncryptionMode.restype=HPDF_STATUS
+def HPDF_SetEncryptionMode(
+                           pdf,    #HPDF_Doc
+                           mode,    #HPDF_EncryptMode
+                           key_len,    #HPDF_UINT
+                          ):
+    key_len=HPDF_UINT(int(key_len))
+    return _HPDF_SetEncryptionMode(
+                                   pdf,    #HPDF_Doc
+                                   mode,    #HPDF_EncryptMode
+                                   key_len,    #HPDF_UINT
+                                  )
+
+
+#--------------------------------------------------------------------------
+#----- compression --------------------------------------------------------
+#HPDF_STATUS HPDF_SetCompressionMode (HPDF_Doc pdf, HPDF_UINT mode)
+HPDF_SetCompressionMode=haru.HPDF_SetCompressionMode
+HPDF_SetCompressionMode.restype=HPDF_STATUS
+
+
+#--------------------------------------------------------------------------
+#----- font ---------------------------------------------------------------
+#const char* HPDF_Font_GetFontName (HPDF_Font font)
+HPDF_Font_GetFontName=haru.HPDF_Font_GetFontName
+HPDF_Font_GetFontName.restype=c_char_p
+
+
+#const char* HPDF_Font_GetEncodingName (HPDF_Font font)
+HPDF_Font_GetEncodingName=haru.HPDF_Font_GetEncodingName
+HPDF_Font_GetEncodingName.restype=c_char_p
+
+
+#HPDF_INT HPDF_Font_GetUnicodeWidth (HPDF_Font font, HPDF_UNICODE code)
+HPDF_Font_GetUnicodeWidth=haru.HPDF_Font_GetUnicodeWidth
+HPDF_Font_GetUnicodeWidth.restype=HPDF_INT
+
+
+#HPDF_Box HPDF_Font_GetBBox (HPDF_Font font)
+HPDF_Font_GetBBox=haru.HPDF_Font_GetBBox
+HPDF_Font_GetBBox.restype=HPDF_Box
+
+#HPDF_INT HPDF_Font_GetAscent (HPDF_Font font)
+HPDF_Font_GetAscent=haru.HPDF_Font_GetAscent
+HPDF_Font_GetAscent.restype=HPDF_INT
+
+#HPDF_INT HPDF_Font_GetDescent (HPDF_Font font)
+HPDF_Font_GetDescent=haru.HPDF_Font_GetDescent
+HPDF_Font_GetDescent.restype=HPDF_INT
+
+#HPDF_UINT HPDF_Font_GetXHeight (HPDF_Font font)
+HPDF_Font_GetXHeight=haru.HPDF_Font_GetXHeight
+HPDF_Font_GetXHeight.restype=HPDF_UINT
+
+
+#HPDF_UINT HPDF_Font_GetCapHeight (HPDF_Font font)
+HPDF_Font_GetCapHeight=haru.HPDF_Font_GetCapHeight
+HPDF_Font_GetCapHeight.restype=HPDF_UINT
+
+
+#HPDF_TextWidth HPDF_Font_TextWidth (HPDF_Font font, const HPDF_BYTE *text, HPDF_UINT len)
+HPDF_Font_TextWidth=haru.HPDF_Font_TextWidth
+HPDF_Font_TextWidth.restype=HPDF_TextWidth
+
+
+#HPDF_UINT HPDF_Font_MeasureText (HPDF_Font font, const HPDF_BYTE *text, HPDF_UINT len, HPDF_REAL width, HPDF_REAL font_size, HPDF_REAL char_space, HPDF_REAL word_space, HPDF_BOOL wordwrap, HPDF_REAL *real_width)
+_HPDF_Font_MeasureText=haru.HPDF_Font_MeasureText
+_HPDF_Font_MeasureText.restype=HPDF_UINT
+def HPDF_Font_MeasureText(
+                          font,    #HPDF_Font
+                          text,    #POINTER(HPDF_BYTE)
+                          length,    #HPDF_UINT
+                          width,    #HPDF_REAL
+                          font_size,    #HPDF_REAL
+                          char_space,    #HPDF_REAL
+                          word_space,    #HPDF_REAL
+                          wordwrap,    #HPDF_BOOL
+                          real_width,    #POINTER(HPDF_REAL)
+                         ):
+    if type(text) in (types.TupleType, types.ListType):
+        length=len(text)
+        text=pointer((HPDF_BYTE*length)(*text))
+
+    length=HPDF_UINT(int(length))
+
+    width=HPDF_REAL(width)
+    font_size=HPDF_REAL(font_size)
+    char_space=HPDF_REAL(char_space)
+    word_space=HPDF_REAL(word_space)
+    real_width=HPDF_REAL(real_width)
+    return _HPDF_Font_MeasureText(
+                                  font,    #HPDF_Font
+                                  text,    #POINTER(HPDF_BYTE)
+                                  length,    #HPDF_UINT
+                                  width,    #HPDF_REAL
+                                  font_size,    #HPDF_REAL
+                                  char_space,    #HPDF_REAL
+                                  word_space,    #HPDF_REAL
+                                  wordwrap,    #HPDF_BOOL
+                                  real_width,    #POINTER(HPDF_REAL)
+                                 )
+
+
+#--------------------------------------------------------------------------
+#----- extended graphics state --------------------------------------------
+#HPDF_ExtGState HPDF_CreateExtGState (HPDF_Doc pdf)
+HPDF_CreateExtGState=haru.HPDF_CreateExtGState
+HPDF_CreateExtGState.restype=HPDF_ExtGState
+
+
+#HPDF_STATUS HPDF_ExtGState_SetAlphaStroke (HPDF_ExtGState ext_gstate, HPDF_REAL value)
+_HPDF_ExtGState_SetAlphaStroke=haru.HPDF_ExtGState_SetAlphaStroke
+_HPDF_ExtGState_SetAlphaStroke.restype=HPDF_STATUS
+def HPDF_ExtGState_SetAlphaStroke(
+                                  ext_gstate,    #HPDF_ExtGState
+                                  value,    #HPDF_REAL
+                                 ):
+    value=HPDF_REAL(value)
+    return _HPDF_ExtGState_SetAlphaStroke(
+                                          ext_gstate,    #HPDF_ExtGState
+                                          value,    #HPDF_REAL
+                                         )
+
+
+#HPDF_STATUS HPDF_ExtGState_SetAlphaFill (HPDF_ExtGState ext_gstate, HPDF_REAL value)
+_HPDF_ExtGState_SetAlphaFill=haru.HPDF_ExtGState_SetAlphaFill
+_HPDF_ExtGState_SetAlphaFill.restype=HPDF_STATUS
+def HPDF_ExtGState_SetAlphaFill(
+                                ext_gstate,    #HPDF_ExtGState
+                                value,    #HPDF_REAL
+                               ):
+    value=HPDF_REAL(value)
+    return _HPDF_ExtGState_SetAlphaFill(
+                                        ext_gstate,    #HPDF_ExtGState
+                                        value,    #HPDF_REAL
+                                       )
+
+
+#HPDF_STATUS HPDF_ExtGState_SetBlendMode (HPDF_ExtGState ext_gstate, HPDF_BlendMode mode)
+HPDF_ExtGState_SetBlendMode=haru.HPDF_ExtGState_SetBlendMode
+HPDF_ExtGState_SetBlendMode.restype=HPDF_STATUS
+
+
+#--------------------------------------------------------------------------
+#--------------------------------------------------------------------------
+#HPDF_REAL HPDF_Page_TextWidth (HPDF_Page page, const char *text)
+_HPDF_Page_TextWidth=haru.HPDF_Page_TextWidth
+_HPDF_Page_TextWidth.restype=HPDF_REAL
+def HPDF_Page_TextWidth(
+                        page,           #HPDF_Page
+                        text,           #c_char_p
+                       ):
+    if type(text) in (types.ListType, types.TupleType):
+        if type(text[-1]) != types.StringType:
+            text=[chr(i) for i in text]
+        text=''.join(text)
+
+    return _HPDF_Page_TextWidth(
+                                page,           #HPDF_Page
+                                text,           #c_char_p
+                               )
+
+
+#HPDF_UINT HPDF_Page_MeasureText (HPDF_Page page, const char *text, HPDF_REAL width, HPDF_BOOL wordwrap, HPDF_REAL *real_width)
+_HPDF_Page_MeasureText=haru.HPDF_Page_MeasureText
+_HPDF_Page_MeasureText.restype=HPDF_UINT
+def HPDF_Page_MeasureText(
+                          page,    #HPDF_Page
+                          text,    #c_char_p
+                          width,    #HPDF_REAL
+                          wordwrap,    #HPDF_BOOL
+                          real_width,    #POINTER(HPDF_REAL)
+                         ):
+    width=HPDF_REAL(width)
+    real_width=HPDF_REAL(real_width)
+    return _HPDF_Page_MeasureText(
+                                  page,    #HPDF_Page
+                                  text,    #c_char_p
+                                  width,    #HPDF_REAL
+                                  wordwrap,    #HPDF_BOOL
+                                  real_width,    #POINTER(HPDF_REAL)
+                                 )
+
+
+#HPDF_REAL
+#HPDF_Page_GetWidth  (HPDF_Page   page);
+HPDF_Page_GetWidth=haru.HPDF_Page_GetWidth
+HPDF_Page_GetWidth.restype=HPDF_REAL
+
+
+#HPDF_REAL HPDF_Page_GetHeight (HPDF_Page page)
+HPDF_Page_GetHeight=haru.HPDF_Page_GetHeight
+HPDF_Page_GetHeight.restype=HPDF_REAL
+
+
+#HPDF_UINT16 HPDF_Page_GetGMode (HPDF_Page page)
+HPDF_Page_GetGMode=haru.HPDF_Page_GetGMode
+HPDF_Page_GetGMode.restype=HPDF_UINT16
+
+
+#HPDF_Point HPDF_Page_GetCurrentPos (HPDF_Page page)
+HPDF_Page_GetCurrentPos=haru.HPDF_Page_GetCurrentPos
+HPDF_Page_GetCurrentPos.restype=HPDF_Point
+
+
+#HPDF_STATUS HPDF_Page_GetCurrentPos2 (HPDF_Page page, HPDF_Point *pos)
+_HPDF_Page_GetCurrentPos2=haru.HPDF_Page_GetCurrentPos2
+_HPDF_Page_GetCurrentPos2.restype=HPDF_STATUS
+def HPDF_Page_GetCurrentPos2(
+                             page,    #HPDF_Page
+                             pos=None,    #POINTER(HPDF_Point)
+                            ):
+    pos=HPDF_Point()
+    ret= _HPDF_Page_GetCurrentPos2(
+                                   page,    #HPDF_Page
+                                   pos,    #POINTER(HPDF_Point)
+                                  )
+    return ret, pos.x, pos.y
+
+
+#HPDF_Point HPDF_Page_GetCurrentTextPos (HPDF_Page page)
+HPDF_Page_GetCurrentTextPos=haru.HPDF_Page_GetCurrentTextPos
+HPDF_Page_GetCurrentTextPos.restype=HPDF_Point
+
+
+#HPDF_STATUS HPDF_Page_GetCurrentTextPos2 (HPDF_Page page, HPDF_Point *pos)
+_HPDF_Page_GetCurrentTextPos2=haru.HPDF_Page_GetCurrentTextPos2
+_HPDF_Page_GetCurrentTextPos2.restype=HPDF_STATUS
+def HPDF_Page_GetCurrentTextPos2(
+                                 page,    #HPDF_Page
+                                 pos=None,    #POINTER(HPDF_Point)
+                                ):
+    pos=HPDF_Point()
+    ret= _HPDF_Page_GetCurrentTextPos2(
+                                       page,    #HPDF_Page
+                                       pos,    #POINTER(HPDF_Point)
+                                      )
+    return ret, pos.x, pos.y
+
+
+#HPDF_Font HPDF_Page_GetCurrentFont (HPDF_Page page)
+HPDF_Page_GetCurrentFont=haru.HPDF_Page_GetCurrentFont
+HPDF_Page_GetCurrentFont.restype=HPDF_Font
+
+
+#HPDF_REAL HPDF_Page_GetCurrentFontSize (HPDF_Page page)
+HPDF_Page_GetCurrentFontSize=haru.HPDF_Page_GetCurrentFontSize
+HPDF_Page_GetCurrentFontSize.restype=HPDF_REAL
+
+
+#HPDF_TransMatrix HPDF_Page_GetTransMatrix (HPDF_Page page)
+HPDF_Page_GetTransMatrix=haru.HPDF_Page_GetTransMatrix
+HPDF_Page_GetTransMatrix.restype=HPDF_TransMatrix
+
+
+#HPDF_REAL HPDF_Page_GetLineWidth (HPDF_Page page)
+HPDF_Page_GetLineWidth=haru.HPDF_Page_GetLineWidth
+HPDF_Page_GetLineWidth.restype=HPDF_REAL
+
+#HPDF_LineCap HPDF_Page_GetLineCap (HPDF_Page page)
+HPDF_Page_GetLineCap=haru.HPDF_Page_GetLineCap
+HPDF_Page_GetLineCap.restype=HPDF_LineCap
+
+
+#HPDF_LineJoin HPDF_Page_GetLineJoin (HPDF_Page page)
+HPDF_Page_GetLineJoin=haru.HPDF_Page_GetLineJoin
+HPDF_Page_GetLineJoin.restype=HPDF_LineJoin
+
+
+#HPDF_REAL HPDF_Page_GetMiterLimit (HPDF_Page page)
+HPDF_Page_GetMiterLimit=haru.HPDF_Page_GetMiterLimit
+HPDF_Page_GetMiterLimit.restype=HPDF_REAL
+
+
+#HPDF_DashMode HPDF_Page_GetDash (HPDF_Page page)
+HPDF_Page_GetDash=haru.HPDF_Page_GetDash
+HPDF_Page_GetDash.restype=HPDF_DashMode
+
+
+#HPDF_REAL HPDF_Page_GetFlat (HPDF_Page page)
+HPDF_Page_GetFlat=haru.HPDF_Page_GetFlat
+HPDF_Page_GetFlat.restype=HPDF_REAL
+
+
+#HPDF_REAL HPDF_Page_GetCharSpace (HPDF_Page page)
+HPDF_Page_GetCharSpace=haru.HPDF_Page_GetCharSpace
+HPDF_Page_GetCharSpace.restype=HPDF_REAL
+
+
+#HPDF_REAL HPDF_Page_GetWordSpace (HPDF_Page page)
+HPDF_Page_GetWordSpace=haru.HPDF_Page_GetWordSpace
+HPDF_Page_GetWordSpace.restype=HPDF_REAL
+
+
+#HPDF_REAL HPDF_Page_GetHorizontalScalling (HPDF_Page page)
+HPDF_Page_GetHorizontalScalling=haru.HPDF_Page_GetHorizontalScalling
+HPDF_Page_GetHorizontalScalling.restype=HPDF_REAL
+
+
+#HPDF_REAL HPDF_Page_GetTextLeading (HPDF_Page page)
+HPDF_Page_GetTextLeading=haru.HPDF_Page_GetTextLeading
+HPDF_Page_GetTextLeading.restype=HPDF_REAL
+
+
+#HPDF_TextRenderingMode HPDF_Page_GetTextRenderingMode (HPDF_Page page)
+HPDF_Page_GetTextRenderingMode=haru.HPDF_Page_GetTextRenderingMode
+HPDF_Page_GetTextRenderingMode.restype=HPDF_TextRenderingMode
+
+
+# This function is obsolete. Use HPDF_Page_GetTextRise.
+
+#HPDF_REAL HPDF_Page_GetTextRaise (HPDF_Page page)
+HPDF_Page_GetTextRaise=haru.HPDF_Page_GetTextRaise
+HPDF_Page_GetTextRaise.restype=HPDF_REAL
+
+
+#HPDF_REAL HPDF_Page_GetTextRise (HPDF_Page page)
+HPDF_Page_GetTextRise=haru.HPDF_Page_GetTextRise
+HPDF_Page_GetTextRise.restype=HPDF_REAL
+
+
+#HPDF_RGBColor HPDF_Page_GetRGBFill (HPDF_Page page)
+HPDF_Page_GetRGBFill=haru.HPDF_Page_GetRGBFill
+HPDF_Page_GetRGBFill.restype=HPDF_RGBColor
+
+
+#HPDF_RGBColor HPDF_Page_GetRGBStroke (HPDF_Page page)
+HPDF_Page_GetRGBStroke=haru.HPDF_Page_GetRGBStroke
+HPDF_Page_GetRGBStroke.restype=HPDF_RGBColor
+
+
+#HPDF_CMYKColor HPDF_Page_GetCMYKFill (HPDF_Page page)
+HPDF_Page_GetCMYKFill=haru.HPDF_Page_GetCMYKFill
+HPDF_Page_GetCMYKFill.restype=HPDF_CMYKColor
+
+
+#HPDF_CMYKColor HPDF_Page_GetCMYKStroke (HPDF_Page page)
+HPDF_Page_GetCMYKStroke=haru.HPDF_Page_GetCMYKStroke
+HPDF_Page_GetCMYKStroke.restype=HPDF_CMYKColor
+
+
+#HPDF_REAL HPDF_Page_GetGrayFill (HPDF_Page page)
+HPDF_Page_GetGrayFill=haru.HPDF_Page_GetGrayFill
+HPDF_Page_GetGrayFill.restype=HPDF_REAL
+
+
+#HPDF_REAL HPDF_Page_GetGrayStroke (HPDF_Page page)
+HPDF_Page_GetGrayStroke=haru.HPDF_Page_GetGrayStroke
+HPDF_Page_GetGrayStroke.restype=HPDF_REAL
+
+
+#HPDF_ColorSpace HPDF_Page_GetStrokingColorSpace (HPDF_Page page)
+HPDF_Page_GetStrokingColorSpace=haru.HPDF_Page_GetStrokingColorSpace
+HPDF_Page_GetStrokingColorSpace.restype=HPDF_ColorSpace
+
+
+#HPDF_ColorSpace HPDF_Page_GetFillingColorSpace (HPDF_Page page)
+HPDF_Page_GetFillingColorSpace=haru.HPDF_Page_GetFillingColorSpace
+HPDF_Page_GetFillingColorSpace.restype=HPDF_ColorSpace
+
+
+#HPDF_TransMatrix HPDF_Page_GetTextMatrix (HPDF_Page page)
+HPDF_Page_GetTextMatrix=haru.HPDF_Page_GetTextMatrix
+HPDF_Page_GetTextMatrix.restype=HPDF_TransMatrix
+
+
+#HPDF_UINT HPDF_Page_GetGStateDepth (HPDF_Page page)
+HPDF_Page_GetGStateDepth=haru.HPDF_Page_GetGStateDepth
+HPDF_Page_GetGStateDepth.restype=HPDF_UINT
+
+
+#--------------------------------------------------------------------------
+#----- GRAPHICS OPERATORS -------------------------------------------------
+
+
+#--- General graphics state ---------------------------------------------
+# w
+#HPDF_STATUS HPDF_Page_SetLineWidth (HPDF_Page page, HPDF_REAL line_width)
+_HPDF_Page_SetLineWidth=haru.HPDF_Page_SetLineWidth
+_HPDF_Page_SetLineWidth.restype=HPDF_STATUS
+def HPDF_Page_SetLineWidth(
+                           page,    #HPDF_Page
+                           line_width,    #HPDF_REAL
+                          ):
+    line_width=HPDF_REAL(line_width)
+    return _HPDF_Page_SetLineWidth(
+                                   page,    #HPDF_Page
+                                   line_width,    #HPDF_REAL
+                                  )
+
+
+# J
+#HPDF_STATUS HPDF_Page_SetLineCap (HPDF_Page page, HPDF_LineCap line_cap)
+HPDF_Page_SetLineCap=haru.HPDF_Page_SetLineCap
+HPDF_Page_SetLineCap.restype=HPDF_STATUS
+
+
+# j
+#HPDF_STATUS HPDF_Page_SetLineJoin (HPDF_Page page, HPDF_LineJoin line_join)
+HPDF_Page_SetLineJoin=haru.HPDF_Page_SetLineJoin
+HPDF_Page_SetLineJoin.restype=HPDF_STATUS
+
+
+# M
+
+#HPDF_STATUS HPDF_Page_SetMiterLimit (HPDF_Page page, HPDF_REAL miter_limit)
+_HPDF_Page_SetMiterLimit=haru.HPDF_Page_SetMiterLimit
+_HPDF_Page_SetMiterLimit.restype=HPDF_STATUS
+def HPDF_Page_SetMiterLimit(
+                            page,    #HPDF_Page
+                            miter_limit,    #HPDF_REAL
+                           ):
+    miter_limit=HPDF_REAL(miter_limit)
+    return _HPDF_Page_SetMiterLimit(
+                                    page,    #HPDF_Page
+                                    miter_limit,    #HPDF_REAL
+                                   )
+
+
+# d
+#HPDF_STATUS HPDF_Page_SetDash (HPDF_Page page, const HPDF_UINT16 *dash_ptn, HPDF_UINT num_param, HPDF_UINT phase)
+_HPDF_Page_SetDash=haru.HPDF_Page_SetDash
+_HPDF_Page_SetDash.restype=HPDF_STATUS
+def HPDF_Page_SetDash(
+                      page,    #HPDF_Page
+                      dash_ptn,    #POINTER(HPDF_UINT16)
+                      num_param,    #HPDF_UINT
+                      phase,    #HPDF_UINT
+                     ):
+    if type(dash_ptn) in (types.ListType, types.TupleType):
+        num_param=len(dash_ptn)
+        dash_ptn=pointer((HPDF_UINT16*num_param)(*dash_ptn))
+    return _HPDF_Page_SetDash(
+                              page,    #HPDF_Page
+                              dash_ptn,    #POINTER(HPDF_UINT16)
+                              num_param,    #HPDF_UINT
+                              phase,    #HPDF_UINT
+                             )
+
+
+# ri --not implemented yet
+
+# i
+
+#HPDF_STATUS HPDF_Page_SetFlat (HPDF_Page page, HPDF_REAL flatness)
+_HPDF_Page_SetFlat=haru.HPDF_Page_SetFlat
+_HPDF_Page_SetFlat.restype=HPDF_STATUS
+def HPDF_Page_SetFlat(
+                      page,    #HPDF_Page
+                      flatness,    #HPDF_REAL
+                     ):
+    flatness=HPDF_REAL(flatness)
+    return _HPDF_Page_SetFlat(
+                              page,    #HPDF_Page
+                              flatness,    #HPDF_REAL
+                             )
+
+
+# gs
+
+#HPDF_STATUS HPDF_Page_SetExtGState (HPDF_Page page, HPDF_ExtGState ext_gstate)
+HPDF_Page_SetExtGState=haru.HPDF_Page_SetExtGState
+HPDF_Page_SetExtGState.restype=HPDF_STATUS
+
+
+#--- Special graphic state operator --------------------------------------
+# q
+#HPDF_STATUS HPDF_Page_GSave (HPDF_Page page)
+HPDF_Page_GSave=haru.HPDF_Page_GSave
+HPDF_Page_GSave.restype=HPDF_STATUS
+
+
+# Q
+#HPDF_STATUS HPDF_Page_GRestore (HPDF_Page page)
+HPDF_Page_GRestore=haru.HPDF_Page_GRestore
+HPDF_Page_GRestore.restype=HPDF_STATUS
+
+
+# cm
+
+#HPDF_STATUS HPDF_Page_Concat (HPDF_Page page, HPDF_REAL a, HPDF_REAL b, HPDF_REAL c, HPDF_REAL d, HPDF_REAL x, HPDF_REAL y)
+_HPDF_Page_Concat=haru.HPDF_Page_Concat
+_HPDF_Page_Concat.restype=HPDF_STATUS
+def HPDF_Page_Concat(
+                     page,    #HPDF_Page
+                     a,    #HPDF_REAL
+                     b,    #HPDF_REAL
+                     c,    #HPDF_REAL
+                     d,    #HPDF_REAL
+                     x,    #HPDF_REAL
+                     y,    #HPDF_REAL
+                    ):
+    a=HPDF_REAL(a)
+    b=HPDF_REAL(b)
+    c=HPDF_REAL(c)
+    d=HPDF_REAL(d)
+    x=HPDF_REAL(x)
+    y=HPDF_REAL(y)
+    return _HPDF_Page_Concat(
+                             page,    #HPDF_Page
+                             a,    #HPDF_REAL
+                             b,    #HPDF_REAL
+                             c,    #HPDF_REAL
+                             d,    #HPDF_REAL
+                             x,    #HPDF_REAL
+                             y,    #HPDF_REAL
+                            )
+
+
+#--- Path construction operator ------------------------------------------
+# m
+#HPDF_STATUS HPDF_Page_MoveTo (HPDF_Page page, HPDF_REAL x, HPDF_REAL y)
+_HPDF_Page_MoveTo=haru.HPDF_Page_MoveTo
+_HPDF_Page_MoveTo.restype=HPDF_STATUS
+def HPDF_Page_MoveTo(
+                     page,    #HPDF_Page
+                     x,    #HPDF_REAL
+                     y,    #HPDF_REAL
+                    ):
+    x=HPDF_REAL(x)
+    y=HPDF_REAL(y)
+    return _HPDF_Page_MoveTo(
+                             page,    #HPDF_Page
+                             x,    #HPDF_REAL
+                             y,    #HPDF_REAL
+                            )
+
+
+# l
+#HPDF_STATUS HPDF_Page_LineTo (HPDF_Page page, HPDF_REAL x, HPDF_REAL y)
+_HPDF_Page_LineTo=haru.HPDF_Page_LineTo
+_HPDF_Page_LineTo.restype=HPDF_STATUS
+def HPDF_Page_LineTo(
+                     page,    #HPDF_Page
+                     x,    #HPDF_REAL
+                     y,    #HPDF_REAL
+                    ):
+    x=HPDF_REAL(x)
+    y=HPDF_REAL(y)
+    return _HPDF_Page_LineTo(
+                             page,    #HPDF_Page
+                             x,    #HPDF_REAL
+                             y,    #HPDF_REAL
+                            )
+
+
+# c
+
+#HPDF_STATUS HPDF_Page_CurveTo (HPDF_Page page, HPDF_REAL x1, HPDF_REAL y1, HPDF_REAL x2, HPDF_REAL y2, HPDF_REAL x3, HPDF_REAL y3)
+_HPDF_Page_CurveTo=haru.HPDF_Page_CurveTo
+_HPDF_Page_CurveTo.restype=HPDF_STATUS
+def HPDF_Page_CurveTo(
+                      page,    #HPDF_Page
+                      x1,    #HPDF_REAL
+                      y1,    #HPDF_REAL
+                      x2,    #HPDF_REAL
+                      y2,    #HPDF_REAL
+                      x3,    #HPDF_REAL
+                      y3,    #HPDF_REAL
+                     ):
+    x1=HPDF_REAL(x1)
+    y1=HPDF_REAL(y1)
+    x2=HPDF_REAL(x2)
+    y2=HPDF_REAL(y2)
+    x3=HPDF_REAL(x3)
+    y3=HPDF_REAL(y3)
+    return _HPDF_Page_CurveTo(
+                              page,    #HPDF_Page
+                              x1,    #HPDF_REAL
+                              y1,    #HPDF_REAL
+                              x2,    #HPDF_REAL
+                              y2,    #HPDF_REAL
+                              x3,    #HPDF_REAL
+                              y3,    #HPDF_REAL
+                             )
+
+
+# v
+#HPDF_STATUS HPDF_Page_CurveTo2 (HPDF_Page page, HPDF_REAL x2, HPDF_REAL y2, HPDF_REAL x3, HPDF_REAL y3)
+_HPDF_Page_CurveTo2=haru.HPDF_Page_CurveTo2
+_HPDF_Page_CurveTo2.restype=HPDF_STATUS
+def HPDF_Page_CurveTo2(
+                       page,    #HPDF_Page
+                       x2,    #HPDF_REAL
+                       y2,    #HPDF_REAL
+                       x3,    #HPDF_REAL
+                       y3,    #HPDF_REAL
+                      ):
+    x2=HPDF_REAL(x2)
+    y2=HPDF_REAL(y2)
+    x3=HPDF_REAL(x3)
+    y3=HPDF_REAL(y3)
+    return _HPDF_Page_CurveTo2(
+                               page,    #HPDF_Page
+                               x2,    #HPDF_REAL
+                               y2,    #HPDF_REAL
+                               x3,    #HPDF_REAL
+                               y3,    #HPDF_REAL
+                              )
+
+
+# y
+#HPDF_STATUS HPDF_Page_CurveTo3 (HPDF_Page page, HPDF_REAL x1, HPDF_REAL y1, HPDF_REAL x3, HPDF_REAL y3)
+_HPDF_Page_CurveTo3=haru.HPDF_Page_CurveTo3
+_HPDF_Page_CurveTo3.restype=HPDF_STATUS
+def HPDF_Page_CurveTo3(
+                       page,    #HPDF_Page
+                       x1,    #HPDF_REAL
+                       y1,    #HPDF_REAL
+                       x3,    #HPDF_REAL
+                       y3,    #HPDF_REAL
+                      ):
+    x1=HPDF_REAL(x1)
+    y1=HPDF_REAL(y1)
+    x3=HPDF_REAL(x3)
+    y3=HPDF_REAL(y3)
+    return _HPDF_Page_CurveTo3(
+                               page,    #HPDF_Page
+                               x1,    #HPDF_REAL
+                               y1,    #HPDF_REAL
+                               x3,    #HPDF_REAL
+                               y3,    #HPDF_REAL
+                              )
+
+
+# h
+#HPDF_STATUS HPDF_Page_ClosePath (HPDF_Page page)
+HPDF_Page_ClosePath=haru.HPDF_Page_ClosePath
+HPDF_Page_ClosePath.restype=HPDF_STATUS
+
+# re
+#HPDF_STATUS HPDF_Page_Rectangle (HPDF_Page page, HPDF_REAL x, HPDF_REAL y, HPDF_REAL width, HPDF_REAL height)
+_HPDF_Page_Rectangle=haru.HPDF_Page_Rectangle
+_HPDF_Page_Rectangle.restype=HPDF_STATUS
+def HPDF_Page_Rectangle(
+                        page,    #HPDF_Page
+                        x,    #HPDF_REAL
+                        y,    #HPDF_REAL
+                        width,    #HPDF_REAL
+                        height,    #HPDF_REAL
+                       ):
+    x=HPDF_REAL(x)
+    y=HPDF_REAL(y)
+    width=HPDF_REAL(width)
+    height=HPDF_REAL(height)
+    return _HPDF_Page_Rectangle(
+                                page,    #HPDF_Page
+                                x,    #HPDF_REAL
+                                y,    #HPDF_REAL
+                                width,    #HPDF_REAL
+                                height,    #HPDF_REAL
+                               )
+
+
+#--- Path painting operator ---------------------------------------------
+# S
+#HPDF_STATUS HPDF_Page_Stroke (HPDF_Page page)
+_HPDF_Page_Stroke=haru.HPDF_Page_Stroke
+_HPDF_Page_Stroke.restype=HPDF_STATUS
+def HPDF_Page_Stroke(
+                     page,    #HPDF_Page
+                    ):
+    return _HPDF_Page_Stroke(
+                             page,    #HPDF_Page
+                            )
+
+
+# s
+
+#HPDF_STATUS HPDF_Page_ClosePathStroke (HPDF_Page page)
+HPDF_Page_ClosePathStroke=haru.HPDF_Page_ClosePathStroke
+HPDF_Page_ClosePathStroke.restype=HPDF_STATUS
+
+
+# f
+#HPDF_STATUS HPDF_Page_Fill (HPDF_Page page)
+HPDF_Page_Fill=haru.HPDF_Page_Fill
+HPDF_Page_Fill.restype=HPDF_STATUS
+
+
+# f*
+#HPDF_STATUS HPDF_Page_Eofill (HPDF_Page page)
+HPDF_Page_Eofill=haru.HPDF_Page_Eofill
+HPDF_Page_Eofill.restype=HPDF_STATUS
+
+
+# B
+#HPDF_STATUS HPDF_Page_FillStroke (HPDF_Page page)
+HPDF_Page_FillStroke=haru.HPDF_Page_FillStroke
+HPDF_Page_FillStroke.restype=HPDF_STATUS
+
+
+# B*
+
+#HPDF_STATUS HPDF_Page_EofillStroke (HPDF_Page page)
+HPDF_Page_EofillStroke=haru.HPDF_Page_EofillStroke
+HPDF_Page_EofillStroke.restype=HPDF_STATUS
+
+
+# b
+
+#HPDF_STATUS HPDF_Page_ClosePathFillStroke (HPDF_Page page)
+HPDF_Page_ClosePathFillStroke=haru.HPDF_Page_ClosePathFillStroke
+HPDF_Page_ClosePathFillStroke.restype=HPDF_STATUS
+
+
+# b*
+
+#HPDF_STATUS HPDF_Page_ClosePathEofillStroke (HPDF_Page page)
+HPDF_Page_ClosePathEofillStroke=haru.HPDF_Page_ClosePathEofillStroke
+HPDF_Page_ClosePathEofillStroke.restype=HPDF_STATUS
+
+
+# n
+
+#HPDF_STATUS HPDF_Page_EndPath (HPDF_Page page)
+HPDF_Page_EndPath=haru.HPDF_Page_EndPath
+HPDF_Page_EndPath.restype=HPDF_STATUS
+
+
+#--- Clipping paths operator --------------------------------------------
+# W
+#HPDF_STATUS HPDF_Page_Clip (HPDF_Page page)
+HPDF_Page_Clip=haru.HPDF_Page_Clip
+HPDF_Page_Clip.restype=HPDF_STATUS
+
+
+# W*
+#HPDF_STATUS HPDF_Page_Eoclip (HPDF_Page page)
+HPDF_Page_Eoclip=haru.HPDF_Page_Eoclip
+HPDF_Page_Eoclip.restype=HPDF_STATUS
+
+
+#--- Text object operator -----------------------------------------------
+# BT
+#HPDF_STATUS HPDF_Page_BeginText (HPDF_Page page)
+HPDF_Page_BeginText=haru.HPDF_Page_BeginText
+HPDF_Page_BeginText.restype=HPDF_STATUS
+
+
+# ET
+#HPDF_STATUS HPDF_Page_EndText (HPDF_Page page)
+HPDF_Page_EndText=haru.HPDF_Page_EndText
+HPDF_Page_EndText.restype=HPDF_STATUS
+
+
+#--- Text state ---------------------------------------------------------
+# Tc
+
+#HPDF_STATUS HPDF_Page_SetCharSpace (HPDF_Page page, HPDF_REAL value)
+_HPDF_Page_SetCharSpace=haru.HPDF_Page_SetCharSpace
+_HPDF_Page_SetCharSpace.restype=HPDF_STATUS
+def HPDF_Page_SetCharSpace(
+                           page,    #HPDF_Page
+                           value,    #HPDF_REAL
+                          ):
+    value=HPDF_REAL(value)
+    return _HPDF_Page_SetCharSpace(
+                                   page,    #HPDF_Page
+                                   value,    #HPDF_REAL
+                                  )
+
+
+# Tw
+
+#HPDF_STATUS HPDF_Page_SetWordSpace (HPDF_Page page, HPDF_REAL value)
+_HPDF_Page_SetWordSpace=haru.HPDF_Page_SetWordSpace
+_HPDF_Page_SetWordSpace.restype=HPDF_STATUS
+def HPDF_Page_SetWordSpace(
+                           page,    #HPDF_Page
+                           value,    #HPDF_REAL
+                          ):
+    value=HPDF_REAL(value)
+    return _HPDF_Page_SetWordSpace(
+                                   page,    #HPDF_Page
+                                   value,    #HPDF_REAL
+                                  )
+
+
+# Tz
+
+#HPDF_STATUS HPDF_Page_SetHorizontalScalling (HPDF_Page page, HPDF_REAL value)
+_HPDF_Page_SetHorizontalScalling=haru.HPDF_Page_SetHorizontalScalling
+_HPDF_Page_SetHorizontalScalling.restype=HPDF_STATUS
+def HPDF_Page_SetHorizontalScalling(
+                                    page,    #HPDF_Page
+                                    value,    #HPDF_REAL
+                                   ):
+    value=HPDF_REAL(value)
+    return _HPDF_Page_SetHorizontalScalling(
+                                            page,    #HPDF_Page
+                                            value,    #HPDF_REAL
+                                           )
+
+
+# TL
+#HPDF_STATUS HPDF_Page_SetTextLeading (HPDF_Page page, HPDF_REAL value)
+_HPDF_Page_SetTextLeading=haru.HPDF_Page_SetTextLeading
+_HPDF_Page_SetTextLeading.restype=HPDF_STATUS
+def HPDF_Page_SetTextLeading(
+                             page,    #HPDF_Page
+                             value,    #HPDF_REAL
+                            ):
+    value=HPDF_REAL(value)
+    return _HPDF_Page_SetTextLeading(
+                                     page,    #HPDF_Page
+                                     value,    #HPDF_REAL
+                                    )
+
+
+# Tf
+#HPDF_STATUS HPDF_Page_SetFontAndSize (HPDF_Page page, HPDF_Font font, HPDF_REAL size)
+_HPDF_Page_SetFontAndSize=haru.HPDF_Page_SetFontAndSize
+_HPDF_Page_SetFontAndSize.restype=HPDF_STATUS
+def HPDF_Page_SetFontAndSize(
+                             page,    #HPDF_Page
+                             font,    #HPDF_Font
+                             size,    #HPDF_REAL
+                            ):
+    size=HPDF_REAL(size)
+    return _HPDF_Page_SetFontAndSize(
+                                     page,    #HPDF_Page
+                                     font,    #HPDF_Font
+                                     size,    #HPDF_REAL
+                                    )
+
+
+# Tr
+
+#HPDF_STATUS HPDF_Page_SetTextRenderingMode (HPDF_Page page, HPDF_TextRenderingMode mode)
+HPDF_Page_SetTextRenderingMode=haru.HPDF_Page_SetTextRenderingMode
+HPDF_Page_SetTextRenderingMode.restype=HPDF_STATUS
+
+
+# Ts
+
+#HPDF_STATUS HPDF_Page_SetTextRise (HPDF_Page page, HPDF_REAL value)
+_HPDF_Page_SetTextRise=haru.HPDF_Page_SetTextRise
+_HPDF_Page_SetTextRise.restype=HPDF_STATUS
+def HPDF_Page_SetTextRise(
+                          page,    #HPDF_Page
+                          value,    #HPDF_REAL
+                         ):
+    value=HPDF_REAL(value)
+    return _HPDF_Page_SetTextRise(
+                                  page,    #HPDF_Page
+                                  value,    #HPDF_REAL
+                                 )
+
+
+# This function is obsolete. Use HPDF_Page_SetTextRise.
+
+#HPDF_STATUS HPDF_Page_SetTextRaise (HPDF_Page page, HPDF_REAL value)
+_HPDF_Page_SetTextRaise=haru.HPDF_Page_SetTextRaise
+_HPDF_Page_SetTextRaise.restype=HPDF_STATUS
+def HPDF_Page_SetTextRaise(
+                           page,    #HPDF_Page
+                           value,    #HPDF_REAL
+                          ):
+    value=HPDF_REAL(value)
+    return _HPDF_Page_SetTextRaise(
+                                   page,    #HPDF_Page
+                                   value,    #HPDF_REAL
+                                  )
+
+
+#--- Text positioning ---------------------------------------------------
+# Td
+#HPDF_STATUS HPDF_Page_MoveTextPos (HPDF_Page page, HPDF_REAL x, HPDF_REAL y)
+_HPDF_Page_MoveTextPos=haru.HPDF_Page_MoveTextPos
+_HPDF_Page_MoveTextPos.restype=HPDF_STATUS
+def HPDF_Page_MoveTextPos(
+                          page,    #HPDF_Page
+                          x,    #HPDF_REAL
+                          y,    #HPDF_REAL
+                         ):
+    x=HPDF_REAL(x)
+    y=HPDF_REAL(y)
+    return _HPDF_Page_MoveTextPos(
+                                  page,    #HPDF_Page
+                                  x,    #HPDF_REAL
+                                  y,    #HPDF_REAL
+                                 )
+
+
+# TD
+
+#HPDF_STATUS HPDF_Page_MoveTextPos2 (HPDF_Page page, HPDF_REAL x, HPDF_REAL y)
+_HPDF_Page_MoveTextPos2=haru.HPDF_Page_MoveTextPos2
+_HPDF_Page_MoveTextPos2.restype=HPDF_STATUS
+def HPDF_Page_MoveTextPos2(
+                           page,    #HPDF_Page
+                           x,    #HPDF_REAL
+                           y,    #HPDF_REAL
+                          ):
+    x=HPDF_REAL(x)
+    y=HPDF_REAL(y)
+    return _HPDF_Page_MoveTextPos2(
+                                   page,    #HPDF_Page
+                                   x,    #HPDF_REAL
+                                   y,    #HPDF_REAL
+                                  )
+
+
+# Tm
+
+#HPDF_STATUS HPDF_Page_SetTextMatrix (HPDF_Page page, HPDF_REAL a, HPDF_REAL b, HPDF_REAL c, HPDF_REAL d, HPDF_REAL x, HPDF_REAL y)
+_HPDF_Page_SetTextMatrix=haru.HPDF_Page_SetTextMatrix
+_HPDF_Page_SetTextMatrix.restype=HPDF_STATUS
+def HPDF_Page_SetTextMatrix(
+                            page,    #HPDF_Page
+                            a,    #HPDF_REAL
+                            b,    #HPDF_REAL
+                            c,    #HPDF_REAL
+                            d,    #HPDF_REAL
+                            x,    #HPDF_REAL
+                            y,    #HPDF_REAL
+                           ):
+    a=HPDF_REAL(a)
+    b=HPDF_REAL(b)
+    c=HPDF_REAL(c)
+    d=HPDF_REAL(d)
+    x=HPDF_REAL(x)
+    y=HPDF_REAL(y)
+    return _HPDF_Page_SetTextMatrix(
+                                    page,    #HPDF_Page
+                                    a,    #HPDF_REAL
+                                    b,    #HPDF_REAL
+                                    c,    #HPDF_REAL
+                                    d,    #HPDF_REAL
+                                    x,    #HPDF_REAL
+                                    y,    #HPDF_REAL
+                                   )
+
+
+# T*
+
+#HPDF_STATUS HPDF_Page_MoveToNextLine (HPDF_Page page)
+HPDF_Page_MoveToNextLine=haru.HPDF_Page_MoveToNextLine
+HPDF_Page_MoveToNextLine.restype=HPDF_STATUS
+
+#--- Text showing -------------------------------------------------------
+
+
+# Tj
+#HPDF_STATUS HPDF_Page_ShowText (HPDF_Page page, const char *text)
+_HPDF_Page_ShowText=haru.HPDF_Page_ShowText
+_HPDF_Page_ShowText.restype=HPDF_STATUS
+def HPDF_Page_ShowText(page,
+                       text
+                      ):
+    if type(text) in (types.ListType, types.TupleType):
+        if type(text[-1]) != types.StringType:
+            text=[chr(i) for i in text]
+        text=''.join(text)
+    return _HPDF_Page_ShowText(page,
+                       text
+                      )
+
+
+# TJ
+
+# '
+#HPDF_STATUS HPDF_Page_ShowTextNextLine (HPDF_Page page, const char *text)
+HPDF_Page_ShowTextNextLine=haru.HPDF_Page_ShowTextNextLine
+HPDF_Page_ShowTextNextLine.restype=HPDF_STATUS
+
+
+# "
+
+#HPDF_STATUS HPDF_Page_ShowTextNextLineEx (HPDF_Page page, HPDF_REAL word_space, HPDF_REAL char_space, const char *text)
+_HPDF_Page_ShowTextNextLineEx=haru.HPDF_Page_ShowTextNextLineEx
+_HPDF_Page_ShowTextNextLineEx.restype=HPDF_STATUS
+def HPDF_Page_ShowTextNextLineEx(
+                                 page,    #HPDF_Page
+                                 word_space,    #HPDF_REAL
+                                 char_space,    #HPDF_REAL
+                                 text,    #c_char_p
+                                ):
+    word_space=HPDF_REAL(word_space)
+    char_space=HPDF_REAL(char_space)
+    return _HPDF_Page_ShowTextNextLineEx(
+                                         page,    #HPDF_Page
+                                         word_space,    #HPDF_REAL
+                                         char_space,    #HPDF_REAL
+                                         text,    #c_char_p
+                                        )
+
+
+#--- Color showing ------------------------------------------------------
+# cs --not implemented yet
+# CS --not implemented yet
+# sc --not implemented yet
+# scn --not implemented yet
+# SC --not implemented yet
+# SCN --not implemented yet
+
+# g
+#HPDF_STATUS HPDF_Page_SetGrayFill (HPDF_Page page, HPDF_REAL gray)
+_HPDF_Page_SetGrayFill=haru.HPDF_Page_SetGrayFill
+_HPDF_Page_SetGrayFill.restype=HPDF_STATUS
+def HPDF_Page_SetGrayFill(
+                          page,    #HPDF_Page
+                          gray,    #HPDF_REAL
+                         ):
+    gray=HPDF_REAL(gray)
+    return _HPDF_Page_SetGrayFill(
+                                  page,    #HPDF_Page
+                                  gray,    #HPDF_REAL
+                                 )
+
+
+# G
+
+#HPDF_STATUS HPDF_Page_SetGrayStroke (HPDF_Page page, HPDF_REAL gray)
+_HPDF_Page_SetGrayStroke=haru.HPDF_Page_SetGrayStroke
+_HPDF_Page_SetGrayStroke.restype=HPDF_STATUS
+def HPDF_Page_SetGrayStroke(
+                            page,    #HPDF_Page
+                            gray,    #HPDF_REAL
+                           ):
+    gray=HPDF_REAL(gray)
+    return _HPDF_Page_SetGrayStroke(
+                                    page,    #HPDF_Page
+                                    gray,    #HPDF_REAL
+                                   )
+
+
+# rg
+#HPDF_STATUS HPDF_Page_SetRGBFill (HPDF_Page page, HPDF_REAL r, HPDF_REAL g, HPDF_REAL b)
+_HPDF_Page_SetRGBFill=haru.HPDF_Page_SetRGBFill
+_HPDF_Page_SetRGBFill.restype=HPDF_STATUS
+def HPDF_Page_SetRGBFill(
+                         page,    #HPDF_Page
+                         r,    #HPDF_REAL
+                         g,    #HPDF_REAL
+                         b,    #HPDF_REAL
+                        ):
+    r=HPDF_REAL(r)
+    g=HPDF_REAL(g)
+    b=HPDF_REAL(b)
+    return _HPDF_Page_SetRGBFill(
+                                 page,    #HPDF_Page
+                                 r,    #HPDF_REAL
+                                 g,    #HPDF_REAL
+                                 b,    #HPDF_REAL
+                                )
+
+
+# RG
+#HPDF_STATUS HPDF_Page_SetRGBStroke (HPDF_Page page, HPDF_REAL r, HPDF_REAL g, HPDF_REAL b)
+_HPDF_Page_SetRGBStroke=haru.HPDF_Page_SetRGBStroke
+_HPDF_Page_SetRGBStroke.restype=HPDF_STATUS
+def HPDF_Page_SetRGBStroke(
+                           page,    #HPDF_Page
+                           r,    #HPDF_REAL
+                           g,    #HPDF_REAL
+                           b,    #HPDF_REAL
+                          ):
+    r=HPDF_REAL(r)
+    g=HPDF_REAL(g)
+    b=HPDF_REAL(b)
+    return _HPDF_Page_SetRGBStroke(
+                                   page,    #HPDF_Page
+                                   r,    #HPDF_REAL
+                                   g,    #HPDF_REAL
+                                   b,    #HPDF_REAL
+                                  )
+
+
+# k
+
+#HPDF_STATUS HPDF_Page_SetCMYKFill (HPDF_Page page, HPDF_REAL c, HPDF_REAL m, HPDF_REAL y, HPDF_REAL k)
+_HPDF_Page_SetCMYKFill=haru.HPDF_Page_SetCMYKFill
+_HPDF_Page_SetCMYKFill.restype=HPDF_STATUS
+def HPDF_Page_SetCMYKFill(
+                          page,    #HPDF_Page
+                          c,    #HPDF_REAL
+                          m,    #HPDF_REAL
+                          y,    #HPDF_REAL
+                          k,    #HPDF_REAL
+                         ):
+    c=HPDF_REAL(c)
+    m=HPDF_REAL(m)
+    y=HPDF_REAL(y)
+    k=HPDF_REAL(k)
+    return _HPDF_Page_SetCMYKFill(
+                                  page,    #HPDF_Page
+                                  c,    #HPDF_REAL
+                                  m,    #HPDF_REAL
+                                  y,    #HPDF_REAL
+                                  k,    #HPDF_REAL
+                                 )
+
+
+# K
+
+#HPDF_STATUS HPDF_Page_SetCMYKStroke (HPDF_Page page, HPDF_REAL c, HPDF_REAL m, HPDF_REAL y, HPDF_REAL k)
+_HPDF_Page_SetCMYKStroke=haru.HPDF_Page_SetCMYKStroke
+_HPDF_Page_SetCMYKStroke.restype=HPDF_STATUS
+def HPDF_Page_SetCMYKStroke(
+                            page,    #HPDF_Page
+                            c,    #HPDF_REAL
+                            m,    #HPDF_REAL
+                            y,    #HPDF_REAL
+                            k,    #HPDF_REAL
+                           ):
+    c=HPDF_REAL(c)
+    m=HPDF_REAL(m)
+    y=HPDF_REAL(y)
+    k=HPDF_REAL(k)
+    return _HPDF_Page_SetCMYKStroke(
+                                    page,    #HPDF_Page
+                                    c,    #HPDF_REAL
+                                    m,    #HPDF_REAL
+                                    y,    #HPDF_REAL
+                                    k,    #HPDF_REAL
+                                   )
+
+
+#--- Shading patterns ---------------------------------------------------
+# sh --not implemented yet
+
+#--- In-line images -----------------------------------------------------
+# BI --not implemented yet
+# ID --not implemented yet
+# EI --not implemented yet
+
+#--- XObjects -----------------------------------------------------------
+# Do
+
+#HPDF_STATUS HPDF_Page_ExecuteXObject (HPDF_Page page, HPDF_XObject obj)
+HPDF_Page_ExecuteXObject=haru.HPDF_Page_ExecuteXObject
+HPDF_Page_ExecuteXObject.restype=HPDF_STATUS
+
+
+#--- Marked content -----------------------------------------------------
+# BMC --not implemented yet
+# BDC --not implemented yet
+# EMC --not implemented yet
+# MP --not implemented yet
+# DP --not implemented yet
+
+#--- Compatibility ------------------------------------------------------
+# BX --not implemented yet
+# EX --not implemented yet
+
+#HPDF_STATUS HPDF_Page_DrawImage (HPDF_Page page, HPDF_Image image, HPDF_REAL x, HPDF_REAL y, HPDF_REAL width, HPDF_REAL height)
+_HPDF_Page_DrawImage=haru.HPDF_Page_DrawImage
+_HPDF_Page_DrawImage.restype=HPDF_STATUS
+def HPDF_Page_DrawImage(
+                        page,    #HPDF_Page
+                        image,    #HPDF_Image
+                        x,    #HPDF_REAL
+                        y,    #HPDF_REAL
+                        width,    #HPDF_REAL
+                        height,    #HPDF_REAL
+                       ):
+    x=HPDF_REAL(x)
+    y=HPDF_REAL(y)
+    width=HPDF_REAL(width)
+    height=HPDF_REAL(height)
+    return _HPDF_Page_DrawImage(
+                                page,    #HPDF_Page
+                                image,    #HPDF_Image
+                                x,    #HPDF_REAL
+                                y,    #HPDF_REAL
+                                width,    #HPDF_REAL
+                                height,    #HPDF_REAL
+                               )
+
+
+#HPDF_STATUS HPDF_Page_Circle (HPDF_Page page, HPDF_REAL x, HPDF_REAL y, HPDF_REAL ray)
+_HPDF_Page_Circle=haru.HPDF_Page_Circle
+_HPDF_Page_Circle.restype=HPDF_STATUS
+def HPDF_Page_Circle(
+                     page,    #HPDF_Page
+                     x,    #HPDF_REAL
+                     y,    #HPDF_REAL
+                     ray,    #HPDF_REAL
+                    ):
+    x=HPDF_REAL(x)
+    y=HPDF_REAL(y)
+    ray=HPDF_REAL(ray)
+    return _HPDF_Page_Circle(
+                             page,    #HPDF_Page
+                             x,    #HPDF_REAL
+                             y,    #HPDF_REAL
+                             ray,    #HPDF_REAL
+                            )
+
+
+#HPDF_STATUS HPDF_Page_Ellipse (HPDF_Page page, HPDF_REAL x, HPDF_REAL y, HPDF_REAL xray, HPDF_REAL yray)
+_HPDF_Page_Ellipse=haru.HPDF_Page_Ellipse
+_HPDF_Page_Ellipse.restype=HPDF_STATUS
+def HPDF_Page_Ellipse(
+                      page,    #HPDF_Page
+                      x,    #HPDF_REAL
+                      y,    #HPDF_REAL
+                      xray,    #HPDF_REAL
+                      yray,    #HPDF_REAL
+                     ):
+    x=HPDF_REAL(x)
+    y=HPDF_REAL(y)
+    xray=HPDF_REAL(xray)
+    yray=HPDF_REAL(yray)
+    return _HPDF_Page_Ellipse(
+                              page,    #HPDF_Page
+                              x,    #HPDF_REAL
+                              y,    #HPDF_REAL
+                              xray,    #HPDF_REAL
+                              yray,    #HPDF_REAL
+                             )
+
+
+#HPDF_STATUS HPDF_Page_Arc (HPDF_Page page, HPDF_REAL x, HPDF_REAL y, HPDF_REAL ray, HPDF_REAL ang1, HPDF_REAL ang2)
+_HPDF_Page_Arc=haru.HPDF_Page_Arc
+_HPDF_Page_Arc.restype=HPDF_STATUS
+def HPDF_Page_Arc(
+                  page,    #HPDF_Page
+                  x,    #HPDF_REAL
+                  y,    #HPDF_REAL
+                  ray,    #HPDF_REAL
+                  ang1,    #HPDF_REAL
+                  ang2,    #HPDF_REAL
+                 ):
+    x=HPDF_REAL(x)
+    y=HPDF_REAL(y)
+    ray=HPDF_REAL(ray)
+    ang1=HPDF_REAL(ang1)
+    ang2=HPDF_REAL(ang2)
+    return _HPDF_Page_Arc(
+                          page,    #HPDF_Page
+                          x,    #HPDF_REAL
+                          y,    #HPDF_REAL
+                          ray,    #HPDF_REAL
+                          ang1,    #HPDF_REAL
+                          ang2,    #HPDF_REAL
+                         )
+
+
+#HPDF_STATUS HPDF_Page_TextOut (HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, const char *text)
+_HPDF_Page_TextOut=haru.HPDF_Page_TextOut
+_HPDF_Page_TextOut.restype=HPDF_STATUS
+def HPDF_Page_TextOut(
+                      page,    #HPDF_Page
+                      xpos,    #HPDF_REAL
+                      ypos,    #HPDF_REAL
+                      text,    #c_char_p
+                     ):
+    xpos=HPDF_REAL(xpos)
+    ypos=HPDF_REAL(ypos)
+    if type(text) in (types.ListType, types.TupleType):
+        if type(text[-1]) != types.StringType:
+            text=[chr(i) for i in text]
+        text=''.join(text)
+
+    return _HPDF_Page_TextOut(
+                              page,    #HPDF_Page
+                              xpos,    #HPDF_REAL
+                              ypos,    #HPDF_REAL
+                              text,    #c_char_p
+                             )
+
+
+#HPDF_STATUS HPDF_Page_TextRect (HPDF_Page page, HPDF_REAL left, HPDF_REAL top, HPDF_REAL right, HPDF_REAL bottom, const char *text, HPDF_TextAlignment align, HPDF_UINT *len)
+#???
+_HPDF_Page_TextRect=haru.HPDF_Page_TextRect
+_HPDF_Page_TextRect.restype=HPDF_STATUS
+def HPDF_Page_TextRect(
+                       page,    #HPDF_Page
+                       left,    #HPDF_REAL
+                       top,    #HPDF_REAL
+                       right,    #HPDF_REAL
+                       bottom,    #HPDF_REAL
+                       text,    #c_char_p
+                       align,    #HPDF_TextAlignment
+                       length,    #POINTER(HPDF_UINT)
+                      ):
+    left=HPDF_REAL(left)
+    top=HPDF_REAL(top)
+    right=HPDF_REAL(right)
+    bottom=HPDF_REAL(bottom)
+
+    if type(length) in (types.ListType, types.TupleType):
+        size=len(length)
+        length=pointer((HPDF_UINT*size)(*length))
+
+    return _HPDF_Page_TextRect(
+                               page,    #HPDF_Page
+                               left,    #HPDF_REAL
+                               top,    #HPDF_REAL
+                               right,    #HPDF_REAL
+                               bottom,    #HPDF_REAL
+                               text,    #c_char_p
+                               align,    #HPDF_TextAlignment
+                               length,    #POINTER(HPDF_UINT)
+                              )
+
+
+#HPDF_STATUS HPDF_Page_SetSlideShow (HPDF_Page page, HPDF_TransitionStyle type, HPDF_REAL disp_time, HPDF_REAL trans_time)
+_HPDF_Page_SetSlideShow=haru.HPDF_Page_SetSlideShow
+_HPDF_Page_SetSlideShow.restype=HPDF_STATUS
+def HPDF_Page_SetSlideShow(
+                           page,    #HPDF_Page
+                           tType,    #HPDF_TransitionStyle
+                           disp_time,    #HPDF_REAL
+                           trans_time,    #HPDF_REAL
+                          ):
+    disp_time=HPDF_REAL(disp_time)
+    trans_time=HPDF_REAL(trans_time)
+    return _HPDF_Page_SetSlideShow(
+                                   page,    #HPDF_Page
+                                   tType,    #HPDF_TransitionStyle
+                                   disp_time,    #HPDF_REAL
+                                   trans_time,    #HPDF_REAL
+                                  )
+
+
+NULL=0
+
+HPDF_NOPNGLIB=False

+ 545 - 0
pdf.mod/libharu/bindings/python/hpdf_consts.py

@@ -0,0 +1,545 @@
+###
+## * << Haru Free PDF Library 2.0.8 >> -- hpdf_consts.h
+## *
+## * URL http://libharu.org/
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+from hpdf_types import *
+
+#----------------------------------------------------------------------------
+
+HPDF_TRUE                  =1
+HPDF_FALSE                 =0
+
+HPDF_OK                    =0
+HPDF_NOERROR               =0
+
+#----- default values -------------------------------------------------------
+
+# buffer size which is required when we convert to character string.
+HPDF_TMP_BUF_SIZ           =512
+HPDF_SHORT_BUF_SIZ         =32
+HPDF_REAL_LEN              =11
+HPDF_INT_LEN               =11
+HPDF_TEXT_DEFAULT_LEN      =256
+HPDF_UNICODE_HEADER_LEN    =2
+HPDF_DATE_TIME_STR_LEN     =23
+
+# length of each item defined in PDF
+HPDF_BYTE_OFFSET_LEN       =10
+HPDF_OBJ_ID_LEN            =7
+HPDF_GEN_NO_LEN            =5
+
+# default value of Graphic State
+HPDF_DEF_FONT              ="Helvetica"
+HPDF_DEF_PAGE_LAYOUT       =HPDF_PAGE_LAYOUT_SINGLE
+HPDF_DEF_PAGE_MODE         =HPDF_PAGE_MODE_USE_NONE
+HPDF_DEF_WORDSPACE         =0
+HPDF_DEF_CHARSPACE         =0
+HPDF_DEF_FONTSIZE          =10
+HPDF_DEF_HSCALING          =100
+HPDF_DEF_LEADING           =0
+HPDF_DEF_RENDERING_MODE    =HPDF_FILL
+HPDF_DEF_RISE              =0
+HPDF_DEF_RAISE             =HPDF_DEF_RISE
+HPDF_DEF_LINEWIDTH         =1
+HPDF_DEF_LINECAP           =HPDF_BUTT_END
+HPDF_DEF_LINEJOIN          =HPDF_MITER_JOIN
+HPDF_DEF_MITERLIMIT        =10
+HPDF_DEF_FLATNESS          =1
+HPDF_DEF_PAGE_NUM          =1
+
+HPDF_BS_DEF_WIDTH          =1
+
+# default page-size
+HPDF_DEF_PAGE_WIDTH        =595.276
+HPDF_DEF_PAGE_HEIGHT       =841.89
+
+HPDF_VERSION_TEXT          ="2.0.8"
+
+#---------------------------------------------------------------------------
+#----- compression mode ----------------------------------------------------
+
+HPDF_COMP_NONE           =0x00
+HPDF_COMP_TEXT           =0x01
+HPDF_COMP_IMAGE          =0x02
+HPDF_COMP_METADATA       =0x04
+HPDF_COMP_ALL            =0x0F
+HPDF_COMP_BEST_COMPRESS  =0x10
+HPDF_COMP_BEST_SPEED     =0x20
+
+HPDF_COMP_MASK           =0xFF
+
+
+#----------------------------------------------------------------------------
+#----- permission flags (only Revision 2 is supported)-----------------------
+
+HPDF_ENABLE_READ        =0
+HPDF_ENABLE_PRINT       =4
+HPDF_ENABLE_EDIT_ALL    =8
+HPDF_ENABLE_COPY        =16
+HPDF_ENABLE_EDIT        =32
+
+
+#----------------------------------------------------------------------------
+#------ viewer preferences definitions --------------------------------------
+
+HPDF_HIDE_TOOLBAR   =1
+HPDF_HIDE_MENUBAR   =2
+HPDF_HIDE_WINDOW_UI =4
+HPDF_FIT_WINDOW     =8
+HPDF_CENTER_WINDOW  =16
+
+
+#---------------------------------------------------------------------------
+#------ limitation of object implementation (PDF1.4) -----------------------
+
+HPDF_LIMIT_MAX_INT            =2147483647
+HPDF_LIMIT_MIN_INT            =-2147483647
+
+HPDF_LIMIT_MAX_REAL           =32767
+HPDF_LIMIT_MIN_REAL           =-32767
+
+HPDF_LIMIT_MAX_STRING_LEN     =65535
+HPDF_LIMIT_MAX_NAME_LEN       =127
+
+HPDF_LIMIT_MAX_ARRAY          =8191
+HPDF_LIMIT_MAX_DICT_ELEMENT   =4095
+HPDF_LIMIT_MAX_XREF_ELEMENT   =8388607
+HPDF_LIMIT_MAX_GSTATE         =28
+HPDF_LIMIT_MAX_DEVICE_N       =8
+HPDF_LIMIT_MAX_DEVICE_N_V15   =32
+HPDF_LIMIT_MAX_CID            =65535
+HPDF_MAX_GENERATION_NUM       =65535
+
+HPDF_MIN_PAGE_HEIGHT          =3
+HPDF_MIN_PAGE_WIDTH           =3
+HPDF_MAX_PAGE_HEIGHT          =14400
+HPDF_MAX_PAGE_WIDTH           =14400
+HPDF_MIN_MAGNIFICATION_FACTOR =8
+HPDF_MAX_MAGNIFICATION_FACTOR =3200
+
+#---------------------------------------------------------------------------
+#------ limitation of various properties -----------------------------------
+
+HPDF_MIN_PAGE_SIZE         =3
+HPDF_MAX_PAGE_SIZE         =14400
+HPDF_MIN_HORIZONTALSCALING =10
+HPDF_MAX_HORIZONTALSCALING =300
+HPDF_MIN_WORDSPACE         =-30
+HPDF_MAX_WORDSPACE         =300
+HPDF_MIN_CHARSPACE         =-30
+HPDF_MAX_CHARSPACE         =300
+HPDF_MAX_FONTSIZE          =300
+HPDF_MAX_ZOOMSIZE          =10
+HPDF_MAX_LEADING           =300
+HPDF_MAX_LINEWIDTH         =100
+HPDF_MAX_DASH_PATTERN      =100
+
+HPDF_MAX_JWW_NUM           =128
+
+#----------------------------------------------------------------------------
+#----- country code definition ----------------------------------------------
+
+HPDF_COUNTRY_AF ="AF"    # AFGHANISTAN
+HPDF_COUNTRY_AL ="AL"    # ALBANIA
+HPDF_COUNTRY_DZ ="DZ"    # ALGERIA
+HPDF_COUNTRY_AS ="AS"    # AMERICAN SAMOA
+HPDF_COUNTRY_AD ="AD"    # ANDORRA
+HPDF_COUNTRY_AO ="AO"    # ANGOLA
+HPDF_COUNTRY_AI ="AI"    # ANGUILLA
+HPDF_COUNTRY_AQ ="AQ"    # ANTARCTICA
+HPDF_COUNTRY_AG ="AG"    # ANTIGUA AND BARBUDA
+HPDF_COUNTRY_AR ="AR"    # ARGENTINA
+HPDF_COUNTRY_AM ="AM"    # ARMENIA
+HPDF_COUNTRY_AW ="AW"    # ARUBA
+HPDF_COUNTRY_AU ="AU"    # AUSTRALIA
+HPDF_COUNTRY_AT ="AT"    # AUSTRIA
+HPDF_COUNTRY_AZ ="AZ"    # AZERBAIJAN
+HPDF_COUNTRY_BS ="BS"    # BAHAMAS
+HPDF_COUNTRY_BH ="BH"    # BAHRAIN
+HPDF_COUNTRY_BD ="BD"    # BANGLADESH
+HPDF_COUNTRY_BB ="BB"    # BARBADOS
+HPDF_COUNTRY_BY ="BY"    # BELARUS
+HPDF_COUNTRY_BE ="BE"    # BELGIUM
+HPDF_COUNTRY_BZ ="BZ"    # BELIZE
+HPDF_COUNTRY_BJ ="BJ"    # BENIN
+HPDF_COUNTRY_BM ="BM"    # BERMUDA
+HPDF_COUNTRY_BT ="BT"    # BHUTAN
+HPDF_COUNTRY_BO ="BO"    # BOLIVIA
+HPDF_COUNTRY_BA ="BA"    # BOSNIA AND HERZEGOWINA
+HPDF_COUNTRY_BW ="BW"    # BOTSWANA
+HPDF_COUNTRY_BV ="BV"    # BOUVET ISLAND
+HPDF_COUNTRY_BR ="BR"    # BRAZIL
+HPDF_COUNTRY_IO ="IO"    # BRITISH INDIAN OCEAN TERRITORY
+HPDF_COUNTRY_BN ="BN"    # BRUNEI DARUSSALAM
+HPDF_COUNTRY_BG ="BG"    # BULGARIA
+HPDF_COUNTRY_BF ="BF"    # BURKINA FASO
+HPDF_COUNTRY_BI ="BI"    # BURUNDI
+HPDF_COUNTRY_KH ="KH"    # CAMBODIA
+HPDF_COUNTRY_CM ="CM"    # CAMEROON
+HPDF_COUNTRY_CA ="CA"    # CANADA
+HPDF_COUNTRY_CV ="CV"    # CAPE VERDE
+HPDF_COUNTRY_KY ="KY"    # CAYMAN ISLANDS
+HPDF_COUNTRY_CF ="CF"    # CENTRAL AFRICAN REPUBLIC
+HPDF_COUNTRY_TD ="TD"    # CHAD
+HPDF_COUNTRY_CL ="CL"    # CHILE
+HPDF_COUNTRY_CN ="CN"    # CHINA
+HPDF_COUNTRY_CX ="CX"    # CHRISTMAS ISLAND
+HPDF_COUNTRY_CC ="CC"    # COCOS (KEELING) ISLANDS
+HPDF_COUNTRY_CO ="CO"    # COLOMBIA
+HPDF_COUNTRY_KM ="KM"    # COMOROS
+HPDF_COUNTRY_CG ="CG"    # CONGO
+HPDF_COUNTRY_CK ="CK"    # COOK ISLANDS
+HPDF_COUNTRY_CR ="CR"    # COSTA RICA
+HPDF_COUNTRY_CI ="CI"    # COTE D'IVOIRE
+HPDF_COUNTRY_HR ="HR"    # CROATIA (local name: Hrvatska)
+HPDF_COUNTRY_CU ="CU"    # CUBA
+HPDF_COUNTRY_CY ="CY"    # CYPRUS
+HPDF_COUNTRY_CZ ="CZ"    # CZECH REPUBLIC
+HPDF_COUNTRY_DK ="DK"    # DENMARK
+HPDF_COUNTRY_DJ ="DJ"    # DJIBOUTI
+HPDF_COUNTRY_DM ="DM"    # DOMINICA
+HPDF_COUNTRY_DO ="DO"    # DOMINICAN REPUBLIC
+HPDF_COUNTRY_TP ="TP"    # EAST TIMOR
+HPDF_COUNTRY_EC ="EC"    # ECUADOR
+HPDF_COUNTRY_EG ="EG"    # EGYPT
+HPDF_COUNTRY_SV ="SV"    # EL SALVADOR
+HPDF_COUNTRY_GQ ="GQ"    # EQUATORIAL GUINEA
+HPDF_COUNTRY_ER ="ER"    # ERITREA
+HPDF_COUNTRY_EE ="EE"    # ESTONIA
+HPDF_COUNTRY_ET ="ET"    # ETHIOPIA
+HPDF_COUNTRY_FK ="FK"   # FALKLAND ISLANDS (MALVINAS)
+HPDF_COUNTRY_FO ="FO"    # FAROE ISLANDS
+HPDF_COUNTRY_FJ ="FJ"    # FIJI
+HPDF_COUNTRY_FI ="FI"    # FINLAND
+HPDF_COUNTRY_FR ="FR"    # FRANCE
+HPDF_COUNTRY_FX ="FX"    # FRANCE, METROPOLITAN
+HPDF_COUNTRY_GF ="GF"    # FRENCH GUIANA
+HPDF_COUNTRY_PF ="PF"    # FRENCH POLYNESIA
+HPDF_COUNTRY_TF ="TF"    # FRENCH SOUTHERN TERRITORIES
+HPDF_COUNTRY_GA ="GA"    # GABON
+HPDF_COUNTRY_GM ="GM"    # GAMBIA
+HPDF_COUNTRY_GE ="GE"    # GEORGIA
+HPDF_COUNTRY_DE ="DE"    # GERMANY
+HPDF_COUNTRY_GH ="GH"    # GHANA
+HPDF_COUNTRY_GI ="GI"    # GIBRALTAR
+HPDF_COUNTRY_GR ="GR"    # GREECE
+HPDF_COUNTRY_GL ="GL"    # GREENLAND
+HPDF_COUNTRY_GD ="GD"    # GRENADA
+HPDF_COUNTRY_GP ="GP"    # GUADELOUPE
+HPDF_COUNTRY_GU ="GU"    # GUAM
+HPDF_COUNTRY_GT ="GT"    # GUATEMALA
+HPDF_COUNTRY_GN ="GN"    # GUINEA
+HPDF_COUNTRY_GW ="GW"    # GUINEA-BISSAU
+HPDF_COUNTRY_GY ="GY"    # GUYANA
+HPDF_COUNTRY_HT ="HT"    # HAITI
+HPDF_COUNTRY_HM ="HM"    # HEARD AND MC DONALD ISLANDS
+HPDF_COUNTRY_HN ="HN"    # HONDURAS
+HPDF_COUNTRY_HK ="HK"    # HONG KONG
+HPDF_COUNTRY_HU ="HU"    # HUNGARY
+HPDF_COUNTRY_IS ="IS"    # ICELAND
+HPDF_COUNTRY_IN ="IN"    # INDIA
+HPDF_COUNTRY_ID ="ID"    # INDONESIA
+HPDF_COUNTRY_IR ="IR"    # IRAN (ISLAMIC REPUBLIC OF)
+HPDF_COUNTRY_IQ ="IQ"    # IRAQ
+HPDF_COUNTRY_IE ="IE"    # IRELAND
+HPDF_COUNTRY_IL ="IL"    # ISRAEL
+HPDF_COUNTRY_IT ="IT"    # ITALY
+HPDF_COUNTRY_JM ="JM"    # JAMAICA
+HPDF_COUNTRY_JP ="JP"    # JAPAN
+HPDF_COUNTRY_JO ="JO"    # JORDAN
+HPDF_COUNTRY_KZ ="KZ"    # KAZAKHSTAN
+HPDF_COUNTRY_KE ="KE"    # KENYA
+HPDF_COUNTRY_KI ="KI"    # KIRIBATI
+HPDF_COUNTRY_KP ="KP"    # KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF
+HPDF_COUNTRY_KR ="KR"    # KOREA, REPUBLIC OF
+HPDF_COUNTRY_KW ="KW"    # KUWAIT
+HPDF_COUNTRY_KG ="KG"    # KYRGYZSTAN
+HPDF_COUNTRY_LA ="LA"    # LAO PEOPLE'S DEMOCRATIC REPUBLIC
+HPDF_COUNTRY_LV ="LV"    # LATVIA
+HPDF_COUNTRY_LB ="LB"    # LEBANON
+HPDF_COUNTRY_LS ="LS"    # LESOTHO
+HPDF_COUNTRY_LR ="LR"    # LIBERIA
+HPDF_COUNTRY_LY ="LY"    # LIBYAN ARAB JAMAHIRIYA
+HPDF_COUNTRY_LI ="LI"    # LIECHTENSTEIN
+HPDF_COUNTRY_LT ="LT"    # LITHUANIA
+HPDF_COUNTRY_LU ="LU"    # LUXEMBOURG
+HPDF_COUNTRY_MO ="MO"    # MACAU
+HPDF_COUNTRY_MK ="MK"    # MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF
+HPDF_COUNTRY_MG ="MG"    # MADAGASCAR
+HPDF_COUNTRY_MW ="MW"    # MALAWI
+HPDF_COUNTRY_MY ="MY"    # MALAYSIA
+HPDF_COUNTRY_MV ="MV"    # MALDIVES
+HPDF_COUNTRY_ML ="ML"    # MALI
+HPDF_COUNTRY_MT ="MT"    # MALTA
+HPDF_COUNTRY_MH ="MH"    # MARSHALL ISLANDS
+HPDF_COUNTRY_MQ ="MQ"    # MARTINIQUE
+HPDF_COUNTRY_MR ="MR"    # MAURITANIA
+HPDF_COUNTRY_MU ="MU"    # MAURITIUS
+HPDF_COUNTRY_YT ="YT"    # MAYOTTE
+HPDF_COUNTRY_MX ="MX"    # MEXICO
+HPDF_COUNTRY_FM ="FM"    # MICRONESIA, FEDERATED STATES OF
+HPDF_COUNTRY_MD ="MD"    # MOLDOVA, REPUBLIC OF
+HPDF_COUNTRY_MC ="MC"    # MONACO
+HPDF_COUNTRY_MN ="MN"    # MONGOLIA
+HPDF_COUNTRY_MS ="MS"    # MONTSERRAT
+HPDF_COUNTRY_MA ="MA"    # MOROCCO
+HPDF_COUNTRY_MZ ="MZ"    # MOZAMBIQUE
+HPDF_COUNTRY_MM ="MM"    # MYANMAR
+HPDF_COUNTRY_NA ="NA"    # NAMIBIA
+HPDF_COUNTRY_NR ="NR"    # NAURU
+HPDF_COUNTRY_NP ="NP"    # NEPAL
+HPDF_COUNTRY_NL ="NL"    # NETHERLANDS
+HPDF_COUNTRY_AN ="AN"    # NETHERLANDS ANTILLES
+HPDF_COUNTRY_NC ="NC"    # NEW CALEDONIA
+HPDF_COUNTRY_NZ ="NZ"    # NEW ZEALAND
+HPDF_COUNTRY_NI ="NI"    # NICARAGUA
+HPDF_COUNTRY_NE ="NE"    # NIGER
+HPDF_COUNTRY_NG ="NG"    # NIGERIA
+HPDF_COUNTRY_NU ="NU"    # NIUE
+HPDF_COUNTRY_NF ="NF"    # NORFOLK ISLAND
+HPDF_COUNTRY_MP ="MP"    # NORTHERN MARIANA ISLANDS
+HPDF_COUNTRY_NO ="NO"    # NORWAY
+HPDF_COUNTRY_OM ="OM"    # OMAN
+HPDF_COUNTRY_PK ="PK"    # PAKISTAN
+HPDF_COUNTRY_PW ="PW"    # PALAU
+HPDF_COUNTRY_PA ="PA"    # PANAMA
+HPDF_COUNTRY_PG ="PG"    # PAPUA NEW GUINEA
+HPDF_COUNTRY_PY ="PY"    # PARAGUAY
+HPDF_COUNTRY_PE ="PE"    # PERU
+HPDF_COUNTRY_PH ="PH"    # PHILIPPINES
+HPDF_COUNTRY_PN ="PN"    # PITCAIRN
+HPDF_COUNTRY_PL ="PL"    # POLAND
+HPDF_COUNTRY_PT ="PT"    # PORTUGAL
+HPDF_COUNTRY_PR ="PR"    # PUERTO RICO
+HPDF_COUNTRY_QA ="QA"    # QATAR
+HPDF_COUNTRY_RE ="RE"    # REUNION
+HPDF_COUNTRY_RO ="RO"    # ROMANIA
+HPDF_COUNTRY_RU ="RU"    # RUSSIAN FEDERATION
+HPDF_COUNTRY_RW ="RW"    # RWANDA
+HPDF_COUNTRY_KN ="KN"    # SAINT KITTS AND NEVIS
+HPDF_COUNTRY_LC ="LC"    # SAINT LUCIA
+HPDF_COUNTRY_VC ="VC"    # SAINT VINCENT AND THE GRENADINES
+HPDF_COUNTRY_WS ="WS"    # SAMOA
+HPDF_COUNTRY_SM ="SM"    # SAN MARINO
+HPDF_COUNTRY_ST ="ST"    # SAO TOME AND PRINCIPE
+HPDF_COUNTRY_SA ="SA"    # SAUDI ARABIA
+HPDF_COUNTRY_SN ="SN"    # SENEGAL
+HPDF_COUNTRY_SC ="SC"    # SEYCHELLES
+HPDF_COUNTRY_SL ="SL"    # SIERRA LEONE
+HPDF_COUNTRY_SG ="SG"    # SINGAPORE
+HPDF_COUNTRY_SK ="SK"    # SLOVAKIA (Slovak Republic)
+HPDF_COUNTRY_SI ="SI"    # SLOVENIA
+HPDF_COUNTRY_SB ="SB"    # SOLOMON ISLANDS
+HPDF_COUNTRY_SO ="SO"    # SOMALIA
+HPDF_COUNTRY_ZA ="ZA"    # SOUTH AFRICA
+HPDF_COUNTRY_ES ="ES"    # SPAIN
+HPDF_COUNTRY_LK ="LK"    # SRI LANKA
+HPDF_COUNTRY_SH ="SH"    # ST. HELENA
+HPDF_COUNTRY_PM ="PM"    # ST. PIERRE AND MIQUELON
+HPDF_COUNTRY_SD ="SD"    # SUDAN
+HPDF_COUNTRY_SR ="SR"    # SURINAME
+HPDF_COUNTRY_SJ ="SJ"    # SVALBARD AND JAN MAYEN ISLANDS
+HPDF_COUNTRY_SZ ="SZ"    # SWAZILAND
+HPDF_COUNTRY_SE ="SE"    # SWEDEN
+HPDF_COUNTRY_CH ="CH"    # SWITZERLAND
+HPDF_COUNTRY_SY ="SY"    # SYRIAN ARAB REPUBLIC
+HPDF_COUNTRY_TW ="TW"    # TAIWAN, PROVINCE OF CHINA
+HPDF_COUNTRY_TJ ="TJ"    # TAJIKISTAN
+HPDF_COUNTRY_TZ ="TZ"    # TANZANIA, UNITED REPUBLIC OF
+HPDF_COUNTRY_TH ="TH"    # THAILAND
+HPDF_COUNTRY_TG ="TG"    # TOGO
+HPDF_COUNTRY_TK ="TK"    # TOKELAU
+HPDF_COUNTRY_TO ="TO"    # TONGA
+HPDF_COUNTRY_TT ="TT"    # TRINIDAD AND TOBAGO
+HPDF_COUNTRY_TN ="TN"    # TUNISIA
+HPDF_COUNTRY_TR ="TR"    # TURKEY
+HPDF_COUNTRY_TM ="TM"    # TURKMENISTAN
+HPDF_COUNTRY_TC ="TC"    # TURKS AND CAICOS ISLANDS
+HPDF_COUNTRY_TV ="TV"    # TUVALU
+HPDF_COUNTRY_UG ="UG"    # UGANDA
+HPDF_COUNTRY_UA ="UA"    # UKRAINE
+HPDF_COUNTRY_AE ="AE"    # UNITED ARAB EMIRATES
+HPDF_COUNTRY_GB ="GB"    # UNITED KINGDOM
+HPDF_COUNTRY_US ="US"    # UNITED STATES
+HPDF_COUNTRY_UM ="UM"    # UNITED STATES MINOR OUTLYING ISLANDS
+HPDF_COUNTRY_UY ="UY"    # URUGUAY
+HPDF_COUNTRY_UZ ="UZ"    # UZBEKISTAN
+HPDF_COUNTRY_VU ="VU"    # VANUATU
+HPDF_COUNTRY_VA ="VA"    # VATICAN CITY STATE (HOLY SEE)
+HPDF_COUNTRY_VE ="VE"    # VENEZUELA
+HPDF_COUNTRY_VN ="VN"    # VIET NAM
+HPDF_COUNTRY_VG ="VG"    # VIRGIN ISLANDS (BRITISH)
+HPDF_COUNTRY_VI ="VI"    # VIRGIN ISLANDS (U.S.)
+HPDF_COUNTRY_WF ="WF"    # WALLIS AND FUTUNA ISLANDS
+HPDF_COUNTRY_EH ="EH"    # WESTERN SAHARA
+HPDF_COUNTRY_YE ="YE"    # YEMEN
+HPDF_COUNTRY_YU ="YU"    # YUGOSLAVIA
+HPDF_COUNTRY_ZR ="ZR"    # ZAIRE
+HPDF_COUNTRY_ZM ="ZM"    # ZAMBIA
+HPDF_COUNTRY_ZW ="ZW"    # ZIMBABWE
+
+#----------------------------------------------------------------------------
+#----- lang code definition -------------------------------------------------
+
+HPDF_LANG_AA   ="aa"     # Afar
+HPDF_LANG_AB   ="ab"     # Abkhazian
+HPDF_LANG_AF   ="af"     # Afrikaans
+HPDF_LANG_AM   ="am"     # Amharic
+HPDF_LANG_AR   ="ar"     # Arabic
+HPDF_LANG_AS   ="as"     # Assamese
+HPDF_LANG_AY   ="ay"     # Aymara
+HPDF_LANG_AZ   ="az"     # Azerbaijani
+HPDF_LANG_BA   ="ba"     # Bashkir
+HPDF_LANG_BE   ="be"     # Byelorussian
+HPDF_LANG_BG   ="bg"     # Bulgarian
+HPDF_LANG_BH   ="bh"     # Bihari
+HPDF_LANG_BI   ="bi"     # Bislama
+HPDF_LANG_BN   ="bn"     # Bengali Bangla
+HPDF_LANG_BO   ="bo"     # Tibetan
+HPDF_LANG_BR   ="br"     # Breton
+HPDF_LANG_CA   ="ca"     # Catalan
+HPDF_LANG_CO   ="co"     # Corsican
+HPDF_LANG_CS   ="cs"     # Czech
+HPDF_LANG_CY   ="cy"     # Welsh
+HPDF_LANG_DA   ="da"     # Danish
+HPDF_LANG_DE   ="de"     # German
+HPDF_LANG_DZ   ="dz"     # Bhutani
+HPDF_LANG_EL   ="el"     # Greek
+HPDF_LANG_EN   ="en"     # English
+HPDF_LANG_EO   ="eo"     # Esperanto
+HPDF_LANG_ES   ="es"     # Spanish
+HPDF_LANG_ET   ="et"     # Estonian
+HPDF_LANG_EU   ="eu"     # Basque
+HPDF_LANG_FA   ="fa"     # Persian
+HPDF_LANG_FI   ="fi"     # Finnish
+HPDF_LANG_FJ   ="fj"     # Fiji
+HPDF_LANG_FO   ="fo"     # Faeroese
+HPDF_LANG_FR   ="fr"     # French
+HPDF_LANG_FY   ="fy"     # Frisian
+HPDF_LANG_GA   ="ga"     # Irish
+HPDF_LANG_GD   ="gd"     # Scots Gaelic
+HPDF_LANG_GL   ="gl"     # Galician
+HPDF_LANG_GN   ="gn"     # Guarani
+HPDF_LANG_GU   ="gu"     # Gujarati
+HPDF_LANG_HA   ="ha"     # Hausa
+HPDF_LANG_HI   ="hi"     # Hindi
+HPDF_LANG_HR   ="hr"     # Croatian
+HPDF_LANG_HU   ="hu"     # Hungarian
+HPDF_LANG_HY   ="hy"     # Armenian
+HPDF_LANG_IA   ="ia"     # Interlingua
+HPDF_LANG_IE   ="ie"     # Interlingue
+HPDF_LANG_IK   ="ik"     # Inupiak
+HPDF_LANG_IN   ="in"     # Indonesian
+HPDF_LANG_IS   ="is"     # Icelandic
+HPDF_LANG_IT   ="it"     # Italian
+HPDF_LANG_IW   ="iw"     # Hebrew
+HPDF_LANG_JA   ="ja"     # Japanese
+HPDF_LANG_JI   ="ji"     # Yiddish
+HPDF_LANG_JW   ="jw"     # Javanese
+HPDF_LANG_KA   ="ka"     # Georgian
+HPDF_LANG_KK   ="kk"     # Kazakh
+HPDF_LANG_KL   ="kl"     # Greenlandic
+HPDF_LANG_KM   ="km"     # Cambodian
+HPDF_LANG_KN   ="kn"     # Kannada
+HPDF_LANG_KO   ="ko"     # Korean
+HPDF_LANG_KS   ="ks"     # Kashmiri
+HPDF_LANG_KU   ="ku"     # Kurdish
+HPDF_LANG_KY   ="ky"     # Kirghiz
+HPDF_LANG_LA   ="la"     # Latin
+HPDF_LANG_LN   ="ln"     # Lingala
+HPDF_LANG_LO   ="lo"     # Laothian
+HPDF_LANG_LT   ="lt"     # Lithuanian
+HPDF_LANG_LV   ="lv"     # Latvian,Lettish
+HPDF_LANG_MG   ="mg"     # Malagasy
+HPDF_LANG_MI   ="mi"     # Maori
+HPDF_LANG_MK   ="mk"     # Macedonian
+HPDF_LANG_ML   ="ml"     # Malayalam
+HPDF_LANG_MN   ="mn"     # Mongolian
+HPDF_LANG_MO   ="mo"     # Moldavian
+HPDF_LANG_MR   ="mr"     # Marathi
+HPDF_LANG_MS   ="ms"     # Malay
+HPDF_LANG_MT   ="mt"     # Maltese
+HPDF_LANG_MY   ="my"     # Burmese
+HPDF_LANG_NA   ="na"     # Nauru
+HPDF_LANG_NE   ="ne"     # Nepali
+HPDF_LANG_NL   ="nl"     # Dutch
+HPDF_LANG_NO   ="no"     # Norwegian
+HPDF_LANG_OC   ="oc"     # Occitan
+HPDF_LANG_OM   ="om"     # (Afan)Oromo
+HPDF_LANG_OR   ="or"     # Oriya
+HPDF_LANG_PA   ="pa"     # Punjabi
+HPDF_LANG_PL   ="pl"     # Polish
+HPDF_LANG_PS   ="ps"     # Pashto,Pushto
+HPDF_LANG_PT   ="pt"     # Portuguese
+HPDF_LANG_QU   ="qu"     # Quechua
+HPDF_LANG_RM   ="rm"     # Rhaeto-Romance
+HPDF_LANG_RN   ="rn"     # Kirundi
+HPDF_LANG_RO   ="ro"     # Romanian
+HPDF_LANG_RU   ="ru"     # Russian
+HPDF_LANG_RW   ="rw"     # Kinyarwanda
+HPDF_LANG_SA   ="sa"     # Sanskrit
+HPDF_LANG_SD   ="sd"     # Sindhi
+HPDF_LANG_SG   ="sg"     # Sangro
+HPDF_LANG_SH   ="sh"     # Serbo-Croatian
+HPDF_LANG_SI   ="si"     # Singhalese
+HPDF_LANG_SK   ="sk"     # Slovak
+HPDF_LANG_SL   ="sl"     # Slovenian
+HPDF_LANG_SM   ="sm"     # Samoan
+HPDF_LANG_SN   ="sn"     # Shona
+HPDF_LANG_SO   ="so"     # Somali
+HPDF_LANG_SQ   ="sq"     # Albanian
+HPDF_LANG_SR   ="sr"     # Serbian
+HPDF_LANG_SS   ="ss"     # Siswati
+HPDF_LANG_ST   ="st"     # Sesotho
+HPDF_LANG_SU   ="su"     # Sundanese
+HPDF_LANG_SV   ="sv"     # Swedish
+HPDF_LANG_SW   ="sw"     # Swahili
+HPDF_LANG_TA   ="ta"     # Tamil
+HPDF_LANG_TE   ="te"     # Tegulu
+HPDF_LANG_TG   ="tg"     # Tajik
+HPDF_LANG_TH   ="th"     # Thai
+HPDF_LANG_TI   ="ti"     # Tigrinya
+HPDF_LANG_TK   ="tk"     # Turkmen
+HPDF_LANG_TL   ="tl"     # Tagalog
+HPDF_LANG_TN   ="tn"     # Setswanato Tonga
+HPDF_LANG_TR   ="tr"     # Turkish
+HPDF_LANG_TS   ="ts"     # Tsonga
+HPDF_LANG_TT   ="tt"     # Tatar
+HPDF_LANG_TW   ="tw"     # Twi
+HPDF_LANG_UK   ="uk"     # Ukrainian
+HPDF_LANG_UR   ="ur"     # Urdu
+HPDF_LANG_UZ   ="uz"     # Uzbek
+HPDF_LANG_VI   ="vi"     # Vietnamese
+HPDF_LANG_VO   ="vo"     # Volapuk
+HPDF_LANG_WO   ="wo"     # Wolof
+HPDF_LANG_XH   ="xh"     # Xhosa
+HPDF_LANG_YO   ="yo"     # Yoruba
+HPDF_LANG_ZH   ="zh"     # Chinese
+HPDF_LANG_ZU   ="zu"     # Zulu
+
+
+#----------------------------------------------------------------------------
+#----- Graphics mode --------------------------------------------------------
+
+HPDF_GMODE_PAGE_DESCRIPTION      =0x0001
+HPDF_GMODE_PATH_OBJECT           =0x0002
+HPDF_GMODE_TEXT_OBJECT           =0x0004
+HPDF_GMODE_CLIPPING_PATH         =0x0008
+HPDF_GMODE_SHADING               =0x0010
+HPDF_GMODE_INLINE_IMAGE          =0x0020
+HPDF_GMODE_EXTERNAL_OBJECT       =0x0040

+ 164 - 0
pdf.mod/libharu/bindings/python/hpdf_errorcode.py

@@ -0,0 +1,164 @@
+error_detail={
+0x1001: 'Internal error. The consistency of the data was lost.',
+
+0x1002: 'Internal error. The consistency of the data was lost.',
+0x1003: 'Internal error. The consistency of the data was lost.',
+0x1004: 'The length of the data exceeds HPDF_LIMIT_MAX_STRING_LEN.',
+
+0x1005: 'Cannot get a pallet data from PNG image.',
+
+0x1007: 'The count of elements of a dictionary exceeds HPDF_LIMIT_MAX_DICT_ELEMENT',
+
+0x1008: 'Internal error. The consistency of the data was lost.',
+0x1009: 'Internal error. The consistency of the data was lost.',
+0x100A: 'Internal error. The consistency of the data was lost.',
+0x100B: 'HPDF_SetPermission() OR HPDF_SetEncryptMode() was called before a password is set.',
+
+0x100C: 'Internal error. The consistency of the data was lost.',
+
+0x100E: 'Tried to register a font that has been registered.',
+
+0x100F: 'Cannot register a character to the japanese word wrap characters list.',
+
+
+0x1011: 'Tried to set the owner password to NULL.\nThe owner password and user password is the same.',
+0x1013: 'Internal error. The consistency of the data was lost.',
+0x1014: 'The depth of the stack exceeded HPDF_LIMIT_MAX_GSTATE.',
+
+0x1015: 'Memory allocation failed.',
+
+0x1016: 'File processing failed. (A detailed code is set.)',
+
+0x1017: 'Cannot open a file. (A detailed code is set.)',
+
+
+0x1019: 'Tried to load a font that has been registered.',
+0x101A: 'The format of a font-file is invalid .\nInternal error. The consistency of the data was lost.',
+0x101B: 'Cannot recognize a header of an afm file.',
+
+0x101C: 'The specified annotation handle is invalid.',
+
+
+0x101E: 'Bit-per-component of a image which was set as mask-image is invalid.',
+
+0x101F: 'Cannot recognize char-matrics-data of an afm file.',
+0x1020: '1. The color_space parameter of HPDF_LoadRawImage is invalid.\n2. Color-space of a image which was set as mask-image is invalid.\n3. The function which is invalid in the present color-space was invoked.',
+
+0x1021: 'Invalid value was set when invoking HPDF_SetCommpressionMode().',
+
+0x1022: 'An invalid date-time value was set.',
+
+0x1023: 'An invalid destination handle was set.',
+
+
+0x1025: 'An invalid document handle is set.',
+0x1026: 'The function which is invalid in the present state was invoked.',
+0x1027: 'An invalid encoder handle is set.',
+0x1028: 'A combination between font and encoder is wrong.',
+
+
+0x102B: 'An Invalid encoding name is specified.',
+
+0x102C: 'The length of the key of encryption is invalid.',
+
+0x102D: '1. An invalid font handle was set.\n2. Unsupported font format.',
+
+0x102E: 'Internal error. The consistency of the data was lost.',
+0x102F: 'A font which has the specified name is not found.',
+
+0x1030: 'Unsupported image format.',
+
+0x1031: 'Unsupported image format.',
+0x1032: 'Cannot read a postscript-name from an afm file.',
+0x1033: '1. An invalid object is set.\n2. Internal error. The consistency of the data was lost.',
+0x1034: 'Internal error. The consistency of the data was lost.',
+0x1035: '1. Invoked HPDF_Image_SetColorMask() against the image-object which was set a mask-image.',
+
+0x1036: 'An invalid outline-handle was specified.',
+
+0x1037: 'An invalid page-handle was specified.',
+
+0x1038: 'An invalid pages-handle was specified. (internal error)',
+
+0x1039: 'An invalid value is set.',
+
+
+0x103B: 'Invalid PNG image format.',
+0x103C: 'Internal error. The consistency of the data was lost.',
+0x103D: 'Internal error. The "_FILE_NAME" entry for delayed loading is missing.',
+
+0x103F: 'Invalid .TTC file format.',
+
+0x1040: 'The index parameter was exceed the number of included fonts',
+
+0x1041: 'Cannot read a width-data from an afm file.',
+0x1042: 'Internal error. The consistency of the data was lost.',
+0x1043: 'An error has returned from PNGLIB while loading an image.',
+
+0x1044: 'Internal error. The consistency of the data was lost.',
+0x1045: 'Internal error. The consistency of the data was lost.',
+
+0x1049: 'Internal error. The consistency of the data was lost.',
+0x104A: 'Internal error. The consistency of the data was lost.',
+0x104B: 'Internal error. The consistency of the data was lost.',
+0x104C: 'There are no graphics-states to be restored.',
+
+0x104D: 'Internal error. The consistency of the data was lost.',
+0x104E: 'The current font is not set.',
+
+0x104F: 'An invalid font-handle was specified.',
+
+0x1050: 'An invalid font-size was set.',
+
+0x1051: 'See Graphics mode.',
+
+0x1052: 'Internal error. The consistency of the data was lost.',
+0x1053: 'The specified value is not a multiple of 90.',
+
+0x1054: 'An invalid page-size was set.',
+0x1055: 'An invalid image-handle was set.',
+
+0x1056: 'The specified value is out of range.',
+
+0x1057: 'The specified value is out of range.',
+0x1058: 'Unexpected EOF marker was detected.',
+
+0x1059: 'Internal error. The consistency of the data was lost.',
+
+0x105B: 'The length of the specified text is too long.',
+
+0x105C: 'The execution of a function was skipped because of other errors.',
+
+0x105D: 'This font cannot be embedded. (restricted by license)',
+
+0x105E: 'Unsupported ttf format. (cannot find unicode cmap.)',
+
+0x105F: 'Unsupported ttf format.',
+0x1060: 'Unsupported ttf format. (cannot find a necessary table) ',
+0x1061: 'Internal error. The consistency of the data was lost.',
+0x1062: '1. The library is not configured to use PNGLIB.\n2. Internal error. The consistency of the data was lost.',
+0x1063: 'Unsupported Jpeg format.',
+0x1064: 'Failed to parse .PFB file.',
+
+0x1065: 'Internal error. The consistency of the data was lost.',
+0x1066: 'An error has occurred while executing a function of Zlib.',
+
+0x1067: 'An error returned from Zlib.',
+
+0x1068: 'An invalid URI was set.',
+
+0x1069: 'An invalid page-layout was set.',
+
+0x1070: 'An invalid page-mode was set.',
+
+0x1071: 'An invalid page-num-style was set.',
+
+0x1072: 'An invalid icon was set.',
+
+0x1073: 'An invalid border-style was set.',
+
+0x1074: 'An invalid page-direction was set.',
+
+0x1075: 'An invalid font-handle was specified.',
+
+}

+ 552 - 0
pdf.mod/libharu/bindings/python/hpdf_types.py

@@ -0,0 +1,552 @@
+###
+## * << Haru Free PDF Library 2.0.3 >> -- hpdf_types.h
+## *
+## * URL http://libharu.org/
+## *
+## * Copyright (c) 1999-2006 Takeshi Kanno
+## *
+## * Permission to use, copy, modify, distribute and sell this software
+## * and its documentation for any purpose is hereby granted without fee,
+## * provided that the above copyright notice appear in all copies and
+## * that both that copyright notice and this permission notice appear
+## * in supporting documentation.
+## * It is provided "as is" without express or implied warranty.
+## *
+##
+## port to python by Li Jun
+## http://groups.google.com/group/pythoncia
+
+from ctypes import *
+
+#----------------------------------------------------------------------------
+#----- type definition ------------------------------------------------------
+
+
+#  native OS integer types
+HPDF_INT=c_int
+HPDF_UINT=c_uint
+
+
+#  32bit integer types
+HPDF_INT32=c_int
+HPDF_UINT32=c_uint
+
+
+#  16bit integer types
+HPDF_INT16=c_short
+HPDF_UINT16=c_ushort
+
+
+#  8bit integer types
+HPDF_INT8=c_char
+HPDF_UINT8=c_ubyte
+
+
+#  8bit binary types
+HPDF_BYTE=c_ubyte
+
+
+#  float type (32bit IEEE754)
+HPDF_REAL=c_float
+
+
+#  double type (64bit IEEE754)
+HPDF_DOUBLE=c_double
+
+
+#  boolean type (0: False, !0: True)
+HPDF_BOOL=c_int
+
+
+#  error-no type (32bit unsigned integer)
+HPDF_STATUS=c_ulong
+
+
+#  character-code type (16bit)
+HPDF_CID=HPDF_UINT16
+HPDF_UNICODE=HPDF_UINT16
+
+
+#  HPDF_Point struct
+class _HPDF_Point(Structure):
+    _fields_=[
+              ('x',            HPDF_REAL),
+              ('y',            HPDF_REAL),
+             ]
+HPDF_Point = _HPDF_Point
+
+class _HPDF_Rect(Structure):
+    _fields_=[
+              ('left',         HPDF_REAL),
+              ('bottom',       HPDF_REAL),
+              ('right',        HPDF_REAL),
+              ('top',          HPDF_REAL),
+             ]
+HPDF_Rect = _HPDF_Rect
+
+HPDF_Box= _HPDF_Rect
+
+# HPDF_Date struct
+class _HPDF_Date(Structure):
+    _fields_=[
+              ('year',         HPDF_INT),
+              ('month',        HPDF_INT),
+              ('day',          HPDF_INT),
+              ('hour',         HPDF_INT),
+              ('minutes',      HPDF_INT),
+              ('seconds',      HPDF_INT),
+              ('ind',          c_char),
+              ('off_hour',     HPDF_INT),
+              ('off_minutes',  HPDF_INT),
+             ]
+HPDF_Date = _HPDF_Date
+
+
+#enum starts
+## date-time type parameters
+HPDF_INFO_CREATION_DATE     =0
+HPDF_INFO_MOD_DATE          =1
+
+## string type parameters
+HPDF_INFO_AUTHOR            =2
+HPDF_INFO_CREATOR           =3
+HPDF_INFO_PRODUCER          =4
+HPDF_INFO_TITLE             =5
+HPDF_INFO_SUBJECT           =6
+HPDF_INFO_KEYWORDS          =7
+HPDF_INFO_EOF               =8
+HPDF_InfoType               =c_int
+#enum ends
+
+#enum starts
+HPDF_VER_12                 =0
+HPDF_VER_13                 =1
+HPDF_VER_14                 =2
+HPDF_VER_15                 =3
+HPDF_VER_16                 =4
+HPDF_VER_EOF                =5
+HPDF_PDFVer                 =c_int
+#enum ends
+
+
+
+#enum starts
+HPDF_ENCRYPT_R2             =2
+HPDF_ENCRYPT_R3             =3
+HPDF_EncryptMode            =c_int
+#enum ends
+
+
+
+
+##typedef void
+##(HPDF_STDCALL *HPDF_Error_Handler)  (HPDF_STATUS   error_no,
+##                                     HPDF_STATUS   detail_no,
+##                                     void         *user_data)
+def HPDF_Error_Handler(restype,
+                       error_no,
+                       detail_no,
+                       user_data):
+    return CFUNCTYPE(restype,
+                     error_no,
+                     detail_no,
+                     user_data,
+                    )
+
+#typedef void*
+#(HPDF_STDCALL *HPDF_Alloc_Func)  (HPDF_UINT  size)
+HPDF_Alloc_Func=CFUNCTYPE(c_void_p,
+                          HPDF_UINT,        #size
+                         )
+
+
+#typedef void
+#(HPDF_STDCALL *HPDF_Free_Func)  (void  *aptr)
+HPDF_Free_Func=CFUNCTYPE(None,
+                         c_void_p,          #aptr
+                        )
+
+
+#---------------------------------------------------------------------------
+#------ text width struct --------------------------------------------------
+
+class _HPDF_TextWidth(Structure):
+    _fields_=[
+              ('numchars',            HPDF_UINT),
+
+              # don't use this value (it may be change in the feature).
+              # use numspace as alternated.
+              ('numwords',            HPDF_UINT),
+
+              ('width',               HPDF_UINT),
+              ('numspace',            HPDF_UINT),
+             ]
+HPDF_TextWidth = _HPDF_TextWidth
+
+
+#---------------------------------------------------------------------------
+#------ dash mode ----------------------------------------------------------
+
+class _HPDF_DashMode(Structure):
+    _fields_=[
+              ('ptn',                 HPDF_UINT16*8),
+              ('num_ptn',             HPDF_UINT),
+              ('phase',               HPDF_UINT),
+             ]
+HPDF_DashMode = _HPDF_DashMode
+
+
+#---------------------------------------------------------------------------
+#----- HPDF_TransMatrix struct ---------------------------------------------
+
+class _HPDF_TransMatrix(Structure):
+    _fields_=[
+              ('a',                   HPDF_REAL),
+              ('b',                   HPDF_REAL),
+              ('c',                   HPDF_REAL),
+              ('d',                   HPDF_REAL),
+              ('x',                   HPDF_REAL),
+              ('y',                   HPDF_REAL),
+             ]
+HPDF_TransMatrix = _HPDF_TransMatrix
+
+
+
+
+#---------------------------------------------------------------------------
+
+#enum starts
+HPDF_CS_DEVICE_GRAY            =0
+HPDF_CS_DEVICE_RGB             =1
+HPDF_CS_DEVICE_CMYK            =2
+HPDF_CS_CAL_GRAY               =3
+HPDF_CS_CAL_RGB                =4
+HPDF_CS_LAB                    =5
+HPDF_CS_ICC_BASED              =6
+HPDF_CS_SEPARATION             =7
+HPDF_CS_DEVICE_N               =8
+HPDF_CS_INDEXED                =9
+HPDF_CS_PATTERN                =10
+HPDF_CS_EOF                    =11
+HPDF_ColorSpace                =c_int
+#enum ends
+
+
+
+#---------------------------------------------------------------------------
+#----- HPDF_RGBColor struct ------------------------------------------------
+
+class _HPDF_RGBColor(Structure):
+    _fields_=[
+              ('r',            HPDF_REAL),
+              ('g',            HPDF_REAL),
+              ('b',            HPDF_REAL),
+             ]
+HPDF_RGBColor = _HPDF_RGBColor
+
+#---------------------------------------------------------------------------
+#----- HPDF_CMYKColor struct -----------------------------------------------
+
+class _HPDF_CMYKColor(Structure):
+    _fields_=[
+              ('c',             HPDF_REAL),
+              ('m',             HPDF_REAL),
+              ('y',             HPDF_REAL),
+              ('k',             HPDF_REAL),
+             ]
+HPDF_CMYKColor=_HPDF_CMYKColor
+
+#---------------------------------------------------------------------------
+#------ The line cap style -------------------------------------------------
+
+#enum starts
+HPDF_BUTT_END                                =0
+HPDF_ROUND_END                               =1
+HPDF_PROJECTING_SQUARE_END                   =2
+HPDF_LINECAP_EOF                             =3
+HPDF_LineCap                                 =c_int
+#enum ends
+
+
+
+#----------------------------------------------------------------------------
+#------ The line join style -------------------------------------------------
+
+#enum starts
+HPDF_MITER_JOIN                              =0
+HPDF_ROUND_JOIN                              =1
+HPDF_BEVEL_JOIN                              =2
+HPDF_LINEJOIN_EOF                            =3
+HPDF_LineJoin                                =c_int
+#enum ends
+
+
+
+#----------------------------------------------------------------------------
+#------ The text rendering mode ---------------------------------------------
+
+#enum starts
+HPDF_FILL                                    =0
+HPDF_STROKE                                  =1
+HPDF_FILL_THEN_STROKE                        =2
+HPDF_INVISIBLE                               =3
+HPDF_FILL_CLIPPING                           =4
+HPDF_STROKE_CLIPPING                         =5
+HPDF_FILL_STROKE_CLIPPING                    =6
+HPDF_CLIPPING                                =7
+HPDF_RENDERING_MODE_EOF                      =8
+HPDF_TextRenderingMode                       =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_WMODE_HORIZONTAL                        =0
+HPDF_WMODE_VERTICAL                          =1
+HPDF_WMODE_EOF                               =2
+HPDF_WritingMode                             =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_PAGE_LAYOUT_SINGLE                      =0
+HPDF_PAGE_LAYOUT_ONE_COLUMN                  =1
+HPDF_PAGE_LAYOUT_TWO_COLUMN_LEFT             =2
+HPDF_PAGE_LAYOUT_TWO_COLUMN_RIGHT            =3
+HPDF_PAGE_LAYOUT_EOF                         =4
+HPDF_PageLayout                              =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_PAGE_MODE_USE_NONE                      =0
+HPDF_PAGE_MODE_USE_OUTLINE                   =1
+HPDF_PAGE_MODE_USE_THUMBS                    =2
+HPDF_PAGE_MODE_FULL_SCREEN                   =3
+HPDF_PAGE_MODE_USE_OC                        =4     #???
+HPDF_PAGE_MODE_USE_ATTACHMENTS               =5     #???
+HPDF_PAGE_MODE_EOF                           =6
+HPDF_PageMode                                =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_PAGE_NUM_STYLE_DECIMAL                  =0
+HPDF_PAGE_NUM_STYLE_UPPER_ROMAN              =1
+HPDF_PAGE_NUM_STYLE_LOWER_ROMAN              =2
+HPDF_PAGE_NUM_STYLE_UPPER_LETTERS            =3
+HPDF_PAGE_NUM_STYLE_LOWER_LETTERS            =4
+HPDF_PAGE_NUM_STYLE_EOF                      =5
+HPDF_PageNumStyle                            =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_XYZ                                     =0
+HPDF_FIT                                     =1
+HPDF_FIT_H                                   =2
+HPDF_FIT_V                                   =3
+HPDF_FIT_R                                   =4
+HPDF_FIT_B                                   =5
+HPDF_FIT_BH                                  =6
+HPDF_FIT_BV                                  =7
+HPDF_DST_EOF                                 =8
+HPDF_DestinationType                         =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_ANNOT_TEXT_NOTES                        =0
+HPDF_ANNOT_LINK                              =1
+HPDF_ANNOT_SOUND                             =2
+HPDF_ANNOT_FREE_TEXT                         =3
+HPDF_ANNOT_STAMP                             =4
+HPDF_ANNOT_SQUARE                            =5
+HPDF_ANNOT_CIRCLE                            =6
+HPDF_ANNOT_STRIKE_OUT                        =7
+HPDF_ANNOT_HIGHTLIGHT                        =8
+HPDF_ANNOT_UNDERLINE                         =9
+HPDF_ANNOT_INK                               =10
+HPDF_ANNOT_FILE_ATTACHMENT                   =11
+HPDF_ANNOT_POPUP                             =12
+HPDF_AnnotType                               =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_ANNOT_INVISIBLE                         =0
+HPDF_ANNOT_HIDDEN                            =1
+HPDF_ANNOT_PRINT                             =2
+HPDF_ANNOT_NOZOOM                            =3
+HPDF_ANNOT_NOROTATE                          =4
+HPDF_ANNOT_NOVIEW                            =5
+HPDF_ANNOT_READONLY                          =6
+HPDF_AnnotFlgs                               =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_ANNOT_NO_HIGHTLIGHT                     =0
+HPDF_ANNOT_INVERT_BOX                        =1
+HPDF_ANNOT_INVERT_BORDER                     =2
+HPDF_ANNOT_DOWN_APPEARANCE                   =3
+HPDF_ANNOT_HIGHTLIGHT_MODE_EOF               =4
+HPDF_AnnotHighlightMode                      =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_ANNOT_ICON_COMMENT                      =0
+HPDF_ANNOT_ICON_KEY                          =1
+HPDF_ANNOT_ICON_NOTE                         =2
+HPDF_ANNOT_ICON_HELP                         =3
+HPDF_ANNOT_ICON_NEW_PARAGRAPH                =4
+HPDF_ANNOT_ICON_PARAGRAPH                    =5
+HPDF_ANNOT_ICON_INSERT                       =6
+HPDF_ANNOT_ICON_EOF                          =7
+HPDF_AnnotIcon                               =c_int
+#enum ends
+
+
+
+
+
+#----------------------------------------------------------------------------
+#------ border stype --------------------------------------------------------
+
+#enum starts
+HPDF_BS_SOLID                                =0
+HPDF_BS_DASHED                               =1
+HPDF_BS_BEVELED                              =2
+HPDF_BS_INSET                                =3
+HPDF_BS_UNDERLINED                           =4
+HPDF_BSSubtype                               =c_int
+#enum ends
+
+
+
+
+#----- blend modes ----------------------------------------------------------
+
+#enum starts
+HPDF_BM_NORMAL                               =0
+HPDF_BM_MULTIPLY                             =1
+HPDF_BM_SCREEN                               =2
+HPDF_BM_OVERLAY                              =3
+HPDF_BM_DARKEN                               =4
+HPDF_BM_LIGHTEN                              =5
+HPDF_BM_COLOR_DODGE                          =6
+HPDF_BM_COLOR_BUM                            =7
+HPDF_BM_HARD_LIGHT                           =8
+HPDF_BM_SOFT_LIGHT                           =9
+HPDF_BM_DIFFERENCE                           =10
+HPDF_BM_EXCLUSHON                            =11
+HPDF_BM_EOF                                  =12
+HPDF_BlendMode                               =c_int
+#enum ends
+
+
+
+#----- slide show -----------------------------------------------------------
+
+#enum starts
+HPDF_TS_WIPE_RIGHT                           =0
+HPDF_TS_WIPE_UP                              =1
+HPDF_TS_WIPE_LEFT                            =2
+HPDF_TS_WIPE_DOWN                            =3
+HPDF_TS_BARN_DOORS_HORIZONTAL_OUT            =4
+HPDF_TS_BARN_DOORS_HORIZONTAL_IN             =5
+HPDF_TS_BARN_DOORS_VERTICAL_OUT              =6
+HPDF_TS_BARN_DOORS_VERTICAL_IN               =7
+HPDF_TS_BOX_OUT                              =8
+HPDF_TS_BOX_IN                               =9
+HPDF_TS_BLINDS_HORIZONTAL                    =10
+HPDF_TS_BLINDS_VERTICAL                      =11
+HPDF_TS_DISSOLVE                             =12
+HPDF_TS_GLITTER_RIGHT                        =13
+HPDF_TS_GLITTER_DOWN                         =14
+HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT     =15
+HPDF_TS_REPLACE                              =16
+HPDF_TS_EOF                                  =17
+HPDF_TransitionStyle                         =c_int
+#enum ends
+
+
+
+#----------------------------------------------------------------------------
+
+#enum starts
+HPDF_PAGE_SIZE_LETTER                        =0
+HPDF_PAGE_SIZE_LEGAL                         =1
+HPDF_PAGE_SIZE_A3                            =2
+HPDF_PAGE_SIZE_A4                            =3
+HPDF_PAGE_SIZE_A5                            =4
+HPDF_PAGE_SIZE_B4                            =5
+HPDF_PAGE_SIZE_B5                            =6
+HPDF_PAGE_SIZE_EXECUTIVE                     =7
+HPDF_PAGE_SIZE_US4x6                         =8
+HPDF_PAGE_SIZE_US4x8                         =9
+HPDF_PAGE_SIZE_US5x7                         =10
+HPDF_PAGE_SIZE_COMM10                        =11
+HPDF_PAGE_SIZE_EOF                           =12
+HPDF_PageSizes                               =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_PAGE_PORTRAIT                           =0
+HPDF_PAGE_LANDSCAPE                          =1
+HPDF_PageDirection                           =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_ENCODER_TYPE_SINGLE_BYTE                =0
+HPDF_ENCODER_TYPE_DOUBLE_BYTE                =1
+HPDF_ENCODER_TYPE_UNINITIALIZED              =2
+HPDF_ENCODER_UNKNOWN                         =3
+HPDF_EncoderType                             =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_BYTE_TYPE_SINGLE                        =0
+HPDF_BYTE_TYPE_LEAD                          =1
+HPDF_BYTE_TYPE_TRAIL                         =2
+HPDF_BYTE_TYPE_UNKNOWN                       =3
+HPDF_ByteType                                =c_int
+#enum ends
+
+
+
+
+#enum starts
+HPDF_TALIGN_LEFT                             =0
+HPDF_TALIGN_RIGHT                            =1
+HPDF_TALIGN_CENTER                           =2
+HPDF_TALIGN_JUSTIFY                          =3
+HPDF_TextAlignment                           =c_int
+#enum ends

+ 178 - 0
pdf.mod/libharu/bindings/ruby/Makefile.msvc

@@ -0,0 +1,178 @@
+
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = .
+topdir = C:/ruby/lib/ruby/1.8/i386-mswin32
+hdrdir = $(topdir)
+VPATH = $(srcdir);$(topdir);$(hdrdir)
+
+DESTDIR = C:
+prefix = $(DESTDIR)/ruby
+exec_prefix = $(prefix)
+sitedir = $(prefix)/lib/ruby/site_ruby
+rubylibdir = $(libdir)/ruby/$(ruby_version)
+top_srcdir = $(DESTDIR)/work/ruby-1.8.4
+archdir = $(rubylibdir)/$(arch)
+sbindir = $(exec_prefix)/sbin
+datadir = $(prefix)/share
+includedir = $(prefix)/include
+infodir = $(prefix)/info
+sysconfdir = $(prefix)/etc
+mandir = $(prefix)/man
+libdir = $(exec_prefix)/lib
+sharedstatedir = $(DESTDIR)/etc
+oldincludedir = $(DESTDIR)/usr/include
+sitearchdir = $(sitelibdir)/$(sitearch)
+localstatedir = $(DESTDIR)/var
+bindir = $(exec_prefix)/bin
+sitelibdir = $(sitedir)/$(ruby_version)
+libexecdir = $(exec_prefix)/libexec
+
+CC = cl -nologo
+LIBRUBY = $(RUBY_SO_NAME).lib
+LIBRUBY_A = $(RUBY_SO_NAME)-static.lib
+LIBRUBYARG_SHARED = $(LIBRUBY)
+LIBRUBYARG_STATIC = $(LIBRUBY_A)
+
+CFLAGS   =  -MT -Zi -O2b2xg- -G6 
+CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) -I..\..\include
+CXXFLAGS = $(CFLAGS) 
+DLDFLAGS =  -link -incremental:no -debug -opt:ref -opt:icf -dll $(LIBPATH) -libpath:..\..\ -libpath:..\..\\win32\msvc -def:$(DEFFILE) -implib:$(*F:.so=)-$(arch).lib -pdb:$(*F:.so=)-$(arch).pdb 
+LDSHARED = cl -nologo -LD
+AR = lib -nologo
+EXEEXT = .exe
+
+RUBY_INSTALL_NAME = ruby
+RUBY_SO_NAME = msvcrt-ruby18
+arch = i386-mswin32
+sitearch = i386-msvcrt
+ruby_version = 1.8
+ruby = C:/ruby/bin/ruby
+RUBY = $(ruby:/=\)
+RM = $(RUBY) -run -e rm -- -f
+MAKEDIRS = @$(RUBY) -run -e mkdir -- -p
+INSTALL = copy > nul
+INSTALL_PROG = $(INSTALL)
+INSTALL_DATA = $(INSTALL)
+COPY = copy > nul
+
+#### End of system configuration section. ####
+
+preload = 
+
+libpath = $(libdir)
+LIBPATH =  -libpath:"$(libdir)"
+DEFFILE = $(TARGET)-$(arch).def
+
+CLEANFILES = 
+DISTCLEANFILES = vc*.pdb $(DEFFILE)
+
+extout = 
+extout_prefix = 
+target_prefix = 
+LOCAL_LIBS = 
+LIBS = $(LIBRUBYARG_SHARED)  oldnames.lib user32.lib advapi32.lib wsock32.lib  libhpdf.lib libpng.lib zlib.lib
+SRCS = hpdf.c
+OBJS = hpdf.obj
+TARGET = hpdf
+DLLIB = $(TARGET).so
+STATIC_LIB = 
+
+RUBYCOMMONDIR = $(sitedir)$(target_prefix)
+RUBYLIBDIR    = $(sitelibdir)$(target_prefix)
+RUBYARCHDIR   = $(sitearchdir)$(target_prefix)
+
+TARGET_SO     = $(DLLIB)
+CLEANLIBS     = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
+CLEANOBJS     = *.obj *.lib *.s[ol] *.pdb *.exp *.bak
+
+all:		$(DLLIB)
+static:		$(STATIC_LIB)
+
+clean:
+		@-$(RM) $(CLEANLIBS:/=\) $(CLEANOBJS:/=\) $(CLEANFILES:/=\)
+
+distclean:	clean
+		@-$(RM) Makefile extconf.h conftest.* mkmf.log
+		@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES:/=\)
+
+realclean:	distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
+	$(INSTALL_PROG) $(DLLIB:/=\) $(RUBYARCHDIR:/=\)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+$(RUBYARCHDIR):
+	$(MAKEDIRS) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .cxx .cpp .obj
+
+{$(srcdir)}.cc{}.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+{$(topdir)}.cc{}.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+{$(hdrdir)}.cc{}.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+.cc.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+{$(srcdir)}.cxx{}.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+{$(topdir)}.cxx{}.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+{$(hdrdir)}.cxx{}.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+.cxx.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+{$(srcdir)}.cpp{}.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+{$(topdir)}.cpp{}.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+{$(hdrdir)}.cpp{}.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+.cpp.obj:
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
+
+{$(srcdir)}.c{}.obj:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+
+{$(topdir)}.c{}.obj:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+
+{$(hdrdir)}.c{}.obj:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+
+.c.obj:
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+
+$(DLLIB): $(DEFFILE) $(OBJS)
+	@-$(RM) $@
+	$(LDSHARED) -Fe$(@) $(OBJS) $(LIBS) $(LOCAL_LIBS) $(DLDFLAGS)
+
+
+
+$(DEFFILE): 
+	$(RUBY) -e "puts 'EXPORTS', 'Init_$(TARGET)'"  > $@
+
+$(OBJS): {.;$(srcdir);$(topdir);$(hdrdir)}ruby.h {.;$(srcdir);$(topdir);$(hdrdir)}defines.h

+ 77 - 0
pdf.mod/libharu/bindings/ruby/demo/arc_demo.rb

@@ -0,0 +1,77 @@
+#
+# << Haru Free PDF Library 2.0.2 >> -- arc_demo.rb
+#
+# http://libharu.org/
+#
+# Copyright (c) 1999-2006 Takeshi Kanno
+#
+# Permission to use, copy, modify, distribute and sell this software
+# and its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear
+# in supporting documentation.
+# It is provided "as is" without express or implied warranty.
+#
+
+require "hpdf"
+
+pdf = HPDFDoc.new
+
+# add a new page object. #
+page = pdf.add_page
+
+page.set_height(220)
+page.set_width(200)
+
+# draw pie chart
+#
+#   A: 45% Red
+#   B: 25% Blue
+#   C: 15% green
+#   D: other yellow
+#
+
+# A #
+page.set_rgb_fill(1.0, 0, 0)
+page.move_to(100, 100)
+page.line_to(100, 180)
+page.arc(100, 100, 80, 0, 360 * 0.45)
+pos = page.get_current_pos
+page.line_to(100, 100)
+page.fill
+
+# B #
+page.set_rgb_fill(0, 0, 1.0)
+page.move_to(100, 100)
+page.line_to(pos[0], pos[1])
+page.arc(100, 100, 80, 360 * 0.45, 360 * 0.7)
+pos = page.get_current_pos
+page.line_to(100, 100)
+page.fill
+
+# C #
+page.set_rgb_fill(0, 1.0, 0)
+page.move_to(100, 100)
+page.line_to(pos[0], pos[1])
+page.arc(100, 100, 80, 360 * 0.7, 360 * 0.85)
+pos = page.get_current_pos
+page.line_to(100, 100)
+page.fill
+
+# D #
+page.set_rgb_fill(1.0, 1.0, 0)
+page.move_to(100, 100)
+page.line_to(pos[0], pos[1])
+page.arc(100, 100, 80, 360 * 0.85, 360)
+pos = page.get_current_pos
+page.line_to(100, 100)
+page.fill
+
+# draw center circle #
+page.set_gray_stroke(0)
+page.set_gray_fill(1)
+page.circle(100, 100, 30)
+page.fill
+
+pdf.save_to_file($0 + ".pdf")
+

+ 86 - 0
pdf.mod/libharu/bindings/ruby/demo/demo.rb

@@ -0,0 +1,86 @@
+#
+# << Haru Free PDF Library 2.0.0 >> -- demo.rb
+#
+# Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+#
+# Permission to use, copy, modify, distribute and sell this software
+# and its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear
+# in supporting documentation.
+# It is provided "as is" without express or implied warranty.
+#
+
+require "hpdf"
+
+if ARGV.empty?
+  line = 'Ruby Rocks'
+else
+  line = ARGV.join(" ")
+end
+
+pdf = HPDFDoc.new
+
+page = pdf.add_page
+
+x = 578
+r1 = 25
+
+40.step(1, -3) do |xw|
+  tone = 1.0 - (xw / 40.0) * 0.2
+
+  page.set_line_width(xw.to_f)
+  page.set_rgb_stroke(tone, 1.0, tone)
+  page.circle(50.0, 750.0, r1.to_f)
+  page.stroke
+  r1 += xw
+end
+
+40.step(1, -3) do |xw|
+  tone = 1.0 - (xw / 40.0) * 0.2
+
+  page.set_line_width(xw.to_f)
+  page.set_rgb_stroke(tone, tone, 1.0)
+  page.move_to(x.to_f, 0.0)
+  page.line_to(x.to_f, 842.0)
+  page.stroke
+  x = (x - xw - 2)
+end
+
+page.set_rgb_stroke(0.0, 0.0, 0.0)
+page.set_line_width(1.0)
+page.rectangle(20.0, 20.0, 558.0, 802.0)
+page.stroke
+
+font = pdf.get_font("Helvetica", nil)
+bbox = font.get_bbox
+
+y = 800
+50.step(5, -5) do |size|
+  height = (bbox[3] - bbox[1]) / 1000 * size
+  y = y - height
+
+  page.begin_text
+  page.set_font_and_size(font, size.to_f)
+  page.text_out(30.0, y.to_f, line)
+  page.end_text
+end
+
+(0...360).step(20) do |angle|
+  page.set_rgb_fill(rand, rand, rand)
+
+  page.begin_text
+  rad = angle / 180.0 * 3.141592
+  page.set_font_and_size(font, 20.0)
+  page.set_text_matrix(Math.cos(rad),
+                        Math.sin(rad),
+                        -Math.sin(rad), 
+                        Math.cos(rad),
+                        300 + Math.cos(rad) * 40,
+                        300 + Math.sin(rad) * 40)
+  page.show_text(line)
+  page.end_text
+end
+
+pdf.save_to_file("demo.pdf")
+

+ 36 - 0
pdf.mod/libharu/bindings/ruby/demo/encryption.rb

@@ -0,0 +1,36 @@
+#
+# << Haru Free PDF Library 2.0.0 >> -- encryption.rb
+#
+# Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+#
+# Permission to use, copy, modify, distribute and sell this software
+# and its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear
+# in supporting documentation.
+# It is provided "as is" without express or implied warranty.
+#
+
+require "hpdf"
+
+pdf = HPDFDoc.new
+
+text = "This is an encrypt document example."
+owner_passwd = "owner"
+user_passwd = "user"
+
+font1 = pdf.get_font("Helvetica", nil)
+
+page = pdf.add_page
+
+page.set_size(HPDFDoc::HPDF_PAGE_SIZE_B5, HPDFDoc::HPDF_PAGE_LANDSCAPE)
+
+page.begin_text
+page.set_font_and_size(font1, 20)
+page.text_rect(0, page.get_height / 2 + 20, page.get_width, page.get_height / 2 -10, text, HPDFDoc::HPDF_TALIGN_CENTER)
+page.end_text
+
+pdf.set_password(owner_passwd, user_passwd)
+
+pdf.save_to_file($0 + ".pdf")
+

+ 166 - 0
pdf.mod/libharu/bindings/ruby/demo/ext_gstater_demo.rb

@@ -0,0 +1,166 @@
+#
+# << Haru Free PDF Library 2.0.6 >> -- ext_gstate_demo.rb
+#
+# http://libharu.org/
+#
+# Copyright (c) 1999-2006 Takeshi Kanno
+#
+# Permission to use, copy, modify, distribute and sell this software
+# and its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear
+# in supporting documentation.
+# It is provided "as is" without express or implied warranty.
+#
+
+require "hpdf"
+
+def draw_circles(page, description, x, y)
+  page.set_line_width(1)
+  page.set_rgb_stroke(0, 0, 0)
+
+  page.set_rgb_fill(1, 0, 0)
+  page.circle(x + 40, y + 40, 40)
+  page.close_path_fill_stroke()
+
+  page.set_rgb_fill(0, 1, 0)
+  page.circle(x + 100, y + 40, 40)
+  page.close_path_fill_stroke()
+
+  page.set_rgb_fill(0, 0, 1)
+  page.circle(x + 70, y + 74.64, 40)
+  page.close_path_fill_stroke()
+
+  page.set_rgb_fill(0, 0, 0)
+  page.begin_text()
+  page.text_out(x + 0.0, y + 130.0, description)
+  page.end_text()
+end
+
+pdf = HPDFDoc.new
+
+PAGE_WIDTH = 600
+PAGE_HEIGHT = 900
+
+# add a new page object. #
+page = pdf.add_page
+page.set_height(PAGE_HEIGHT)
+page.set_width(PAGE_WIDTH)
+
+font = pdf.get_font("Helvetica-Bold", nil)
+
+page.set_font_and_size(font, 10)
+
+# normal
+page.gsave()
+draw_circles(page, "normal", 40, PAGE_HEIGHT - 170)
+page.grestore()
+
+# transparency (0.8)
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_alpha_fill(0.8)
+gstate.set_alpha_stroke(0.8)
+page.set_ext_gstate(gstate)
+draw_circles(page, "alpha fill = 0.8", 230, PAGE_HEIGHT - 170)
+page.grestore()
+
+# transparency (0.4)
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_alpha_fill(0.4)
+gstate.set_alpha_stroke(0.4)
+page.set_ext_gstate(gstate)
+draw_circles(page, "alpha fill = 0.4", 420, PAGE_HEIGHT - 170)
+page.grestore()
+
+# blend-mode=HPDF_BM_MULTIPLY
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_blend_mode(HPDFDoc::HPDF_BM_MULTIPLY)
+page.set_ext_gstate(gstate)
+draw_circles(page, "HPDF_BM_MULTIPLY", 40, PAGE_HEIGHT - 340)
+page.grestore()
+
+# blend-mode=HPDF_BM_SCREEN
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_blend_mode(HPDFDoc::HPDF_BM_SCREEN)
+page.set_ext_gstate(gstate)
+draw_circles(page, "HPDF_BM_SCREEN", 230, PAGE_HEIGHT - 340)
+page.grestore()
+
+# blend-mode=HPDF_BM_OVERLAY
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_blend_mode(HPDFDoc::HPDF_BM_OVERLAY)
+page.set_ext_gstate(gstate)
+draw_circles(page, "HPDF_BM_OVERLAY", 420, PAGE_HEIGHT - 340)
+page.grestore()
+
+# blend-mode=HPDF_BM_DARKEN
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_blend_mode(HPDFDoc::HPDF_BM_DARKEN)
+page.set_ext_gstate(gstate)
+draw_circles(page, "HPDF_BM_DARKEN", 40, PAGE_HEIGHT - 510)
+page.grestore()
+
+# blend-mode=HPDF_BM_LIGHTEN
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_blend_mode(HPDFDoc::HPDF_BM_LIGHTEN)
+page.set_ext_gstate(gstate)
+draw_circles(page, "HPDF_BM_LIGHTEN", 230, PAGE_HEIGHT - 510)
+page.grestore()
+
+# blend-mode=HPDF_BM_COLOR_DODGE
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_blend_mode(HPDFDoc::HPDF_BM_COLOR_DODGE)
+page.set_ext_gstate(gstate)
+draw_circles(page, "HPDF_BM_COLOR_DODGE", 420, PAGE_HEIGHT - 510)
+page.grestore()
+
+# blend-mode=HPDF_BM_COLOR_BUM
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_blend_mode(HPDFDoc::HPDF_BM_COLOR_BUM)
+page.set_ext_gstate(gstate)
+draw_circles(page, "HPDF_BM_COLOR_BUM", 40, PAGE_HEIGHT - 680)
+page.grestore()
+
+# blend-mode=HPDF_BM_HARD_LIGHT
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_blend_mode(HPDFDoc::HPDF_BM_HARD_LIGHT)
+page.set_ext_gstate(gstate)
+draw_circles(page, "HPDF_BM_HARD_LIGHT", 230, PAGE_HEIGHT - 680)
+page.grestore()
+
+# blend-mode=HPDF_BM_SOFT_LIGHT
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_blend_mode(HPDFDoc::HPDF_BM_SOFT_LIGHT)
+page.set_ext_gstate(gstate)
+draw_circles(page, "HPDF_BM_SOFT_LIGHT", 420, PAGE_HEIGHT - 680)
+page.grestore()
+
+# blend-mode=HPDF_BM_DIFFERENCE
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_blend_mode(HPDFDoc::HPDF_BM_DIFFERENCE)
+page.set_ext_gstate(gstate)
+draw_circles(page, "HPDF_BM_DIFFERENCE", 40, PAGE_HEIGHT - 850)
+page.grestore()
+
+# blend-mode=HPDF_BM_EXCLUSHON
+page.gsave()
+gstate = pdf.create_ext_gstate()
+gstate.set_blend_mode(HPDFDoc::HPDF_BM_EXCLUSHON)
+page.set_ext_gstate(gstate)
+draw_circles(page, "HPDF_BM_EXCLUSHON", 230, PAGE_HEIGHT - 850)
+page.grestore()
+
+pdf.save_to_file($0 + ".pdf")
+

+ 61 - 0
pdf.mod/libharu/bindings/ruby/demo/font_demo.rb

@@ -0,0 +1,61 @@
+#
+# << Haru Free PDF Library 2.0.0 >> -- font_example.rb
+#
+# Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+#
+# Permission to use, copy, modify, distribute and sell this software
+# and its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear
+# in supporting documentation.
+# It is provided "as is" without express or implied warranty.
+#
+
+require "hpdf"
+
+font_list = ["Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", "Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique", "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", "Symbol", "ZapfDingbats", nil]
+
+pdf = HPDFDoc.new
+
+page = pdf.add_page
+height = page.get_height
+width = page.get_width
+
+page.set_line_width(1.0)
+page.rectangle(50.0, 50.0, width - 100.0, height - 110.0)
+page.stroke
+
+font1 = pdf.get_font("Helvetica", nil)
+
+title = "Font Example"
+page.set_font_and_size(font1, 24.0)
+tw = page.text_width(title)
+page.begin_text
+page.text_out((width - tw) / 2, height - 50.0, title)
+page.set_font_and_size(font1, 16.0)
+page.text_out(60.0, height - 80.0, "<Standerd Type1 fonts samples>")
+page.end_text
+
+samp_text = "abcdefgABCDEFG12345!#$\%&+-@?"
+
+page.begin_text
+page.move_text_pos(60.0, height - 105.0)
+
+i = 0
+while font_list[i]
+  font2 = pdf.get_font(font_list[i], nil)
+
+  page.set_font_and_size(font1, 9.0)
+  page.show_text(font_list[i])
+  page.move_text_pos(0.0, -18.0)
+
+  page.set_font_and_size(font2, 20.0)
+  page.show_text(samp_text)
+  page.move_text_pos(0.0, -20.0)
+
+  i = i + 1
+end
+
+page.end_text
+pdf.save_to_file($0 + ".pdf")
+

+ 117 - 0
pdf.mod/libharu/bindings/ruby/demo/jpfont_demo.rb

@@ -0,0 +1,117 @@
+#
+# << Alternative PDF Library 1.0.0 >> -- font_example.rb
+#
+# Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+#
+# Permission to use, copy, modify, distribute and sell this software
+# and its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear
+# in supporting documentation.
+# It is provided "as is" without express or implied warranty.
+#
+
+require "hpdf"
+
+SAMP_TEXT1 = "abcdefgABCDEFG123!#$\%&+-@?"
+SAMP_TEXT2 = "アメンボ赤いなあいうえお。浮き藻に小エビもおよいでる。"
+
+pdf = HPDFDoc.new
+
+pdf.set_compression_mode(HPDFDoc::HPDF_COMP_ALL)
+pdf.use_jp_fonts
+pdf.use_jp_encodings
+
+title_font = pdf.get_font("Helvetica", nil)
+
+font = Array.new(16)
+
+font[0] = pdf.get_font("MS-Mincyo", "90ms-RKSJ-H")
+font[1] = pdf.get_font("MS-Mincyo,Bold", "90ms-RKSJ-H")
+font[2] = pdf.get_font("MS-Mincyo,Italic", "90ms-RKSJ-H")
+font[3] = pdf.get_font("MS-Mincyo,BoldItalic", "90ms-RKSJ-H")
+font[4] = pdf.get_font("MS-PMincyo", "90msp-RKSJ-H")
+font[5] = pdf.get_font("MS-PMincyo,Bold", "90msp-RKSJ-H")
+font[6] = pdf.get_font("MS-PMincyo,Italic", "90msp-RKSJ-H")
+font[7] = pdf.get_font("MS-PMincyo,BoldItalic", "90msp-RKSJ-H")
+font[8] = pdf.get_font("MS-Gothic", "90ms-RKSJ-H")
+font[9] = pdf.get_font("MS-Gothic,Bold", "90ms-RKSJ-H")
+font[10] = pdf.get_font("MS-Gothic,Italic", "90ms-RKSJ-H")
+font[11] = pdf.get_font("MS-Gothic,BoldItalic", "90ms-RKSJ-H")
+font[12] = pdf.get_font("MS-PGothic", "90msp-RKSJ-H")
+font[13] = pdf.get_font("MS-PGothic,Bold", "90msp-RKSJ-H")
+font[14] = pdf.get_font("MS-PGothic,Italic", "90msp-RKSJ-H")
+font[15] = pdf.get_font("MS-PGothic,BoldItalic","90msp-RKSJ-H")
+
+# set page mode to use outlines.
+pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_USE_OUTLINE)
+
+encoder = pdf.get_encoder("90ms-RKSJ-H")
+
+# create outline root.
+root = pdf.create_outline(nil, "日本語フォント", encoder);
+
+i = 0
+while font[i]
+  print font[i].get_font_name, "\n"
+  page = pdf.add_page
+  
+  outline = pdf.create_outline(root, font[i].get_font_name, nil)
+  dst = page.create_destination
+  outline.set_destination(dst)
+  
+  page.set_font_and_size(title_font, 10.0)
+  
+  page.begin_text
+  page.move_text_pos(10.0, 190.0)
+  page.show_text(font[i].get_font_name)
+  
+  page.set_font_and_size(font[i], 15.0)
+  page.move_text_pos(10.0, -20.0)
+  page.show_text("abcdefghijklmnopqrstuvwxyz")
+  page.move_text_pos(0.0, -20.0)
+  page.show_text("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+  page.move_text_pos(0.0, -20.0)
+  page.show_text("1234567890")
+  page.move_text_pos(0.0, -20.0)
+  
+  page.set_font_and_size(font[i], 10.0);
+  page.show_text(SAMP_TEXT2)
+  page.move_text_pos(0.0, -18.0)
+  
+  page.set_font_and_size(font[i], 16.0);
+  page.show_text(SAMP_TEXT2)
+  page.move_text_pos(0.0, -27.0)
+  
+  page.set_font_and_size(font[i], 23.0);
+  page.show_text(SAMP_TEXT2)
+  page.move_text_pos(0.0, -36.0)
+  
+  page.set_font_and_size(font[i], 30.0);
+  page.show_text(SAMP_TEXT2)
+  
+  p = page.get_current_text_pos
+  page.end_text
+  
+  page.set_width(p[0] + 20)
+  page.set_height(210.0)
+  
+  page.set_line_width(0.5)
+  
+  page.move_to(10.0, 185.0)
+  page.line_to(p[0] + 10.0, 185.0)
+  page.stroke
+  
+  page.move_to(10.0, 125.0)
+  page.line_to(p[0] + 10.0, 125.0)
+  page.stroke
+  
+  page.move_to(10.0, p[1] - 12.0)
+  page.line_to(p[0] + 10.0, p[1] - 12)
+  page.stroke
+      
+  i = i + 1
+end
+
+pdf.save_to_file($0 + ".pdf")
+

+ 296 - 0
pdf.mod/libharu/bindings/ruby/demo/line_demo.rb

@@ -0,0 +1,296 @@
+#
+# << Haru Free PDF Library 2.0.2 >> -- line_demo.rb
+#
+# http://libharu.org/
+#
+# Copyright (c) 1999-2006 Takeshi Kanno
+#
+# Permission to use, copy, modify, distribute and sell this software
+# and its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear
+# in supporting documentation.
+# It is provided "as is" without express or implied warranty.
+#
+
+require "hpdf"
+
+def draw_line(page, x, y, text)
+  page.begin_text
+  page.move_text_pos(x, y - 10)
+  page.show_text(text)
+  page.end_text
+
+  page.move_to(x, y - 15)
+  page.line_to(x + 220, y - 15)
+  page.stroke
+end
+
+def draw_line2(page, x, y, text)
+  page.begin_text
+  page.move_text_pos(x, y)
+  page.show_text(text)
+  page.end_text
+
+  page.move_to(x + 30, y - 25)
+  page.line_to(x + 160, y - 25)
+  page.stroke
+end
+
+def draw_rect(page, x, y, text)
+  page.begin_text
+  page.move_text_pos(x, y - 10)
+  page.show_text(text)
+  page.end_text
+
+  page.rectangle(x, y - 40, 220, 25)
+end
+
+pdf = HPDFDoc.new
+
+pdf.set_compression_mode(HPDFDoc::HPDF_COMP_ALL)
+
+font = pdf.get_font("Helvetica", nil)
+
+page = pdf.add_page
+
+#print the lines of the page.#
+page.set_line_width(1)
+x = page.get_width - 100
+y = page.get_height - 110
+page.rectangle(50, 50, x, y)
+page.stroke
+
+#print the title of the page (with positioning center).#
+page.set_font_and_size(font, 24)
+tw = page.text_width('Line Demo')
+page.begin_text
+
+x =(page.get_width - tw) / 2
+y = page.get_height - 50
+page.move_text_pos(x, y)
+
+page.show_text('Line Demo')
+page.end_text
+
+page.set_font_and_size(font, 10)
+
+#Draw various widths of lines.#
+page.set_line_width(0)
+draw_line(page, 60, 770, 'line width = 0')
+
+page.set_line_width(1.0)
+draw_line(page, 60, 740, 'line width = 1.0')
+
+page.set_line_width(2.0)
+draw_line(page, 60, 710, 'line width = 2.0')
+
+#Line dash pattern#
+page.set_line_width(1.0)
+
+page.set_dash([3], 1)
+draw_line(page, 60, 680, 'dash_ptn=[3], phase=1 -- 2 on, 3 off, 3 on...')
+
+page.set_dash([7, 3], 2)
+draw_line(page, 60, 650, 'dash_ptn=[7, 3], phase=2 -- 5 on 3 off, 7 on,...')
+
+page.set_dash([8, 7, 2, 7], 0)
+draw_line(page, 60, 620, 'dash_ptn=[8, 7, 2, 7], phase=0')
+
+page.set_dash([], 0)
+
+page.set_line_width(30)
+page.set_rgb_stroke(0.0, 0.5, 0.0)
+
+#Line Cap Style#
+page.set_line_cap(HPDFDoc::HPDF_BUTT_END)
+draw_line2(page, 60, 570, 'HPDF_BUTT_END')
+
+page.set_line_cap(HPDFDoc::HPDF_ROUND_END)
+draw_line2(page, 60, 505, 'HPDF_ROUND_END')
+
+page.set_line_cap(HPDFDoc::HPDF_PROJECTING_SQUARE_END)
+draw_line2(page, 60, 440, 'HPDF_PROJECTING_SQUARE_END')
+
+#Line Join Style#
+page.set_line_width(30)
+page.set_rgb_stroke(0.0, 0.0, 0.5)
+
+page.set_line_join(HPDFDoc::HPDF_MITER_JOIN)
+page.move_to(120, 300)
+page.line_to(160, 340)
+page.line_to(200, 300)
+page.stroke
+
+page.begin_text
+page.move_text_pos(60, 360)
+page.show_text('HPDF_MITER_JOIN')
+page.end_text
+
+page.set_line_join(HPDFDoc::HPDF_ROUND_JOIN)
+page.move_to(120, 195)
+page.line_to(160, 235)
+page.line_to(200, 195)
+page.stroke
+
+page.begin_text
+page.move_text_pos(60, 255)
+page.show_text('HPDF_ROUND_JOIN')
+page.end_text
+
+page.set_line_join(HPDFDoc::HPDF_BEVEL_JOIN)
+page.move_to(120, 90)
+page.line_to(160, 130)
+page.line_to(200, 90)
+page.stroke
+
+page.begin_text
+page.move_text_pos(60, 150)
+page.show_text('HPDF_BEVEL_JOIN')
+page.end_text
+
+# Draw rectangle #
+page.set_line_width(2)
+page.set_rgb_stroke(0, 0, 0)
+page.set_rgb_fill(0.75, 0.0, 0.0)
+
+draw_rect(page, 300, 770, 'stroke')
+page.stroke
+
+draw_rect(page, 300, 720, 'Fill')
+page.fill
+
+draw_rect(page, 300, 670, 'Fill then stroke')
+page.fill_stroke
+
+#clip Rect#
+page.gsave  # Save the current graphic state#
+draw_rect(page, 300, 620, 'Clip rectangle')
+page.clip
+page.stroke
+page.set_font_and_size(font, 13)
+
+page.begin_text
+page.move_text_pos(290, 600)
+page.set_text_leading(12)
+page.show_text('Clip Clip Clip Clip Clip Clipi Clip Clip Clip')
+page.show_text_next_line('Clip Clip Clip Clip Clip Clip Clip Clip Clip')
+page.show_text_next_line('Clip Clip Clip Clip Clip Clip Clip Clip Clip')
+page.end_text
+page.grestore
+
+x0 = 330
+y0 = 440
+x1 = 430
+y1 = 530
+x2 = 480
+y2 = 470
+x3 = 480
+y3 = 90
+
+#Curve Example(curve_to2)#
+page.set_rgb_fill(0, 0, 0)
+
+page.begin_text
+page.move_text_pos(300, 540)
+page.show_text('curve_to2(x1, y1, x2. y2)')
+page.end_text
+
+page.begin_text
+page.move_text_pos(x0 + 5, y0 - 5)
+page.show_text('Current point')
+page.move_text_pos(x1 - x0, y1 - y0)
+page.show_text('(x1, y1)')
+page.move_text_pos(x2 - x1, y2 - y1)
+page.show_text('(x2, y2)')
+page.end_text
+
+page.set_dash([], 0)
+
+page.set_line_width(0.5)
+page.move_to(x1, y1)
+page.line_to(x2, y2)
+page.stroke
+
+page.set_dash([], 0)
+
+page.set_line_width(1.5)
+
+page.move_to(x0, y0)
+page.curve_to2(x1, y1, x2, y2)
+page.stroke
+
+#Curve Example(curve_to3)#
+y0 = y0 - 150
+y1 = y1 - 150
+y2 = y2 - 150
+
+page.begin_text
+page.move_text_pos(300, 390)
+page.show_text('curve_to3(x1, y1, x2. y2)')
+page.end_text
+
+page.begin_text
+page.move_text_pos(x0 + 5, y0 - 5)
+page.show_text('Current point')
+page.move_text_pos(x1 - x0, y1 - y0)
+page.show_text('(x1, y1)')
+page.move_text_pos(x2 - x1, y2 - y1)
+page.show_text('(x2, y2)')
+page.end_text
+
+page.set_dash([3], 1)
+
+page.set_line_width(0.5)
+page.move_to(x0, y0)
+page.line_to(x1, y1)
+page.stroke
+
+page.set_dash([], 0)
+
+page.set_line_width(1.5)
+page.move_to(x0, y0)
+page.curve_to3(x1, y1, x2, y2)
+page.stroke
+
+# Curve Example(curve_to)
+y0 = y0 - 150
+y1 = y1 - 160
+y2 = y2 - 130
+x2 = x2 + 10
+
+page.begin_text
+page.move_text_pos(300, 240)
+page.show_text('curve_to(x1, y1, x2. y2, x3, y3)')
+page.end_text
+
+page.begin_text
+page.move_text_pos(x0 + 5, y0 - 5)
+page.show_text('Current point')
+page.move_text_pos(x1 - x0, y1 - y0)
+page.show_text('(x1, y1)')
+page.move_text_pos(x2 - x1, y2 - y1)
+page.show_text('(x2, y2)')
+page.move_text_pos(x3 - x2, y3 - y2)
+page.show_text('(x3, y3)')
+page.end_text
+
+page.set_dash([3], 1)
+
+page.set_line_width(0.5)
+page.move_to(x0, y0)
+page.line_to(x1, y1)
+page.stroke
+page.move_to(x2, y2)
+page.line_to(x3, y3)
+page.stroke
+
+page.set_dash([], 0)
+
+page.set_line_width(1.5)
+page.move_to(x0, y0)
+page.curve_to(x1, y1, x2, y2, x3, y3)
+page.stroke
+
+pdf.save_to_file($0 + ".pdf")
+

+ 134 - 0
pdf.mod/libharu/bindings/ruby/demo/slide_show_demo.rb

@@ -0,0 +1,134 @@
+#
+# << Haru Free PDF Library 2.0.6 >> -- slideshow_demo.rb
+#
+# http://libharu.org/
+#
+# Copyright (c) 1999-2006 Takeshi Kanno
+#
+# Permission to use, copy, modify, distribute and sell this software
+# and its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear
+# in supporting documentation.
+# It is provided "as is" without express or implied warranty.
+#
+
+require "hpdf"
+
+RAND_MAX = 255
+
+def print_page(page, caption, font, style, prev, next_p)
+
+  r = rand
+  g = rand
+  b = rand
+
+  page.set_width(800)
+  page.set_height(600)
+
+  page.set_rgb_fill(r, g, b)
+  page.rectangle(0, 0, 800, 600)
+  page.fill()
+
+  page.set_rgb_fill(1 - r, 1 - b, 1 - b)
+  page.set_font_and_size(font, 30)
+
+  page.begin_text()
+  page.set_text_matrix(0.8, 0.0, 0.0, 1.0, 0.0, 0.0);   
+  page.text_out(50, 530, caption)
+
+  page.set_text_matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0);   
+  page.set_font_and_size(font, 20)
+  page.text_out(55, 300, "Type \"Ctrl+L\" in order to return from full screen mode.")
+  page.end_text()
+
+  page.set_slide_show(style, 5, 1)
+  page.set_font_and_size(font, 20)
+
+  if (next_p != nil) 
+    page.begin_text()
+    page.text_out(680, 50, "Next=>")
+    page.end_text()
+
+    dst = next_p.create_destination()
+    dst.set_fit()
+    annot = page.create_link_annot(680, 50, 680, 70, dst)
+    annot.set_border_style(0, 0, 0)
+    annot.set_highlight_mode(HPDFDoc::HPDF_ANNOT_INVERT_BOX)
+  end
+
+  if (prev != nil) 
+    page.begin_text()
+    page.text_out(50, 50, "<=Prev")
+    page.end_text()
+
+    dst = prev.create_destination()
+    dst.set_fit()
+    annot = page.create_link_annot(50, 50, 110, 70, dst)
+    annot.set_border_style(0, 0, 0)
+    annot.set_highlight_mode(HPDFDoc::HPDF_ANNOT_INVERT_BOX)
+  end
+
+end
+
+
+pdf = HPDFDoc.new
+
+font = pdf.get_font("Courier", nil)
+page_0 = pdf.add_page()
+page_1 = pdf.add_page()
+page_2 = pdf.add_page()
+page_3 = pdf.add_page()
+page_4 = pdf.add_page()
+page_5 = pdf.add_page()
+page_6 = pdf.add_page()
+page_7 = pdf.add_page()
+page_8 = pdf.add_page()
+page_9 = pdf.add_page()
+page_10 = pdf.add_page()
+page_11 = pdf.add_page()
+page_12 = pdf.add_page()
+page_13 = pdf.add_page()
+page_14 = pdf.add_page()
+page_15 = pdf.add_page()
+page_16 = pdf.add_page()
+
+print_page(page_0, "HPDFDoc::HPDF_TS_WIPE_RIGHT", font, 
+    HPDFDoc::HPDF_TS_WIPE_RIGHT, nil, page_1);
+print_page(page_1, "HPDFDoc::HPDF_TS_WIPE_UP", font, 
+    HPDFDoc::HPDF_TS_WIPE_UP, page_0, page_2);
+print_page(page_2, "HPDFDoc::HPDF_TS_WIPE_LEFT", font, 
+    HPDFDoc::HPDF_TS_WIPE_LEFT, page_1, page_3);
+print_page(page_3, "HPDFDoc::HPDF_TS_WIPE_DOWN", font, 
+    HPDFDoc::HPDF_TS_WIPE_DOWN, page_2, page_4);
+print_page(page_4, "HPDFDoc::HPDF_TS_BARN_DOORS_HORIZONTAL_OUT", font, 
+    HPDFDoc::HPDF_TS_BARN_DOORS_HORIZONTAL_OUT, page_3, page_5);
+print_page(page_5, "HPDFDoc::HPDF_TS_BARN_DOORS_HORIZONTAL_IN", font, 
+    HPDFDoc::HPDF_TS_BARN_DOORS_HORIZONTAL_IN, page_4, page_6);
+print_page(page_6, "HPDFDoc::HPDF_TS_BARN_DOORS_VERTICAL_OUT", font, 
+    HPDFDoc::HPDF_TS_BARN_DOORS_VERTICAL_OUT, page_5, page_7);
+print_page(page_7, "HPDFDoc::HPDF_TS_BARN_DOORS_VERTICAL_IN", font, 
+    HPDFDoc::HPDF_TS_BARN_DOORS_VERTICAL_IN, page_6, page_8);
+print_page(page_8, "HPDFDoc::HPDF_TS_BOX_OUT", font, 
+    HPDFDoc::HPDF_TS_BOX_OUT, page_7, page_9);
+print_page(page_9, "HPDFDoc::HPDF_TS_BOX_IN", font, 
+    HPDFDoc::HPDF_TS_BOX_IN, page_8, page_10);
+print_page(page_10, "HPDFDoc::HPDF_TS_BLINDS_HORIZONTAL", font, 
+    HPDFDoc::HPDF_TS_BLINDS_HORIZONTAL, page_9, page_11);
+print_page(page_11, "HPDFDoc::HPDF_TS_BLINDS_VERTICAL", font, 
+    HPDFDoc::HPDF_TS_BLINDS_VERTICAL, page_10, page_12);
+print_page(page_12, "HPDFDoc::HPDF_TS_DISSOLVE", font, 
+    HPDFDoc::HPDF_TS_DISSOLVE, page_11, page_13);
+print_page(page_13, "HPDFDoc::HPDF_TS_GLITTER_RIGHT", font, 
+    HPDFDoc::HPDF_TS_GLITTER_RIGHT, page_12, page_14);
+print_page(page_14, "HPDFDoc::HPDF_TS_GLITTER_DOWN", font, 
+    HPDFDoc::HPDF_TS_GLITTER_DOWN, page_13, page_15);
+print_page(page_15, "HPDFDoc::HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT", font, 
+    HPDFDoc::HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT, page_14, page_16);
+print_page(page_16, "HPDFDoc::HPDF_TS_REPLACE", font, 
+    HPDFDoc::HPDF_TS_REPLACE, page_15, nil);
+
+pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_FULL_SCREEN)
+
+pdf.save_to_file($0 + ".pdf")
+

+ 186 - 0
pdf.mod/libharu/bindings/ruby/demo/text_demo2.rb

@@ -0,0 +1,186 @@
+#
+# << Haru Free PDF Library 2.0.0 >> -- text_demo2.rb
+#
+# Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
+#
+# Permission to use, copy, modify, distribute and sell this software
+# and its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear
+# in supporting documentation.
+# It is provided "as is" without express or implied warranty.
+#
+
+require "hpdf"
+
+samp_text = "The quick brown fox jumps over the lazy dog. "
+
+pdf = HPDFDoc.new
+
+page = pdf.add_page
+page.set_size(HPDFDoc::HPDF_PAGE_SIZE_A5, HPDFDoc::HPDF_PAGE_PORTRAIT)
+height = page.get_height
+
+font = pdf.get_font("Helvetica", nil)
+page.set_text_leading(20)
+
+# HPDF_TALIGN_LEFT
+left = 25
+top = 545
+right = 200
+bottom = top - 40
+
+page.rectangle(left, bottom, right - left, top - bottom)
+page.stroke
+
+page.begin_text
+page.set_font_and_size(font, 10)
+page.text_out(left, top + 3, "HPDF_TALIGN_LEFT")
+
+page.set_font_and_size(font, 13)
+page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_LEFT)
+page.end_text
+
+# HPDF_TALIGN_RIGHT
+left = 220
+right = 395
+
+page.rectangle(left, bottom, right - left, top - bottom)
+page.stroke
+
+page.begin_text
+page.set_font_and_size(font, 10)
+page.text_out(left, top + 3, "HPDF_TALIGN_RIGHT")
+
+page.set_font_and_size(font, 13)
+page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_RIGHT)
+page.end_text
+
+# HPDF_TALIGN_CENTER
+left = 25
+top = 475
+right = 200
+bottom = top - 40
+
+page.rectangle(left, bottom, right - left, top - bottom)
+page.stroke
+
+page.begin_text
+page.set_font_and_size(font, 10)
+page.text_out(left, top + 3, "HPDF_TALIGN_CENTER")
+
+page.set_font_and_size(font, 13)
+page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_CENTER)
+page.end_text
+
+# HPDF_TALIGN_JUSTIFY
+left = 220
+right = 395
+
+page.rectangle(left, bottom, right - left, top - bottom)
+page.stroke
+
+page.begin_text
+page.set_font_and_size(font, 10)
+page.text_out(left, top + 3, "HPDF_TALIGN_JUSTIFY")
+
+page.set_font_and_size(font, 13)
+page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_JUSTIFY)
+page.end_text
+
+
+# Skewed coordinate system
+
+angle1 = 5.0
+angle2 = 10.0
+rad1 = angle1 / 180 * 3.141592
+rad2 = angle2 / 180 * 3.141592
+
+page.gsave
+
+page.concat(1, Math.tan(rad1), Math.tan(rad2), 1, 25, 350)
+    left = 0
+    top = 40
+    right = 175
+    bottom = 0
+
+page.rectangle(left, bottom, right - left,
+                top - bottom)
+page.stroke
+
+page.begin_text
+
+page.set_font_and_size(font, 10)
+page.text_out(left, top + 3, "Skewed coordinate system")
+
+page.set_font_and_size(font, 13)
+page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_LEFT)
+
+page.end_text
+
+page.grestore
+
+
+# Rotated coordinate system
+page.gsave
+
+angle1 = 5.0
+rad1 = angle1 / 180 * 3.141592
+
+page.concat(Math.cos(rad1), Math.sin(rad1), -Math.sin(rad1), Math.cos(rad1), 220, 350)
+left = 0
+top = 40
+right = 175
+bottom = 0
+
+page.rectangle(left, bottom, right - left,
+                top - bottom)
+page.stroke
+
+page.begin_text
+
+page.set_font_and_size(font, 10)
+page.text_out(left, top + 3, "Rotated coordinate system")
+
+page.set_font_and_size(font, 13)
+page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_LEFT)
+
+page.end_text
+
+page.grestore
+
+
+# text along a circle
+page.set_gray_stroke(0)
+page.circle(210, 190, 145)
+page.circle(210, 190, 113)
+page.stroke
+
+angle1 = 360.0 / samp_text.length
+angle2 = 180.0
+
+page.begin_text
+font = pdf.get_font("Courier-Bold", nil)
+page.set_font_and_size(font, 30)
+
+i = 0
+while i < samp_text.length
+  rad1 = (angle2 - 90) / 180 * 3.141592
+  rad2 = angle2 / 180 * 3.141592
+
+  x = 210.0 + Math.cos(rad2) * 122
+  y = 190.0 + Math.sin(rad2) * 122
+
+  page.set_text_matrix(Math.cos(rad1), Math.sin(rad1), -Math.sin(rad1), Math.cos(rad1), x, y)
+
+  page.show_text(samp_text[i, 1])
+  angle2 -= angle1
+  i = i + 1
+end
+
+page.end_text
+
+
+pdf.save_to_file($0 + ".pdf")
+
+

+ 106 - 0
pdf.mod/libharu/bindings/ruby/demo/ttfont_demo.rb

@@ -0,0 +1,106 @@
+#
+# << Haru Free PDF Library 2.0.2 >> -- ttfont_demo.rb
+#
+# http://libharu.org/
+#
+# Copyright (c) 1999-2006 Takeshi Kanno
+#
+# Permission to use, copy, modify, distribute and sell this software
+# and its documentation for any purpose is hereby granted without fee,
+# provided that the above copyright notice appear in all copies and
+# that both that copyright notice and this permission notice appear
+# in supporting documentation.
+# It is provided "as is" without express or implied warranty.
+#
+
+require "hpdf"
+
+SAMP_TXT = "The quick brown fox jumps over the lazy dog."
+
+font_name = ARGV.shift
+flg = ARGV.shift
+
+if !font_name
+   print 'usage: ttfont_demo.rb [path to font file] -E(embedding font).'
+   exit(1)
+end
+
+pdf = HPDFDoc.new
+
+pdf.set_compression_mode(HPDFDoc::HPDF_COMP_ALL)
+
+# Add a new page object. #
+page = pdf.add_page
+
+title_font = pdf.get_font("Helvetica", nil)
+
+if (flg == "-E")
+  embed = HPDFDoc::HPDF_TRUE
+else
+  embed = HPDFDoc::HPDF_FALSE
+end
+
+detail_font_name = pdf.load_ttfont_from_file(font_name, embed)
+print font_name, ' load OK.[', detail_font_name, ']'
+
+detail_font = pdf.get_font(detail_font_name, nil)
+
+page.set_font_and_size(title_font, 10)
+
+page.begin_text
+
+# Move the position of the text to top of the page. #
+page.move_text_pos(10, 190)
+page.show_text(detail_font_name)
+
+if (embed)
+  page.show_text("(Embedded Subset)")
+end
+
+page.set_font_and_size(detail_font, 15)
+page.move_text_pos(10, -20)
+page.show_text("abcdefghijklmnopqrstuvwxyz")
+page.move_text_pos(0, -20)
+page.show_text("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+page.move_text_pos(0, -20)
+page.show_text("1234567890")
+page.move_text_pos(0, -20)
+
+page.set_font_and_size(detail_font, 10)
+page.show_text(SAMP_TXT)
+page.move_text_pos(0, -18)
+
+page.set_font_and_size(detail_font, 16)
+page.show_text(SAMP_TXT)
+page.move_text_pos(0, -27)
+
+page.set_font_and_size(detail_font, 23)
+page.show_text(SAMP_TXT)
+page.move_text_pos(0, -36)
+
+page.set_font_and_size(detail_font, 30)
+page.show_text(SAMP_TXT)
+page.move_text_pos(0, -36)
+
+tw = page.text_width(SAMP_TXT)
+page_height = 210
+page_width = tw + 40
+
+page.set_width(page_width)
+page.set_height(page_height)
+
+# Finish to print text. #
+page.end_text
+
+page.set_line_width(0.5)
+
+page.move_to(10, page_height - 25)
+page.line_to(page_width - 10, page_height - 25)
+page.stroke
+
+page.move_to(10, page_height - 85)
+page.line_to(page_width - 10, page_height - 85)
+page.stroke
+
+pdf.save_to_file($0 + ".pdf")
+

+ 6 - 0
pdf.mod/libharu/bindings/ruby/extconf.rb

@@ -0,0 +1,6 @@
+require 'mkmf'
+$CPPFLAGS = $CPPFLAGS + " -I../../include"
+$LDFLAGS = $LDFLAGS + " -L../../"
+$LIBS = $LIBS + " -lhpdf -lpng -lz"
+create_makefile 'hpdf'
+

+ 6 - 0
pdf.mod/libharu/bindings/ruby/extconf.rb.all

@@ -0,0 +1,6 @@
+require 'mkmf'
+$CPPFLAGS = $CPPFLAGS + " -I../../include"
+$LDFLAGS = $LDFLAGS + " -L../../"
+$LIBS = $LIBS + " -lhpdf -lpng -lz"
+create_makefile 'hpdf'
+

+ 6 - 0
pdf.mod/libharu/bindings/ruby/extconf.rb.nopnglib

@@ -0,0 +1,6 @@
+require 'mkmf'
+$CPPFLAGS = $CPPFLAGS + " -I../../include"
+$LDFLAGS = $LDFLAGS + " -L../../"
+$LIBS = $LIBS + " -lhpdf -lz"
+create_makefile 'hpdf'
+

+ 6 - 0
pdf.mod/libharu/bindings/ruby/extconf.rb.nozlib

@@ -0,0 +1,6 @@
+require 'mkmf'
+$CPPFLAGS = $CPPFLAGS + " -I../../include"
+$LDFLAGS = $LDFLAGS + " -L../../"
+$LIBS = $LIBS + " -lhpdf"
+create_makefile 'hpdf'
+

+ 3779 - 0
pdf.mod/libharu/bindings/ruby/hpdf.c

@@ -0,0 +1,3779 @@
+/*
+ * << Haru Free PDF Library 2.0.5 >> -- hpdf.c
+ *
+ * URL http://libharu.org/
+ *
+ * Copyright (c) 1999-2006 Takeshi Kanno
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * 2006.08.03 update.
+ */
+
+#include "ruby.h"
+#include "ruby/io.h"
+
+#include "hpdf.h"
+#include "hpdf_conf.h"
+#include "hpdf_utils.h"
+#include "hpdf_pages.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+static VALUE rb_cHPDFDoc;
+static VALUE rb_cHPDFPage;
+static VALUE rb_cHPDFImage;
+static VALUE rb_cHPDFFont;
+static VALUE rb_cHPDFOutline;
+static VALUE rb_cHPDFEncoder;
+static VALUE rb_cHPDFDestination;
+static VALUE rb_cHPDFAnnotation;
+static VALUE rb_cHPDFExtGState;
+static VALUE rb_eHPDFError;
+
+static void
+hpdf_free (HPDF_Doc pdf);
+
+
+static void
+hpdf_error_handler  (HPDF_STATUS  error_no,
+                     HPDF_STATUS  detail_no,
+                     void         *user_data)
+{
+    char msg[256];
+
+    snprintf(msg, 256, "ERROR 0x%04lX-0x%04lX", error_no, detail_no);
+
+    rb_raise(rb_eHPDFError, "%s", msg);
+}
+
+
+static VALUE
+hpdf_new ()
+{
+    HPDF_Doc pdf = HPDF_New(hpdf_error_handler, NULL);
+
+    HPDF_PTRACE(("hpdf_new pdf=%p\n", pdf));
+
+    if (!pdf)
+        rb_raise(rb_eHPDFError, "cannot create HPDF_Doc object.");
+
+    return Data_Wrap_Struct (rb_cHPDFDoc, 0, hpdf_free, pdf);
+}
+
+static void
+hpdf_free (HPDF_Doc pdf)
+{
+    HPDF_PTRACE(("hpdf_free pdf=%p\n", pdf));
+
+    HPDF_Free (pdf);
+}
+
+static VALUE
+hpdf_new_doc (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_new_doc pdf=%p\n", pdf));
+
+    ret = HPDF_NewDoc(pdf);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_free_doc (VALUE obj)
+{
+    HPDF_Doc pdf;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_free_doc pdf=%p\n", pdf));
+
+    HPDF_FreeDoc(pdf);
+
+    return Qnil;
+}
+
+static VALUE
+hpdf_has_doc (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_has_doc pdf=%p\n", pdf));
+
+    ret = HPDF_HasDoc(pdf);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_free_doc_all (VALUE obj)
+{
+    HPDF_Doc pdf;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_free_doc_all pdf=%p\n", pdf));
+
+    HPDF_FreeDocAll(pdf);
+
+    return Qnil;
+}
+
+static VALUE
+hpdf_save_to_file (VALUE obj, VALUE file_name)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Check_Type(file_name, T_STRING);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_save_to_file pdf=%p\n", pdf));
+
+    ret = HPDF_SaveToFile(pdf, StringValuePtr(file_name));
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_get_error (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_get_error pdf=%p\n", pdf));
+
+    ret = HPDF_GetError(pdf);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_reset_error (VALUE obj)
+{
+    HPDF_Doc pdf;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_reset_error pdf=%p\n", pdf));
+
+    HPDF_ResetError(pdf);
+
+    return Qnil;
+}
+
+static VALUE
+hpdf_set_page_configuration (VALUE obj, VALUE page_per_pages)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+    HPDF_UINT i;
+
+    i = NUM2INT(page_per_pages);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_set_page_configuration pdf=%p\n", pdf));
+
+    ret = HPDF_SetPagesConfiguration(pdf, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_get_page_by_index (VALUE obj, VALUE index)
+{
+    HPDF_Page page;
+    HPDF_Doc pdf;
+    HPDF_UINT i;
+
+    i = NUM2INT(index);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_get_page_by_index pdf=%p\n", pdf));
+
+    page = HPDF_GetPageByIndex(pdf, i);
+
+    return Data_Wrap_Struct (rb_cHPDFPage, 0, 0, page);
+}
+
+static VALUE
+hpdf_get_page_layout (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_UINT layout;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_get_page_layout pdf=%p\n", pdf));
+
+    layout = HPDF_GetPageLayout(pdf);
+
+    return INT2NUM(layout);
+}
+
+static VALUE
+hpdf_set_page_layout (VALUE obj, VALUE layout)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+    HPDF_UINT i;
+
+    i = NUM2INT(layout);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_set_page_layout pdf=%p\n", pdf));
+
+    ret = HPDF_SetPageLayout(pdf, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_get_page_mode (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_UINT mode;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_get_page_mode pdf=%p\n", pdf));
+
+    mode = HPDF_GetPageMode(pdf);
+
+    return INT2NUM(mode);
+}
+
+static VALUE
+hpdf_set_page_mode (VALUE obj, VALUE mode)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+    HPDF_UINT i;
+
+    i = NUM2INT(mode);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_set_page_mode pdf=%p\n", pdf));
+
+    ret = HPDF_SetPageMode(pdf, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_set_open_action (VALUE obj, VALUE action)
+{
+    HPDF_Doc pdf;
+    HPDF_Destination dst;
+    HPDF_STATUS ret;
+
+    if (HPDF_StrCmp(rb_obj_classname(action), "HPDFDestination") != 0)
+        rb_raise(rb_eHPDFError, "invalid argument(1).");
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+    Data_Get_Struct(action, HPDF_Array_Rec, dst);
+
+    HPDF_PTRACE(("hpdf_set_open_action pdf=%p\n", pdf));
+
+    ret = HPDF_SetOpenAction(pdf, dst);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_get_viewer_preference (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_UINT mode;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_get_viewer_preference pdf=%p\n", pdf));
+
+    mode = HPDF_GetViewerPreference(pdf);
+
+    return INT2NUM(mode);
+}
+
+static VALUE
+hpdf_set_viewer_preference (VALUE obj, VALUE value)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+    HPDF_UINT i;
+
+    i = NUM2INT(value);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_set_viewer_preference pdf=%p\n", pdf));
+
+    ret = HPDF_SetViewerPreference(pdf, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_get_current_page (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_Doc pdf;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_get_current_page pdf=%p\n", pdf));
+
+    page = HPDF_GetCurrentPage(pdf);
+
+    return Data_Wrap_Struct (rb_cHPDFPage, 0, 0, page);
+}
+
+static VALUE
+hpdf_add_page (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_Doc pdf;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_add_page pdf=%p\n", pdf));
+
+    page = HPDF_AddPage(pdf);
+
+    return Data_Wrap_Struct (rb_cHPDFPage, 0, 0, page);
+}
+
+static VALUE
+hpdf_insert_page (VALUE obj, VALUE page)
+{
+    HPDF_Page target;
+    HPDF_Page new_page;
+    HPDF_Doc pdf;
+
+    if (HPDF_StrCmp(rb_obj_classname(page), "HPDFPage") != 0)
+        rb_raise(rb_eHPDFError, "invalid argument(1).");
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+    Data_Get_Struct(page, HPDF_Dict_Rec, target);
+
+    HPDF_PTRACE(("hpdf_insert_page pdf=%p\n", pdf));
+
+    new_page = HPDF_InsertPage(pdf, target);
+
+    return Data_Wrap_Struct (rb_cHPDFPage, 0, 0, new_page);
+}
+
+static VALUE
+hpdf_page_set_width (VALUE obj, VALUE width)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    f = NUM2DBL(width);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_set_width page=%p\n", page));
+
+    ret = HPDF_Page_SetWidth(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_height (VALUE obj, VALUE height)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    f = NUM2DBL(height);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_set_height page=%p\n", page));
+
+    ret = HPDF_Page_SetHeight(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_size (VALUE obj, VALUE size, VALUE direction)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_INT i1;
+    HPDF_INT i2;
+
+    i1 = NUM2INT(size);
+    i2 = NUM2INT(direction);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_set_size page=%p\n", page));
+
+    ret = HPDF_Page_SetSize(page, i1, i2);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_rotate (VALUE obj, VALUE angle)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_INT i;
+
+    i = NUM2INT(angle);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_set_rotate page=%p\n", page));
+
+    ret = HPDF_Page_SetRotate(page, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_get_font (VALUE obj, VALUE font_name, VALUE encoding_name)
+{
+    HPDF_Font font;
+    HPDF_Doc pdf;
+    const char *s1;
+    const char *s2;
+
+    s1 = StringValuePtr(font_name);
+
+    if (encoding_name == Qnil)
+        s2 = NULL;
+    else {
+        s2 = StringValuePtr(encoding_name);
+
+        if (HPDF_StrLen(s2, -1) == 0)
+            s2 = NULL;
+    }
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_get_font pdf=%p\n", pdf));
+
+    font = HPDF_GetFont(pdf, s1, s2);
+
+    return Data_Wrap_Struct (rb_cHPDFFont, 0, 0, font);
+}
+
+static VALUE
+hpdf_load_type1font_from_file (VALUE obj, VALUE afm, VALUE pfa)
+{
+    const char* font_name;
+    HPDF_Doc pdf;
+    const char *s1;
+    const char *s2;
+
+    s1 = StringValuePtr(afm);
+    s2 = StringValuePtr(pfa);
+
+    if (HPDF_StrLen(s2, -1) == 0)
+        s2 = NULL;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_load_type1font_from_file pdf=%p\n", pdf));
+
+    font_name = HPDF_LoadType1FontFromFile(pdf, s1, s2);
+
+    return rb_str_new2(font_name);
+}
+
+static VALUE
+hpdf_load_ttfont_from_file (VALUE obj, VALUE file_name, VALUE embedding)
+{
+    const char* font_name;
+    HPDF_Doc pdf;
+    const char *s;
+    HPDF_INT i;
+
+    s = StringValuePtr(file_name);
+    i = NUM2INT(embedding);
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_load_ttfont_from_file pdf=%p\n", pdf));
+
+    font_name = HPDF_LoadTTFontFromFile(pdf, s, i);
+
+    return rb_str_new2(font_name);
+}
+
+static VALUE
+hpdf_load_ttfont_from_file2 (VALUE obj, VALUE file_name, VALUE index, VALUE embedding)
+{
+    const char* font_name;
+    HPDF_Doc pdf;
+    const char *s;
+    HPDF_INT i1;
+    HPDF_INT i2;
+
+    s = StringValuePtr(file_name);
+    i1 = NUM2INT(index);
+    i2 = NUM2INT(embedding);
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_load_ttfont_from_file2 pdf=%p\n", pdf));
+
+    font_name = HPDF_LoadTTFontFromFile2(pdf, s, i1, i2);
+
+    return rb_str_new2(font_name);
+}
+
+static VALUE
+hpdf_add_page_label (VALUE obj, VALUE page_num, VALUE style, VALUE first_page, VALUE prefix)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+    HPDF_INT i1;
+    HPDF_INT i2;
+    HPDF_INT i3;
+    const char *s;
+
+    i1 = NUM2INT(page_num);
+    i2 = NUM2INT(style);
+    i3 = NUM2INT(first_page);
+    s = StringValuePtr(prefix);
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_add_page_label pdf=%p\n", pdf));
+
+    ret = HPDF_AddPageLabel(pdf, i1, i2, i3, s);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_use_jp_fonts (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_use_jp_fonts pdf=%p\n", pdf));
+
+    ret = HPDF_UseJPFonts(pdf);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_use_kr_fonts (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_use_kr_fonts pdf=%p\n", pdf));
+
+    ret = HPDF_UseKRFonts(pdf);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_use_cns_fonts (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_use_cns_fonts pdf=%p\n", pdf));
+
+    ret = HPDF_UseCNSFonts(pdf);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_use_cnt_fonts (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_use_cnt_fonts pdf=%p\n", pdf));
+
+    ret = HPDF_UseCNSFonts(pdf);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_create_outline (VALUE obj, VALUE parent, VALUE title, VALUE encoder)
+{
+    HPDF_Doc pdf;
+    HPDF_Outline outline1 = NULL;
+    HPDF_Outline outline2;
+    HPDF_Encoder e = NULL;
+    const char *s;
+
+    if (HPDF_StrCmp(rb_obj_classname(parent), "HPDFOutline") == 0)
+        Data_Get_Struct(parent, HPDF_Dict_Rec, outline1);
+
+    if (HPDF_StrCmp(rb_obj_classname(encoder), "HPDFEncoder") == 0)
+        Data_Get_Struct(encoder, HPDF_Encoder_Rec, e);
+
+    s = StringValuePtr(title);
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_create_outline pdf=%p\n", pdf));
+
+    outline2 = HPDF_CreateOutline(pdf, outline1, s, e);
+
+    return Data_Wrap_Struct (rb_cHPDFOutline, 0, 0, outline2);
+}
+
+
+static VALUE
+hpdf_outline_set_opend (VALUE obj, VALUE opend)
+{
+    HPDF_Outline outline;
+    HPDF_STATUS ret;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, outline);
+    i = NUM2INT(opend);
+
+    HPDF_PTRACE(("hpdf_outline_set_opend outline=%p\n", outline));
+
+    ret = HPDF_Outline_SetOpened(outline, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_outline_set_destination (VALUE obj, VALUE dest)
+{
+    HPDF_Outline outline;
+    HPDF_Destination d;
+    HPDF_STATUS ret;
+
+    if (HPDF_StrCmp(rb_obj_classname(dest), "HPDFDestination") != 0)
+        rb_raise(rb_eHPDFError, "invalid argument(1).");
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, outline);
+    Data_Get_Struct(dest, HPDF_Array_Rec, d);
+
+    HPDF_PTRACE(("hpdf_outline_set_destination outline=%p\n", outline));
+
+    ret = HPDF_Outline_SetDestination(outline, d);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_page_create_destination (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_Destination d;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_create_destination page=%p\n", page));
+
+    d = HPDF_Page_CreateDestination(page);
+
+    return Data_Wrap_Struct (rb_cHPDFDestination, 0, 0, d);
+}
+
+static VALUE
+hpdf_destination_set_xyz (VALUE obj, VALUE left, VALUE top, VALUE zoom)
+{
+    HPDF_Destination d;
+    HPDF_STATUS ret;
+    HPDF_INT i1;
+    HPDF_INT i2;
+    HPDF_INT i3;
+
+    Data_Get_Struct(obj, HPDF_Array_Rec, d);
+    i1 = NUM2INT(left);
+    i2 = NUM2INT(top);
+    i3 = NUM2INT(zoom);
+
+    HPDF_PTRACE(("hpdf_destination_set_xyz destination=%p\n", d));
+
+    ret = HPDF_Destination_SetXYZ(d, i1, i2, i3);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_destination_set_fit (VALUE obj)
+{
+    HPDF_Destination d;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Array_Rec, d);
+
+    HPDF_PTRACE(("hpdf_destination_set_fit destination=%p\n", d));
+
+    ret = HPDF_Destination_SetFit(d);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_destination_set_fit_h (VALUE obj, VALUE top)
+{
+    HPDF_Destination d;
+    HPDF_STATUS ret;
+    HPDF_INT i1;
+
+    Data_Get_Struct(obj, HPDF_Array_Rec, d);
+    i1 = NUM2INT(top);
+
+    HPDF_PTRACE(("hpdf_destination_set_fit_h destination=%p\n", d));
+
+    ret = HPDF_Destination_SetFitH(d, i1);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_destination_set_fit_v (VALUE obj, VALUE left)
+{
+    HPDF_Destination d;
+    HPDF_STATUS ret;
+    HPDF_INT i1;
+
+    Data_Get_Struct(obj, HPDF_Array_Rec, d);
+    i1 = NUM2INT(left);
+
+    HPDF_PTRACE(("hpdf_destination_set_fit_v destination=%p\n", d));
+
+    ret = HPDF_Destination_SetFitV(d, i1);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_destination_set_fit_b (VALUE obj)
+{
+    HPDF_Destination d;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Array_Rec, d);
+
+    HPDF_PTRACE(("hpdf_destination_set_fit_b destination=%p\n", d));
+
+    ret = HPDF_Destination_SetFitB(d);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_destination_set_fit_bh (VALUE obj, VALUE top)
+{
+    HPDF_Destination d;
+    HPDF_STATUS ret;
+    HPDF_INT i1;
+
+    Data_Get_Struct(obj, HPDF_Array_Rec, d);
+    i1 = NUM2INT(top);
+
+    HPDF_PTRACE(("hpdf_destination_set_fit_bh destination=%p\n", d));
+
+    ret = HPDF_Destination_SetFitBH(d, i1);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_destination_set_fit_bv (VALUE obj, VALUE left)
+{
+    HPDF_Destination d;
+    HPDF_STATUS ret;
+    HPDF_INT i1;
+
+    Data_Get_Struct(obj, HPDF_Array_Rec, d);
+    i1 = NUM2INT(left);
+
+    HPDF_PTRACE(("hpdf_destination_set_fit_bv destination=%p\n", d));
+
+    ret = HPDF_Destination_SetFitBV(d, i1);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_destination_set_fit_r (VALUE obj, VALUE left, VALUE bottom, VALUE right, VALUE top)
+{
+    HPDF_Destination d;
+    HPDF_STATUS ret;
+    HPDF_INT i1;
+    HPDF_INT i2;
+    HPDF_INT i3;
+    HPDF_INT i4;
+
+    Data_Get_Struct(obj, HPDF_Array_Rec, d);
+    i1 = NUM2INT(left);
+    i2 = NUM2INT(bottom);
+    i3 = NUM2INT(right);
+    i4 = NUM2INT(top);
+
+    HPDF_PTRACE(("hpdf_destination_set_fit_r destination=%p\n", d));
+
+    ret = HPDF_Destination_SetFitR(d, i1, i2, i3, i4);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_get_encoder (VALUE obj, VALUE encoding_name)
+{
+    HPDF_Encoder encoder;
+    HPDF_Doc pdf;
+    const char *s1;
+
+    s1 = StringValuePtr(encoding_name);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_get_encoder pdf=%p\n", pdf));
+
+    encoder = HPDF_GetEncoder(pdf, s1);
+
+    return Data_Wrap_Struct (rb_cHPDFEncoder, 0, 0, encoder);
+}
+
+static VALUE
+hpdf_get_current_encoder (VALUE obj)
+{
+    HPDF_Encoder encoder;
+    HPDF_Doc pdf;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_get_current_encoder pdf=%p\n", pdf));
+
+    encoder = HPDF_GetCurrentEncoder(pdf);
+
+    return Data_Wrap_Struct (rb_cHPDFEncoder, 0, 0, encoder);
+}
+
+static VALUE
+hpdf_set_current_encoder (VALUE obj, VALUE encoding_name)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+    const char *s1;
+
+    s1 = StringValuePtr(encoding_name);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_set_current_encoder pdf=%p\n", pdf));
+
+    ret = HPDF_SetCurrentEncoder(pdf, s1);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_encoder_get_type (VALUE obj)
+{
+    HPDF_Encoder encoder;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Encoder_Rec, encoder);
+
+    HPDF_PTRACE(("hpdf_encoder_get_type encoder=%p\n", encoder));
+
+    ret = HPDF_Encoder_GetType(encoder);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_encoder_get_byte_type (VALUE obj, VALUE text, VALUE index)
+{
+    HPDF_Encoder encoder;
+    const char *s;
+    HPDF_INT i;
+    HPDF_STATUS ret;
+
+    s = StringValuePtr(text);
+    i = NUM2INT(index);
+
+    Data_Get_Struct(obj, HPDF_Encoder_Rec, encoder);
+
+    HPDF_PTRACE(("hpdf_encoder_get_byte_type encoder=%p\n", encoder));
+
+    ret = HPDF_Encoder_GetByteType(encoder, s, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_encoder_get_unicode (VALUE obj, VALUE code)
+{
+    HPDF_Encoder encoder;
+    HPDF_INT i;
+    HPDF_STATUS ret;
+
+    i = NUM2INT(code);
+
+    Data_Get_Struct(obj, HPDF_Encoder_Rec, encoder);
+
+    HPDF_PTRACE(("hpdf_encoder_get_unicode encoder=%p\n", encoder));
+
+    ret = HPDF_Encoder_GetUnicode(encoder, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_encoder_get_writing_mode (VALUE obj)
+{
+    HPDF_Encoder encoder;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Encoder_Rec, encoder);
+
+    HPDF_PTRACE(("hpdf_encoder_get_writing_mode encoder=%p\n", encoder));
+
+    ret = HPDF_Encoder_GetWritingMode(encoder);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_use_jp_encodings (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_use_jp_encodings pdf=%p\n", pdf));
+
+    ret = HPDF_UseJPEncodings(pdf);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_use_kr_encodings (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_use_kr_encodings pdf=%p\n", pdf));
+
+    ret = HPDF_UseKREncodings(pdf);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_use_cns_encodings (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_use_cns_encodings pdf=%p\n", pdf));
+
+    ret = HPDF_UseCNSEncodings(pdf);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_use_cnt_encodings (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_use_cnt_encodings pdf=%p\n", pdf));
+
+    ret = HPDF_UseCNTEncodings(pdf);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_create_text_annot (VALUE obj, VALUE left, VALUE bottom, VALUE right, VALUE top, VALUE text, VALUE encoder)
+{
+    HPDF_Page page;
+    HPDF_Rect rect;
+    HPDF_Encoder e = NULL;
+    const char *s;
+    HPDF_Annotation annot;
+
+    if (HPDF_StrCmp(rb_obj_classname(encoder), "HPDFEncoder") == 0)
+        Data_Get_Struct(encoder, HPDF_Encoder_Rec, e);
+
+    s = StringValuePtr(text);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    rect.left = NUM2INT(left);
+    rect.bottom = NUM2INT(bottom);
+    rect.right = NUM2INT(right);
+    rect.top = NUM2INT(top);
+
+    HPDF_PTRACE(("hpdf_page_create_text_annot page=%p\n", page));
+
+    annot = HPDF_Page_CreateTextAnnot(page, rect, s, e);
+
+    return Data_Wrap_Struct (rb_cHPDFAnnotation, 0, 0, annot);
+}
+
+
+static VALUE
+hpdf_page_create_link_annot (VALUE obj, VALUE left, VALUE bottom, VALUE right, VALUE top, VALUE dest)
+{
+    HPDF_Page page;
+    HPDF_Rect rect;
+    HPDF_Destination d = NULL;
+    HPDF_Annotation annot;
+
+    if (HPDF_StrCmp(rb_obj_classname(dest), "HPDFDestination") == 0)
+        Data_Get_Struct(dest, HPDF_Array_Rec, d);
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    rect.left = NUM2INT(left);
+    rect.bottom = NUM2INT(bottom);
+    rect.right = NUM2INT(right);
+    rect.top = NUM2INT(top);
+
+    HPDF_PTRACE(("hpdf_page_create_link_annot page=%p\n", page));
+
+    annot = HPDF_Page_CreateLinkAnnot(page, rect, d);
+
+    return Data_Wrap_Struct (rb_cHPDFAnnotation, 0, 0, annot);
+}
+
+static VALUE
+hpdf_page_create_uri_link_annot (VALUE obj, VALUE left, VALUE bottom, VALUE right, VALUE top, VALUE uri)
+{
+    HPDF_Page page;
+    HPDF_Rect rect;
+    const char *s;
+    HPDF_Annotation annot;
+
+    s = StringValuePtr(uri);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    rect.left = NUM2INT(left);
+    rect.bottom = NUM2INT(bottom);
+    rect.right = NUM2INT(right);
+    rect.top = NUM2INT(top);
+
+    HPDF_PTRACE(("hpdf_page_create_uri_link_annot page=%p\n", page));
+
+    annot = HPDF_Page_CreateURILinkAnnot(page, rect, s);
+
+    return Data_Wrap_Struct (rb_cHPDFAnnotation, 0, 0, annot);
+}
+
+static VALUE
+hpdf_linkannot_set_highlight_mode (VALUE obj, VALUE mode)
+{
+    HPDF_Annotation annot;
+    HPDF_STATUS ret;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, annot);
+    i = NUM2INT(mode);
+
+    HPDF_PTRACE(("hpdf_linkannot_set_highlight_mode annot=%p\n", annot));
+
+    ret = HPDF_LinkAnnot_SetHighlightMode(annot, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_linkannot_set_border_style (VALUE obj, VALUE width, VALUE dash_on, VALUE dash_off)
+{
+    HPDF_Annotation annot;
+    HPDF_STATUS ret;
+    HPDF_INT i1;
+    HPDF_INT i2;
+    HPDF_INT i3;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, annot);
+    i1 = NUM2INT(width);
+    i2 = NUM2INT(dash_on);
+    i3 = NUM2INT(dash_off);
+
+    HPDF_PTRACE(("hpdf_linkannot_set_border_style annot=%p\n", annot));
+
+    ret = HPDF_LinkAnnot_SetBorderStyle(annot, i1, i2, i3);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_textannot_set_icon (VALUE obj, VALUE icon)
+{
+    HPDF_Annotation annot;
+    HPDF_STATUS ret;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, annot);
+    i = NUM2INT(icon);
+
+    HPDF_PTRACE(("hpdf_textannot_set_highlight_mode annot=%p\n", annot));
+
+    ret = HPDF_TextAnnot_SetIcon(annot, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_textannot_set_opened (VALUE obj, VALUE opened)
+{
+    HPDF_Annotation annot;
+    HPDF_STATUS ret;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, annot);
+    i = NUM2INT(opened);
+
+    HPDF_PTRACE(("hpdf_textannot_set_opened annot=%p\n", annot));
+
+    ret = HPDF_TextAnnot_SetOpened(annot, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_load_png_image_from_file (VALUE obj, VALUE file_name)
+{
+    HPDF_Doc pdf;
+    HPDF_Image image;
+    const char *s;
+
+    s = StringValuePtr(file_name);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_load_png_image_from_file pdf=%p\n", pdf));
+
+    image = HPDF_LoadPngImageFromFile(pdf, s);
+
+    return Data_Wrap_Struct (rb_cHPDFImage, 0, 0, image);
+}
+
+
+static VALUE
+hpdf_load_jpeg_image_from_file (VALUE obj, VALUE file_name)
+{
+    HPDF_Doc pdf;
+    HPDF_Image image;
+    const char *s;
+
+    s = StringValuePtr(file_name);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_load_png_image_from_file pdf=%p\n", pdf));
+
+    image = HPDF_LoadJpegImageFromFile(pdf, s);
+
+    return Data_Wrap_Struct (rb_cHPDFImage, 0, 0, image);
+}
+
+
+static VALUE
+hpdf_image_get_size (VALUE obj)
+{
+    HPDF_Image image;
+    HPDF_Point p;
+    VALUE ret;
+    VALUE x;
+    VALUE y;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, image);
+
+    HPDF_PTRACE(("hpdf_image_get_size image=%p\n", image));
+
+    p = HPDF_Image_GetSize(image);
+
+    ret = rb_ary_new();
+    x = rb_float_new(p.x);
+    y = rb_float_new(p.y);
+    rb_ary_push(ret, x);
+    rb_ary_push(ret, y);
+
+    return ret;
+}
+
+
+static VALUE
+hpdf_image_get_width (VALUE obj)
+{
+    HPDF_Image image;
+    HPDF_UINT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, image);
+
+    HPDF_PTRACE(("hpdf_image_get_width image=%p\n", image));
+
+    i = HPDF_Image_GetWidth(image);
+
+    return INT2NUM(i);
+}
+
+
+static VALUE
+hpdf_image_get_height (VALUE obj)
+{
+    HPDF_Image image;
+    HPDF_UINT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, image);
+
+    HPDF_PTRACE(("hpdf_image_get_height image=%p\n", image));
+
+    i = HPDF_Image_GetHeight(image);
+
+    return INT2NUM(i);
+}
+
+static VALUE
+hpdf_image_get_bits_per_component (VALUE obj)
+{
+    HPDF_Image image;
+    HPDF_UINT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, image);
+
+    HPDF_PTRACE(("hpdf_encoder_get_unicode image=%p\n", image));
+
+    i = HPDF_Image_GetBitsPerComponent(image);
+
+    return INT2NUM(i);
+}
+
+static VALUE
+hpdf_image_get_color_space (VALUE obj)
+{
+    const char* ret;
+    HPDF_Image image;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, image);
+
+    HPDF_PTRACE(("hpdf_image_get_color_space image=%p\n", image));
+
+    ret = HPDF_Image_GetColorSpace(image);
+
+    return rb_str_new2(ret);
+}
+
+static VALUE
+hpdf_image_set_color_mask (VALUE obj, VALUE rmin, VALUE rmax, VALUE gmin, VALUE gmax, VALUE bmin, VALUE bmax)
+{
+    HPDF_Image image;
+    HPDF_STATUS ret;
+    HPDF_INT i1;
+    HPDF_INT i2;
+    HPDF_INT i3;
+    HPDF_INT i4;
+    HPDF_INT i5;
+    HPDF_INT i6;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, image);
+    i1 = NUM2INT(rmin);
+    i2 = NUM2INT(rmax);
+    i3 = NUM2INT(gmin);
+    i4 = NUM2INT(gmax);
+    i5 = NUM2INT(bmin);
+    i6 = NUM2INT(bmax);
+
+    HPDF_PTRACE(("hpdf_image_set_color_mask image=%p\n", image));
+
+    ret = HPDF_Image_SetColorMask(image, i1, i2, i3, i4, i5, i6);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_image_set_mask_image (VALUE obj, VALUE mask_image)
+{
+    HPDF_Image image1;
+    HPDF_Image image2;
+    HPDF_STATUS ret;
+
+    if (HPDF_StrCmp(rb_obj_classname(mask_image), "HPDFImage") != 0)
+        rb_raise(rb_eHPDFError, "invalid argument(1).");
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, image1);
+    Data_Get_Struct(mask_image, HPDF_Dict_Rec, image2);
+
+    HPDF_PTRACE(("hpdf_image_set_mask_image image=%p\n", image1));
+
+    ret = HPDF_Image_SetMaskImage(image1, image2);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_set_info_attr (VALUE obj, VALUE type, VALUE value)
+{
+    HPDF_Doc pdf;
+    const char *s;
+    HPDF_INT i;
+    HPDF_STATUS ret;
+
+    i = NUM2INT(type);
+    s = StringValuePtr(value);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_set_info_attr pdf=%p\n", pdf));
+
+    ret = HPDF_SetInfoAttr(pdf, i, s);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_get_info_attr (VALUE obj, VALUE type)
+{
+    HPDF_Doc pdf;
+    HPDF_INT i;
+    const char *ret;
+
+    i = NUM2INT(type);
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_get_info_attr pdf=%p\n", pdf));
+
+    ret = HPDF_GetInfoAttr(pdf, i);
+
+    return rb_str_new2(ret);
+}
+
+static VALUE
+hpdf_set_info_date_attr (VALUE obj, VALUE type, VALUE year, VALUE month, VALUE day, VALUE hour, VALUE minutes, VALUE seconds, VALUE ind, VALUE off_hour, VALUE off_minuttes)
+{
+    HPDF_Doc pdf;
+    const char *s;
+    HPDF_INT tp;
+    HPDF_Date dt;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+    s = StringValuePtr(ind);
+    if (HPDF_StrLen(s, -1) != 1 || (s[0] != '+' && s[0] != '-' && s[0] != 'Z' && s[0] != ' ')) {
+        rb_raise(rb_eHPDFError, "The eighth argument must be either of '+','-','Z',' '.");
+    }
+
+    tp = NUM2INT(type);
+    dt.year = NUM2INT(year);
+    dt.month = NUM2INT(month);
+    dt.day = NUM2INT(day);
+    dt.hour = NUM2INT(hour);
+    dt.minutes = NUM2INT(minutes);
+    dt.seconds = NUM2INT(seconds);
+    dt.ind = s[0];
+    dt.off_hour = NUM2INT(off_hour);
+    dt.off_minutes = NUM2INT(off_minuttes);
+
+    HPDF_PTRACE(("hpdf_set_info_attr pdf=%p\n", pdf));
+
+    ret = HPDF_SetInfoDateAttr(pdf, tp, dt);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_set_password (VALUE obj, VALUE owner_passwd, VALUE user_passwd)
+{
+    HPDF_Doc pdf;
+    const char *s1;
+    const char *s2;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+    s1 = StringValuePtr(owner_passwd);
+    s2 = StringValuePtr(user_passwd);
+
+    HPDF_PTRACE(("hpdf_set_password pdf=%p\n", pdf));
+
+    ret = HPDF_SetPassword(pdf, s1, s2);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_set_permission (VALUE obj, VALUE permission)
+{
+    HPDF_Doc pdf;
+    HPDF_INT i;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+    i = NUM2INT(permission);
+
+    HPDF_PTRACE(("hpdf_set_permission pdf=%p\n", pdf));
+
+    ret = HPDF_SetPermission(pdf, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_set_encryption_mode (VALUE obj, VALUE mode, VALUE key_len)
+{
+    HPDF_Doc pdf;
+    HPDF_INT i1;
+    HPDF_INT i2;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+    i1 = NUM2INT(mode);
+    i2 = NUM2INT(key_len);
+
+    HPDF_PTRACE(("hpdf_set_encryption_mode pdf=%p\n", pdf));
+
+    ret = HPDF_SetEncryptionMode(pdf, i1, i2);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_set_compression_mode (VALUE obj, VALUE mode)
+{
+    HPDF_Doc pdf;
+    HPDF_INT i;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+    i = NUM2INT(mode);
+
+    HPDF_PTRACE(("hpdf_set_compression_mode pdf=%p\n", pdf));
+
+    ret = HPDF_SetCompressionMode(pdf, i);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_page_text_width (VALUE obj, VALUE text)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+    const char *s;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    s = StringValuePtr(text);
+
+    HPDF_PTRACE(("hpdf_page_text_width page=%p\n", page));
+
+    f = HPDF_Page_TextWidth(page, s);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_measure_text (VALUE obj, VALUE text, VALUE width, VALUE wordwrap)
+{
+    HPDF_Page page;
+    const char *s;
+    HPDF_INT i1;
+    HPDF_INT i2;
+    HPDF_INT ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    s = StringValuePtr(text);
+    i1 = NUM2INT(width);
+    i2 = NUM2INT(wordwrap);
+
+    HPDF_PTRACE(("hpdf_page_test_width page=%p\n", page));
+
+    ret = HPDF_Page_MeasureText(page, s, i1, i2, NULL);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_create_ext_gstate (VALUE obj)
+{
+    HPDF_Doc pdf;
+    HPDF_ExtGState gstate;
+
+    Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
+
+    HPDF_PTRACE(("hpdf_create_ext_gstate pdf=%p\n", pdf));
+
+    gstate = HPDF_CreateExtGState(pdf);
+
+    return Data_Wrap_Struct (rb_cHPDFExtGState, 0, 0, gstate);
+}
+
+
+static VALUE
+hpdf_ext_gstate_set_alpha_stroke (VALUE obj, VALUE value)
+{
+    HPDF_ExtGState gstate;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    f = NUM2DBL(value);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, gstate);
+
+    HPDF_PTRACE(("hpdf_ext_gstate_set_alpha_stroke page=%p\n", gstate));
+
+    ret = HPDF_ExtGState_SetAlphaStroke(gstate, f);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_ext_gstate_set_alpha_fill (VALUE obj, VALUE value)
+{
+    HPDF_ExtGState gstate;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    f = NUM2DBL(value);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, gstate);
+
+    HPDF_PTRACE(("hpdf_ext_gstate_set_alpha_fill page=%p\n", gstate));
+
+    ret = HPDF_ExtGState_SetAlphaFill(gstate, f);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_ext_gstate_set_blend_mode (VALUE obj, VALUE mode)
+{
+    HPDF_ExtGState gstate;
+    HPDF_STATUS ret;
+    HPDF_INT i;
+
+    i = NUM2INT(mode);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, gstate);
+
+    HPDF_PTRACE(("hpdf_ext_gstate_set_blend_mode page=%p\n", gstate));
+
+    ret = HPDF_ExtGState_SetBlendMode(gstate, i);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_page_set_ext_gstate (VALUE obj, VALUE gstate)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_ExtGState gs;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    Data_Get_Struct(gstate, HPDF_Dict_Rec, gs);
+
+    HPDF_PTRACE(("hpdf_page_set_ext_gstate page=%p\n", page));
+
+    ret = HPDF_Page_SetExtGState(page, gs);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_page_get_width (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_width page=%p\n", page));
+
+    f = HPDF_Page_GetWidth(page);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_get_height (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_height page=%p\n", page));
+
+    f = HPDF_Page_GetHeight(page);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_get_gmode (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_UINT16 ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_gmode page=%p\n", page));
+
+    ret = HPDF_Page_GetGMode(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_get_current_pos (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_Point p;
+    VALUE ret;
+    VALUE x;
+    VALUE y;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_current_pos page=%p\n", page));
+
+    p = HPDF_Page_GetCurrentPos(page);
+
+    ret = rb_ary_new();
+    x = rb_float_new(p.x);
+    y = rb_float_new(p.y);
+    rb_ary_push(ret, x);
+    rb_ary_push(ret, y);
+
+    return ret;
+}
+
+static VALUE
+hpdf_page_get_current_text_pos (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_Point p;
+    VALUE ret;
+    VALUE x;
+    VALUE y;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_current_text_pos page=%p\n", page));
+
+    p = HPDF_Page_GetCurrentTextPos(page);
+
+    ret = rb_ary_new();
+    x = rb_float_new(p.x);
+    y = rb_float_new(p.y);
+    rb_ary_push(ret, x);
+    rb_ary_push(ret, y);
+
+    return ret;
+}
+
+static VALUE
+hpdf_page_get_current_font (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_Font font;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_current_font page=%p\n", page));
+
+    font = HPDF_Page_GetCurrentFont(page);
+
+    return Data_Wrap_Struct (rb_cHPDFFont, 0, 0, font);
+}
+
+static VALUE
+hpdf_font_get_font_name (VALUE obj)
+{
+    HPDF_Font font;
+    const char* font_name;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, font);
+
+    HPDF_PTRACE(("hpdf_font_get_font_name font=%p\n", font));
+
+    font_name = HPDF_Font_GetFontName(font);
+
+    return rb_str_new2(font_name);
+}
+
+static VALUE
+hpdf_font_get_encoding_name (VALUE obj)
+{
+    HPDF_Font font;
+    const char* encoding_name;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, font);
+
+    HPDF_PTRACE(("hpdf_font_get_encoding_name font=%p\n", font));
+
+    encoding_name = HPDF_Font_GetEncodingName(font);
+
+    return rb_str_new2(encoding_name);
+}
+
+static VALUE
+hpdf_font_get_unicode_width (VALUE obj, VALUE code)
+{
+    HPDF_Font font;
+    HPDF_UINT i;
+    HPDF_INT ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, font);
+    i = NUM2INT(code);
+
+    HPDF_PTRACE(("hpdf_font_get_unicode_width font=%p\n", font));
+
+    ret = HPDF_Font_GetUnicodeWidth(font, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_font_get_bbox (VALUE obj)
+{
+    HPDF_Font font;
+    HPDF_Rect rect;
+    VALUE ret;
+    VALUE left;
+    VALUE bottom;
+    VALUE right;
+    VALUE top;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, font);
+
+    HPDF_PTRACE(("hpdf_font_get_bbox font=%p\n", font));
+
+    rect = HPDF_Font_GetBBox(font);
+
+    ret = rb_ary_new();
+    left = rb_float_new(rect.left);
+    bottom = rb_float_new(rect.bottom);
+    right = rb_float_new(rect.right);
+    top = rb_float_new(rect.top);
+    rb_ary_push(ret, left);
+    rb_ary_push(ret, bottom);
+    rb_ary_push(ret, right);
+    rb_ary_push(ret, top);
+
+    return ret;
+}
+
+static VALUE
+hpdf_font_get_ascent (VALUE obj)
+{
+    HPDF_Font font;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, font);
+
+    HPDF_PTRACE(("hpdf_font_get_ascent font=%p\n", font));
+
+    i = HPDF_Font_GetAscent(font);
+
+    return NUM2INT(i);
+}
+
+static VALUE
+hpdf_font_get_descent (VALUE obj)
+{
+    HPDF_Font font;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, font);
+
+    HPDF_PTRACE(("hpdf_font_get_descent font=%p\n", font));
+
+    i = HPDF_Font_GetDescent(font);
+
+    return NUM2INT(i);
+}
+
+static VALUE
+hpdf_font_get_x_height (VALUE obj)
+{
+    HPDF_Font font;
+    HPDF_UINT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, font);
+
+    HPDF_PTRACE(("hpdf_font_get_x_height font=%p\n", font));
+
+    i = HPDF_Font_GetXHeight(font);
+
+    return NUM2INT(i);
+}
+
+static VALUE
+hpdf_font_get_cap_height (VALUE obj)
+{
+    HPDF_Font font;
+    HPDF_UINT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, font);
+
+    HPDF_PTRACE(("hpdf_font_get_cap_height font=%p\n", font));
+
+    i = HPDF_Font_GetCapHeight(font);
+
+    return NUM2INT(i);
+}
+
+static VALUE
+hpdf_page_get_current_font_size (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_current_font_size page=%p\n", page));
+
+    f = HPDF_Page_GetCurrentFontSize(page);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_get_trans_matrix (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_TransMatrix tm;
+    VALUE ret;
+    VALUE a;
+    VALUE b;
+    VALUE c;
+    VALUE d;
+    VALUE x;
+    VALUE y;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_trans_matrix page=%p\n", page));
+
+    tm = HPDF_Page_GetTransMatrix(page);
+
+    ret = rb_ary_new();
+    a = rb_float_new(tm.a);
+    b = rb_float_new(tm.b);
+    c = rb_float_new(tm.c);
+    d = rb_float_new(tm.d);
+    x = rb_float_new(tm.x);
+    y = rb_float_new(tm.y);
+    rb_ary_push(ret, a);
+    rb_ary_push(ret, b);
+    rb_ary_push(ret, c);
+    rb_ary_push(ret, d);
+    rb_ary_push(ret, x);
+    rb_ary_push(ret, y);
+
+    return ret;
+}
+
+static VALUE
+hpdf_page_get_line_width (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_line_width page=%p\n", page));
+
+    f = HPDF_Page_GetLineWidth(page);
+
+    return rb_float_new(f);
+}
+
+
+static VALUE
+hpdf_page_get_line_cap (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_line_cap page=%p\n", page));
+
+    i = HPDF_Page_GetLineCap(page);
+
+    return NUM2INT(i);
+}
+
+static VALUE
+hpdf_page_get_line_join (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_line_join page=%p\n", page));
+
+    i = HPDF_Page_GetLineJoin(page);
+
+    return NUM2INT(i);
+}
+
+static VALUE
+hpdf_page_get_miter_limit (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_miter_limit page=%p\n", page));
+
+    f = HPDF_Page_GetMiterLimit(page);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_get_dash (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_DashMode dm;
+    VALUE ret;
+    VALUE num_ptn;
+    VALUE phase;
+    HPDF_UINT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_dash page=%p\n", page));
+
+    dm = HPDF_Page_GetDash(page);
+
+    ret = rb_ary_new();
+    num_ptn = NUM2INT(dm.num_ptn);
+    rb_ary_push(ret, num_ptn);
+
+    for (i = 0; i < dm.num_ptn; i++) {
+        VALUE ptn = NUM2INT(dm.ptn[i]);
+        rb_ary_push(ret, ptn);
+    }
+
+    phase = NUM2INT(dm.phase);
+    rb_ary_push(ret, phase);
+
+    return ret;
+}
+
+static VALUE
+hpdf_page_get_flat (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_flat page=%p\n", page));
+
+    f = HPDF_Page_GetFlat(page);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_get_char_space (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_char_space page=%p\n", page));
+
+    f = HPDF_Page_GetCharSpace(page);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_get_word_space (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_word_space page=%p\n", page));
+
+    f = HPDF_Page_GetWordSpace(page);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_get_horizontal_scalling (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_horizontal_scalling page=%p\n", page));
+
+    f = HPDF_Page_GetHorizontalScalling(page);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_get_text_leading (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_text_leading page=%p\n", page));
+
+    f = HPDF_Page_GetTextLeading(page);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_get_text_rendering_mode (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_text_rendering_mode page=%p\n", page));
+
+    i = HPDF_Page_GetTextRenderingMode(page);
+
+    return NUM2INT(i);
+}
+
+static VALUE
+hpdf_page_get_text_raise (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_text_raise page=%p\n", page));
+
+    f = HPDF_Page_GetTextRaise(page);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_get_rgb_fill (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_RGBColor c;
+    VALUE ret;
+    VALUE r;
+    VALUE g;
+    VALUE b;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_rgb_fill page=%p\n", page));
+
+    c = HPDF_Page_GetRGBFill(page);
+
+    ret = rb_ary_new();
+    r = rb_float_new(c.r);
+    g = rb_float_new(c.g);
+    b = rb_float_new(c.b);
+    rb_ary_push(ret, r);
+    rb_ary_push(ret, g);
+    rb_ary_push(ret, b);
+
+    return ret;
+}
+
+static VALUE
+hpdf_page_get_rgb_stroke (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_RGBColor col;
+    VALUE ret;
+    VALUE r;
+    VALUE g;
+    VALUE b;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_rgb_stroke page=%p\n", page));
+
+    col = HPDF_Page_GetRGBStroke(page);
+
+    ret = rb_ary_new();
+    r = rb_float_new(col.r);
+    g = rb_float_new(col.g);
+    b = rb_float_new(col.b);
+    rb_ary_push(ret, r);
+    rb_ary_push(ret, g);
+    rb_ary_push(ret, b);
+
+    return ret;
+}
+
+static VALUE
+hpdf_page_get_cmyk_fill (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_CMYKColor col;
+    VALUE ret;
+    VALUE c;
+    VALUE m;
+    VALUE y;
+    VALUE k;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_cmyk_fill page=%p\n", page));
+
+    col = HPDF_Page_GetCMYKFill(page);
+
+    ret = rb_ary_new();
+    c = rb_float_new(col.c);
+    m = rb_float_new(col.m);
+    y = rb_float_new(col.y);
+    k = rb_float_new(col.k);
+    rb_ary_push(ret, c);
+    rb_ary_push(ret, m);
+    rb_ary_push(ret, y);
+    rb_ary_push(ret, k);
+
+    return ret;
+}
+
+static VALUE
+hpdf_page_get_cmyk_stroke (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_CMYKColor col;
+    VALUE ret;
+    VALUE c;
+    VALUE m;
+    VALUE y;
+    VALUE k;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_cmyk_stroke page=%p\n", page));
+
+    col = HPDF_Page_GetCMYKStroke(page);
+
+    ret = rb_ary_new();
+    c = rb_float_new(col.c);
+    m = rb_float_new(col.m);
+    y = rb_float_new(col.y);
+    k = rb_float_new(col.k);
+    rb_ary_push(ret, c);
+    rb_ary_push(ret, m);
+    rb_ary_push(ret, y);
+    rb_ary_push(ret, k);
+
+    return ret;
+}
+
+static VALUE
+hpdf_page_get_gray_fill (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_gray_fill page=%p\n", page));
+
+    f = HPDF_Page_GetGrayFill(page);
+
+    return rb_float_new(f);
+}
+
+
+static VALUE
+hpdf_page_get_gray_stroke (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_gray_stroke page=%p\n", page));
+
+    f = HPDF_Page_GetGrayStroke(page);
+
+    return rb_float_new(f);
+}
+
+static VALUE
+hpdf_page_get_stroking_color_space (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_stroking_color_space page=%p\n", page));
+
+    i = HPDF_Page_GetStrokingColorSpace(page);
+
+    return NUM2INT(i);
+}
+
+static VALUE
+hpdf_page_get_filling_color_space (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_filling_color_space page=%p\n", page));
+
+    i = HPDF_Page_GetFillingColorSpace(page);
+
+    return NUM2INT(i);
+}
+
+static VALUE
+hpdf_page_get_text_matrix (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_TransMatrix tm;
+    VALUE ret;
+    VALUE a;
+    VALUE b;
+    VALUE c;
+    VALUE d;
+    VALUE x;
+    VALUE y;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_text_matrix page=%p\n", page));
+
+    tm = HPDF_Page_GetTextMatrix(page);
+
+    ret = rb_ary_new();
+    a = rb_float_new(tm.a);
+    b = rb_float_new(tm.b);
+    c = rb_float_new(tm.c);
+    d = rb_float_new(tm.d);
+    x = rb_float_new(tm.x);
+    y = rb_float_new(tm.y);
+    rb_ary_push(ret, a);
+    rb_ary_push(ret, b);
+    rb_ary_push(ret, c);
+    rb_ary_push(ret, d);
+    rb_ary_push(ret, x);
+    rb_ary_push(ret, y);
+
+    return ret;
+}
+
+
+static VALUE
+hpdf_page_set_line_width (VALUE obj, VALUE line_width)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    f = NUM2DBL(line_width);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_set_line_width page=%p\n", page));
+
+    ret = HPDF_Page_SetLineWidth(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_line_cap (VALUE obj, VALUE line_cap)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_INT i;
+
+    i = NUM2INT(line_cap);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_set_line_cap page=%p\n", page));
+
+    ret = HPDF_Page_SetLineCap(page, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_line_join (VALUE obj, VALUE line_join)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    f = NUM2DBL(line_join);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_set_line_join page=%p\n", page));
+
+    ret = HPDF_Page_SetLineCap(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_miter_limit (VALUE obj, VALUE miter_limit)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    f = NUM2DBL(miter_limit);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_set_miter_limit page=%p\n", page));
+
+    ret = HPDF_Page_SetMiterLimit(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_dash (VALUE obj, VALUE ptn, VALUE phase)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_UINT16 dash_ptn[8];
+    HPDF_UINT num_ptn;
+    VALUE *pptn;
+    HPDF_UINT dash_phase;
+    HPDF_UINT i;
+
+    if (TYPE(ptn) != T_ARRAY)
+        rb_raise(rb_eHPDFError, "argument 1 must be an array.");
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_set_dash page=%p\n", page));
+
+    dash_phase = NUM2INT(phase);
+    num_ptn = RARRAY_LEN(ptn);
+    if (!num_ptn) {
+        ret = HPDF_Page_SetDash(page, NULL, 0, 0);
+        return INT2NUM(ret);
+    }
+
+    for (i = 0; i < 8; i++)
+        dash_ptn[i] = 0;
+
+    pptn = RARRAY_PTR(ptn);
+    for (i = 0; i < num_ptn; i++) {
+        dash_ptn[i] = NUM2INT(*pptn);
+
+        pptn++;
+    }
+
+    ret = HPDF_Page_SetDash(page, dash_ptn, num_ptn, dash_phase);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_flat (VALUE obj, VALUE flatness)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    f = NUM2DBL(flatness);
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_set_flat page=%p\n", page));
+
+    ret = HPDF_Page_SetFlat(page, f);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_page_gsave (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_gsave page=%p\n", page));
+
+    ret = HPDF_Page_GSave(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_grestore (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_grestore page=%p\n", page));
+
+    ret = HPDF_Page_GRestore(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_get_gstate_depth (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_UINT ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_get_gstate_depth page=%p\n", page));
+
+    ret = HPDF_Page_GetGStateDepth(page);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_page_concat (VALUE obj, VALUE a, VALUE b, VALUE c, VALUE d, VALUE x, VALUE y)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+    HPDF_REAL f5;
+    HPDF_REAL f6;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(a);
+    f2 = NUM2DBL(b);
+    f3 = NUM2DBL(c);
+    f4 = NUM2DBL(d);
+    f5 = NUM2DBL(x);
+    f6 = NUM2DBL(y);
+
+    HPDF_PTRACE(("hpdf_page_concat page=%p\n", page));
+
+    ret = HPDF_Page_Concat(page, f1, f2, f3, f4, f5, f6);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_page_move_to (VALUE obj, VALUE x, VALUE y)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(x);
+    f2 = NUM2DBL(y);
+
+    HPDF_PTRACE(("hpdf_page_move_to page=%p\n", page));
+
+    ret = HPDF_Page_MoveTo(page, f1, f2);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_line_to (VALUE obj, VALUE x, VALUE y)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(x);
+    f2 = NUM2DBL(y);
+
+    HPDF_PTRACE(("hpdf_page_line_to page=%p\n", page));
+
+    ret = HPDF_Page_LineTo(page, f1, f2);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_curve_to (VALUE obj, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+    HPDF_REAL f5;
+    HPDF_REAL f6;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(x1);
+    f2 = NUM2DBL(y1);
+    f3 = NUM2DBL(x2);
+    f4 = NUM2DBL(y2);
+    f5 = NUM2DBL(x3);
+    f6 = NUM2DBL(y3);
+
+    HPDF_PTRACE(("hpdf_page_curve_to page=%p\n", page));
+
+    ret = HPDF_Page_CurveTo(page, f1, f2, f3, f4, f5, f6);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_curve_to2 (VALUE obj, VALUE x2, VALUE y2, VALUE x3, VALUE y3)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(x2);
+    f2 = NUM2DBL(y2);
+    f3 = NUM2DBL(x3);
+    f4 = NUM2DBL(y3);
+
+    HPDF_PTRACE(("hpdf_page_curve_to2 page=%p\n", page));
+
+    ret = HPDF_Page_CurveTo2(page, f1, f2, f3, f4);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_curve_to3 (VALUE obj, VALUE x1, VALUE y1, VALUE x3, VALUE y3)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(x1);
+    f2 = NUM2DBL(y1);
+    f3 = NUM2DBL(x3);
+    f4 = NUM2DBL(y3);
+
+    HPDF_PTRACE(("hpdf_page_curve_to3 page=%p\n", page));
+
+    ret = HPDF_Page_CurveTo3(page, f1, f2, f3, f4);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_close_path (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_close_path page=%p\n", page));
+
+    ret = HPDF_Page_ClosePath(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_rectangle (VALUE obj, VALUE x, VALUE y, VALUE width, VALUE height)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(x);
+    f2 = NUM2DBL(y);
+    f3 = NUM2DBL(width);
+    f4 = NUM2DBL(height);
+
+    HPDF_PTRACE(("hpdf_page_curve_to page=%p\n", page));
+
+    ret = HPDF_Page_Rectangle(page, f1, f2, f3, f4);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_stroke (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_stroke page=%p\n", page));
+
+    ret = HPDF_Page_Stroke(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_close_path_stroke (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_close_path_stroke page=%p\n", page));
+
+    ret = HPDF_Page_ClosePathStroke(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_fill (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_fill page=%p\n", page));
+
+    ret = HPDF_Page_Fill(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_eofill (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_eofill page=%p\n", page));
+
+    ret = HPDF_Page_Eofill(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_fill_stroke (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_fill_stroke page=%p\n", page));
+
+    ret = HPDF_Page_FillStroke(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_eofill_stroke (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_eofill_stroke page=%p\n", page));
+
+    ret = HPDF_Page_EofillStroke(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_close_path_fill_stroke (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_close_path_fill_stroke page=%p\n", page));
+
+    ret = HPDF_Page_ClosePathFillStroke(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_close_path_eofill_stroke (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_close_path_eofill_stroke page=%p\n", page));
+
+    ret = HPDF_Page_ClosePathEofillStroke(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_end_path (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_end_path page=%p\n", page));
+
+    ret = HPDF_Page_EndPath(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_clip (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_end_path page=%p\n", page));
+
+    ret = HPDF_Page_Clip(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_eoclip (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_eoclip page=%p\n", page));
+
+    ret = HPDF_Page_Eoclip(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_begin_text (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_begin_text page=%p\n", page));
+
+    ret = HPDF_Page_BeginText(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_end_text (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_end_text page=%p\n", page));
+
+    ret = HPDF_Page_EndText(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_char_space (VALUE obj, VALUE char_space)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f = NUM2DBL(char_space);
+
+    HPDF_PTRACE(("hpdf_page_set_char_space page=%p\n", page));
+
+    ret = HPDF_Page_SetCharSpace(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_word_space (VALUE obj, VALUE word_space)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f = NUM2DBL(word_space);
+
+    HPDF_PTRACE(("hpdf_page_set_word_space page=%p\n", page));
+
+    ret = HPDF_Page_SetWordSpace(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_horizontal_scalling (VALUE obj, VALUE scalling)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f = NUM2DBL(scalling);
+
+    HPDF_PTRACE(("hpdf_page_set_horizontal_scalling page=%p\n", page));
+
+    ret = HPDF_Page_SetHorizontalScalling(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_text_leading (VALUE obj, VALUE leading)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f = NUM2DBL(leading);
+
+    HPDF_PTRACE(("hpdf_page_set_text_leading page=%p\n", page));
+
+    ret = HPDF_Page_SetTextLeading(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_font_and_size (VALUE obj, VALUE font, VALUE size)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+    HPDF_Font fo;
+
+    if (HPDF_StrCmp(rb_obj_classname(font), "HPDFFont") != 0)
+        rb_raise(rb_eHPDFError, "invalid argument(1).");
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    Data_Get_Struct(font, HPDF_Dict_Rec, fo);
+    f = NUM2DBL(size);
+
+    HPDF_PTRACE(("hpdf_page_set_text_leading page=%p\n", page));
+
+    ret = HPDF_Page_SetFontAndSize(page, fo, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_text_rendering_mode (VALUE obj, VALUE mode)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_INT i;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    i = NUM2INT(mode);
+
+    HPDF_PTRACE(("hpdf_page_set_text_leading page=%p\n", page));
+
+    ret = HPDF_Page_SetTextRenderingMode(page, i);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_text_raise (VALUE obj, VALUE raise)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f = NUM2DBL(raise);
+
+    HPDF_PTRACE(("hpdf_page_set_text_raise page=%p\n", page));
+
+    ret = HPDF_Page_SetTextRaise(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_move_text_pos (VALUE obj, VALUE x, VALUE y)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(x);
+    f2 = NUM2DBL(y);
+
+    HPDF_PTRACE(("hpdf_page_move_text_pos page=%p\n", page));
+
+    ret = HPDF_Page_MoveTextPos(page, f1, f2);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_page_move_text_pos2 (VALUE obj, VALUE x, VALUE y)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(x);
+    f2 = NUM2DBL(y);
+
+    HPDF_PTRACE(("hpdf_page_move_text_pos2 page=%p\n", page));
+
+    ret = HPDF_Page_MoveTextPos2(page, f1, f2);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_page_set_text_matrix (VALUE obj, VALUE a, VALUE b, VALUE c, VALUE d, VALUE x, VALUE y)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+    HPDF_REAL f5;
+    HPDF_REAL f6;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(a);
+    f2 = NUM2DBL(b);
+    f3 = NUM2DBL(c);
+    f4 = NUM2DBL(d);
+    f5 = NUM2DBL(x);
+    f6 = NUM2DBL(y);
+
+    HPDF_PTRACE(("hpdf_page_set_text_matrix page=%p\n", page));
+
+    ret = HPDF_Page_SetTextMatrix(page, f1, f2, f3, f4, f5, f6);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_move_to_next_line (VALUE obj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+
+    HPDF_PTRACE(("hpdf_page_move_to_next_line page=%p\n", page));
+
+    ret = HPDF_Page_MoveToNextLine(page);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_show_text (VALUE obj, VALUE text)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    const char *s;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    s = StringValuePtr(text);
+
+    HPDF_PTRACE(("hpdf_page_show_text page=%p\n", page));
+
+    ret = HPDF_Page_ShowText(page, s);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_show_text_next_line (VALUE obj, VALUE text)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    const char *s;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    s = StringValuePtr(text);
+
+    HPDF_PTRACE(("hpdf_page_show_text_next_line page=%p\n", page));
+
+    ret = HPDF_Page_ShowTextNextLine(page, s);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_show_text_next_line_ex (VALUE obj, VALUE char_space, VALUE word_space, VALUE text)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    const char *s;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    s = StringValuePtr(text);
+    f1 = NUM2DBL(char_space);
+    f2 = NUM2DBL(word_space);
+
+    HPDF_PTRACE(("hpdf_page_show_text_next_line_ex page=%p\n", page));
+
+    ret = HPDF_Page_ShowTextNextLineEx(page, f1, f2, s);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_gray_fill (VALUE obj, VALUE gray)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f = NUM2DBL(gray);
+
+    HPDF_PTRACE(("hpdf_page_set_gray_fill page=%p\n", page));
+
+    ret = HPDF_Page_SetGrayFill(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_gray_stroke (VALUE obj, VALUE gray)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f = NUM2DBL(gray);
+
+    HPDF_PTRACE(("hpdf_page_set_gray_stroke page=%p\n", page));
+
+    ret = HPDF_Page_SetGrayStroke(page, f);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_rgb_fill (VALUE obj, VALUE r, VALUE g, VALUE b)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(r);
+    f2 = NUM2DBL(g);
+    f3 = NUM2DBL(b);
+
+    HPDF_PTRACE(("hpdf_page_set_rgb_fill page=%p\n", page));
+
+    ret = HPDF_Page_SetRGBFill(page, f1, f2, f3);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_rgb_stroke (VALUE obj, VALUE r, VALUE g, VALUE b)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(r);
+    f2 = NUM2DBL(g);
+    f3 = NUM2DBL(b);
+
+    HPDF_PTRACE(("hpdf_page_set_rgb_stroke page=%p\n", page));
+
+    ret = HPDF_Page_SetRGBStroke(page, f1, f2, f3);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_cmyk_fill (VALUE obj, VALUE c, VALUE m, VALUE y, VALUE k)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(c);
+    f2 = NUM2DBL(m);
+    f3 = NUM2DBL(y);
+    f4 = NUM2DBL(k);
+
+    HPDF_PTRACE(("hpdf_page_set_cmyk_fill page=%p\n", page));
+
+    ret = HPDF_Page_SetCMYKFill(page, f1, f2, f3, f4);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_cmyk_stroke (VALUE obj, VALUE c, VALUE m, VALUE y, VALUE k)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(c);
+    f2 = NUM2DBL(m);
+    f3 = NUM2DBL(y);
+    f4 = NUM2DBL(k);
+
+    HPDF_PTRACE(("hpdf_page_set_cmyk_stroke page=%p\n", page));
+
+    ret = HPDF_Page_SetCMYKStroke(page, f1, f2, f3, f4);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_execute_xobject (VALUE obj, VALUE xobj)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_Image img;
+
+    if (HPDF_StrCmp(rb_obj_classname(xobj), "HPDFImage") != 0)
+        rb_raise(rb_eHPDFError, "invalid argument(1).");
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    Data_Get_Struct(xobj, HPDF_Dict_Rec, img);
+
+    HPDF_PTRACE(("hpdf_page_execute_xobject page=%p\n", page));
+
+    ret = HPDF_Page_ExecuteXObject(page, img);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_draw_image (VALUE obj, VALUE image, VALUE x, VALUE y, VALUE width, VALUE height)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_Image img;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+
+    if (HPDF_StrCmp(rb_obj_classname(image), "HPDFImage") != 0)
+        rb_raise(rb_eHPDFError, "invalid argument(1).");
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    Data_Get_Struct(image, HPDF_Dict_Rec, img);
+    f1 = NUM2DBL(x);
+    f2 = NUM2DBL(y);
+    f3 = NUM2DBL(width);
+    f4 = NUM2DBL(height);
+
+    HPDF_PTRACE(("hpdf_page_draw_image page=%p\n", page));
+
+    ret = HPDF_Page_DrawImage(page, img, f1, f2, f3, f4);
+
+    return INT2NUM(ret);
+}
+
+
+static VALUE
+hpdf_page_circle (VALUE obj, VALUE x, VALUE y, VALUE ray)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(x);
+    f2 = NUM2DBL(y);
+    f3 = NUM2DBL(ray);
+
+    HPDF_PTRACE(("hpdf_page_circle page=%p\n", page));
+
+    ret = HPDF_Page_Circle(page, f1, f2, f3);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_arc (VALUE obj, VALUE x, VALUE y, VALUE ray, VALUE ang1, VALUE ang2)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+    HPDF_REAL f5;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(x);
+    f2 = NUM2DBL(y);
+    f3 = NUM2DBL(ray);
+    f4 = NUM2DBL(ang1);
+    f5 = NUM2DBL(ang2);
+
+    HPDF_PTRACE(("hpdf_page_arc page=%p\n", page));
+
+    ret = HPDF_Page_Arc(page, f1, f2, f3, f4, f5);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_ellipse (VALUE obj, VALUE x, VALUE y, VALUE xray, VALUE yray)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(x);
+    f2 = NUM2DBL(y);
+    f3 = NUM2DBL(xray);
+    f4 = NUM2DBL(yray);
+
+    HPDF_PTRACE(("hpdf_page_ellipse page=%p\n", page));
+
+    ret = HPDF_Page_Ellipse(page, f1, f2, f3, f4);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_text_out (VALUE obj, VALUE xpos, VALUE ypos, VALUE text)
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    const char *s;
+    HPDF_REAL x;
+    HPDF_REAL y;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    s = StringValuePtr(text);
+    x = NUM2DBL(xpos);
+    y = NUM2DBL(ypos);
+
+    HPDF_PTRACE(("hpdf_page_text_out page=%p\n", page));
+
+    ret = HPDF_Page_TextOut(page, x, y, s);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_text_rect (VALUE obj, VALUE left, VALUE top, VALUE right, VALUE bottom, VALUE text, VALUE align)
+
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    const char *s;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_REAL f3;
+    HPDF_REAL f4;
+    HPDF_UINT i1;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    s = StringValuePtr(text);
+    f1 = NUM2DBL(left);
+    f2 = NUM2DBL(top);
+    f3 = NUM2DBL(right);
+    f4 = NUM2DBL(bottom);
+    i1 = NUM2INT(align);
+
+    HPDF_PTRACE(("hpdf_page_text_rect page=%p\n", page));
+
+    ret = HPDF_Page_TextRect(page, f1, f2, f3, f4, s, i1, NULL);
+
+    return INT2NUM(ret);
+}
+
+static VALUE
+hpdf_page_set_slide_show (VALUE obj, VALUE type, VALUE disp_time, VALUE trans_time)
+
+{
+    HPDF_Page page;
+    HPDF_STATUS ret;
+    HPDF_REAL f1;
+    HPDF_REAL f2;
+    HPDF_UINT i1;
+
+    Data_Get_Struct(obj, HPDF_Dict_Rec, page);
+    f1 = NUM2DBL(disp_time);
+    f2 = NUM2DBL(trans_time);
+    i1 = NUM2INT(type);
+
+    HPDF_PTRACE(("hpdf_page_set_slide_show page=%p\n", page));
+
+    ret = HPDF_Page_SetSlideShow(page, i1, f1, f2);
+
+    return INT2NUM(ret);
+}
+
+
+
+void
+Init_hpdf()
+{
+    rb_cHPDFDoc = rb_define_class("HPDFDoc", rb_cObject);
+    rb_cHPDFPage = rb_define_class("HPDFPage", rb_cObject);
+    rb_cHPDFImage = rb_define_class("HPDFImage", rb_cObject);
+    rb_cHPDFFont = rb_define_class("HPDFFont", rb_cObject);
+    rb_cHPDFOutline = rb_define_class("HPDFOutline", rb_cObject);
+    rb_cHPDFEncoder = rb_define_class("HPDFEncoder", rb_cObject);
+    rb_cHPDFDestination = rb_define_class("HPDFDestination", rb_cObject);
+    rb_cHPDFAnnotation = rb_define_class("HPDFAnnotation", rb_cObject);
+    rb_cHPDFExtGState = rb_define_class("HPDFExtGState", rb_cObject);
+
+
+    rb_define_singleton_method(rb_cHPDFDoc, "new", hpdf_new, 0);
+    rb_define_method(rb_cHPDFDoc, "new_doc", hpdf_new_doc, 0);
+    rb_define_method(rb_cHPDFDoc, "free_doc", hpdf_free_doc, 0);
+    rb_define_method(rb_cHPDFDoc, "has_doc", hpdf_has_doc, 0);
+    rb_define_method(rb_cHPDFDoc, "free_doc_all", hpdf_free_doc_all, 0);
+    rb_define_method(rb_cHPDFDoc, "save_to_file", hpdf_save_to_file, 1);
+    rb_define_method(rb_cHPDFDoc, "get_error", hpdf_get_error, 0);
+    rb_define_method(rb_cHPDFDoc, "reset_error", hpdf_reset_error, 0);
+    rb_define_method(rb_cHPDFDoc, "set_page_configuration", hpdf_set_page_configuration, 1);
+    rb_define_method(rb_cHPDFDoc, "get_page_by_index", hpdf_get_page_by_index, 1);
+    rb_define_method(rb_cHPDFDoc, "get_page_layout", hpdf_get_page_layout, 0);
+    rb_define_method(rb_cHPDFDoc, "set_page_layout", hpdf_set_page_layout, 1);
+    rb_define_method(rb_cHPDFDoc, "get_page_mode", hpdf_get_page_mode, 0);
+    rb_define_method(rb_cHPDFDoc, "set_page_mode", hpdf_set_page_mode, 1);
+    rb_define_method(rb_cHPDFDoc, "set_open_action", hpdf_set_open_action, 1);
+    rb_define_method(rb_cHPDFDoc, "get_viewer_preference", hpdf_get_viewer_preference, 0);
+    rb_define_method(rb_cHPDFDoc, "set_viewer_preference", hpdf_set_viewer_preference, 1);
+    rb_define_method(rb_cHPDFDoc, "get_current_page", hpdf_get_current_page, 0);
+    rb_define_method(rb_cHPDFDoc, "add_page", hpdf_add_page, 0);
+    rb_define_method(rb_cHPDFDoc, "insert_page", hpdf_insert_page, 1);
+
+    rb_define_method(rb_cHPDFPage, "set_width", hpdf_page_set_width, 1);
+    rb_define_method(rb_cHPDFPage, "set_height", hpdf_page_set_height, 1);
+    rb_define_method(rb_cHPDFPage, "set_size", hpdf_page_set_size, 2);
+    rb_define_method(rb_cHPDFPage, "set_rotate", hpdf_page_set_rotate, 1);
+
+    rb_define_method(rb_cHPDFDoc, "get_font", hpdf_get_font, 2);
+    rb_define_method(rb_cHPDFDoc, "load_type1font_from_file", hpdf_load_type1font_from_file, 2);
+    rb_define_method(rb_cHPDFDoc, "load_ttfont_from_file", hpdf_load_ttfont_from_file, 2);
+    rb_define_method(rb_cHPDFDoc, "load_ttfont_from_file2", hpdf_load_ttfont_from_file2, 3);
+    rb_define_method(rb_cHPDFDoc, "add_page_label", hpdf_add_page_label, 4);
+    rb_define_method(rb_cHPDFDoc, "use_jp_fonts", hpdf_use_jp_fonts, 0);
+    rb_define_method(rb_cHPDFDoc, "use_kr_fonts", hpdf_use_kr_fonts, 0);
+    rb_define_method(rb_cHPDFDoc, "use_cns_fonts", hpdf_use_cns_fonts, 0);
+    rb_define_method(rb_cHPDFDoc, "use_cnt_fonts", hpdf_use_cnt_fonts, 0);
+
+    rb_define_method(rb_cHPDFDoc, "create_outline", hpdf_create_outline, 3);
+    rb_define_method(rb_cHPDFOutline, "set_opend", hpdf_outline_set_opend, 1);
+    rb_define_method(rb_cHPDFOutline, "set_destination", hpdf_outline_set_destination, 1);
+
+    rb_define_method(rb_cHPDFPage, "create_destination", hpdf_page_create_destination, 0);
+    rb_define_method(rb_cHPDFDestination, "set_xyz", hpdf_destination_set_xyz, 3);
+    rb_define_method(rb_cHPDFDestination, "set_fit", hpdf_destination_set_fit, 0);
+    rb_define_method(rb_cHPDFDestination, "set_fit_h", hpdf_destination_set_fit_h, 1);
+    rb_define_method(rb_cHPDFDestination, "set_fit_v", hpdf_destination_set_fit_v, 1);
+    rb_define_method(rb_cHPDFDestination, "set_fit_r", hpdf_destination_set_fit_r, 4);
+    rb_define_method(rb_cHPDFDestination, "set_fit_b", hpdf_destination_set_fit_b, 0);
+    rb_define_method(rb_cHPDFDestination, "set_fit_bh", hpdf_destination_set_fit_bh, 1);
+    rb_define_method(rb_cHPDFDestination, "set_fit_bv", hpdf_destination_set_fit_bv, 1);
+
+    rb_define_method(rb_cHPDFDoc, "get_encoder", hpdf_get_encoder, 1);
+    rb_define_method(rb_cHPDFDoc, "get_current_encoder", hpdf_get_current_encoder, 0);
+    rb_define_method(rb_cHPDFDoc, "set_current_encoder", hpdf_set_current_encoder, 1);
+    rb_define_method(rb_cHPDFEncoder, "get_type", hpdf_encoder_get_type, 0);
+    rb_define_method(rb_cHPDFEncoder, "get_byte_type", hpdf_encoder_get_byte_type, 1);
+    rb_define_method(rb_cHPDFEncoder, "get_unicode", hpdf_encoder_get_unicode, 1);
+    rb_define_method(rb_cHPDFEncoder, "get_writing_mode", hpdf_encoder_get_writing_mode, 0);
+    rb_define_method(rb_cHPDFDoc, "use_jp_encodings", hpdf_use_jp_encodings, 0);
+    rb_define_method(rb_cHPDFDoc, "use_kr_encodings", hpdf_use_kr_encodings, 0);
+    rb_define_method(rb_cHPDFDoc, "use_cns_encodings", hpdf_use_cns_encodings, 0);
+    rb_define_method(rb_cHPDFDoc, "use_cnt_encodings", hpdf_use_cnt_encodings, 0);
+
+    rb_define_method(rb_cHPDFPage, "create_text_annot", hpdf_page_create_text_annot, 6);
+    rb_define_method(rb_cHPDFPage, "create_link_annot", hpdf_page_create_link_annot, 5);
+    rb_define_method(rb_cHPDFPage, "create_uri_link_annot", hpdf_page_create_uri_link_annot, 5);
+    rb_define_method(rb_cHPDFAnnotation, "set_highlight_mode", hpdf_linkannot_set_highlight_mode, 1);
+    rb_define_method(rb_cHPDFAnnotation, "set_border_style", hpdf_linkannot_set_border_style, 3);
+    rb_define_method(rb_cHPDFAnnotation, "set_icon", hpdf_textannot_set_icon, 1);
+    rb_define_method(rb_cHPDFAnnotation, "set_opened", hpdf_textannot_set_opened, 1);
+
+    rb_define_method(rb_cHPDFDoc, "load_png_image_from_file", hpdf_load_png_image_from_file, 1);
+    rb_define_method(rb_cHPDFDoc, "load_jpeg_image_from_file", hpdf_load_jpeg_image_from_file, 1);
+    rb_define_method(rb_cHPDFImage, "get_size", hpdf_image_get_size, 0);
+    rb_define_method(rb_cHPDFImage, "get_width", hpdf_image_get_width, 0);
+    rb_define_method(rb_cHPDFImage, "get_height", hpdf_image_get_height, 0);
+    rb_define_method(rb_cHPDFImage, "get_bits_per_component", hpdf_image_get_bits_per_component, 0);
+    rb_define_method(rb_cHPDFImage, "get_color_space", hpdf_image_get_color_space, 0);
+    rb_define_method(rb_cHPDFImage, "set_color_mask", hpdf_image_set_color_mask, 6);
+    rb_define_method(rb_cHPDFImage, "set_mask_image", hpdf_image_set_mask_image, 1);
+
+    rb_define_method(rb_cHPDFDoc, "set_info_attr", hpdf_set_info_attr, 2);
+    rb_define_method(rb_cHPDFDoc, "get_info_attr", hpdf_get_info_attr, 1);
+    rb_define_method(rb_cHPDFDoc, "set_info_date_attr", hpdf_set_info_date_attr, 10);
+    rb_define_method(rb_cHPDFDoc, "set_password", hpdf_set_password, 2);
+    rb_define_method(rb_cHPDFDoc, "set_permission", hpdf_set_permission, 1);
+    rb_define_method(rb_cHPDFDoc, "set_encryption_mode", hpdf_set_encryption_mode, 2);
+    rb_define_method(rb_cHPDFDoc, "set_compression_mode", hpdf_set_compression_mode, 1);
+
+    rb_define_method(rb_cHPDFPage, "text_width", hpdf_page_text_width, 1);
+    rb_define_method(rb_cHPDFPage, "measure_text", hpdf_page_measure_text, 3);
+    rb_define_method(rb_cHPDFPage, "get_width", hpdf_page_get_width, 0);
+    rb_define_method(rb_cHPDFPage, "get_height", hpdf_page_get_height, 0);
+    rb_define_method(rb_cHPDFPage, "get_gmode", hpdf_page_get_gmode, 0);
+    rb_define_method(rb_cHPDFPage, "get_current_pos", hpdf_page_get_current_pos, 0);
+    rb_define_method(rb_cHPDFPage, "get_current_text_pos", hpdf_page_get_current_text_pos, 0);
+    rb_define_method(rb_cHPDFPage, "get_current_font", hpdf_page_get_current_font, 0);
+
+    rb_define_method(rb_cHPDFFont, "get_font_name", hpdf_font_get_font_name, 0);
+    rb_define_method(rb_cHPDFFont, "get_encoding_name", hpdf_font_get_encoding_name, 0);
+    rb_define_method(rb_cHPDFFont, "get_unicode_width", hpdf_font_get_unicode_width, 1);
+    rb_define_method(rb_cHPDFFont, "get_bbox", hpdf_font_get_bbox, 0);
+    rb_define_method(rb_cHPDFFont, "get_ascent", hpdf_font_get_ascent, 0);
+    rb_define_method(rb_cHPDFFont, "get_descent", hpdf_font_get_descent, 0);
+    rb_define_method(rb_cHPDFFont, "get_x_height", hpdf_font_get_x_height, 0);
+    rb_define_method(rb_cHPDFFont, "get_cap_height", hpdf_font_get_cap_height, 0);
+
+    rb_define_method(rb_cHPDFPage, "get_current_font_size", hpdf_page_get_current_font_size, 0);
+    rb_define_method(rb_cHPDFPage, "get_trans_matrix", hpdf_page_get_trans_matrix, 0);
+    rb_define_method(rb_cHPDFPage, "get_line_width", hpdf_page_get_line_width, 0);
+    rb_define_method(rb_cHPDFPage, "get_line_cap", hpdf_page_get_line_cap, 0);
+    rb_define_method(rb_cHPDFPage, "get_line_join", hpdf_page_get_line_join, 0);
+    rb_define_method(rb_cHPDFPage, "get_miter_limit", hpdf_page_get_miter_limit, 0);
+    rb_define_method(rb_cHPDFPage, "get_dash", hpdf_page_get_dash, 0);
+    rb_define_method(rb_cHPDFPage, "get_flat", hpdf_page_get_flat, 0);
+    rb_define_method(rb_cHPDFPage, "get_char_space", hpdf_page_get_char_space, 0);
+    rb_define_method(rb_cHPDFPage, "get_word_space", hpdf_page_get_word_space, 0);
+    rb_define_method(rb_cHPDFPage, "get_horizontal_scalling", hpdf_page_get_horizontal_scalling, 0);
+    rb_define_method(rb_cHPDFPage, "get_text_leading", hpdf_page_get_text_leading, 0);
+    rb_define_method(rb_cHPDFPage, "get_text_rendering_mode", hpdf_page_get_text_rendering_mode, 0);
+    rb_define_method(rb_cHPDFPage, "get_text_raise", hpdf_page_get_text_raise, 0);
+    rb_define_method(rb_cHPDFPage, "get_rgb_fill", hpdf_page_get_rgb_fill, 0);
+    rb_define_method(rb_cHPDFPage, "get_rgb_stroke", hpdf_page_get_rgb_stroke, 0);
+    rb_define_method(rb_cHPDFPage, "get_cmyk_fill", hpdf_page_get_cmyk_fill, 0);
+    rb_define_method(rb_cHPDFPage, "get_cmyk_stroke", hpdf_page_get_cmyk_stroke, 0);
+    rb_define_method(rb_cHPDFPage, "get_gray_fill", hpdf_page_get_gray_fill, 0);
+    rb_define_method(rb_cHPDFPage, "get_gray_stroke", hpdf_page_get_gray_stroke, 0);
+    rb_define_method(rb_cHPDFPage, "get_stroking_color_space", hpdf_page_get_stroking_color_space, 0);
+    rb_define_method(rb_cHPDFPage, "get_filling_color_space", hpdf_page_get_filling_color_space, 0);
+    rb_define_method(rb_cHPDFPage, "get_text_matrix", hpdf_page_get_text_matrix, 0);
+
+    rb_define_method(rb_cHPDFPage, "set_line_width", hpdf_page_set_line_width, 1);
+    rb_define_method(rb_cHPDFPage, "set_line_cap", hpdf_page_set_line_cap, 1);
+    rb_define_method(rb_cHPDFPage, "set_line_join", hpdf_page_set_line_join, 1);
+    rb_define_method(rb_cHPDFPage, "set_miter_limit", hpdf_page_set_miter_limit, 1);
+    rb_define_method(rb_cHPDFPage, "set_dash", hpdf_page_set_dash, 2);
+    rb_define_method(rb_cHPDFPage, "set_flat", hpdf_page_set_flat, 1);
+    rb_define_method(rb_cHPDFPage, "gsave", hpdf_page_gsave, 0);
+    rb_define_method(rb_cHPDFPage, "grestore", hpdf_page_grestore, 0);
+    rb_define_method(rb_cHPDFPage, "get_gstate_depth", hpdf_page_get_gstate_depth, 0);
+    rb_define_method(rb_cHPDFPage, "concat", hpdf_page_concat, 6);
+    rb_define_method(rb_cHPDFPage, "move_to", hpdf_page_move_to, 2);
+    rb_define_method(rb_cHPDFPage, "line_to", hpdf_page_line_to, 2);
+    rb_define_method(rb_cHPDFPage, "curve_to", hpdf_page_curve_to, 6);
+    rb_define_method(rb_cHPDFPage, "curve_to2", hpdf_page_curve_to2, 4);
+    rb_define_method(rb_cHPDFPage, "curve_to3", hpdf_page_curve_to3, 4);
+    rb_define_method(rb_cHPDFPage, "close_path", hpdf_page_close_path, 0);
+    rb_define_method(rb_cHPDFPage, "rectangle", hpdf_page_rectangle, 4);
+    rb_define_method(rb_cHPDFPage, "stroke", hpdf_page_stroke, 0);
+    rb_define_method(rb_cHPDFPage, "close_path_stroke", hpdf_page_close_path_stroke, 0);
+    rb_define_method(rb_cHPDFPage, "fill", hpdf_page_fill, 0);
+    rb_define_method(rb_cHPDFPage, "eofill", hpdf_page_eofill, 0);
+    rb_define_method(rb_cHPDFPage, "fill_stroke", hpdf_page_fill_stroke, 0);
+    rb_define_method(rb_cHPDFPage, "eofill_stroke", hpdf_page_eofill_stroke, 0);
+    rb_define_method(rb_cHPDFPage, "close_path_fill_stroke", hpdf_page_close_path_fill_stroke, 0);
+    rb_define_method(rb_cHPDFPage, "close_path_eofill_stroke", hpdf_page_close_path_eofill_stroke, 0);
+    rb_define_method(rb_cHPDFPage, "end_path", hpdf_page_end_path, 0);
+    rb_define_method(rb_cHPDFPage, "clip", hpdf_page_clip, 0);
+    rb_define_method(rb_cHPDFPage, "page_clip", hpdf_page_clip, 0);
+    rb_define_method(rb_cHPDFPage, "eoclip", hpdf_page_eoclip, 0);
+    rb_define_method(rb_cHPDFPage, "begin_text", hpdf_page_begin_text, 0);
+    rb_define_method(rb_cHPDFPage, "end_text", hpdf_page_end_text, 0);
+    rb_define_method(rb_cHPDFPage, "set_char_space", hpdf_page_set_char_space, 1);
+    rb_define_method(rb_cHPDFPage, "set_word_space", hpdf_page_set_word_space, 1);
+    rb_define_method(rb_cHPDFPage, "set_horizontal_scalling", hpdf_page_set_horizontal_scalling, 1);
+    rb_define_method(rb_cHPDFPage, "set_text_leading", hpdf_page_set_text_leading, 1);
+    rb_define_method(rb_cHPDFPage, "set_font_and_size", hpdf_page_set_font_and_size, 2);
+    rb_define_method(rb_cHPDFPage, "set_text_rendering_mode", hpdf_page_set_text_rendering_mode, 1);
+    rb_define_method(rb_cHPDFPage, "set_text_raise", hpdf_page_set_text_raise, 1);
+    rb_define_method(rb_cHPDFPage, "move_text_pos", hpdf_page_move_text_pos, 2);
+    rb_define_method(rb_cHPDFPage, "move_text_pos2", hpdf_page_move_text_pos2, 2);
+    rb_define_method(rb_cHPDFPage, "set_text_matrix", hpdf_page_set_text_matrix, 6);
+    rb_define_method(rb_cHPDFPage, "move_to_next_line", hpdf_page_move_to_next_line, 0);
+    rb_define_method(rb_cHPDFPage, "show_text", hpdf_page_show_text, 1);
+    rb_define_method(rb_cHPDFPage, "show_text_next_line", hpdf_page_show_text_next_line, 1);
+    rb_define_method(rb_cHPDFPage, "show_text_next_line_ex", hpdf_page_show_text_next_line_ex, 3);
+    rb_define_method(rb_cHPDFPage, "set_gray_fill", hpdf_page_set_gray_fill, 1);
+    rb_define_method(rb_cHPDFPage, "set_gray_stroke", hpdf_page_set_gray_stroke, 1);
+    rb_define_method(rb_cHPDFPage, "set_rgb_fill", hpdf_page_set_rgb_fill, 3);
+    rb_define_method(rb_cHPDFPage, "set_rgb_stroke", hpdf_page_set_rgb_stroke, 3);
+    rb_define_method(rb_cHPDFPage, "set_cmyk_fill", hpdf_page_set_cmyk_fill, 4);
+    rb_define_method(rb_cHPDFPage, "set_cmyk_stroke", hpdf_page_set_cmyk_stroke, 4);
+    rb_define_method(rb_cHPDFPage, "execute_xobject", hpdf_page_execute_xobject, 1);
+    rb_define_method(rb_cHPDFPage, "draw_image", hpdf_page_draw_image, 5);
+    rb_define_method(rb_cHPDFPage, "circle", hpdf_page_circle, 3);
+    rb_define_method(rb_cHPDFPage, "ellipse", hpdf_page_ellipse, 4);
+    rb_define_method(rb_cHPDFPage, "arc", hpdf_page_arc, 5);
+    rb_define_method(rb_cHPDFPage, "text_out", hpdf_page_text_out, 3);
+    rb_define_method(rb_cHPDFPage, "text_rect", hpdf_page_text_rect, 6);
+
+    rb_define_method(rb_cHPDFPage, "set_slide_show", hpdf_page_set_slide_show, 3);
+
+    rb_define_method(rb_cHPDFDoc, "create_ext_gstate", hpdf_create_ext_gstate, 0);
+    rb_define_method(rb_cHPDFExtGState, "set_alpha_stroke", hpdf_ext_gstate_set_alpha_stroke, 1);
+    rb_define_method(rb_cHPDFExtGState, "set_alpha_fill", hpdf_ext_gstate_set_alpha_fill, 1);
+    rb_define_method(rb_cHPDFExtGState, "set_blend_mode", hpdf_ext_gstate_set_blend_mode, 1);
+    rb_define_method(rb_cHPDFPage, "set_ext_gstate", hpdf_page_set_ext_gstate, 1);
+
+    rb_eHPDFError = rb_define_class("HPDFError", rb_eStandardError);
+
+    rb_define_const(rb_cHPDFDoc, "HPDF_TRUE", INT2FIX(HPDF_TRUE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_FALSE", INT2FIX(HPDF_FALSE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_COMP_NONE", INT2FIX(HPDF_COMP_NONE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_COMP_TEXT", INT2FIX(HPDF_COMP_TEXT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_COMP_IMAGE", INT2FIX(HPDF_COMP_IMAGE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_COMP_METADATA", INT2FIX(HPDF_COMP_METADATA));
+    rb_define_const(rb_cHPDFDoc, "HPDF_COMP_ALL", INT2FIX(HPDF_COMP_ALL));
+    rb_define_const(rb_cHPDFDoc, "HPDF_HIDE_TOOLBAR", INT2FIX(HPDF_HIDE_TOOLBAR));
+    rb_define_const(rb_cHPDFDoc, "HPDF_HIDE_MENUBAR", INT2FIX(HPDF_HIDE_MENUBAR));
+    rb_define_const(rb_cHPDFDoc, "HPDF_HIDE_WINDOW_UI", INT2FIX(HPDF_HIDE_WINDOW_UI));
+    rb_define_const(rb_cHPDFDoc, "HPDF_FIT_WINDOW", INT2FIX(HPDF_FIT_WINDOW));
+    rb_define_const(rb_cHPDFDoc, "HPDF_CENTER_WINDOW", INT2FIX(HPDF_CENTER_WINDOW));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ENABLE_READ", INT2FIX(HPDF_ENABLE_READ));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ENABLE_PRINT", INT2FIX(HPDF_ENABLE_PRINT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ENABLE_EDIT_ALL", INT2FIX(HPDF_ENABLE_EDIT_ALL));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ENABLE_COPY", INT2FIX(HPDF_ENABLE_COPY));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ENABLE_EDIT", INT2FIX(HPDF_ENABLE_EDIT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_INFO_CREATION_DATE", INT2FIX(HPDF_INFO_CREATION_DATE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_INFO_MOD_DATE", INT2FIX(HPDF_INFO_MOD_DATE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_INFO_AUTHOR", INT2FIX(HPDF_INFO_AUTHOR));
+    rb_define_const(rb_cHPDFDoc, "HPDF_INFO_CREATOR", INT2FIX(HPDF_INFO_CREATOR));
+    rb_define_const(rb_cHPDFDoc, "HPDF_INFO_PRODUCER", INT2FIX(HPDF_INFO_PRODUCER));
+    rb_define_const(rb_cHPDFDoc, "HPDF_INFO_TITLE", INT2FIX(HPDF_INFO_TITLE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_INFO_SUBJECT", INT2FIX(HPDF_INFO_SUBJECT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_INFO_KEYWORDS", INT2FIX(HPDF_INFO_KEYWORDS));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ENCRYPT_R2", INT2FIX(HPDF_ENCRYPT_R2));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ENCRYPT_R3", INT2FIX(HPDF_ENCRYPT_R3));
+    rb_define_const(rb_cHPDFDoc, "HPDF_CS_DEVICE_GRAY", INT2FIX(HPDF_CS_DEVICE_GRAY));
+    rb_define_const(rb_cHPDFDoc, "HPDF_CS_DEVICE_RGB", INT2FIX(HPDF_CS_DEVICE_RGB));
+    rb_define_const(rb_cHPDFDoc, "HPDF_CS_DEVICE_CMYK", INT2FIX(HPDF_CS_DEVICE_CMYK));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BUTT_END", INT2FIX(HPDF_BUTT_END));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ROUND_END", INT2FIX(HPDF_ROUND_END));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PROJECTING_SQUARE_END", INT2FIX(HPDF_PROJECTING_SQUARE_END));
+    rb_define_const(rb_cHPDFDoc, "HPDF_MITER_JOIN", INT2FIX(HPDF_MITER_JOIN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ROUND_JOIN", INT2FIX(HPDF_ROUND_JOIN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BEVEL_JOIN", INT2FIX(HPDF_BEVEL_JOIN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_FILL", INT2FIX(HPDF_FILL));
+    rb_define_const(rb_cHPDFDoc, "HPDF_STROKE", INT2FIX(HPDF_STROKE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_FILL_THEN_STROKE", INT2FIX(HPDF_FILL_THEN_STROKE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_INVISIBLE", INT2FIX(HPDF_INVISIBLE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_FILL_CLIPPING", INT2FIX(HPDF_FILL_CLIPPING));
+    rb_define_const(rb_cHPDFDoc, "HPDF_STROKE_CLIPPING", INT2FIX(HPDF_STROKE_CLIPPING));
+    rb_define_const(rb_cHPDFDoc, "HPDF_FILL_STROKE_CLIPPING", INT2FIX(HPDF_FILL_STROKE_CLIPPING));
+    rb_define_const(rb_cHPDFDoc, "HPDF_CLIPPING", INT2FIX(HPDF_CLIPPING));
+    rb_define_const(rb_cHPDFDoc, "HPDF_WMODE_HORIZONTAL", INT2FIX(HPDF_WMODE_HORIZONTAL));
+    rb_define_const(rb_cHPDFDoc, "HPDF_WMODE_VERTICAL", INT2FIX(HPDF_WMODE_VERTICAL));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_LAYOUT_SINGLE", INT2FIX(HPDF_PAGE_LAYOUT_SINGLE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_LAYOUT_ONE_COLUMN", INT2FIX(HPDF_PAGE_LAYOUT_ONE_COLUMN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_LAYOUT_TWO_COLUMN_LEFT", INT2FIX(HPDF_PAGE_LAYOUT_TWO_COLUMN_LEFT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_LAYOUT_TWO_COLUMN_RIGHT", INT2FIX(HPDF_PAGE_LAYOUT_TWO_COLUMN_RIGHT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_MODE_USE_NONE", INT2FIX(HPDF_PAGE_MODE_USE_NONE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_MODE_USE_OUTLINE", INT2FIX(HPDF_PAGE_MODE_USE_OUTLINE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_MODE_USE_THUMBS", INT2FIX(HPDF_PAGE_MODE_USE_THUMBS));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_MODE_FULL_SCREEN", INT2FIX(HPDF_PAGE_MODE_FULL_SCREEN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_NUM_STYLE_DECIMAL", INT2FIX(HPDF_PAGE_NUM_STYLE_DECIMAL));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_NUM_STYLE_UPPER_ROMAN", INT2FIX(HPDF_PAGE_NUM_STYLE_UPPER_ROMAN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_NUM_STYLE_LOWER_ROMAN", INT2FIX(HPDF_PAGE_NUM_STYLE_LOWER_ROMAN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_NUM_STYLE_UPPER_LETTERS", INT2FIX(HPDF_PAGE_NUM_STYLE_UPPER_LETTERS));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_NUM_STYLE_LOWER_LETTERS", INT2FIX(HPDF_PAGE_NUM_STYLE_LOWER_LETTERS));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ANNOT_NO_HIGHTLIGHT", INT2FIX(HPDF_ANNOT_NO_HIGHTLIGHT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ANNOT_INVERT_BOX", INT2FIX(HPDF_ANNOT_INVERT_BOX));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ANNOT_INVERT_BORDER", INT2FIX(HPDF_ANNOT_INVERT_BORDER));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ANNOT_DOWN_APPEARANCE", INT2FIX(HPDF_ANNOT_DOWN_APPEARANCE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ANNOT_ICON_COMMENT", INT2FIX(HPDF_ANNOT_ICON_COMMENT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ANNOT_ICON_KEY", INT2FIX(HPDF_ANNOT_ICON_KEY));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ANNOT_ICON_NOTE", INT2FIX(HPDF_ANNOT_ICON_NOTE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ANNOT_ICON_HELP", INT2FIX(HPDF_ANNOT_ICON_HELP));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ANNOT_ICON_NEW_PARAGRAPH", INT2FIX(HPDF_ANNOT_ICON_NEW_PARAGRAPH));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ANNOT_ICON_PARAGRAPH", INT2FIX(HPDF_ANNOT_ICON_PARAGRAPH));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ANNOT_ICON_INSERT", INT2FIX(HPDF_ANNOT_ICON_INSERT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_LETTER", INT2FIX(HPDF_PAGE_SIZE_LETTER));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_LEGAL", INT2FIX(HPDF_PAGE_SIZE_LEGAL));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_A3", INT2FIX(HPDF_PAGE_SIZE_A3));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_A4", INT2FIX(HPDF_PAGE_SIZE_A4));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_A5", INT2FIX(HPDF_PAGE_SIZE_A5));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_B4", INT2FIX(HPDF_PAGE_SIZE_B4));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_B5", INT2FIX(HPDF_PAGE_SIZE_B5));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_EXECUTIVE", INT2FIX(HPDF_PAGE_SIZE_EXECUTIVE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_US4x6", INT2FIX(HPDF_PAGE_SIZE_US4x6));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_US4x8", INT2FIX(HPDF_PAGE_SIZE_US4x8));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_US5x7", INT2FIX(HPDF_PAGE_SIZE_US5x7));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_SIZE_COMM10", INT2FIX(HPDF_PAGE_SIZE_COMM10));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_PORTRAIT", INT2FIX(HPDF_PAGE_PORTRAIT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_PAGE_LANDSCAPE", INT2FIX(HPDF_PAGE_LANDSCAPE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ENCODER_TYPE_SINGLE_BYTE", INT2FIX(HPDF_ENCODER_TYPE_SINGLE_BYTE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ENCODER_TYPE_DOUBLE_BYTE", INT2FIX(HPDF_ENCODER_TYPE_DOUBLE_BYTE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_ENCODER_TYPE_UNINITIALIZED", INT2FIX(HPDF_ENCODER_TYPE_UNINITIALIZED));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BYTE_TYPE_SINGLE", INT2FIX(HPDF_BYTE_TYPE_SINGLE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BYTE_TYPE_LEAD", INT2FIX(HPDF_BYTE_TYPE_LEAD));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BYTE_TYPE_TRAIL", INT2FIX(HPDF_BYTE_TYPE_TRAIL));
+    rb_define_const(rb_cHPDFDoc, "HPDF_GMODE_PAGE_DESCRIPTION", INT2FIX(HPDF_GMODE_PAGE_DESCRIPTION));
+    rb_define_const(rb_cHPDFDoc, "HPDF_GMODE_PATH_OBJECT", INT2FIX(HPDF_GMODE_PATH_OBJECT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_GMODE_TEXT_OBJECT", INT2FIX(HPDF_GMODE_TEXT_OBJECT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_GMODE_CLIPPING_PATH", INT2FIX(HPDF_GMODE_CLIPPING_PATH));
+    rb_define_const(rb_cHPDFDoc, "HPDF_GMODE_SHADING", INT2FIX(HPDF_GMODE_SHADING));
+    rb_define_const(rb_cHPDFDoc, "HPDF_GMODE_INLINE_IMAGE", INT2FIX(HPDF_GMODE_INLINE_IMAGE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_GMODE_EXTERNAL_OBJECT", INT2FIX(HPDF_GMODE_EXTERNAL_OBJECT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TALIGN_LEFT", INT2FIX(HPDF_TALIGN_LEFT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TALIGN_RIGHT", INT2FIX(HPDF_TALIGN_RIGHT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TALIGN_CENTER", INT2FIX(HPDF_TALIGN_CENTER));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TALIGN_JUSTIFY", INT2FIX(HPDF_TALIGN_JUSTIFY));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_NORMAL", INT2FIX(HPDF_BM_NORMAL));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_MULTIPLY", INT2FIX(HPDF_BM_MULTIPLY));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_SCREEN", INT2FIX(HPDF_BM_SCREEN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_OVERLAY", INT2FIX(HPDF_BM_OVERLAY));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_DARKEN", INT2FIX(HPDF_BM_DARKEN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_LIGHTEN", INT2FIX(HPDF_BM_LIGHTEN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_COLOR_DODGE", INT2FIX(HPDF_BM_COLOR_DODGE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_COLOR_BUM", INT2FIX(HPDF_BM_COLOR_BUM));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_HARD_LIGHT", INT2FIX(HPDF_BM_HARD_LIGHT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_SOFT_LIGHT", INT2FIX(HPDF_BM_SOFT_LIGHT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_DIFFERENCE", INT2FIX(HPDF_BM_DIFFERENCE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_BM_EXCLUSHON", INT2FIX(HPDF_BM_EXCLUSHON));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_WIPE_RIGHT", INT2FIX(HPDF_TS_WIPE_RIGHT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_WIPE_UP", INT2FIX(HPDF_TS_WIPE_UP));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_WIPE_LEFT", INT2FIX(HPDF_TS_WIPE_LEFT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_WIPE_DOWN", INT2FIX(HPDF_TS_WIPE_DOWN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_BARN_DOORS_HORIZONTAL_OUT", INT2FIX(HPDF_TS_BARN_DOORS_HORIZONTAL_OUT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_BARN_DOORS_HORIZONTAL_IN", INT2FIX(HPDF_TS_BARN_DOORS_HORIZONTAL_IN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_BARN_DOORS_VERTICAL_OUT", INT2FIX(HPDF_TS_BARN_DOORS_VERTICAL_OUT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_BARN_DOORS_VERTICAL_IN", INT2FIX(HPDF_TS_BARN_DOORS_VERTICAL_IN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_BOX_OUT", INT2FIX(HPDF_TS_BOX_OUT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_BOX_IN", INT2FIX(HPDF_TS_BOX_IN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_BLINDS_HORIZONTAL", INT2FIX(HPDF_TS_BLINDS_HORIZONTAL));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_BLINDS_VERTICAL", INT2FIX(HPDF_TS_BLINDS_VERTICAL));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_DISSOLVE", INT2FIX(HPDF_TS_DISSOLVE));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_GLITTER_RIGHT", INT2FIX(HPDF_TS_GLITTER_RIGHT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_GLITTER_DOWN", INT2FIX(HPDF_TS_GLITTER_DOWN));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT", INT2FIX(HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT));
+    rb_define_const(rb_cHPDFDoc, "HPDF_TS_REPLACE", INT2FIX(HPDF_TS_REPLACE));
+}
+

+ 51 - 0
pdf.mod/libharu/bindings/vb.net/README.vbnet

@@ -0,0 +1,51 @@
+To use this interface, build Haru as a shared-library (DLL) or use binary 
+package for win32.
+
+There are some example programs in demo directory. The steps to run the 
+demonstration programs is as follows. 
+
+1. Build libharu as a shared library and copy libhpdf.dll to "if\vb.net\demo"
+   directory. (Or expand binary package for win32) 
+   and copy libhpdf.dll to "if\vb.net\demo" directory.)
+
+2. Compile and run demo programs. (Don't forget to compile hpdfvb.vb together.)
+
+   vbc /out:FontDemo.exe FontDemo.vb ..\hpdfvb.vb 
+   FontDemo.exe
+
+   vbc /out:ImageDemo.exe ImageDemo.vb ..\hpdfvb.vb 
+   ImageDemo.exe
+
+   vbc /out:LineDemo.exe LineDemo.vb ..\hpdfvb.vb
+   LineDemo.exe
+
+   vbc /out:OutlineDemo.exe OutlineDemo.vb ..\hpdfvb.vb
+   OutlineDemo.exe
+
+   vbc /out:Encryption.exe Encryption.vb ..\hpdfvb.vb
+   Encryption.exe
+
+   vbc /out:Permission.exe Permission.vb ..\hpdfvb.vb
+   Permission.exe
+
+   vbc /out:RawImageDemo.exe RawImageDemo.vb ..\hpdfvb.vb
+   RawImageDemo.exe
+
+   vbc /out:TextDemo.exe TextDemo.vb ..\hpdfvb.vb
+   TextDemo.exe
+
+
+NOTE:
+If you try to compile this examples in Visual Studio I've found that I had to place
+the 'hpdfvb.vb' in the 'demo' folder, and I also had to change the default namespace
+for the project to 'empty' such that it found the hpdf namespace defined in that module.
+
+I've also successfully been able to compile just the hpdfv.vb as an assembly DLL, then used
+the 'Add Reference...' feature in Visual Studio to import the module as a utility so that
+I didn't need to include the actual 'hpdfvb.vb' source file into my projects.
+
+
+NOTE:
+libhpdf.dll is required to run the program which uses the VB.Net interface for libharu.
+This interface should work for all versions of .NET (1.1, 2.0, 3.5 etc.).
+

+ 38 - 0
pdf.mod/libharu/bindings/vb.net/demo/Encryption.vb

@@ -0,0 +1,38 @@
+Imports HPdf
+
+Module Encryption
+
+    Sub Main()
+        Const owner_passwd As String = "owner"
+        Const user_passwd As String = "user"
+        Const text As String = "This is an encrypt document example."
+        Console.WriteLine("libhpdf-" + HPdfDoc.HPdfGetVersion())
+
+        Try
+            Dim pdf As HPdfDoc = New HPdfDoc()
+
+            ' create default-font 
+            Dim font As HPdfFont = pdf.GetFont("Helvetica", Nothing)
+
+            ' add a new page object. 
+            Dim page As HPdfPage = pdf.AddPage()
+
+            page.SetSize(HPdfPageSizes.HPDF_PAGE_SIZE_B5, HPdfPageDirection.HPDF_PAGE_LANDSCAPE)
+
+            page.BeginText()
+            page.SetFontAndSize(font, 20)
+            Dim tw As Single = page.TextWidth(text)
+            page.MoveTextPos((page.GetWidth() - tw) / 2, (page.GetHeight() - 20) / 2)
+            page.ShowText(text)
+            page.EndText()
+
+            pdf.SetPassword(owner_passwd, user_passwd)
+
+            ' save the document to a file 
+            pdf.SaveToFile("Encryption.pdf")
+
+        Catch ex As Exception
+            Console.Error.WriteLine(ex.Message)
+        End Try
+    End Sub
+End Module

+ 81 - 0
pdf.mod/libharu/bindings/vb.net/demo/FontDemo.vb

@@ -0,0 +1,81 @@
+Imports HPdf
+
+Module TextDemo
+
+    Dim font_list As String() = {"Courier", _
+                                    "Courier-Bold", _
+                                    "Courier-Oblique", _
+                                    "Courier-BoldOblique", _
+                                    "Helvetica", _
+                                    "Helvetica-Bold", _
+                                    "Helvetica-Oblique", _
+                                    "Helvetica-BoldOblique", _
+                                    "Times-Roman", _
+                                    "Times-Bold", _
+                                    "Times-Italic", _
+                                    "Times-BoldItalic", _
+                                    "Symbol", _
+                                    "ZapfDingbats"}
+
+    Sub Main()
+        Console.WriteLine("libhpdf-" & HPdfDoc.HPdfGetVersion())
+
+        Try
+            Const page_title As String = "FontDemo"
+
+            Dim pdf As HPdfDoc = New HPdfDoc()
+            Dim page As HPdfPage = pdf.AddPage()
+
+            Dim height As Single = page.GetHeight()
+            Dim width As Single = page.GetWidth()
+
+            ' Print the lines of the page. 
+            page.SetLineWidth(1)
+            page.Rectangle(50, 50, width - 100, height - 110)
+            page.Stroke()
+
+            ' Print the title of the page (with positioning center). 
+            Dim def_font As HPdfFont = pdf.GetFont("Helvetica", Nothing)
+            page.SetFontAndSize(def_font, 24)
+
+            Dim tw As Single = page.TextWidth(page_title)
+            page.BeginText()
+            page.TextOut((width - tw) / 2, height - 50, page_title)
+            page.EndText()
+
+            ' output subtitle.
+            page.BeginText()
+            page.SetFontAndSize(def_font, 16)
+            page.TextOut(60, height - 80, "<Standard Type1 fonts samples>")
+            page.EndText()
+
+            page.BeginText()
+            page.MoveTextPos(60, height - 105)
+
+            For i As Integer = 1 To font_list.Length - 1
+
+                Const samp_text As String = "abcdefgABCDEFG12345!#$%&+-@?"
+                Dim font As HPdfFont = pdf.GetFont(font_list(i), Nothing)
+
+                ' print a label of text 
+                page.SetFontAndSize(def_font, 9)
+                page.ShowText(font_list(i))
+                page.MoveTextPos(0, -18)
+
+                ' print a sample text. 
+                page.SetFontAndSize(font, 20)
+                page.ShowText(samp_text)
+                page.MoveTextPos(0, -20)
+            Next
+
+            page.EndText()
+
+            pdf.SaveToFile("FontDemo.pdf")
+
+        Catch ex As Exception
+            Console.Error.WriteLine(ex.Message)
+        End Try
+    End Sub
+
+End Module
+    

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff