pdf2json 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (473) hide show
  1. data/README.markdown +9 -0
  2. data/bin/.gitkeep +0 -0
  3. data/ext/extconf.rb +30 -0
  4. data/lib/pdf2json.rb +8 -0
  5. data/pdf2json-0.52-source/AUTHORS +24 -0
  6. data/pdf2json-0.52-source/CHANGES +11 -0
  7. data/pdf2json-0.52-source/Makefile +84 -0
  8. data/pdf2json-0.52-source/Makefile.in +84 -0
  9. data/pdf2json-0.52-source/aclocal.m4 +274 -0
  10. data/pdf2json-0.52-source/aconf-win32.h +86 -0
  11. data/pdf2json-0.52-source/aconf.h +42 -0
  12. data/pdf2json-0.52-source/aconf.h.in +41 -0
  13. data/pdf2json-0.52-source/autom4te.cache/output.0 +6908 -0
  14. data/pdf2json-0.52-source/autom4te.cache/requests +76 -0
  15. data/pdf2json-0.52-source/autom4te.cache/traces.0 +466 -0
  16. data/pdf2json-0.52-source/config.log +1259 -0
  17. data/pdf2json-0.52-source/config.status +1050 -0
  18. data/pdf2json-0.52-source/configure +6908 -0
  19. data/pdf2json-0.52-source/configure.ac +93 -0
  20. data/pdf2json-0.52-source/doc/pdffonts.1 +130 -0
  21. data/pdf2json-0.52-source/doc/pdffonts.cat +107 -0
  22. data/pdf2json-0.52-source/doc/pdffonts.hlp +117 -0
  23. data/pdf2json-0.52-source/doc/pdfimages.1 +102 -0
  24. data/pdf2json-0.52-source/doc/pdfimages.cat +92 -0
  25. data/pdf2json-0.52-source/doc/pdfimages.hlp +101 -0
  26. data/pdf2json-0.52-source/doc/pdfinfo.1 +158 -0
  27. data/pdf2json-0.52-source/doc/pdfinfo.cat +119 -0
  28. data/pdf2json-0.52-source/doc/pdfinfo.hlp +129 -0
  29. data/pdf2json-0.52-source/doc/pdftoppm.1 +115 -0
  30. data/pdf2json-0.52-source/doc/pdftoppm.cat +105 -0
  31. data/pdf2json-0.52-source/doc/pdftoppm.hlp +114 -0
  32. data/pdf2json-0.52-source/doc/pdftops.1 +229 -0
  33. data/pdf2json-0.52-source/doc/pdftops.cat +221 -0
  34. data/pdf2json-0.52-source/doc/pdftops.hlp +231 -0
  35. data/pdf2json-0.52-source/doc/pdftotext.1 +137 -0
  36. data/pdf2json-0.52-source/doc/pdftotext.cat +120 -0
  37. data/pdf2json-0.52-source/doc/pdftotext.hlp +133 -0
  38. data/pdf2json-0.52-source/doc/sample-xpdfrc +91 -0
  39. data/pdf2json-0.52-source/doc/xpdf.1 +513 -0
  40. data/pdf2json-0.52-source/doc/xpdf.cat +476 -0
  41. data/pdf2json-0.52-source/doc/xpdf.hlp +489 -0
  42. data/pdf2json-0.52-source/doc/xpdfrc.5 +480 -0
  43. data/pdf2json-0.52-source/doc/xpdfrc.cat +474 -0
  44. data/pdf2json-0.52-source/doc/xpdfrc.hlp +479 -0
  45. data/pdf2json-0.52-source/fofi/.DS_Store +0 -0
  46. data/pdf2json-0.52-source/fofi/FoFiBase.cc +156 -0
  47. data/pdf2json-0.52-source/fofi/FoFiBase.h +57 -0
  48. data/pdf2json-0.52-source/fofi/FoFiBase.o +0 -0
  49. data/pdf2json-0.52-source/fofi/FoFiEncodings.cc +994 -0
  50. data/pdf2json-0.52-source/fofi/FoFiEncodings.h +36 -0
  51. data/pdf2json-0.52-source/fofi/FoFiEncodings.o +0 -0
  52. data/pdf2json-0.52-source/fofi/FoFiTrueType.cc +2027 -0
  53. data/pdf2json-0.52-source/fofi/FoFiTrueType.h +174 -0
  54. data/pdf2json-0.52-source/fofi/FoFiTrueType.o +0 -0
  55. data/pdf2json-0.52-source/fofi/FoFiType1.cc +252 -0
  56. data/pdf2json-0.52-source/fofi/FoFiType1.h +59 -0
  57. data/pdf2json-0.52-source/fofi/FoFiType1.o +0 -0
  58. data/pdf2json-0.52-source/fofi/FoFiType1C.cc +2603 -0
  59. data/pdf2json-0.52-source/fofi/FoFiType1C.h +233 -0
  60. data/pdf2json-0.52-source/fofi/FoFiType1C.o +0 -0
  61. data/pdf2json-0.52-source/fofi/Makefile +70 -0
  62. data/pdf2json-0.52-source/fofi/Makefile.dep +0 -0
  63. data/pdf2json-0.52-source/fofi/Makefile.in +70 -0
  64. data/pdf2json-0.52-source/fofi/libfofi.a +0 -0
  65. data/pdf2json-0.52-source/fofi/vms_make.com +0 -0
  66. data/pdf2json-0.52-source/freetype.win32/.DS_Store +0 -0
  67. data/pdf2json-0.52-source/freetype.win32/include/.DS_Store +0 -0
  68. data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftconfig.h +528 -0
  69. data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftheader.h +780 -0
  70. data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftmodule.h +32 -0
  71. data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftoption.h +733 -0
  72. data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftstdlib.h +173 -0
  73. data/pdf2json-0.52-source/freetype.win32/include/freetype/freetype.h +3919 -0
  74. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftadvanc.h +179 -0
  75. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftbbox.h +94 -0
  76. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftbdf.h +209 -0
  77. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftbitmap.h +227 -0
  78. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftcache.h +1128 -0
  79. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftchapters.h +103 -0
  80. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftcid.h +166 -0
  81. data/pdf2json-0.52-source/freetype.win32/include/freetype/fterrdef.h +244 -0
  82. data/pdf2json-0.52-source/freetype.win32/include/freetype/fterrors.h +206 -0
  83. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftgasp.h +120 -0
  84. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftglyph.h +613 -0
  85. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftgxval.h +358 -0
  86. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftgzip.h +102 -0
  87. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftimage.h +1313 -0
  88. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftincrem.h +353 -0
  89. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftlcdfil.h +213 -0
  90. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftlist.h +277 -0
  91. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftlzw.h +99 -0
  92. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmac.h +274 -0
  93. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmm.h +378 -0
  94. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmodapi.h +483 -0
  95. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmoderr.h +155 -0
  96. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftotval.h +203 -0
  97. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftoutln.h +537 -0
  98. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftpfr.h +172 -0
  99. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftrender.h +230 -0
  100. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsizes.h +159 -0
  101. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsnames.h +200 -0
  102. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftstroke.h +716 -0
  103. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsynth.h +80 -0
  104. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsystem.h +347 -0
  105. data/pdf2json-0.52-source/freetype.win32/include/freetype/fttrigon.h +350 -0
  106. data/pdf2json-0.52-source/freetype.win32/include/freetype/fttypes.h +588 -0
  107. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftwinfnt.h +274 -0
  108. data/pdf2json-0.52-source/freetype.win32/include/freetype/ftxf86.h +83 -0
  109. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/autohint.h +231 -0
  110. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftcalc.h +179 -0
  111. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftdebug.h +250 -0
  112. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftdriver.h +422 -0
  113. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftgloadr.h +168 -0
  114. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftmemory.h +380 -0
  115. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftobjs.h +1428 -0
  116. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftpic.h +67 -0
  117. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftrfork.h +196 -0
  118. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftserv.h +620 -0
  119. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftstream.h +539 -0
  120. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/fttrace.h +139 -0
  121. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftvalid.h +150 -0
  122. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/internal.h +51 -0
  123. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/pcftypes.h +56 -0
  124. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/psaux.h +873 -0
  125. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/pshints.h +712 -0
  126. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svbdf.h +77 -0
  127. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svcid.h +83 -0
  128. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svgldict.h +82 -0
  129. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svgxval.h +72 -0
  130. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svkern.h +51 -0
  131. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svmm.h +104 -0
  132. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svotval.h +55 -0
  133. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpfr.h +66 -0
  134. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpostnm.h +79 -0
  135. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpscmap.h +164 -0
  136. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpsinfo.h +92 -0
  137. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svsfnt.h +102 -0
  138. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svttcmap.h +106 -0
  139. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svtteng.h +53 -0
  140. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svttglyf.h +67 -0
  141. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svwinfnt.h +50 -0
  142. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svxf86nm.h +55 -0
  143. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/sfnt.h +897 -0
  144. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/t1types.h +270 -0
  145. data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/tttypes.h +1543 -0
  146. data/pdf2json-0.52-source/freetype.win32/include/freetype/t1tables.h +504 -0
  147. data/pdf2json-0.52-source/freetype.win32/include/freetype/ttnameid.h +1247 -0
  148. data/pdf2json-0.52-source/freetype.win32/include/freetype/tttables.h +759 -0
  149. data/pdf2json-0.52-source/freetype.win32/include/freetype/tttags.h +107 -0
  150. data/pdf2json-0.52-source/freetype.win32/include/freetype/ttunpat.h +59 -0
  151. data/pdf2json-0.52-source/freetype.win32/include/ft2build.h +39 -0
  152. data/pdf2json-0.52-source/freetype.win32/lib/freetype_a.lib +0 -0
  153. data/pdf2json-0.52-source/goo/.DS_Store +0 -0
  154. data/pdf2json-0.52-source/goo/FixedPoint.cc +118 -0
  155. data/pdf2json-0.52-source/goo/FixedPoint.h +155 -0
  156. data/pdf2json-0.52-source/goo/FixedPoint.o +0 -0
  157. data/pdf2json-0.52-source/goo/GHash.cc +380 -0
  158. data/pdf2json-0.52-source/goo/GHash.h +78 -0
  159. data/pdf2json-0.52-source/goo/GHash.o +0 -0
  160. data/pdf2json-0.52-source/goo/GList.cc +97 -0
  161. data/pdf2json-0.52-source/goo/GList.h +96 -0
  162. data/pdf2json-0.52-source/goo/GList.o +0 -0
  163. data/pdf2json-0.52-source/goo/GMutex.h +49 -0
  164. data/pdf2json-0.52-source/goo/GString.cc +724 -0
  165. data/pdf2json-0.52-source/goo/GString.cc.fixed +718 -0
  166. data/pdf2json-0.52-source/goo/GString.h +136 -0
  167. data/pdf2json-0.52-source/goo/GString.o +0 -0
  168. data/pdf2json-0.52-source/goo/ImgWriter.o +0 -0
  169. data/pdf2json-0.52-source/goo/JpegWriter.o +0 -0
  170. data/pdf2json-0.52-source/goo/Makefile +72 -0
  171. data/pdf2json-0.52-source/goo/Makefile.dep +0 -0
  172. data/pdf2json-0.52-source/goo/Makefile.in +72 -0
  173. data/pdf2json-0.52-source/goo/PNGWriter.o +0 -0
  174. data/pdf2json-0.52-source/goo/gfile.cc +731 -0
  175. data/pdf2json-0.52-source/goo/gfile.h +138 -0
  176. data/pdf2json-0.52-source/goo/gfile.o +0 -0
  177. data/pdf2json-0.52-source/goo/gmem.cc +264 -0
  178. data/pdf2json-0.52-source/goo/gmem.h +79 -0
  179. data/pdf2json-0.52-source/goo/gmem.o +0 -0
  180. data/pdf2json-0.52-source/goo/gmempp.cc +32 -0
  181. data/pdf2json-0.52-source/goo/gmempp.o +0 -0
  182. data/pdf2json-0.52-source/goo/gtypes.h +29 -0
  183. data/pdf2json-0.52-source/goo/libGoo.a +0 -0
  184. data/pdf2json-0.52-source/goo/parseargs.c +190 -0
  185. data/pdf2json-0.52-source/goo/parseargs.h +71 -0
  186. data/pdf2json-0.52-source/goo/parseargs.o +0 -0
  187. data/pdf2json-0.52-source/goo/vms_directory.c +214 -0
  188. data/pdf2json-0.52-source/goo/vms_dirent.h +67 -0
  189. data/pdf2json-0.52-source/goo/vms_make.com +82 -0
  190. data/pdf2json-0.52-source/goo/vms_sys_dirent.h +54 -0
  191. data/pdf2json-0.52-source/goo/vms_unix_time.h +102 -0
  192. data/pdf2json-0.52-source/goo/vms_unix_times.c +42 -0
  193. data/pdf2json-0.52-source/goo/vms_unlink.c +22 -0
  194. data/pdf2json-0.52-source/ms_make.bat +199 -0
  195. data/pdf2json-0.52-source/splash/.DS_Store +0 -0
  196. data/pdf2json-0.52-source/splash/Makefile +103 -0
  197. data/pdf2json-0.52-source/splash/Makefile.dep +0 -0
  198. data/pdf2json-0.52-source/splash/Makefile.in +103 -0
  199. data/pdf2json-0.52-source/splash/Splash.cc +3310 -0
  200. data/pdf2json-0.52-source/splash/Splash.h +293 -0
  201. data/pdf2json-0.52-source/splash/Splash.o +0 -0
  202. data/pdf2json-0.52-source/splash/SplashBitmap.cc +188 -0
  203. data/pdf2json-0.52-source/splash/SplashBitmap.h +64 -0
  204. data/pdf2json-0.52-source/splash/SplashBitmap.o +0 -0
  205. data/pdf2json-0.52-source/splash/SplashClip.cc +382 -0
  206. data/pdf2json-0.52-source/splash/SplashClip.h +107 -0
  207. data/pdf2json-0.52-source/splash/SplashClip.o +0 -0
  208. data/pdf2json-0.52-source/splash/SplashErrorCodes.h +32 -0
  209. data/pdf2json-0.52-source/splash/SplashFTFont.cc +357 -0
  210. data/pdf2json-0.52-source/splash/SplashFTFont.h +58 -0
  211. data/pdf2json-0.52-source/splash/SplashFTFont.o +0 -0
  212. data/pdf2json-0.52-source/splash/SplashFTFontEngine.cc +179 -0
  213. data/pdf2json-0.52-source/splash/SplashFTFontEngine.h +65 -0
  214. data/pdf2json-0.52-source/splash/SplashFTFontEngine.o +0 -0
  215. data/pdf2json-0.52-source/splash/SplashFTFontFile.cc +114 -0
  216. data/pdf2json-0.52-source/splash/SplashFTFontFile.h +73 -0
  217. data/pdf2json-0.52-source/splash/SplashFTFontFile.o +0 -0
  218. data/pdf2json-0.52-source/splash/SplashFont.cc +176 -0
  219. data/pdf2json-0.52-source/splash/SplashFont.h +104 -0
  220. data/pdf2json-0.52-source/splash/SplashFont.o +0 -0
  221. data/pdf2json-0.52-source/splash/SplashFontEngine.cc +317 -0
  222. data/pdf2json-0.52-source/splash/SplashFontEngine.h +91 -0
  223. data/pdf2json-0.52-source/splash/SplashFontEngine.o +0 -0
  224. data/pdf2json-0.52-source/splash/SplashFontFile.cc +55 -0
  225. data/pdf2json-0.52-source/splash/SplashFontFile.h +60 -0
  226. data/pdf2json-0.52-source/splash/SplashFontFile.o +0 -0
  227. data/pdf2json-0.52-source/splash/SplashFontFileID.cc +23 -0
  228. data/pdf2json-0.52-source/splash/SplashFontFileID.h +30 -0
  229. data/pdf2json-0.52-source/splash/SplashFontFileID.o +0 -0
  230. data/pdf2json-0.52-source/splash/SplashGlyphBitmap.h +26 -0
  231. data/pdf2json-0.52-source/splash/SplashMath.h +89 -0
  232. data/pdf2json-0.52-source/splash/SplashPath.cc +184 -0
  233. data/pdf2json-0.52-source/splash/SplashPath.h +121 -0
  234. data/pdf2json-0.52-source/splash/SplashPath.o +0 -0
  235. data/pdf2json-0.52-source/splash/SplashPattern.cc +40 -0
  236. data/pdf2json-0.52-source/splash/SplashPattern.h +65 -0
  237. data/pdf2json-0.52-source/splash/SplashPattern.o +0 -0
  238. data/pdf2json-0.52-source/splash/SplashScreen.cc +383 -0
  239. data/pdf2json-0.52-source/splash/SplashScreen.h +56 -0
  240. data/pdf2json-0.52-source/splash/SplashScreen.o +0 -0
  241. data/pdf2json-0.52-source/splash/SplashState.cc +165 -0
  242. data/pdf2json-0.52-source/splash/SplashState.h +103 -0
  243. data/pdf2json-0.52-source/splash/SplashState.o +0 -0
  244. data/pdf2json-0.52-source/splash/SplashT1Font.cc +287 -0
  245. data/pdf2json-0.52-source/splash/SplashT1Font.h +57 -0
  246. data/pdf2json-0.52-source/splash/SplashT1Font.o +0 -0
  247. data/pdf2json-0.52-source/splash/SplashT1FontEngine.cc +124 -0
  248. data/pdf2json-0.52-source/splash/SplashT1FontEngine.h +53 -0
  249. data/pdf2json-0.52-source/splash/SplashT1FontEngine.o +0 -0
  250. data/pdf2json-0.52-source/splash/SplashT1FontFile.cc +97 -0
  251. data/pdf2json-0.52-source/splash/SplashT1FontFile.h +58 -0
  252. data/pdf2json-0.52-source/splash/SplashT1FontFile.o +0 -0
  253. data/pdf2json-0.52-source/splash/SplashTypes.h +132 -0
  254. data/pdf2json-0.52-source/splash/SplashXPath.cc +438 -0
  255. data/pdf2json-0.52-source/splash/SplashXPath.h +100 -0
  256. data/pdf2json-0.52-source/splash/SplashXPath.o +0 -0
  257. data/pdf2json-0.52-source/splash/SplashXPathScanner.cc +428 -0
  258. data/pdf2json-0.52-source/splash/SplashXPathScanner.h +87 -0
  259. data/pdf2json-0.52-source/splash/SplashXPathScanner.o +0 -0
  260. data/pdf2json-0.52-source/splash/libsplash.a +0 -0
  261. data/pdf2json-0.52-source/splash/vms_make.com +0 -0
  262. data/pdf2json-0.52-source/src/.DS_Store +0 -0
  263. data/pdf2json-0.52-source/src/GVector.h +101 -0
  264. data/pdf2json-0.52-source/src/ImgOutputDev.cc +1243 -0
  265. data/pdf2json-0.52-source/src/ImgOutputDev.h +307 -0
  266. data/pdf2json-0.52-source/src/ImgOutputDev.o +0 -0
  267. data/pdf2json-0.52-source/src/Makefile +68 -0
  268. data/pdf2json-0.52-source/src/Makefile.in +68 -0
  269. data/pdf2json-0.52-source/src/XmlFonts.cc +367 -0
  270. data/pdf2json-0.52-source/src/XmlFonts.h +91 -0
  271. data/pdf2json-0.52-source/src/XmlFonts.o +0 -0
  272. data/pdf2json-0.52-source/src/XmlLinks.cc +101 -0
  273. data/pdf2json-0.52-source/src/XmlLinks.h +54 -0
  274. data/pdf2json-0.52-source/src/XmlLinks.o +0 -0
  275. data/pdf2json-0.52-source/src/pdf2json +0 -0
  276. data/pdf2json-0.52-source/src/pdf2json.cc +343 -0
  277. data/pdf2json-0.52-source/src/pdf2json.o +0 -0
  278. data/pdf2json-0.52-source/src/pdf2xml.dtd +22 -0
  279. data/pdf2json-0.52-source/src/pdf2xmljson.dtd +9 -0
  280. data/pdf2json-0.52-source/xpdf/.DS_Store +0 -0
  281. data/pdf2json-0.52-source/xpdf/Annot.cc +1556 -0
  282. data/pdf2json-0.52-source/xpdf/Annot.h +142 -0
  283. data/pdf2json-0.52-source/xpdf/Annot.o +0 -0
  284. data/pdf2json-0.52-source/xpdf/Array.cc +73 -0
  285. data/pdf2json-0.52-source/xpdf/Array.h +58 -0
  286. data/pdf2json-0.52-source/xpdf/Array.o +0 -0
  287. data/pdf2json-0.52-source/xpdf/BuiltinFont.cc +65 -0
  288. data/pdf2json-0.52-source/xpdf/BuiltinFont.h +57 -0
  289. data/pdf2json-0.52-source/xpdf/BuiltinFont.o +0 -0
  290. data/pdf2json-0.52-source/xpdf/BuiltinFontTables.cc +4284 -0
  291. data/pdf2json-0.52-source/xpdf/BuiltinFontTables.h +23 -0
  292. data/pdf2json-0.52-source/xpdf/BuiltinFontTables.o +0 -0
  293. data/pdf2json-0.52-source/xpdf/CMap.cc +408 -0
  294. data/pdf2json-0.52-source/xpdf/CMap.h +102 -0
  295. data/pdf2json-0.52-source/xpdf/CMap.o +0 -0
  296. data/pdf2json-0.52-source/xpdf/Catalog.cc +374 -0
  297. data/pdf2json-0.52-source/xpdf/Catalog.h +97 -0
  298. data/pdf2json-0.52-source/xpdf/Catalog.o +0 -0
  299. data/pdf2json-0.52-source/xpdf/CharCodeToUnicode.cc +540 -0
  300. data/pdf2json-0.52-source/xpdf/CharCodeToUnicode.h +117 -0
  301. data/pdf2json-0.52-source/xpdf/CharCodeToUnicode.o +0 -0
  302. data/pdf2json-0.52-source/xpdf/CharTypes.h +24 -0
  303. data/pdf2json-0.52-source/xpdf/CompactFontTables.h +464 -0
  304. data/pdf2json-0.52-source/xpdf/CoreOutputDev.cc +61 -0
  305. data/pdf2json-0.52-source/xpdf/CoreOutputDev.h +61 -0
  306. data/pdf2json-0.52-source/xpdf/Decrypt.cc +776 -0
  307. data/pdf2json-0.52-source/xpdf/Decrypt.h +95 -0
  308. data/pdf2json-0.52-source/xpdf/Decrypt.o +0 -0
  309. data/pdf2json-0.52-source/xpdf/Dict.cc +95 -0
  310. data/pdf2json-0.52-source/xpdf/Dict.h +77 -0
  311. data/pdf2json-0.52-source/xpdf/Dict.o +0 -0
  312. data/pdf2json-0.52-source/xpdf/Error.cc +38 -0
  313. data/pdf2json-0.52-source/xpdf/Error.h +23 -0
  314. data/pdf2json-0.52-source/xpdf/Error.o +0 -0
  315. data/pdf2json-0.52-source/xpdf/ErrorCodes.h +36 -0
  316. data/pdf2json-0.52-source/xpdf/FontEncodingTables.cc +1824 -0
  317. data/pdf2json-0.52-source/xpdf/FontEncodingTables.h +20 -0
  318. data/pdf2json-0.52-source/xpdf/FontEncodingTables.o +0 -0
  319. data/pdf2json-0.52-source/xpdf/Function.cc +1573 -0
  320. data/pdf2json-0.52-source/xpdf/Function.h +229 -0
  321. data/pdf2json-0.52-source/xpdf/Function.o +0 -0
  322. data/pdf2json-0.52-source/xpdf/Gfx.cc +4187 -0
  323. data/pdf2json-0.52-source/xpdf/Gfx.h +312 -0
  324. data/pdf2json-0.52-source/xpdf/Gfx.o +0 -0
  325. data/pdf2json-0.52-source/xpdf/GfxFont.cc +1568 -0
  326. data/pdf2json-0.52-source/xpdf/GfxFont.h +320 -0
  327. data/pdf2json-0.52-source/xpdf/GfxFont.o +0 -0
  328. data/pdf2json-0.52-source/xpdf/GfxState.cc +4137 -0
  329. data/pdf2json-0.52-source/xpdf/GfxState.h +1244 -0
  330. data/pdf2json-0.52-source/xpdf/GfxState.o +0 -0
  331. data/pdf2json-0.52-source/xpdf/GlobalParams.cc +2924 -0
  332. data/pdf2json-0.52-source/xpdf/GlobalParams.cc.old +2908 -0
  333. data/pdf2json-0.52-source/xpdf/GlobalParams.h +466 -0
  334. data/pdf2json-0.52-source/xpdf/GlobalParams.h.old +463 -0
  335. data/pdf2json-0.52-source/xpdf/GlobalParams.o +0 -0
  336. data/pdf2json-0.52-source/xpdf/ImageOutputDev.cc +195 -0
  337. data/pdf2json-0.52-source/xpdf/ImageOutputDev.h +76 -0
  338. data/pdf2json-0.52-source/xpdf/ImageOutputDev.o +0 -0
  339. data/pdf2json-0.52-source/xpdf/JArithmeticDecoder.cc +322 -0
  340. data/pdf2json-0.52-source/xpdf/JArithmeticDecoder.h +109 -0
  341. data/pdf2json-0.52-source/xpdf/JArithmeticDecoder.o +0 -0
  342. data/pdf2json-0.52-source/xpdf/JBIG2Stream.cc +3413 -0
  343. data/pdf2json-0.52-source/xpdf/JBIG2Stream.h +145 -0
  344. data/pdf2json-0.52-source/xpdf/JBIG2Stream.o +0 -0
  345. data/pdf2json-0.52-source/xpdf/JPXStream.cc +3144 -0
  346. data/pdf2json-0.52-source/xpdf/JPXStream.h +351 -0
  347. data/pdf2json-0.52-source/xpdf/JPXStream.o +0 -0
  348. data/pdf2json-0.52-source/xpdf/Lexer.cc +485 -0
  349. data/pdf2json-0.52-source/xpdf/Lexer.h +80 -0
  350. data/pdf2json-0.52-source/xpdf/Lexer.o +0 -0
  351. data/pdf2json-0.52-source/xpdf/Link.cc +806 -0
  352. data/pdf2json-0.52-source/xpdf/Link.cc.old +784 -0
  353. data/pdf2json-0.52-source/xpdf/Link.h +415 -0
  354. data/pdf2json-0.52-source/xpdf/Link.h.old +369 -0
  355. data/pdf2json-0.52-source/xpdf/Link.o +0 -0
  356. data/pdf2json-0.52-source/xpdf/Makefile +232 -0
  357. data/pdf2json-0.52-source/xpdf/Makefile.dep +0 -0
  358. data/pdf2json-0.52-source/xpdf/Makefile.in +232 -0
  359. data/pdf2json-0.52-source/xpdf/NameToCharCode.cc +116 -0
  360. data/pdf2json-0.52-source/xpdf/NameToCharCode.h +42 -0
  361. data/pdf2json-0.52-source/xpdf/NameToCharCode.o +0 -0
  362. data/pdf2json-0.52-source/xpdf/NameToUnicodeTable.h +1097 -0
  363. data/pdf2json-0.52-source/xpdf/Object.cc +231 -0
  364. data/pdf2json-0.52-source/xpdf/Object.h +303 -0
  365. data/pdf2json-0.52-source/xpdf/Object.o +0 -0
  366. data/pdf2json-0.52-source/xpdf/Outline.cc +151 -0
  367. data/pdf2json-0.52-source/xpdf/Outline.h +76 -0
  368. data/pdf2json-0.52-source/xpdf/Outline.o +0 -0
  369. data/pdf2json-0.52-source/xpdf/OutputDev.cc +131 -0
  370. data/pdf2json-0.52-source/xpdf/OutputDev.h +253 -0
  371. data/pdf2json-0.52-source/xpdf/OutputDev.o +0 -0
  372. data/pdf2json-0.52-source/xpdf/PDFCore.cc +2044 -0
  373. data/pdf2json-0.52-source/xpdf/PDFCore.h +321 -0
  374. data/pdf2json-0.52-source/xpdf/PDFDoc.cc +404 -0
  375. data/pdf2json-0.52-source/xpdf/PDFDoc.h +183 -0
  376. data/pdf2json-0.52-source/xpdf/PDFDoc.o +0 -0
  377. data/pdf2json-0.52-source/xpdf/PDFDocEncoding.cc +44 -0
  378. data/pdf2json-0.52-source/xpdf/PDFDocEncoding.h +16 -0
  379. data/pdf2json-0.52-source/xpdf/PDFDocEncoding.o +0 -0
  380. data/pdf2json-0.52-source/xpdf/PSOutputDev.cc +6224 -0
  381. data/pdf2json-0.52-source/xpdf/PSOutputDev.h +395 -0
  382. data/pdf2json-0.52-source/xpdf/PSOutputDev.o +0 -0
  383. data/pdf2json-0.52-source/xpdf/PSTokenizer.cc +135 -0
  384. data/pdf2json-0.52-source/xpdf/PSTokenizer.h +41 -0
  385. data/pdf2json-0.52-source/xpdf/PSTokenizer.o +0 -0
  386. data/pdf2json-0.52-source/xpdf/Page.cc +454 -0
  387. data/pdf2json-0.52-source/xpdf/Page.h +187 -0
  388. data/pdf2json-0.52-source/xpdf/Page.o +0 -0
  389. data/pdf2json-0.52-source/xpdf/Parser.cc +227 -0
  390. data/pdf2json-0.52-source/xpdf/Parser.h +59 -0
  391. data/pdf2json-0.52-source/xpdf/Parser.o +0 -0
  392. data/pdf2json-0.52-source/xpdf/PreScanOutputDev.cc +257 -0
  393. data/pdf2json-0.52-source/xpdf/PreScanOutputDev.h +130 -0
  394. data/pdf2json-0.52-source/xpdf/PreScanOutputDev.o +0 -0
  395. data/pdf2json-0.52-source/xpdf/SecurityHandler.cc +390 -0
  396. data/pdf2json-0.52-source/xpdf/SecurityHandler.h +160 -0
  397. data/pdf2json-0.52-source/xpdf/SecurityHandler.o +0 -0
  398. data/pdf2json-0.52-source/xpdf/SplashOutputDev.cc +2845 -0
  399. data/pdf2json-0.52-source/xpdf/SplashOutputDev.h +247 -0
  400. data/pdf2json-0.52-source/xpdf/SplashOutputDev.o +0 -0
  401. data/pdf2json-0.52-source/xpdf/Stream-CCITT.h +459 -0
  402. data/pdf2json-0.52-source/xpdf/Stream.cc +4627 -0
  403. data/pdf2json-0.52-source/xpdf/Stream.h +858 -0
  404. data/pdf2json-0.52-source/xpdf/Stream.o +0 -0
  405. data/pdf2json-0.52-source/xpdf/TextOutputDev.cc +4090 -0
  406. data/pdf2json-0.52-source/xpdf/TextOutputDev.h +661 -0
  407. data/pdf2json-0.52-source/xpdf/TextOutputDev.o +0 -0
  408. data/pdf2json-0.52-source/xpdf/UTF8.h +56 -0
  409. data/pdf2json-0.52-source/xpdf/UnicodeMap.cc +302 -0
  410. data/pdf2json-0.52-source/xpdf/UnicodeMap.cc.old +293 -0
  411. data/pdf2json-0.52-source/xpdf/UnicodeMap.h +135 -0
  412. data/pdf2json-0.52-source/xpdf/UnicodeMap.h.old +123 -0
  413. data/pdf2json-0.52-source/xpdf/UnicodeMap.o +0 -0
  414. data/pdf2json-0.52-source/xpdf/UnicodeMapTables.h +361 -0
  415. data/pdf2json-0.52-source/xpdf/UnicodeTypeTable.cc +949 -0
  416. data/pdf2json-0.52-source/xpdf/UnicodeTypeTable.h +20 -0
  417. data/pdf2json-0.52-source/xpdf/UnicodeTypeTable.o +0 -0
  418. data/pdf2json-0.52-source/xpdf/XPDFApp.cc +447 -0
  419. data/pdf2json-0.52-source/xpdf/XPDFApp.h +114 -0
  420. data/pdf2json-0.52-source/xpdf/XPDFCore.cc +1655 -0
  421. data/pdf2json-0.52-source/xpdf/XPDFCore.h +251 -0
  422. data/pdf2json-0.52-source/xpdf/XPDFTree.cc +931 -0
  423. data/pdf2json-0.52-source/xpdf/XPDFTree.h +45 -0
  424. data/pdf2json-0.52-source/xpdf/XPDFTreeP.h +87 -0
  425. data/pdf2json-0.52-source/xpdf/XPDFViewer.cc +3488 -0
  426. data/pdf2json-0.52-source/xpdf/XPDFViewer.h +352 -0
  427. data/pdf2json-0.52-source/xpdf/XRef.cc +896 -0
  428. data/pdf2json-0.52-source/xpdf/XRef.h +133 -0
  429. data/pdf2json-0.52-source/xpdf/XRef.o +0 -0
  430. data/pdf2json-0.52-source/xpdf/XpdfPluginAPI.cc +262 -0
  431. data/pdf2json-0.52-source/xpdf/XpdfPluginAPI.h +341 -0
  432. data/pdf2json-0.52-source/xpdf/XpdfPluginAPI.o +0 -0
  433. data/pdf2json-0.52-source/xpdf/about-text.h +48 -0
  434. data/pdf2json-0.52-source/xpdf/about.xbm +6 -0
  435. data/pdf2json-0.52-source/xpdf/backArrow.xbm +6 -0
  436. data/pdf2json-0.52-source/xpdf/backArrowDis.xbm +6 -0
  437. data/pdf2json-0.52-source/xpdf/config.h +112 -0
  438. data/pdf2json-0.52-source/xpdf/dblLeftArrow.xbm +6 -0
  439. data/pdf2json-0.52-source/xpdf/dblLeftArrowDis.xbm +6 -0
  440. data/pdf2json-0.52-source/xpdf/dblRightArrow.xbm +6 -0
  441. data/pdf2json-0.52-source/xpdf/dblRightArrowDis.xbm +6 -0
  442. data/pdf2json-0.52-source/xpdf/find.xbm +6 -0
  443. data/pdf2json-0.52-source/xpdf/findDis.xbm +6 -0
  444. data/pdf2json-0.52-source/xpdf/forwardArrow.xbm +6 -0
  445. data/pdf2json-0.52-source/xpdf/forwardArrowDis.xbm +6 -0
  446. data/pdf2json-0.52-source/xpdf/leftArrow.xbm +5 -0
  447. data/pdf2json-0.52-source/xpdf/leftArrowDis.xbm +5 -0
  448. data/pdf2json-0.52-source/xpdf/libXpdf.a +0 -0
  449. data/pdf2json-0.52-source/xpdf/pdffonts +0 -0
  450. data/pdf2json-0.52-source/xpdf/pdffonts.cc +298 -0
  451. data/pdf2json-0.52-source/xpdf/pdffonts.o +0 -0
  452. data/pdf2json-0.52-source/xpdf/pdfimages +0 -0
  453. data/pdf2json-0.52-source/xpdf/pdfimages.cc +155 -0
  454. data/pdf2json-0.52-source/xpdf/pdfimages.o +0 -0
  455. data/pdf2json-0.52-source/xpdf/pdfinfo +0 -0
  456. data/pdf2json-0.52-source/xpdf/pdfinfo.cc +387 -0
  457. data/pdf2json-0.52-source/xpdf/pdfinfo.o +0 -0
  458. data/pdf2json-0.52-source/xpdf/pdftoppm.cc +203 -0
  459. data/pdf2json-0.52-source/xpdf/pdftops +0 -0
  460. data/pdf2json-0.52-source/xpdf/pdftops.cc +344 -0
  461. data/pdf2json-0.52-source/xpdf/pdftops.o +0 -0
  462. data/pdf2json-0.52-source/xpdf/pdftotext +0 -0
  463. data/pdf2json-0.52-source/xpdf/pdftotext.cc +333 -0
  464. data/pdf2json-0.52-source/xpdf/pdftotext.o +0 -0
  465. data/pdf2json-0.52-source/xpdf/print.xbm +6 -0
  466. data/pdf2json-0.52-source/xpdf/printDis.xbm +6 -0
  467. data/pdf2json-0.52-source/xpdf/rightArrow.xbm +5 -0
  468. data/pdf2json-0.52-source/xpdf/rightArrowDis.xbm +5 -0
  469. data/pdf2json-0.52-source/xpdf/vms_make.com +129 -0
  470. data/pdf2json-0.52-source/xpdf/xpdf.cc +344 -0
  471. data/pdf2json-0.52-source/xpdf/xpdfIcon.xpm +62 -0
  472. data/pdf2json.gemspec +29 -0
  473. metadata +518 -0
