pyropdf 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. {pyropdf-0.1.0 → pyropdf-0.2.0}/Cargo.lock +4 -4
  2. {pyropdf-0.1.0 → pyropdf-0.2.0}/Cargo.toml +1 -1
  3. {pyropdf-0.1.0 → pyropdf-0.2.0}/PKG-INFO +18 -13
  4. pyropdf-0.2.0/README.md +46 -0
  5. pyropdf-0.2.0/crates/pyropdf-engine/proptest-regressions/fonts/tests.txt +7 -0
  6. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/bridge/tests.rs +1 -1
  7. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/content/tests.rs +3 -3
  8. pyropdf-0.2.0/crates/pyropdf-engine/src/extract/glyphs.rs +87 -0
  9. pyropdf-0.2.0/crates/pyropdf-engine/src/extract/images.rs +123 -0
  10. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/extract/mod.rs +4 -0
  11. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/extract/model.rs +10 -0
  12. pyropdf-0.2.0/crates/pyropdf-engine/src/fonts/cff.rs +561 -0
  13. pyropdf-0.2.0/crates/pyropdf-engine/src/fonts/mod.rs +56 -0
  14. pyropdf-0.2.0/crates/pyropdf-engine/src/fonts/sfnt.rs +243 -0
  15. pyropdf-0.2.0/crates/pyropdf-engine/src/fonts/tests.rs +204 -0
  16. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/lib.rs +1 -0
  17. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/render/svg.rs +1 -1
  18. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/render/tests.rs +1 -1
  19. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/annotations.rs +2 -2
  20. pyropdf-0.2.0/crates/pyropdf-python/src/fonts.rs +59 -0
  21. pyropdf-0.2.0/crates/pyropdf-python/src/images.rs +223 -0
  22. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/lib.rs +8 -2
  23. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/pages.rs +125 -1
  24. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/pixmap.rs +19 -0
  25. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/index/tests.rs +2 -2
  26. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/save/tests.rs +1 -1
  27. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/version/tests.rs +1 -1
  28. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/tests/corpus.rs +1 -1
  29. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/__init__.py +20 -0
  30. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_core.pyi +13 -0
  31. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_document.py +178 -1
  32. pyropdf-0.2.0/python/pyropdf/_fonts.py +266 -0
  33. pyropdf-0.2.0/python/pyropdf/_images.py +250 -0
  34. pyropdf-0.2.0/python/pyropdf/_layers.py +325 -0
  35. pyropdf-0.2.0/python/pyropdf/_metadata.py +335 -0
  36. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_page.py +101 -0
  37. pyropdf-0.2.0/python/pyropdf/_page_labels.py +297 -0
  38. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_pages.py +16 -0
  39. pyropdf-0.2.0/python/pyropdf/_sanitize.py +393 -0
  40. pyropdf-0.1.0/README.md +0 -41
  41. {pyropdf-0.1.0 → pyropdf-0.2.0}/LICENSE +0 -0
  42. {pyropdf-0.1.0 → pyropdf-0.2.0}/NOTICE +0 -0
  43. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/Cargo.toml +0 -0
  44. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/annotations/icons.rs +0 -0
  45. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/annotations/missing.rs +0 -0
  46. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/annotations/mod.rs +0 -0
  47. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/annotations/shapes.rs +0 -0
  48. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/annotations/tests.rs +0 -0
  49. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/bridge/mod.rs +0 -0
  50. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/content/mod.rs +0 -0
  51. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/content/page.rs +0 -0
  52. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/extract/provenance.rs +0 -0
  53. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/extract/reads.rs +0 -0
  54. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/extract/tests.rs +0 -0
  55. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/extract/text/layout.rs +0 -0
  56. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/extract/text/search.rs +0 -0
  57. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/extract/text/selection.rs +0 -0
  58. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/extract/text/tables.rs +0 -0
  59. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/extract/text.rs +0 -0
  60. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/forms/defaults.rs +0 -0
  61. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/forms/flatten.rs +0 -0
  62. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/forms/mod.rs +0 -0
  63. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/forms/tests.rs +0 -0
  64. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/forms/text.rs +0 -0
  65. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/ocr/layer.rs +0 -0
  66. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/ocr/mod.rs +0 -0
  67. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/pages/copy.rs +0 -0
  68. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/pages/import/graft.rs +0 -0
  69. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/pages/import.rs +0 -0
  70. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/pages/mod.rs +0 -0
  71. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/render/batch.rs +0 -0
  72. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/render/mod.rs +0 -0
  73. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/standard/appearance.rs +0 -0
  74. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/standard/font.rs +0 -0
  75. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/standard/layout.rs +0 -0
  76. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/standard/mod.rs +0 -0
  77. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/standard/ops.rs +0 -0
  78. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-engine/src/standard/tests.rs +0 -0
  79. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/Cargo.toml +0 -0
  80. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/annotations/links.rs +0 -0
  81. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/buffers.rs +0 -0
  82. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/cancel.rs +0 -0
  83. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/changes.rs +0 -0
  84. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/check.rs +0 -0
  85. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/content.rs +0 -0
  86. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/document.rs +0 -0
  87. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/errors.rs +0 -0
  88. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/forms.rs +0 -0
  89. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/history.rs +0 -0
  90. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/items.rs +0 -0
  91. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/objects.rs +0 -0
  92. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/ocr.rs +0 -0
  93. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/outline.rs +0 -0
  94. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/render.rs +0 -0
  95. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/schema.rs +0 -0
  96. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/security.rs +0 -0
  97. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/source.rs +0 -0
  98. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/text.rs +0 -0
  99. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-python/src/windows_permissions.rs +0 -0
  100. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-schema/Cargo.toml +0 -0
  101. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-schema/src/check/expr.rs +0 -0
  102. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-schema/src/check/mod.rs +0 -0
  103. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-schema/src/check/tests.rs +0 -0
  104. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-schema/src/generated.rs +0 -0
  105. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-schema/src/lib.rs +0 -0
  106. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-schema/src/tests.rs +0 -0
  107. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/Cargo.toml +0 -0
  108. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/clippy.toml +0 -0
  109. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/proptest-regressions/refs/tests.txt +0 -0
  110. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/budget/cancel.rs +0 -0
  111. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/budget/code.rs +0 -0
  112. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/budget/decode.rs +0 -0
  113. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/budget/limits.rs +0 -0
  114. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/budget/mod.rs +0 -0
  115. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/budget/tests.rs +0 -0
  116. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/budget/vec.rs +0 -0
  117. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/error.rs +0 -0
  118. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/index/lex.rs +0 -0
  119. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/index/mod.rs +0 -0
  120. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/index/objstm.rs +0 -0
  121. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/index/read.rs +0 -0
  122. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/index/scan.rs +0 -0
  123. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/lib.rs +0 -0
  124. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/memo/dependencies.rs +0 -0
  125. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/memo/mod.rs +0 -0
  126. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/memo/tests.rs +0 -0
  127. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/pages/mod.rs +0 -0
  128. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/pages/tests.rs +0 -0
  129. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/refs/copy.rs +0 -0
  130. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/refs/derived.rs +0 -0
  131. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/refs/form_impact.rs +0 -0
  132. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/refs/forms.rs +0 -0
  133. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/refs/labels.rs +0 -0
  134. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/refs/mod.rs +0 -0
  135. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/refs/navigation.rs +0 -0
  136. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/refs/roles.rs +0 -0
  137. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/refs/rules.rs +0 -0
  138. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/refs/structure.rs +0 -0
  139. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/refs/tests.rs +0 -0
  140. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/save/base.rs +0 -0
  141. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/save/merge.rs +0 -0
  142. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/save/mod.rs +0 -0
  143. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/save/pack.rs +0 -0
  144. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/save/prune.rs +0 -0
  145. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/save/raw.rs +0 -0
  146. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/save/recode.rs +0 -0
  147. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/save/renumber.rs +0 -0
  148. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/security/crypto.rs +0 -0
  149. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/security/mod.rs +0 -0
  150. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/security/tests.rs +0 -0
  151. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/security/value.rs +0 -0
  152. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/settle/tests.rs +0 -0
  153. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/settle.rs +0 -0
  154. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/value/bytes.rs +0 -0
  155. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/value/mod.rs +0 -0
  156. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/value/read.rs +0 -0
  157. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/value/tests.rs +0 -0
  158. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/version/base.rs +0 -0
  159. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/version/document.rs +0 -0
  160. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/version/mod.rs +0 -0
  161. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/version/stale.rs +0 -0
  162. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/version/table.rs +0 -0
  163. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/version/transaction.rs +0 -0
  164. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/write/mod.rs +0 -0
  165. {pyropdf-0.1.0 → pyropdf-0.2.0}/crates/pyropdf-store/src/write/tests.rs +0 -0
  166. {pyropdf-0.1.0 → pyropdf-0.2.0}/pyproject.toml +0 -0
  167. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_annotations.py +0 -0
  168. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_attachments.py +0 -0
  169. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_changes.py +0 -0
  170. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_check.py +0 -0
  171. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_content.py +0 -0
  172. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_encryption.py +0 -0
  173. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_errors.py +0 -0
  174. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_form.py +0 -0
  175. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_geometry.py +0 -0
  176. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_history.py +0 -0
  177. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_limit_codes.py +0 -0
  178. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_limits.py +0 -0
  179. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_links.py +0 -0
  180. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_markdown.py +0 -0
  181. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_objects.py +0 -0
  182. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_ocr.py +0 -0
  183. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_operations.py +0 -0
  184. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_outline.py +0 -0
  185. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_pixmap.py +0 -0
  186. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_profiles.py +0 -0
  187. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_tables.py +0 -0
  188. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_targets.py +0 -0
  189. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_text.py +0 -0
  190. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/_widgets.py +0 -0
  191. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/py.typed +0 -0
  192. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/typed.py +0 -0
  193. {pyropdf-0.1.0 → pyropdf-0.2.0}/python/pyropdf/typed.pyi +0 -0
  194. {pyropdf-0.1.0 → pyropdf-0.2.0}/tools/arlington/model/LICENSE +0 -0
