pdfdancer-client-python 0.2.6__py3-none-any.whl → 0.2.8__py3-none-any.whl

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.

Potentially problematic release.


This version of pdfdancer-client-python might be problematic. Click here for more details.

pdfdancer/pdfdancer_v1.py CHANGED
@@ -26,13 +26,16 @@ from .models import (
26
26
  FindRequest, DeleteRequest, MoveRequest, AddRequest, ModifyRequest, ModifyTextRequest, ChangeFormFieldRequest,
27
27
  ShapeType, PositionMode
28
28
  )
29
- from .types import PathObject, ParagraphObject, TextLineObject, ImageObject, FormObject, FormFieldObject, PageObject
29
+ from .types import PathObject, ParagraphObject, TextLineObject, ImageObject, FormObject, FormFieldObject
30
30
 
31
31
 
32
32
  class PageClient:
33
33
  def __init__(self, page_index: int, root: "PDFDancer"):
34
34
  self.page_index = page_index
35
35
  self.root = root
36
+ self.object_type = ObjectType.PAGE
37
+ self.position = Position.at_page(page_index)
38
+ self.internal_id = f"PAGE-{page_index}"
36
39
 
37
40
  def select_paths_at(self, x: float, y: float) -> List[PathObject]:
38
41
  # noinspection PyProtectedMember
@@ -99,8 +102,17 @@ class PageClient:
99
102
  # noinspection PyProtectedMember
100
103
  return self.root._to_form_field_objects(self.root._find_form_fields(position))
101
104
 
102
- def get(self) -> PageObject:
103
- return self.root._to_page_object(self.root._get_page(self.page_index))
105
+ @classmethod
106
+ def from_ref(cls, root: 'PDFDancer', object_ref: ObjectRef) -> 'PageClient':
107
+ page_client = PageClient(page_index=object_ref.position.page_index, root=root)
108
+ return page_client
109
+
110
+ def delete(self) -> bool:
111
+ # noinspection PyProtectedMember
112
+ return self.root._delete_page(self._ref())
113
+
114
+ def _ref(self):
115
+ return ObjectRef(internal_id=self.internal_id, position=self.position, type=self.object_type)
104
116
 
105
117
 
106
118
  class PDFDancer:
@@ -472,7 +484,7 @@ class PDFDancer:
472
484
 
473
485
  # Page Operations
474
486
 
475
- def pages(self) -> List[PageObject]:
487
+ def pages(self) -> List[PageClient]:
476
488
  return self._to_page_objects(self._get_pages())
477
489
 
478
490
  def _get_pages(self) -> List[ObjectRef]:
@@ -767,7 +779,7 @@ class PDFDancer:
767
779
 
768
780
  # Document Operations
769
781
 
770
- def get_pdf_file(self) -> bytes:
782
+ def get_bytes(self) -> bytes:
771
783
  """
772
784
  Downloads the current state of the PDF document with all modifications applied.
773
785
 
@@ -792,7 +804,7 @@ class PDFDancer:
792
804
  raise ValidationException("File path cannot be null or empty")
793
805
 
794
806
  try:
795
- pdf_data = self.get_pdf_file()
807
+ pdf_data = self.get_bytes()
796
808
  output_path = Path(file_path)
797
809
 
798
810
  # Create parent directories if they don't exist
@@ -898,8 +910,8 @@ class PDFDancer:
898
910
  return [FormFieldObject(self, ref.internal_id, ref.type, ref.position, ref.name, ref.value) for ref in
899
911
  path_refs]
900
912
 
901
- def _to_page_objects(self, path_refs: List[ObjectRef]) -> List[PageObject]:
902
- return [PageObject(self, ref.internal_id, ref.type, ref.position) for ref in path_refs]
913
+ def _to_page_objects(self, path_refs: List[ObjectRef]) -> List[PageClient]:
914
+ return [PageClient.from_ref(self, ref) for ref in path_refs]
903
915
 
904
- def _to_page_object(self, ref: ObjectRef) -> PageObject:
905
- return PageObject(self, ref.internal_id, ref.type, ref.position)
916
+ def _to_page_object(self, ref: ObjectRef) -> PageClient:
917
+ return PageClient.from_ref(self, ref)
pdfdancer/types.py CHANGED
@@ -239,10 +239,3 @@ class FormFieldObject(PDFObjectBase):
239
239
  ref.name = self.name
240
240
  ref.value = self.value
241
241
  return ref
242
-
243
-
244
- class PageObject(PDFObjectBase):
245
-
246
- def delete(self) -> bool:
247
- # noinspection PyProtectedMember
248
- return self._client._delete_page(self.object_ref())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pdfdancer-client-python
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: Python client for PDFDancer API
5
5
  Author-email: "The Famous Cat Ltd." <hi@thefamouscat.com>
6
6
  License: MIT
@@ -3,9 +3,9 @@ pdfdancer/exceptions.py,sha256=Y5zwNVZprsv2hvKX304cXWobJt11nrEhCzLklu2wiO8,1567
3
3
  pdfdancer/image_builder.py,sha256=Omxc2LcieJ1MbvWBXR5_sfia--eAucTUe0KWgr22HYo,842
4
4
  pdfdancer/models.py,sha256=SmkKScr47uVs6FCWUAVIg6rucYrYHvbIxZngyA50XyI,15498
5
5
  pdfdancer/paragraph_builder.py,sha256=bAfwX9U2YT1UGX9EKkPnGYvGK3SQP3X1ocxlgyLE_rU,8872
6
- pdfdancer/pdfdancer_v1.py,sha256=Pgv-2L0pYQdOUVK2nUntrGB6hCDKUOMWHYuN8loBM3Q,35540
7
- pdfdancer/types.py,sha256=05zvjA6MEQomNucUUKf5Z33dA7NVFCRu_6LR3Yom1yo,7633
8
- pdfdancer_client_python-0.2.6.dist-info/METADATA,sha256=mQUfTZ7xhjoCWdo6g_5sAerVGtq-tBdaV93Nesj5CcI,6769
9
- pdfdancer_client_python-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- pdfdancer_client_python-0.2.6.dist-info/top_level.txt,sha256=ICwSVRpcCKrdBF9QlaX9Y0e_N3Nk1p7QVxadGOnbxeY,10
11
- pdfdancer_client_python-0.2.6.dist-info/RECORD,,
6
+ pdfdancer/pdfdancer_v1.py,sha256=f9RjlbMRHEFcf2syYVZbtAnv-6Ny-VqMN0Wp_h7to4s,35958
7
+ pdfdancer/types.py,sha256=TtXbOqa8febqTUmYF97tq-y6i-jNuO6UHvmAmSJHz20,7466
8
+ pdfdancer_client_python-0.2.8.dist-info/METADATA,sha256=iw817FadM5Gd8Qmbo4dawXKLRbJPLvJZcuaIjyOiLcU,6769
9
+ pdfdancer_client_python-0.2.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ pdfdancer_client_python-0.2.8.dist-info/top_level.txt,sha256=ICwSVRpcCKrdBF9QlaX9Y0e_N3Nk1p7QVxadGOnbxeY,10
11
+ pdfdancer_client_python-0.2.8.dist-info/RECORD,,