File without changes
Binary file
@@ -0,0 +1,101 @@
1
+ #ifndef _VECTOR_H
2
+ #define _VECTOR_H
3
+ #include "gtypes.h"
4
+
5
+
6
+ template<class T>
7
+ class GVector{
8
+ private:
9
+
10
+ int _size;
11
+ T* last;
12
+ T* storage;
13
+
14
+ void resize(){
15
+ if (_size==0) _size=2;else _size=2*_size;
16
+ T *tmp=new T[_size];
17
+ if (storage){
18
+ last=copy(storage,last,tmp);
19
+ delete [] storage;
20
+ }
21
+ else last=tmp;
22
+ storage=tmp;
23
+ }
24
+
25
+ T* copy(T* src1,T* scr2,T* dest){
26
+ T* tmp=src1;
27
+ T* d=dest;
28
+ while(tmp!=scr2){
29
+ *d=*tmp;
30
+ d++;tmp++;
31
+ }
32
+ return d;
33
+ }
34
+
35
+ public:
36
+ typedef T* iterator;
37
+
38
+ GVector(){
39
+ _size=0;
40
+ last=0;
41
+ storage=0;
42
+ }
43
+
44
+
45
+
46
+ virtual ~GVector(){
47
+ delete[] storage ;
48
+ }
49
+
50
+ void reset(){
51
+ last=storage;
52
+ }
53
+
54
+ int size(){
55
+ return (last-storage);
56
+ }
57
+ void push_back(const T& elem){
58
+ if (!storage||(size() >=_size)) resize();
59
+ *last=elem;
60
+ last++;
61
+
62
+
63
+ }
64
+
65
+
66
+ T pop_back() {
67
+ if (last!=storage) last--;
68
+
69
+ return *last;
70
+ }
71
+
72
+
73
+ T operator[](unsigned int i){
74
+ return *(storage+i);
75
+ }
76
+
77
+
78
+ GBool isEmpty() const{
79
+ return !_size || (last==storage) ;
80
+ }
81
+
82
+
83
+
84
+ iterator begin() const{
85
+ return storage;
86
+ }
87
+
88
+ iterator end() const {
89
+ return last;
90
+ }
91
+ };
92
+ #endif
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
@@ -0,0 +1,1243 @@
1
+ //========================================================================
2
+ //
3
+ // ImgOutputDev.cc
4
+ //
5
+ // Copyright 2011 Devaldi Ltd
6
+ //
7
+ // Copyright 1997-2002 Glyph & Cog, LLC
8
+ //
9
+ // Changed 1999-2000 by G.Ovtcharov
10
+ //
11
+ // Changed 2002 by Mikhail Kruk
12
+ //
13
+ //========================================================================
14
+
15
+ #ifdef __GNUC__
16
+ #pragma implementation
17
+ #endif
18
+
19
+ #include <stdio.h>
20
+ #include <stdlib.h>
21
+ #include <stdarg.h>
22
+ #include <stddef.h>
23
+ #include <ctype.h>
24
+ #include <math.h>
25
+ #include "GString.h"
26
+ #include "GList.h"
27
+ #include "UnicodeMap.h"
28
+ #include "gmem.h"
29
+ #include "config.h"
30
+ #include "Error.h"
31
+ #include "GfxState.h"
32
+ #include "GlobalParams.h"
33
+ #include "ImgOutputDev.h"
34
+ #include "XmlFonts.h"
35
+
36
+
37
+ int HtmlPage::pgNum=0;
38
+ int ImgOutputDev::imgNum=1;
39
+
40
+ extern double scale;
41
+ extern GBool complexMode;
42
+ extern GBool ignore;
43
+ extern GBool printCommands;
44
+ extern GBool printHtml;
45
+ extern GBool noframes;
46
+ extern GBool stout;
47
+ extern GBool xml;
48
+ extern GBool showHidden;
49
+ extern GBool noMerge;
50
+
51
+ static GString* basename(GString* str){
52
+
53
+ char *p=str->getCString();
54
+ int len=str->getLength();
55
+ for (int i=len-1;i>=0;i--)
56
+ if (*(p+i)==SLASH)
57
+ return new GString((p+i+1),len-i-1);
58
+ return new GString(str);
59
+ }
60
+
61
+ static GString* Dirname(GString* str){
62
+
63
+ char *p=str->getCString();
64
+ int len=str->getLength();
65
+ for (int i=len-1;i>=0;i--)
66
+ if (*(p+i)==SLASH)
67
+ return new GString(p,i+1);
68
+ return new GString();
69
+ }
70
+
71
+ //------------------------------------------------------------------------
72
+ // HtmlString
73
+ //------------------------------------------------------------------------
74
+
75
+ HtmlString::HtmlString(GfxState *state, double fontSize, double _charspace, XmlFontAccu* fonts) {
76
+ GfxFont *font;
77
+ double x, y;
78
+
79
+ state->transform(state->getCurX(), state->getCurY(), &x, &y);
80
+ if ((font = state->getFont())) {
81
+ yMin = y - font->getAscent() * fontSize;
82
+ yMax = y - font->getDescent() * fontSize;
83
+ GfxRGB rgb;
84
+ state->getFillRGB(&rgb);
85
+ GString *name = state->getFont()->getName();
86
+ if (!name) name = XmlFont::getDefaultFont(); //new GString("default");
87
+ // XmlFont hfont=XmlFont(name, static_cast<int>(fontSize-1),_charspace, rgb);
88
+ XmlFont hfont=XmlFont(name, static_cast<int>(fontSize-1),0.0, rgb);
89
+ fontpos = fonts->AddFont(hfont);
90
+ } else {
91
+ // this means that the PDF file draws text without a current font,
92
+ // which should never happen
93
+ yMin = y - 0.95 * fontSize;
94
+ yMax = y + 0.35 * fontSize;
95
+ fontpos=0;
96
+ }
97
+ if (yMin == yMax) {
98
+ // this is a sanity check for a case that shouldn't happen -- but
99
+ // if it does happen, we want to avoid dividing by zero later
100
+ yMin = y;
101
+ yMax = y + 1;
102
+ }
103
+ col = 0;
104
+ text = NULL;
105
+ xRight = NULL;
106
+ link = NULL;
107
+ len = size = 0;
108
+ yxNext = NULL;
109
+ xyNext = NULL;
110
+ strSize = 0;
111
+ htext=new GString();
112
+ htext2=new GString();
113
+ dir = textDirUnknown;
114
+ }
115
+
116
+
117
+ HtmlString::~HtmlString() {
118
+ delete text;
119
+ delete htext;
120
+ delete htext2;
121
+ // delete strSize;
122
+ gfree(xRight);
123
+ }
124
+
125
+ void HtmlString::addChar(GfxState *state, double x, double y,
126
+ double dx, double dy, Unicode u) {
127
+ if (dir == textDirUnknown) {
128
+ dir = UnicodeMap::getDirection(u);
129
+ }
130
+
131
+ if (len == size) {
132
+ size += 16;
133
+ text = (Unicode *)grealloc(text, size * sizeof(Unicode));
134
+ xRight = (double *)grealloc(xRight, size * sizeof(double));
135
+ }
136
+ text[len] = u;
137
+ if (len == 0) {
138
+ xMin = x;
139
+ }
140
+ xMax = xRight[len] = x + dx;
141
+ //xMax = xRight[len] = x;
142
+ ++strSize;
143
+ //printf("added char: %f %f xright = %f\n", x, dx, x+dx);
144
+ ++len;
145
+ }
146
+
147
+ void HtmlString::endString()
148
+ {
149
+ if( dir == textDirRightLeft && len > 1 )
150
+ {
151
+ //printf("will reverse!\n");
152
+ for (int i = 0; i < len / 2; i++)
153
+ {
154
+ Unicode ch = text[i];
155
+ text[i] = text[len - i - 1];
156
+ text[len - i - 1] = ch;
157
+ }
158
+ }
159
+ }
160
+
161
+ //------------------------------------------------------------------------
162
+ // HtmlPage
163
+ //------------------------------------------------------------------------
164
+
165
+ HtmlPage::HtmlPage(GBool rawOrder, GBool textAsJSON, GBool compressData, char *imgExtVal) {
166
+ this->rawOrder = rawOrder;
167
+ this->textAsJSON = textAsJSON;
168
+ this->compressData = compressData;
169
+ curStr = NULL;
170
+ yxStrings = NULL;
171
+ xyStrings = NULL;
172
+ yxCur1 = yxCur2 = NULL;
173
+ fonts=new XmlFontAccu();
174
+ links=new XmlLinks();
175
+ pageWidth=0;
176
+ pageHeight=0;
177
+ X1=0;
178
+ X2=0;
179
+ Y1=0;
180
+ Y2=0;
181
+ fontsPageMarker = 0;
182
+ DocName=NULL;
183
+ firstPage = -1;
184
+ imgExt = new GString(imgExtVal);
185
+ }
186
+
187
+ HtmlPage::~HtmlPage() {
188
+ clear();
189
+ if (DocName) delete DocName;
190
+ if (fonts) delete fonts;
191
+ if (links) delete links;
192
+ if (imgExt) delete imgExt;
193
+ }
194
+
195
+ void HtmlPage::updateFont(GfxState *state) {
196
+ GfxFont *font;
197
+ double *fm;
198
+ char *name;
199
+ int code;
200
+ double w;
201
+
202
+ // adjust the font size
203
+ fontSize = state->getTransformedFontSize();
204
+ if ((font = state->getFont()) && font->getType() == fontType3) {
205
+ // This is a hack which makes it possible to deal with some Type 3
206
+ // fonts. The problem is that it's impossible to know what the
207
+ // base coordinate system used in the font is without actually
208
+ // rendering the font. This code tries to guess by looking at the
209
+ // width of the character 'm' (which breaks if the font is a
210
+ // subset that doesn't contain 'm').
211
+ for (code = 0; code < 256; ++code) {
212
+ if ((name = ((Gfx8BitFont *)font)->getCharName(code)) &&
213
+ name[0] == 'm' && name[1] == '\0') {
214
+ break;
215
+ }
216
+ }
217
+ if (code < 256) {
218
+ w = ((Gfx8BitFont *)font)->getWidth(code);
219
+ if (w != 0) {
220
+ // 600 is a generic average 'm' width -- yes, this is a hack
221
+ fontSize *= w / 0.6;
222
+ }
223
+ }
224
+ fm = font->getFontMatrix();
225
+ if (fm[0] != 0) {
226
+ fontSize *= fabs(fm[3] / fm[0]);
227
+ }
228
+ }
229
+ }
230
+
231
+ void HtmlPage::beginString(GfxState *state, GString *s) {
232
+ curStr = new HtmlString(state, fontSize,charspace, fonts);
233
+ }
234
+
235
+
236
+ void HtmlPage::conv(){
237
+ HtmlString *tmp;
238
+
239
+ int linkIndex = 0;
240
+ XmlFont* h;
241
+
242
+ for(tmp=yxStrings;tmp;tmp=tmp->yxNext){
243
+ int pos=tmp->fontpos;
244
+ // printf("%d\n",pos);
245
+ h=fonts->Get(pos);
246
+
247
+ if (tmp->htext) delete tmp->htext;
248
+ tmp->htext=XmlFont::simple(h,tmp->text,tmp->len);
249
+ tmp->htext2=XmlFont::simple(h,tmp->text,tmp->len);
250
+
251
+ if (links->inLink(tmp->xMin,tmp->yMin,tmp->xMax,tmp->yMax, linkIndex)){
252
+ tmp->link = links->getLink(linkIndex);
253
+ /*GString *t=tmp->htext;
254
+ tmp->htext=links->getLink(k)->Link(tmp->htext);
255
+ delete t;*/
256
+ }
257
+ }
258
+
259
+ }
260
+
261
+
262
+ void HtmlPage::addChar(GfxState *state, double x, double y,
263
+ double dx, double dy,
264
+ double ox, double oy, Unicode *u, int uLen) {
265
+ double x1, y1, w1, h1, dx2, dy2;
266
+ int n, i, d;
267
+ state->transform(x, y, &x1, &y1);
268
+ n = curStr->len;
269
+ d = 0;
270
+
271
+ // check that new character is in the same direction as current string
272
+ // and is not too far away from it before adding
273
+ /* if ((UnicodeMap::getDirection(u[0]) != curStr->dir) ||
274
+ (n > 0 &&
275
+ fabs(x1 - curStr->xRight[n-1]) > 0.1 * (curStr->yMax - curStr->yMin))) {
276
+ endString();
277
+ beginString(state, NULL);
278
+ }*/
279
+ state->textTransformDelta(state->getCharSpace() * state->getHorizScaling(),
280
+ 0, &dx2, &dy2);
281
+ dx -= dx2;
282
+ dy -= dy2;
283
+ state->transformDelta(dx, dy, &w1, &h1);
284
+ if (uLen != 0) {
285
+ w1 /= uLen;
286
+ h1 /= uLen;
287
+ }
288
+ /* if (d != 3)
289
+ {
290
+ endString();
291
+ beginString(state, NULL);
292
+ }
293
+ */
294
+
295
+
296
+ for (i = 0; i < uLen; ++i)
297
+ {
298
+ if (u[i] == ' ')
299
+ {
300
+ curStr->addChar(state, x1 + i*w1, y1 + i*h1, w1, h1, u[i]);
301
+ endString();
302
+ beginString(state, NULL);
303
+ }
304
+ else {
305
+ curStr->addChar(state, x1 + i*w1, y1 + i*h1, w1, h1, u[i]); /* xyString */
306
+ }
307
+ }
308
+
309
+ /*
310
+ for (i = 0; i < uLen; ++i) {
311
+ curStr->addChar(state, x1 + i*w1, y1 + i*h1, w1, h1, u[i]);
312
+ }
313
+ */
314
+ }
315
+
316
+ void HtmlPage::endString() {
317
+ HtmlString *p1, *p2;
318
+ double h, y1, y2;
319
+
320
+ // throw away zero-length strings -- they don't have valid xMin/xMax
321
+ // values, and they're useless anyway
322
+
323
+ if (curStr->len == 0) {
324
+ delete curStr;
325
+ curStr = NULL;
326
+ return;
327
+ }
328
+
329
+ curStr->endString();
330
+
331
+ #if 0 //~tmp
332
+ if (curStr->yMax - curStr->yMin > 20) {
333
+ delete curStr;
334
+ curStr = NULL;
335
+ return;
336
+ }
337
+ #endif
338
+
339
+ // insert string in y-major list
340
+ h = curStr->yMax - curStr->yMin;
341
+ y1 = curStr->yMin + 0.5 * h;
342
+ y2 = curStr->yMin + 0.8 * h;
343
+
344
+ if (rawOrder) {
345
+ p1 = yxCur1;
346
+ p2 = NULL;
347
+ } else if ((!yxCur1 ||
348
+ (y1 >= yxCur1->yMin &&
349
+ (y2 >= yxCur1->yMax || curStr->xMax >= yxCur1->xMin))) &&
350
+ (!yxCur2 ||
351
+ (y1 < yxCur2->yMin ||
352
+ (y2 < yxCur2->yMax && curStr->xMax < yxCur2->xMin)))) { /* add space */
353
+ p1 = yxCur1;
354
+ p2 = yxCur2;
355
+ } else {
356
+ for (p1 = NULL, p2 = yxStrings; p2; p1 = p2, p2 = p2->yxNext) {
357
+ if (y1 < p2->yMin || (y2 < p2->yMax && curStr->xMax < p2->xMin))
358
+ break;
359
+ }
360
+ yxCur2 = p2;
361
+ }
362
+
363
+ yxCur1 = curStr;
364
+
365
+ if (p1)
366
+ p1->yxNext = curStr;
367
+ else
368
+ yxStrings = curStr;
369
+
370
+ curStr->yxNext = p2;
371
+ curStr = NULL;
372
+ }
373
+
374
+ void HtmlPage::coalesce() {
375
+ HtmlString *str1, *str2;
376
+ XmlFont *hfont1, *hfont2;
377
+ double space, horSpace, vertSpace, vertOverlap;
378
+ GBool addSpace, addLineBreak;
379
+ int n, i;
380
+ double curX, curY, lastX, lastY;
381
+ int sSize = 0;
382
+ double diff = 0.0;
383
+ double pxSize = 0.0;
384
+ double strSize = 0.0;
385
+ double cspace = 0.0;
386
+
387
+ #if 0 //~ for debugging
388
+ for (str1 = yxStrings; str1; str1 = str1->yxNext) {
389
+ printf("x=%f..%f y=%f..%f size=%2d '",
390
+ str1->xMin, str1->xMax, str1->yMin, str1->yMax,
391
+ (int)(str1->yMax - str1->yMin));
392
+ for (i = 0; i < str1->len; ++i) {
393
+ fputc(str1->text[i] & 0xff, stdout);
394
+ }
395
+ printf("'\n");
396
+ }
397
+ printf("\n------------------------------------------------------------\n\n");
398
+ #endif
399
+
400
+
401
+ str1 = yxStrings;
402
+ if( !str1 ) return;
403
+
404
+ hfont1 = getFont(str1);
405
+
406
+ str1->htext2->append(str1->htext);
407
+ if( str1->getLink() != NULL ) {
408
+ GString *ls = str1->getLink()->getLinkStart();
409
+ str1->htext->insert(0, ls);
410
+ delete ls;
411
+ }
412
+
413
+ curX = str1->xMin; curY = str1->yMin;
414
+ lastX = str1->xMin; lastY = str1->yMin;
415
+
416
+ while (str1 && (str2 = str1->yxNext)) {
417
+ hfont2 = getFont(str2);
418
+ space = str1->yMax - str1->yMin;
419
+ horSpace = str2->xMin - str1->xMax;
420
+ addLineBreak = !noMerge && (fabs(str1->xMin - str2->xMin) < 0.4);
421
+ vertSpace = str2->yMin - str1->yMax;
422
+
423
+ //printf("coalesce %d %d %f? ", str1->dir, str2->dir, d);
424
+
425
+ if (str2->yMin >= str1->yMin && str2->yMin <= str1->yMax)
426
+ {
427
+ vertOverlap = str1->yMax - str2->yMin;
428
+ } else
429
+ if (str2->yMax >= str1->yMin && str2->yMax <= str1->yMax)
430
+ {
431
+ vertOverlap = str2->yMax - str1->yMin;
432
+ } else
433
+ {
434
+ vertOverlap = 0;
435
+ }
436
+
437
+ // str1->dir == str2->dir, in complex mode fonts must be the same, in other modes fonts do not metter
438
+ if ((((
439
+ (rawOrder && vertOverlap > 0.5 * space)
440
+ ||
441
+ (!rawOrder && str2->yMin < str1->yMax)
442
+ ) &&
443
+ (horSpace > -0.5 * space && horSpace < space)
444
+ ) ||
445
+ (vertSpace >= 0 && vertSpace < 0.5 * space && addLineBreak)
446
+ )
447
+ &&
448
+ str1->dir == str2->dir // text direction the same
449
+ &&
450
+ !(str2->len == 1 && str2->htext->getCString()[0] == ' ')
451
+ &&
452
+ !(str1->htext->getCString()[str1->len-1] == ' ')
453
+ )
454
+ {
455
+ diff = str2->xMax - str1->xMin;
456
+
457
+ n = str1->len + str2->len;
458
+
459
+ str1->size = (n + 15) & ~15;
460
+ str1->text = (Unicode *)grealloc(str1->text,
461
+ str1->size * sizeof(Unicode));
462
+ str1->xRight = (double *)grealloc(str1->xRight,
463
+ str1->size * sizeof(double));
464
+
465
+ str1->htext2->append(str2->htext2);
466
+
467
+ XmlLink *hlink1 = str1->getLink();
468
+ XmlLink *hlink2 = str2->getLink();
469
+
470
+ for (i = 0; i < str2->len; ++i) {
471
+ str1->text[str1->len] = str2->text[i];
472
+ str1->xRight[str1->len] = str2->xRight[i];
473
+ ++str1->len;
474
+ }
475
+
476
+ if( !hlink1 || !hlink2 || !hlink1->isEqualDest(*hlink2) ) {
477
+
478
+ if(hlink1 != NULL ){
479
+ //str1->htext->append("\"]");
480
+ }
481
+ if(hlink2 != NULL ) {
482
+ GString *ls = hlink2->getLinkStart();
483
+ str1->htext->append(ls);
484
+ delete ls;
485
+ }
486
+ }
487
+
488
+ str1->htext->append(str2->htext);
489
+ sSize = str1->htext2->getLength();
490
+ pxSize = xoutRoundLower(hfont1->getSize()/scale);
491
+ strSize = (pxSize*(sSize-2));
492
+ cspace = (diff / strSize);//(strSize-pxSize));
493
+ // we check if the fonts are the same and create a new font to ajust the text
494
+ // double diff = str2->xMin - str1->xMin;
495
+ // printf("%s\n",str1->htext2->getCString());
496
+ // str1 now contains href for link of str2 (if it is defined)
497
+ str1->link = str2->link;
498
+
499
+ //XmlFont *newfnt = new XmlFont(*hfont1);
500
+ //newfnt->setCharSpace(cspace);
501
+ //newfnt->setLineSize(curLineSize);
502
+ //str1->fontpos = fonts->AddFont(*newfnt);
503
+ //delete newfnt;
504
+ hfont1 = getFont(str1);
505
+ // we have to reget hfont2 because it's location could have
506
+ // changed on resize GStri;ng *iStr=GString::fromInt(i);
507
+ hfont2 = getFont(str2);
508
+
509
+ hfont1 = hfont2;
510
+
511
+ if (str2->xMax > str1->xMax) {
512
+ str1->xMax = str2->xMax;
513
+ }
514
+
515
+ if (str2->yMax > str1->yMax) {
516
+ str1->yMax = str2->yMax;
517
+ }
518
+
519
+ str1->yxNext = str2->yxNext;
520
+
521
+ delete str2;
522
+ } else {
523
+
524
+ // printf("startX = %f, endX = %f, diff = %f, fontsize = %d, pxSize = %f, stringSize = %d, cspace = %f, strSize = %f\n",str1->xMin,str1->xMax,diff,hfont1->getSize(),pxSize,sSize,cspace,strSize);
525
+
526
+ // keep strings separate
527
+ // printf("no\n");
528
+ // if( hfont1->isBold() )
529
+ // if(str1->getLink() != NULL )
530
+ // str1->htext->append("\"]");
531
+
532
+ str1->xMin = curX; str1->yMin = curY;
533
+ str1 = str2;
534
+ curX = str1->xMin; curY = str1->yMin;
535
+ hfont1 = hfont2;
536
+
537
+ if( str1->getLink() != NULL ) {
538
+ GString *ls = str1->getLink()->getLinkStart();
539
+ str1->htext->insert(0, ls);
540
+ delete ls;
541
+ }
542
+ }
543
+ }
544
+ str1->xMin = curX; str1->yMin = curY;
545
+
546
+ // if(str1->getLink() != NULL )
547
+ // str1->htext->append("]");
548
+
549
+ #if 0 //~ for debugging
550
+ for (str1 = yxStrings; str1; str1 = str1->yxNext) {
551
+ printf("x=%3d..%3d y=%3d..%3d size=%2d ",
552
+ (int)str1->xMin, (int)str1->xMax, (int)str1->yMin, (int)str1->yMax,
553
+ (int)(str1->yMax - str1->yMin));
554
+ printf("'%s'\n", str1->htext->getCString());
555
+ }
556
+ printf("\n-end--------------------------------------------------------\n\n");
557
+ #endif
558
+
559
+ }
560
+
561
+
562
+ void HtmlPage::dumpAsXML(FILE* f,int page, GBool passedFirstPage){
563
+ if(textAsJSON){
564
+ if(passedFirstPage){
565
+ fprintf(f, ",");
566
+ }
567
+ fprintf(f, "{\"number\":%d,\"height\":%d,\"width\":%d,", page,pageHeight,pageWidth);
568
+ }else{
569
+ fprintf(f, "<page number=\"%d\"", page);
570
+ fprintf(f," height=\"%d\" width=\"%d\">", pageHeight,pageWidth);
571
+ }
572
+
573
+ GBool passedFirst = false;
574
+
575
+ /* if(textAsJSON){fprintf(f,"\"fonts\":[");}
576
+ for(int i=fontsPageMarker;i < fonts->size();i++) {
577
+ GString *fontCSStyle = fonts->CSStyle(i,textAsJSON);
578
+ if(textAsJSON && passedFirst) {fprintf(f,",");}
579
+ fprintf(f,"%s",fontCSStyle->getCString());
580
+ passedFirst = true;
581
+ delete fontCSStyle;
582
+ }
583
+ if(textAsJSON){fprintf(f,"]");}
584
+ */
585
+ GString *str, *str1;
586
+
587
+ passedFirst = false;
588
+ if(textAsJSON){
589
+ //fprintf(f,",\"text\":[");
590
+ fprintf(f,"\"text\":[");
591
+ }
592
+
593
+ for(HtmlString *tmp=yxStrings;tmp;tmp=tmp->yxNext){
594
+ if (tmp->htext){
595
+ str=new GString(tmp->htext);
596
+
597
+ if(!compressData){
598
+ if(textAsJSON){
599
+ if(passedFirst){
600
+ fprintf(f,",");
601
+ }
602
+ fprintf(f,"{\"top\":%d,\"left\":%d,",xoutRound(tmp->yMin),xoutRound(tmp->xMin));
603
+ fprintf(f,"\"width\":%d,\"height\":%d,",xoutRound(tmp->xMax-tmp->xMin),xoutRound(tmp->yMax-tmp->yMin));
604
+ fprintf(f,"\"font\":%d,\"data\":\"", tmp->fontpos);
605
+ if (tmp->fontpos!=-1){
606
+ str1=fonts->getCSStyle(tmp->fontpos, str);
607
+ }
608
+ fputs(str1->getCString(),f);
609
+ fprintf(f,"\"}");
610
+ //fprintf(f,"\"}");
611
+ passedFirst = true;
612
+ }else{
613
+ fprintf(f,"<text top=\"%d\" left=\"%d\" ",xoutRound(tmp->yMin),xoutRound(tmp->xMin));
614
+ fprintf(f,"width=\"%d\" height=\"%d\" ",xoutRound(tmp->xMax-tmp->xMin),xoutRound(tmp->yMax-tmp->yMin));
615
+ fprintf(f,"font=\"%d\">", tmp->fontpos);
616
+ if (tmp->fontpos!=-1){
617
+ str1=fonts->getCSStyle(tmp->fontpos, str);
618
+ }
619
+ fputs(str1->getCString(),f);
620
+ delete str;
621
+ delete str1;
622
+ fputs("</text>\n",f);
623
+ }
624
+ }else{
625
+ if(textAsJSON){
626
+ if(passedFirst){
627
+ fprintf(f,",");
628
+ }
629
+
630
+ //fprintf(f,"{\"t\":%d,\"l\":%d,",xoutRound(tmp->yMin),xoutRound(tmp->xMin));
631
+ //fprintf(f,"\"w\":%d,\"h\":%d,",xoutRound(tmp->xMax-tmp->xMin),xoutRound(tmp->yMax-tmp->yMin));
632
+ //fprintf(f,"\"f\":%d,\"d\":\"", tmp->fontpos);
633
+ fprintf(f,"[%d,%d,",xoutRound(tmp->yMin),xoutRound(tmp->xMin));
634
+ fprintf(f,"%d,%d,",xoutRound(tmp->xMax-tmp->xMin),xoutRound(tmp->yMax-tmp->yMin));
635
+ fprintf(f,"%d,\"", tmp->fontpos);
636
+
637
+ if (tmp->fontpos!=-1){
638
+ str1=fonts->getCSStyle(tmp->fontpos, str);
639
+ }
640
+ fputs(str1->getCString(),f);
641
+ fprintf(f,"\"]");
642
+
643
+ passedFirst = true;
644
+ }else{
645
+ fprintf(f,"<t t=\"%d\" l=\"%d\" ",xoutRound(tmp->yMin),xoutRound(tmp->xMin));
646
+ fprintf(f,"w=\"%d\" h=\"%d\" ",xoutRound(tmp->xMax-tmp->xMin),xoutRound(tmp->yMax-tmp->yMin));
647
+ fprintf(f,"f=\"%d\">", tmp->fontpos);
648
+ if (tmp->fontpos!=-1){
649
+ str1=fonts->getCSStyle(tmp->fontpos, str);
650
+ }
651
+ fputs(str1->getCString(),f);
652
+ delete str;
653
+ delete str1;
654
+ fputs("</t>\n",f);
655
+ }
656
+ }
657
+ }
658
+ }
659
+
660
+ if(textAsJSON){
661
+ fputs("]}",f);
662
+ }else{
663
+ fputs("</page>",f);
664
+ }
665
+ }
666
+
667
+ void HtmlPage::dump(FILE *f, int pageNum, GBool passedFirstPage)
668
+ {
669
+ if (complexMode)
670
+ {
671
+ if (xml) dumpAsXML(f, pageNum, passedFirstPage);
672
+ }
673
+ }
674
+
675
+ void HtmlPage::clear() {
676
+ HtmlString *p1, *p2;
677
+
678
+ if (curStr) {
679
+ delete curStr;
680
+ curStr = NULL;
681
+ }
682
+ for (p1 = yxStrings; p1; p1 = p2) {
683
+ p2 = p1->yxNext;
684
+ delete p1;
685
+ }
686
+ yxStrings = NULL;
687
+ xyStrings = NULL;
688
+ yxCur1 = yxCur2 = NULL;
689
+
690
+ if( !noframes )
691
+ {
692
+ delete fonts;
693
+ fonts=new XmlFontAccu();
694
+ fontsPageMarker = 0;
695
+ }
696
+ else
697
+ {
698
+ fontsPageMarker = fonts->size();
699
+ }
700
+
701
+ delete links;
702
+ links=new XmlLinks();
703
+
704
+
705
+ }
706
+
707
+ void HtmlPage::setDocName(char *fname){
708
+ DocName=new GString(fname);
709
+ }
710
+
711
+ void HtmlPage::updateCharSpace(GfxState *state)
712
+ {
713
+ charspace = state->getCharSpace();
714
+ }
715
+
716
+ //------------------------------------------------------------------------
717
+ // HtmlMetaVar
718
+ //------------------------------------------------------------------------
719
+
720
+ HtmlMetaVar::HtmlMetaVar(char *_name, char *_content)
721
+ {
722
+ name = new GString(_name);
723
+ content = new GString(_content);
724
+ }
725
+
726
+ HtmlMetaVar::~HtmlMetaVar()
727
+ {
728
+ delete name;
729
+ delete content;
730
+ }
731
+
732
+ GString* HtmlMetaVar::toString()
733
+ {
734
+ GString *result = new GString("<META name=\"");
735
+ result->append(name);
736
+ result->append("\" content=\"");
737
+ result->append(content);
738
+ result->append("\">");
739
+ return result;
740
+ }
741
+
742
+ //------------------------------------------------------------------------
743
+ // ImgOutputDev
744
+ //------------------------------------------------------------------------
745
+
746
+ static char* HtmlEncodings[][2] = {
747
+ {"Latin1", "ISO-8859-1"},
748
+ {NULL, NULL}
749
+ };
750
+
751
+
752
+ char* ImgOutputDev::mapEncodingToHtml(GString* encoding)
753
+ {
754
+ char* enc = encoding->getCString();
755
+ for(int i = 0; HtmlEncodings[i][0] != NULL; i++)
756
+ {
757
+ if( strcmp(enc, HtmlEncodings[i][0]) == 0 )
758
+ {
759
+ return HtmlEncodings[i][1];
760
+ }
761
+ }
762
+ return enc;
763
+ }
764
+
765
+ ImgOutputDev::ImgOutputDev(char *fileName, char *title,
766
+ char *author, char *keywords, char *subject, char *date,
767
+ char *extension,
768
+ GBool rawOrder, GBool textAsJSON, GBool compressData, int firstPage, GBool outline, int numPages)
769
+ {
770
+ char *htmlEncoding;
771
+ this->numPages = numPages;
772
+ fContentsFrame = NULL;
773
+ docTitle = new GString(title);
774
+ pages = NULL;
775
+ dumpJPEG=gTrue;
776
+ //write = gTrue;
777
+ this->rawOrder = rawOrder;
778
+ this->textAsJSON = textAsJSON;
779
+ this->compressData = compressData;
780
+ this->doOutline = outline;
781
+ ok = gFalse;
782
+ passedFirstPage = gFalse;
783
+ imgNum=1;
784
+ //this->firstPage = firstPage;
785
+ //pageNum=firstPage;
786
+ // open file
787
+ needClose = gFalse;
788
+ pages = new HtmlPage(rawOrder, textAsJSON, compressData, extension);
789
+
790
+ glMetaVars = new GList();
791
+ glMetaVars->append(new HtmlMetaVar("generator", "pdf2json 0.52"));
792
+ if( author ) glMetaVars->append(new HtmlMetaVar("author", author));
793
+ if( keywords ) glMetaVars->append(new HtmlMetaVar("keywords", keywords));
794
+ if( date ) glMetaVars->append(new HtmlMetaVar("date", date));
795
+ if( subject ) glMetaVars->append(new HtmlMetaVar("subject", subject));
796
+
797
+ maxPageWidth = 0;
798
+ maxPageHeight = 0;
799
+
800
+ pages->setDocName(fileName);
801
+ Docname=new GString (fileName);
802
+
803
+ if (noframes) {
804
+ if (stout) page=stdout;
805
+ else {
806
+ GString* right=new GString(fileName);
807
+ //if (xml && !textAsJSON) right->append(".xml");
808
+ //else if (textAsJSON) right->append(".js");
809
+ if (!(page=fopen(right->getCString(),"w"))){
810
+ delete right;
811
+ error(-1, "Couldn't open html file '%s'", right->getCString());
812
+ return;
813
+ }
814
+ delete right;
815
+ }
816
+
817
+ htmlEncoding = mapEncodingToHtml(globalParams->getTextEncodingName());
818
+ if (xml && !textAsJSON)
819
+ {
820
+ fprintf(page, "<?xml version=\"1.0\" encoding=\"%s\"?>\n", htmlEncoding);
821
+ fputs("<!DOCTYPE pdf2xml SYSTEM \"pdf2xml.dtd\">\n\n", page);
822
+ fputs("<pdf2xml>\n",page);
823
+ }else if(textAsJSON){
824
+ fputs("[",page);
825
+ }
826
+ }
827
+ ok = gTrue;
828
+ }
829
+
830
+ ImgOutputDev::~ImgOutputDev() {
831
+ XmlFont::clear();
832
+
833
+ delete Docname;
834
+ delete docTitle;
835
+
836
+ deleteGList(glMetaVars, HtmlMetaVar);
837
+
838
+ if (xml && !textAsJSON) {
839
+ fputs("</pdf2xml>\n",page);
840
+ fclose(page);
841
+ } else if(textAsJSON){
842
+ fputs("]",page);
843
+ fclose(page);
844
+ }
845
+ if (pages)
846
+ delete pages;
847
+ }
848
+
849
+
850
+
851
+ void ImgOutputDev::startPage(int pageNum, GfxState *state,double crop_x1, double crop_y1, double crop_x2, double crop_y2) {
852
+ double x1,y1,x2,y2;
853
+ state->transform(crop_x1,crop_y1,&x1,&y1);
854
+ state->transform(crop_x2,crop_y2,&x2,&y2);
855
+ if(x2<x1) {double x3=x1;x1=x2;x2=x3;}
856
+ if(y2<y1) {double y3=y1;y1=y2;y2=y3;}
857
+
858
+
859
+ this->pageNum = pageNum;
860
+ GString *str=basename(Docname);
861
+ pages->clear();
862
+ if(!noframes)
863
+ {
864
+ if (fContentsFrame)
865
+ {
866
+ if (complexMode)
867
+ fprintf(fContentsFrame,"<A href=\"%s-%d.html\"",str->getCString(),pageNum);
868
+ else
869
+ fprintf(fContentsFrame,"<A href=\"%ss.html#%d\"",str->getCString(),pageNum);
870
+ fprintf(fContentsFrame," target=\"contents\" >Page %d</a><br>\n",pageNum);
871
+ }
872
+ }
873
+
874
+ // pages->pageWidth=static_cast<int>(state->getPageWidth());
875
+ //pages->pageHeight=static_cast<int>(state->getPageHeight());
876
+ pages->pageWidth = (int)(x2-x1);
877
+ pages->pageHeight = (int)(y2-y1);
878
+
879
+
880
+ delete str;
881
+ }
882
+
883
+
884
+ void ImgOutputDev::endPage() {
885
+ pages->conv();
886
+ pages->coalesce();
887
+ pages->dump(page, pageNum, passedFirstPage);
888
+ passedFirstPage = gTrue;
889
+ // I don't yet know what to do in the case when there are pages of different
890
+ // sizes and we want complex output: running ghostscript many times
891
+ // seems very inefficient. So for now I'll just use last page's size
892
+ maxPageWidth = pages->pageWidth;
893
+ maxPageHeight = pages->pageHeight;
894
+
895
+ if(!stout && !globalParams->getErrQuiet()) printf("Page-%d\n",(pageNum));
896
+ }
897
+
898
+ void ImgOutputDev::updateFont(GfxState *state) {
899
+ pages->updateFont(state);
900
+ }
901
+
902
+ void ImgOutputDev::beginString(GfxState *state, GString *s) {
903
+ pages->beginString(state, s);
904
+ }
905
+
906
+ void ImgOutputDev::endString(GfxState *state) {
907
+ pages->endString();
908
+ }
909
+
910
+ void ImgOutputDev::drawChar(GfxState *state, double x, double y,
911
+ double dx, double dy,
912
+ double originX, double originY,
913
+ CharCode code, int nBytes, Unicode *u, int uLen)
914
+ {
915
+ if ( !showHidden && (state->getRender() & 3) == 3) {
916
+ return;
917
+ }
918
+ pages->addChar(state, x, y, dx, dy, originX, originY, u, uLen);
919
+ }
920
+
921
+ void ImgOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
922
+ int width, int height, GBool invert,
923
+ GBool inlineImg) {
924
+
925
+ int i, j;
926
+
927
+ if (ignore||complexMode) {
928
+ OutputDev::drawImageMask(state, ref, str, width, height, invert, inlineImg);
929
+ return;
930
+ }
931
+
932
+ FILE *f1;
933
+ int c;
934
+
935
+ int x0, y0; // top left corner of image
936
+ int w0, h0, w1, h1; // size of image
937
+ double xt, yt, wt, ht;
938
+ GBool rotate, xFlip, yFlip;
939
+ GBool dither;
940
+ int x, y;
941
+ int ix, iy;
942
+ int px1, px2, qx, dx;
943
+ int py1, py2, qy, dy;
944
+ Gulong pixel;
945
+ int nComps, nVals, nBits;
946
+ double r1, g1, b1;
947
+
948
+ // get image position and size
949
+ state->transform(0, 0, &xt, &yt);
950
+ state->transformDelta(1, 1, &wt, &ht);
951
+ if (wt > 0) {
952
+ x0 = xoutRound(xt);
953
+ w0 = xoutRound(wt);
954
+ } else {
955
+ x0 = xoutRound(xt + wt);
956
+ w0 = xoutRound(-wt);
957
+ }
958
+ if (ht > 0) {
959
+ y0 = xoutRound(yt);
960
+ h0 = xoutRound(ht);
961
+ } else {
962
+ y0 = xoutRound(yt + ht);
963
+ h0 = xoutRound(-ht);
964
+ }
965
+ state->transformDelta(1, 0, &xt, &yt);
966
+ rotate = fabs(xt) < fabs(yt);
967
+ if (rotate) {
968
+ w1 = h0;
969
+ h1 = w0;
970
+ xFlip = ht < 0;
971
+ yFlip = wt > 0;
972
+ } else {
973
+ w1 = w0;
974
+ h1 = h0;
975
+ xFlip = wt < 0;
976
+ yFlip = ht > 0;
977
+ }
978
+
979
+ // dump JPEG file
980
+ if (dumpJPEG && str->getKind() == strDCT) {
981
+ GString *fName=new GString(Docname);
982
+ fName->append("-");
983
+ GString *pgNum=GString::fromInt(pageNum);
984
+ GString *imgnum=GString::fromInt(imgNum);
985
+ // open the image file
986
+ fName->append(pgNum)->append("_")->append(imgnum)->append(".jpg");
987
+ ++imgNum;
988
+ if (!(f1 = fopen(fName->getCString(), "wb"))) {
989
+ error(-1, "Couldn't open image file '%s'", fName->getCString());
990
+ return;
991
+ }
992
+
993
+ // initialize stream
994
+ str = ((DCTStream *)str)->getRawStream();
995
+ str->reset();
996
+
997
+ // copy the stream
998
+ while ((c = str->getChar()) != EOF)
999
+ fputc(c, f1);
1000
+
1001
+ fclose(f1);
1002
+
1003
+ if (pgNum) delete pgNum;
1004
+ if (imgnum) delete imgnum;
1005
+ if (fName) delete fName;
1006
+ }
1007
+ else {
1008
+ OutputDev::drawImageMask(state, ref, str, width, height, invert, inlineImg);
1009
+ }
1010
+ }
1011
+
1012
+ void ImgOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
1013
+ int width, int height, GfxImageColorMap *colorMap,
1014
+ int *maskColors, GBool inlineImg) {
1015
+
1016
+ int i, j;
1017
+
1018
+ if (ignore||complexMode) {
1019
+ OutputDev::drawImage(state, ref, str, width, height, colorMap,
1020
+ maskColors, inlineImg);
1021
+ return;
1022
+ }
1023
+
1024
+ FILE *f1;
1025
+ ImageStream *imgStr;
1026
+ Guchar pixBuf[4];
1027
+ GfxColor color;
1028
+ int c;
1029
+
1030
+ int x0, y0; // top left corner of image
1031
+ int w0, h0, w1, h1; // size of image
1032
+ double xt, yt, wt, ht;
1033
+ GBool rotate, xFlip, yFlip;
1034
+ GBool dither;
1035
+ int x, y;
1036
+ int ix, iy;
1037
+ int px1, px2, qx, dx;
1038
+ int py1, py2, qy, dy;
1039
+ Gulong pixel;
1040
+ int nComps, nVals, nBits;
1041
+ double r1, g1, b1;
1042
+
1043
+ // get image position and size
1044
+ state->transform(0, 0, &xt, &yt);
1045
+ state->transformDelta(1, 1, &wt, &ht);
1046
+ if (wt > 0) {
1047
+ x0 = xoutRound(xt);
1048
+ w0 = xoutRound(wt);
1049
+ } else {
1050
+ x0 = xoutRound(xt + wt);
1051
+ w0 = xoutRound(-wt);
1052
+ }
1053
+ if (ht > 0) {
1054
+ y0 = xoutRound(yt);
1055
+ h0 = xoutRound(ht);
1056
+ } else {
1057
+ y0 = xoutRound(yt + ht);
1058
+ h0 = xoutRound(-ht);
1059
+ }
1060
+ state->transformDelta(1, 0, &xt, &yt);
1061
+ rotate = fabs(xt) < fabs(yt);
1062
+ if (rotate) {
1063
+ w1 = h0;
1064
+ h1 = w0;
1065
+ xFlip = ht < 0;
1066
+ yFlip = wt > 0;
1067
+ } else {
1068
+ w1 = w0;
1069
+ h1 = h0;
1070
+ xFlip = wt < 0;
1071
+ yFlip = ht > 0;
1072
+ }
1073
+
1074
+ /*if( !globalParams->getErrQuiet() )
1075
+ printf("image stream of kind %d\n", str->getKind());*/
1076
+ // dump JPEG file
1077
+ if (dumpJPEG && str->getKind() == strDCT) {
1078
+ GString *fName=new GString(Docname);
1079
+ fName->append("-");
1080
+ GString *pgNum= GString::fromInt(pageNum);
1081
+ GString *imgnum= GString::fromInt(imgNum);
1082
+
1083
+ // open the image file
1084
+ fName->append(pgNum)->append("_")->append(imgnum)->append(".jpg");
1085
+ ++imgNum;
1086
+
1087
+ if (!(f1 = fopen(fName->getCString(), "wb"))) {
1088
+ error(-1, "Couldn't open image file '%s'", fName->getCString());
1089
+ return;
1090
+ }
1091
+
1092
+ // initialize stream
1093
+ str = ((DCTStream *)str)->getRawStream();
1094
+ str->reset();
1095
+
1096
+ // copy the stream
1097
+ while ((c = str->getChar()) != EOF)
1098
+ fputc(c, f1);
1099
+
1100
+ fclose(f1);
1101
+
1102
+ delete fName;
1103
+ delete pgNum;
1104
+ delete imgnum;
1105
+ }
1106
+ else {
1107
+ OutputDev::drawImage(state, ref, str, width, height, colorMap,
1108
+ maskColors, inlineImg);
1109
+ }
1110
+ }
1111
+
1112
+ void ImgOutputDev::drawLink(Link* link,Catalog *cat){
1113
+ double _x1,_y1,_x2,_y2,w;
1114
+ int x1,y1,x2,y2;
1115
+
1116
+ link->getBorder(&_x1,&_y1,&_x2,&_y2,&w);
1117
+ cvtUserToDev(_x1,_y1,&x1,&y1);
1118
+
1119
+ cvtUserToDev(_x2,_y2,&x2,&y2);
1120
+
1121
+
1122
+ GString* _dest=getLinkDest(link,cat);
1123
+ XmlLink t((double) x1,(double) y2,(double) x2,(double) y1,_dest);
1124
+ pages->AddLink(t);
1125
+ delete _dest;
1126
+ }
1127
+
1128
+ GString* ImgOutputDev::getLinkDest(Link *link,Catalog* catalog){
1129
+ char *p;
1130
+ switch(link->getAction()->getKind())
1131
+ {
1132
+ case actionGoTo:
1133
+ {
1134
+ GString* file=new GString("actionGoTo:");
1135
+ int page=1;
1136
+ LinkGoTo *ha=(LinkGoTo *)link->getAction();
1137
+ LinkDest *dest=NULL;
1138
+ if (ha->getDest()==NULL)
1139
+ dest=catalog->findDest(ha->getNamedDest());
1140
+ else
1141
+ dest=ha->getDest()->copy();
1142
+ if (dest){
1143
+ if (dest->isPageRef()){
1144
+ Ref pageref=dest->getPageRef();
1145
+ page=catalog->findPage(pageref.num,pageref.gen);
1146
+ }
1147
+ else {
1148
+ page=dest->getPageNum();
1149
+ }
1150
+
1151
+ delete dest;
1152
+
1153
+ GString *str=GString::fromInt(page);
1154
+ file->append(str);
1155
+ file->append(",");
1156
+
1157
+ if (printCommands) printf(" link to page %d ",page);
1158
+ delete str;
1159
+ return file;
1160
+ }
1161
+ else
1162
+ {
1163
+ return new GString();
1164
+ }
1165
+ }
1166
+ case actionGoToR:
1167
+ {
1168
+ LinkGoToR *ha=(LinkGoToR *) link->getAction();
1169
+ LinkDest *dest=NULL;
1170
+ int page=1;
1171
+ GString *file=new GString("actionGoToR:");
1172
+
1173
+ if (ha->getDest()!=NULL) dest=ha->getDest()->copy();
1174
+
1175
+ if (dest&&file){
1176
+ if (!(dest->isPageRef())) page=dest->getPageNum();
1177
+ delete dest;
1178
+
1179
+ if (printCommands) printf(" link to page %d ",page);
1180
+ if (printHtml){
1181
+ p=file->getCString()+file->getLength()-4;
1182
+ file->append(GString::fromInt(page));
1183
+ file->append(",");
1184
+ }
1185
+ }
1186
+ if (printCommands) printf("filename %s\n",file->getCString());
1187
+ return file;
1188
+ }
1189
+ case actionURI:
1190
+ {
1191
+ LinkURI *ha=(LinkURI *) link->getAction();
1192
+ //GString* file=new GString(ha->getURI()->getCString());
1193
+ GString *file=new GString("actionURI:");
1194
+ //file->append(ha->getURI()->getCString());
1195
+ // printf("uri : %s\n",file->getCString());
1196
+ return file;
1197
+ }
1198
+ case actionLaunch:
1199
+ {
1200
+ LinkLaunch *ha=(LinkLaunch *) link->getAction();
1201
+ GString* file=new GString(ha->getFileName()->getCString());
1202
+ if (printHtml) {
1203
+ p=file->getCString()+file->getLength()-4;
1204
+ if (!strcmp(p, ".pdf") || !strcmp(p, ".PDF")){
1205
+ file->del(file->getLength()-4,4);
1206
+ file->append(".html");
1207
+ }
1208
+ if (printCommands) printf("filename %s",file->getCString());
1209
+
1210
+ return file;
1211
+ }
1212
+ }
1213
+ default:
1214
+ return new GString();
1215
+ }
1216
+ }
1217
+
1218
+ void ImgOutputDev::dumpMetaVars(FILE *file)
1219
+ {
1220
+ GString *var;
1221
+
1222
+ for(int i = 0; i < glMetaVars->getLength(); i++)
1223
+ {
1224
+ HtmlMetaVar *t = (HtmlMetaVar*)glMetaVars->get(i);
1225
+ var = t->toString();
1226
+ fprintf(file, "%s\n", var->getCString());
1227
+ delete var;
1228
+ }
1229
+ }
1230
+
1231
+ GBool ImgOutputDev::dumpDocOutline(Catalog* catalog)
1232
+ {
1233
+ FILE * output;
1234
+ GBool bClose = gFalse;
1235
+
1236
+ if (!ok || xml)
1237
+ return gFalse;
1238
+ }
1239
+
1240
+ void ImgOutputDev::updateCharSpace(GfxState *state)
1241
+ {
1242
+ pages->updateCharSpace(state);
1243
+ }