@@ -823,7 +823,7 @@ dependencies = [
823
823
 
824
824
  [[package]]
825
825
  name = "pyropdf-engine"
826
- version = "0.1.0"
826
+ version = "0.2.0"
827
827
  dependencies = [
828
828
  "hayro",
829
829
  "hayro-svg",
@@ -840,7 +840,7 @@ dependencies = [
840
840
 
841
841
  [[package]]
842
842
  name = "pyropdf-python"
843
- version = "0.1.0"
843
+ version = "0.2.0"
844
844
  dependencies = [
845
845
  "flate2",
846
846
  "jpeg-encoder",
@@ -854,11 +854,11 @@ dependencies = [
854
854
 
855
855
  [[package]]
856
856
  name = "pyropdf-schema"
857
- version = "0.1.0"
857
+ version = "0.2.0"
858
858
 
859
859
  [[package]]
860
860
  name = "pyropdf-store"
861
- version = "0.1.0"
861
+ version = "0.2.0"
862
862
  dependencies = [
863
863
  "aes",
864
864
  "flate2",
@@ -3,7 +3,7 @@ members = ["crates/*"]
3
3
  resolver = "3"
4
4
 
5
5
  [workspace.package]
6
- version = "0.1.0"
6
+ version = "0.2.0"
7
7
  authors = ["Yusuke Hayashi <yusuke8h@gmail.com>"]
8
8
  edition = "2024"
9
9
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyropdf
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: Programming Language :: Python :: 3
@@ -31,14 +31,13 @@ Project-URL: Source, https://github.com/yhay81/pyropdf
31
31
 
32
32
  # pyropdf
33
33
 
34
- pyropdf is the successor of [pylopdf](https://github.com/yhay81/pylopdf):
35
- a Python library, implemented in Rust, for complete control of PDF as
36
- ISO 32000-2 defines it. It keeps pylopdf's concept and replaces its
37
- foundation with one versioned object store that every engine reads, so an
38
- edit costs what it touches, every change can be undone, and a failed
39
- transaction leaves the document as it was.
34
+ pyropdf is a Python library, implemented in Rust, for complete control of
35
+ PDF as ISO 32000-2 defines it. It keeps a document on one versioned object
36
+ store that every engine reads, so an edit costs what it touches, every
37
+ change can be undone, and a failed transaction leaves the document as it
38
+ was.
40
39
 
41
- **Status:** alpha. The API may change between minor versions. Documentation:
40
+ **Status:** alpha, 0.2. The API may change between minor versions. Documentation:
42
41
  <https://pyropdf.haya.works/>. [DESIGN.md](DESIGN.md) describes the
43
42
  foundation, and [CHANGELOG.md](CHANGELOG.md) what each release holds.
44
43
 
@@ -58,11 +57,12 @@ with pyropdf.open("input.pdf") as doc:
58
57
  doc.save("output.pdf", incremental=True)
59
58
  ```
60
59
 
61
- The 0.1 releases read text, words, layout, tables, and Markdown, run
62
- offline OCR, render pages to pixmaps and SVG, edit pages, annotations,
63
- links, form fields, outlines, and attachments, and save incrementally or
64
- in full, with encryption. Drawing on a page with `page.draw` comes in a
65
- later release.
60
+ 0.2 reads text, words, layout, tables, images, and Markdown, runs offline
61
+ OCR, renders pages to pixmaps and SVG, edits pages and their boxes,
62
+ annotations, links, form fields, outlines, attachments, metadata, page
63
+ labels, and layers, removes hidden or active content, subsets fonts, and
64
+ saves incrementally or in full, with encryption. Drawing on a page with
65
+ `page.draw` comes in a later release.
66
66
 
67
67
  ## Safety claims
68
68
 
@@ -71,3 +71,8 @@ construction (I2, [#15](https://github.com/yhay81/pyropdf/issues/15)) is
71
71
  released. `DocumentLimits` bounds the work of an operation, but it is not
72
72
  that claim.
73
73
 
74
+ ## Contributing
75
+
76
+ [CONTRIBUTING.md](CONTRIBUTING.md) explains how to build, test, and propose
77
+ a change, and [SECURITY.md](SECURITY.md) how to report a vulnerability.
78
+
@@ -0,0 +1,46 @@
1
+ # pyropdf
2
+
3
+ pyropdf is a Python library, implemented in Rust, for complete control of
4
+ PDF as ISO 32000-2 defines it. It keeps a document on one versioned object
5
+ store that every engine reads, so an edit costs what it touches, every
6
+ change can be undone, and a failed transaction leaves the document as it
7
+ was.
8
+
9
+ **Status:** alpha, 0.2. The API may change between minor versions. Documentation:
10
+ <https://pyropdf.haya.works/>. [DESIGN.md](DESIGN.md) describes the
11
+ foundation, and [CHANGELOG.md](CHANGELOG.md) what each release holds.
12
+
13
+ ```bash
14
+ pip install pyropdf
15
+ ```
16
+
17
+ ```python
18
+ import pyropdf
19
+
20
+ with pyropdf.open("input.pdf") as doc:
21
+ page = doc.pages[0]
22
+ print(page.text())
23
+ page.pixmap(dpi=144).save("page-1.png")
24
+ with doc.transaction("rotate"):
25
+ page.rotation = 90
26
+ doc.save("output.pdf", incremental=True)
27
+ ```
28
+
29
+ 0.2 reads text, words, layout, tables, images, and Markdown, runs offline
30
+ OCR, renders pages to pixmaps and SVG, edits pages and their boxes,
31
+ annotations, links, form fields, outlines, attachments, metadata, page
32
+ labels, and layers, removes hidden or active content, subsets fonts, and
33
+ saves incrementally or in full, with encryption. Drawing on a page with
34
+ `page.draw` comes in a later release.
35
+
36
+ ## Safety claims
37
+
38
+ No pyropdf release claims safety for untrusted input before hayro's bounded
39
+ construction (I2, [#15](https://github.com/yhay81/pyropdf/issues/15)) is
40
+ released. `DocumentLimits` bounds the work of an operation, but it is not
41
+ that claim.
42
+
43
+ ## Contributing
44
+
45
+ [CONTRIBUTING.md](CONTRIBUTING.md) explains how to build, test, and propose
46
+ a change, and [SECURITY.md](SECURITY.md) how to report a vulnerability.
@@ -0,0 +1,7 @@
1
+ # Seeds for failure cases proptest has generated in the past. It is
2
+ # automatically read and these particular cases re-run before any
3
+ # novel cases are generated.
4
+ #
5
+ # It is recommended to check this file in to source control so that
6
+ # everyone who runs the test benefits from these saved cases.
7
+ cc 8d5eb4b40ad54666080e0abf537de7f36596a44a9c88e2452583d3f4b0353bf3 # shrinks to pick = Index(0), cut = Index(0), flips = []
@@ -61,7 +61,7 @@ fn corpus_pages_render_as_hayro_renders_the_original() {
61
61
  .filter(|path| path.extension().is_some_and(|e| e == "pdf"))
62
62
  .collect();
63
63
  files.sort();
64
- assert_eq!(files.len(), 14);
64
+ assert_eq!(files.len(), 15);
65
65
  // Debug builds render slowly: one thread per file.
66
66
  std::thread::scope(|scope| {
67
67
  for path in &files {
@@ -377,7 +377,7 @@ fn every_corpus_page_reads_the_content_that_hayro_reads() {
377
377
  .filter(|path| path.extension().is_some_and(|e| e == "pdf"))
378
378
  .collect();
379
379
  files.sort();
380
- assert_eq!(files.len(), 14);
380
+ assert_eq!(files.len(), 15);
381
381
  let (mut operations_read, mut pages_read) = (0, 0);
382
382
  for path in &files {
383
383
  let bytes = fs::read(path).unwrap();
@@ -413,7 +413,7 @@ fn every_corpus_page_reads_the_content_that_hayro_reads() {
413
413
  pages_read += 1;
414
414
  }
415
415
  }
416
- // 155 pages, with 80,233 operations.
417
- assert_eq!(pages_read, 155);
416
+ // 156 pages, with more than 80,000 operations.
417
+ assert_eq!(pages_read, 156);
418
418
  assert!(operations_read > 80_000, "{operations_read}");
419
419
  }
@@ -0,0 +1,87 @@
1
+ //! The glyphs that a document's pages and annotation appearances draw with
2
+ //! each font, as hayro resolves them for rendering: the glyph use that
3
+ //! subsetting an embedded font program keeps (ISO 32000-2 9.6.4).
4
+
5
+ use std::collections::{BTreeSet, HashMap};
6
+
7
+ use hayro::hayro_interpret::font::Glyph;
8
+ use hayro::hayro_interpret::hayro_syntax::object::{Dict, ObjectIdentifier};
9
+ use hayro::hayro_interpret::{CacheKey, DrawMode, InterpreterCache, InterpreterSettings};
10
+ use hayro::kurbo::{Affine, BezPath, Rect};
11
+ use pyropdf_store::budget::Budget;
12
+
13
+ use super::Error;
14
+ use super::model::{self, ContentSink, GlyphStyle, ItemKinds};
15
+ use crate::bridge::Bridged;
16
+
17
+ /// The sink that gathers the glyph IDs of every outline glyph by font.
18
+ struct Uses {
19
+ /// Glyph IDs by hayro's font cache key, which hashes the font dictionary.
20
+ glyphs: HashMap<u128, BTreeSet<u32>>,
21
+ }
22
+
23
+ impl ContentSink for Uses {
24
+ fn glyph_run(&mut self, _: &GlyphStyle) {}
25
+ fn glyph(&mut self, glyph: &Glyph<'_>, _: Affine, _: Option<Rect>) {
26
+ if let Glyph::Outline(outline) = glyph {
27
+ // A font has at most 65,536 glyphs, so each set stays bounded.
28
+ self.glyphs
29
+ .entry(outline.font_cache_key())
30
+ .or_default()
31
+ .insert(outline.glyph_id().to_u32());
32
+ }
33
+ }
34
+ fn stroke_completes_fill(&mut self) {}
35
+ fn path(&mut self, _: &BezPath, _: Affine, _: &DrawMode) {}
36
+ fn stopped(&self) -> bool {
37
+ false
38
+ }
39
+ }
40
+
41
+ /// Returns, for each font dictionary `fonts` names by object number and
42
+ /// generation, the glyph IDs that the pages, with their annotation
43
+ /// appearances, draw with it: in the same order, empty for a font that no
44
+ /// page draws or that the document lacks. Interpretation runs under
45
+ /// `budget`, as text extraction does.
46
+ pub fn used_glyphs(
47
+ bridged: &Bridged,
48
+ fonts: &[(u32, u16)],
49
+ budget: &Budget,
50
+ ) -> Result<Vec<Vec<u32>>, Error> {
51
+ let pdf = bridged.pdf();
52
+ let settings = InterpreterSettings {
53
+ render_annotations: true,
54
+ ..InterpreterSettings::default()
55
+ };
56
+ let cache = InterpreterCache::new();
57
+ let mut uses = Uses {
58
+ glyphs: HashMap::new(),
59
+ };
60
+ for page in pdf.pages().iter() {
61
+ let (_, sink) = model::collect_page_content(
62
+ pdf,
63
+ page,
64
+ settings.clone(),
65
+ &cache,
66
+ uses,
67
+ ItemKinds::NONE,
68
+ None,
69
+ budget,
70
+ )?;
71
+ uses = sink;
72
+ }
73
+ let xref = pdf.xref();
74
+ Ok(fonts
75
+ .iter()
76
+ .map(|&(number, generation)| {
77
+ let id = ObjectIdentifier::new(
78
+ i32::try_from(number).unwrap_or(i32::MAX),
79
+ i32::from(generation),
80
+ );
81
+ xref.get::<Dict<'_>>(id)
82
+ .and_then(|dict| uses.glyphs.get(&dict.cache_key()))
83
+ .map(|glyphs| glyphs.iter().copied().collect())
84
+ .unwrap_or_default()
85
+ })
86
+ .collect())
87
+ }
@@ -0,0 +1,123 @@
1
+ //! The pixels of one image that a page paints, as hayro decodes them for
2
+ //! rendering (ISO 32000-2 8.9), with its soft mask or mask as alpha.
3
+
4
+ use hayro::hayro_interpret::font::Glyph;
5
+ use hayro::hayro_interpret::{DrawMode, Image, ImageData, InterpreterCache, InterpreterSettings};
6
+ use hayro::kurbo::{Affine, BezPath, Rect};
7
+ use pyropdf_store::budget::{Budget, LimitCode};
8
+
9
+ use super::Error;
10
+ use super::model::{self, ContentSink, GlyphStyle, ItemKinds};
11
+ use crate::bridge::Bridged;
12
+
13
+ /// An image's pixels, row by row from the top, 8 bits per channel.
14
+ pub struct DecodedImage {
15
+ pub width: u32,
16
+ pub height: u32,
17
+ /// Whether `color` holds one gray byte per pixel instead of three.
18
+ pub gray: bool,
19
+ pub color: Vec<u8>,
20
+ /// One alpha byte per pixel, for an image with a mask or a stencil.
21
+ pub alpha: Option<Vec<u8>>,
22
+ }
23
+
24
+ /// The sink that decodes the page's image `target`.
25
+ struct Grab<'b> {
26
+ target: usize,
27
+ budget: &'b Budget,
28
+ found: bool,
29
+ image: Option<DecodedImage>,
30
+ }
31
+
32
+ impl ContentSink for Grab<'_> {
33
+ fn glyph_run(&mut self, _: &GlyphStyle) {}
34
+ fn glyph(&mut self, _: &Glyph<'_>, _: Affine, _: Option<Rect>) {}
35
+ fn stroke_completes_fill(&mut self) {}
36
+ fn path(&mut self, _: &BezPath, _: Affine, _: &DrawMode) {}
37
+ fn stopped(&self) -> bool {
38
+ self.found
39
+ }
40
+
41
+ fn image(&mut self, ordinal: usize, image: &Image<'_, '_>) -> Result<(), Error> {
42
+ if self.found || ordinal != self.target {
43
+ return Ok(());
44
+ }
45
+ self.found = true;
46
+ // The decoded color and alpha, charged before hayro allocates them.
47
+ let pixels = u64::from(image.width()) * u64::from(image.height());
48
+ self.budget
49
+ .charge(LimitCode::TotalDecompressedSize, pixels.saturating_mul(4))?;
50
+ match image {
51
+ Image::Raster(raster) => raster.with_rgba(
52
+ |data, alpha| {
53
+ let (width, height, gray, color) = match data {
54
+ ImageData::Rgb(rgb) => (rgb.width, rgb.height, false, rgb.data),
55
+ ImageData::Luma(luma) => (luma.width, luma.height, true, luma.data),
56
+ };
57
+ // hayro may decode a mask at another size than the image.
58
+ let alpha = alpha
59
+ .filter(|alpha| alpha.width == width && alpha.height == height)
60
+ .map(|alpha| alpha.data);
61
+ self.image = Some(DecodedImage {
62
+ width,
63
+ height,
64
+ gray,
65
+ color,
66
+ alpha,
67
+ });
68
+ },
69
+ None,
70
+ ),
71
+ Image::Stencil(stencil) => stencil.with_stencil(
72
+ |mask, _| {
73
+ let size = mask.data.len();
74
+ self.image = Some(DecodedImage {
75
+ width: mask.width,
76
+ height: mask.height,
77
+ gray: true,
78
+ color: vec![0; size],
79
+ alpha: Some(mask.data),
80
+ });
81
+ },
82
+ None,
83
+ ),
84
+ }
85
+ Ok(())
86
+ }
87
+ }
88
+
89
+ /// Decodes image `ordinal`, counted from 0 in the paint order of
90
+ /// `Page.content()`, of page `index`, painted with annotation appearances
91
+ /// when `annotations` is set. `None` when the page paints fewer images or
92
+ /// hayro cannot decode that one. The decoded bytes count against the
93
+ /// budget's `total_decompressed_size`.
94
+ pub fn page_image(
95
+ bridged: &Bridged,
96
+ index: usize,
97
+ ordinal: usize,
98
+ annotations: bool,
99
+ budget: &Budget,
100
+ ) -> Result<Option<DecodedImage>, Error> {
101
+ let pdf = bridged.pdf();
102
+ let pages = pdf.pages();
103
+ let page = pages.get(index).ok_or(Error::NoPage(index))?;
104
+ let settings = InterpreterSettings {
105
+ render_annotations: annotations,
106
+ ..InterpreterSettings::default()
107
+ };
108
+ let cache = InterpreterCache::new();
109
+ let kinds = ItemKinds {
110
+ text_runs: false,
111
+ paths: false,
112
+ images: true,
113
+ };
114
+ let grab = Grab {
115
+ target: ordinal,
116
+ budget,
117
+ found: false,
118
+ image: None,
119
+ };
120
+ let (_, grab) =
121
+ model::collect_page_content(pdf, page, settings, &cache, grab, kinds, None, budget)?;
122
+ Ok(grab.image)
123
+ }
@@ -17,6 +17,8 @@ use pyropdf_store::budget::Budget;
17
17
 
18
18
  use crate::bridge::Bridged;
19
19
 
20
+ mod glyphs;
21
+ mod images;
20
22
  mod model;
21
23
  mod provenance;
22
24
  mod reads;
@@ -24,6 +26,8 @@ mod reads;
24
26
  mod tests;
25
27
  mod text;
26
28
 
29
+ pub use glyphs::used_glyphs;
30
+ pub use images::{DecodedImage, page_image};
27
31
  pub use model::{
28
32
  BBox, ClipTuple, ContentItem, ContentSink, FontTuple, GlyphStyle, GlyphsTuple, GroupTuple,
29
33
  ImageFormatTuple, ImageTuple, ItemContextTuple, ItemKinds, MarkTuple, PageContent, PaintTuple,
@@ -589,6 +589,11 @@ pub trait ContentSink {
589
589
  /// Whether the sink refused more input, so that the collector stops
590
590
  /// sending glyphs.
591
591
  fn stopped(&self) -> bool;
592
+ /// Receive the image that the collector records as the page's image
593
+ /// `ordinal`, counted from 0 in paint order, when it records images.
594
+ fn image(&mut self, _ordinal: usize, _image: &Image<'_, '_>) -> Result<(), Error> {
595
+ Ok(())
596
+ }
592
597
  }
593
598
 
594
599
  /// The sink of `Page.content()`, which reads only the items.
@@ -719,6 +724,8 @@ pub(crate) struct ContentCollector<'b, S> {
719
724
  runs: u32,
720
725
  outlines: HashMap<u128, Option<GlyphInk>>,
721
726
  type3_boxes: HashMap<u128, Option<Rect>>,
727
+ /// The images recorded so far, the ordinal of the next one.
728
+ images: usize,
722
729
  budget: &'b Budget,
723
730
  error: Option<Error>,
724
731
  }
@@ -748,6 +755,7 @@ impl<'b, S: ContentSink> ContentCollector<'b, S> {
748
755
  runs: 0,
749
756
  outlines: HashMap::new(),
750
757
  type3_boxes: HashMap::new(),
758
+ images: 0,
751
759
  budget,
752
760
  error: None,
753
761
  }
@@ -1152,6 +1160,8 @@ impl<'b, S: ContentSink> ContentCollector<'b, S> {
1152
1160
  }
1153
1161
  let context = self.item_context(props.blend_mode, props.soft_mask.as_ref())?;
1154
1162
  self.charge(1)?;
1163
+ self.sink.image(self.images, image)?;
1164
+ self.images += 1;
1155
1165
  let default_resolution = (DEFAULT_IMAGE_RESOLUTION, DEFAULT_IMAGE_RESOLUTION);
1156
1166
  let record = match image {
1157
1167
  // hayro does not expose the stream of an image mask.