convert-stream 2.4.3__tar.gz → 2.5__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 (31) hide show
  1. {convert_stream-2.4.3 → convert_stream-2.5}/PKG-INFO +3 -3
  2. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/__init__.py +10 -15
  3. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/_version.py +2 -2
  4. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/doc_stream.py +19 -22
  5. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/image/img_object.py +26 -15
  6. convert_stream-2.5/convert_stream/mod_types/__init__.py +11 -0
  7. convert_stream-2.5/convert_stream/mod_types/enums.py +37 -0
  8. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/mod_types/modules.py +6 -6
  9. convert_stream-2.5/convert_stream/pdf/__init__.py +12 -0
  10. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/pdf/pdf_document.py +46 -18
  11. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/pdf/pdf_page.py +12 -9
  12. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/table_files.py +1 -2
  13. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/text/__init__.py +1 -0
  14. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream.egg-info/PKG-INFO +3 -3
  15. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream.egg-info/SOURCES.txt +0 -3
  16. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream.egg-info/requires.txt +2 -2
  17. {convert_stream-2.4.3 → convert_stream-2.5}/pyproject.toml +3 -3
  18. convert_stream-2.4.3/convert_stream/mod_types/__init__.py +0 -13
  19. convert_stream-2.4.3/convert_stream/mod_types/enums.py +0 -65
  20. convert_stream-2.4.3/convert_stream/mod_types/table_types.py +0 -19
  21. convert_stream-2.4.3/convert_stream/pdf/__init__.py +0 -14
  22. convert_stream-2.4.3/convert_stream/pdf/image_to_pdf.py +0 -349
  23. convert_stream-2.4.3/convert_stream/pdf/pdf_to_image.py +0 -223
  24. {convert_stream-2.4.3 → convert_stream-2.5}/README.md +0 -0
  25. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/__main__.py +0 -0
  26. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/image/__init__.py +0 -0
  27. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/text/find_text.py +0 -0
  28. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream/text/terminal.py +0 -0
  29. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream.egg-info/dependency_links.txt +0 -0
  30. {convert_stream-2.4.3 → convert_stream-2.5}/convert_stream.egg-info/top_level.txt +0 -0
  31. {convert_stream-2.4.3 → convert_stream-2.5}/setup.cfg +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: convert_stream
3
- Version: 2.4.3
3
+ Version: 2.5
4
4
  Summary: Manipulação de documentos PDF e Imagens. Converter, Ler, rotacionar exportar etc.
5
5
  Author: Bruno Chaves
6
6
  Requires-Python: >=3.11
7
7
  Description-Content-Type: text/markdown
8
- Requires-Dist: soup_files>=1.4
8
+ Requires-Dist: soup_files>=1.4.2
9
9
  Requires-Dist: PyMuPDF
10
10
  Requires-Dist: scipy
11
11
  Requires-Dist: reportlab
@@ -15,7 +15,7 @@ Requires-Dist: pandas
15
15
  Requires-Dist: Pillow>=11.3.0
16
16
  Requires-Dist: opencv-python
17
17
  Requires-Dist: requests>=2.32.4
18
- Requires-Dist: sheet_stream
18
+ Requires-Dist: sheet_stream>=0.1.3
19
19
 
20
20
  # Configuração instalação:
21
21
  pip3 install -r requirements.txt
@@ -8,11 +8,17 @@ from ._version import (
8
8
  __module_name__, __author__, __license__, __modify_date__, __version__
9
9
  )
10
10
  from .mod_types import (
11
- LibPDF, LibImage, LibPdfToImage, LibImageToPdf, DictTextTable, RotationAngle,
11
+ LibPDF, LibImage, LibPdfToImage, LibImageToPdf, RotationAngle,
12
12
  )
13
- from .image import ImageObject, CollectionImages
14
- from .pdf import DocumentPdf, PageDocumentPdf, CollectionPagePdf, ConvertPdfToImages, ConvertImageToPdf
15
- from .pdf.pdf_document import SearchableTextPdf
13
+ from .image import ImageObject, CollectionImages, ProcessImageScanner
14
+ from .pdf import (
15
+ DocumentPdf, PageDocumentPdf, CollectionPagePdf, SearchableTextPdf
16
+ )
17
+ from .convert import (
18
+ ConvertPdfToImages, ConvertImageToPdf, ABCConvertPdf, ABCConvertImageToPdf,
19
+ DEFAULT_LIB_PDF_TO_IMG, DEFAULT_LIB_IMAGE_TO_PDF, LibPdfToImage, LibImageToPdf,
20
+ )
21
+
16
22
  from .doc_stream import PdfStream, SplitPdf
17
23
  from .table_files import PdfFinder
18
24
  from .text import print_title, print_line, FindStrings
@@ -71,14 +77,3 @@ def read_image(img: Union[str, File, bytes, BytesIO]) -> PdfStream:
71
77
  raise ValueError()
72
78
  return _pdf_stream
73
79
 
74
-
75
- __all__ = [
76
- '__modify_date__', '__author__', '__license__', '__module_name__', '__version__',
77
- 'PdfStream', 'DocumentPdf', 'PageDocumentPdf', 'CollectionPagePdf', 'CollectionImages',
78
- 'ImageObject', 'File', 'Directory', 'LibraryDocs', 'InputFiles', 'SearchableTextPdf',
79
- 'PdfFinder', 'SplitPdf', 'LibImageToPdf', 'RotationAngle', 'ConvertImageToPdf',
80
- 'ConvertPdfToImages', 'LibPDF', 'LibImage', 'LibPdfToImage',
81
- 'read_pdf', 'read_files_pdf', 'read_image', 'DictTextTable',
82
- 'print_title', 'print_line', 'FindStrings',
83
- ]
84
-
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env python3
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- __version__ = '2.2.7'
4
+ __version__ = '2.5'
5
5
  __author__ = 'Bruno Chaves'
6
6
  __license__ = 'MIT'
7
7
  __module_name__ = 'convert_stream'
8
- __modify_date__ = '2025-09-08'
8
+ __modify_date__ = '2025-11-15'
9
9
 
@@ -4,21 +4,18 @@
4
4
  Módulo para trabalhar com pdfs e imagens
5
5
  """
6
6
  from __future__ import annotations
7
- from convert_stream.mod_types.modules import (
8
- DEFAULT_LIB_PDF, DEFAULT_LIB_IMAGE, DEFAULT_LIB_PDF_TO_IMG, DEFAULT_LIB_IMAGE_TO_PDF,
9
- )
10
7
  from convert_stream.mod_types.enums import LibPDF, LibImage, LibPdfToImage
11
8
  from convert_stream.pdf.pdf_page import PageDocumentPdf
12
9
  from convert_stream.image.img_object import ImageObject, CollectionImages
13
10
  from convert_stream.pdf.pdf_document import DocumentPdf, CollectionPagePdf
14
- from convert_stream.pdf.image_to_pdf import LibImageToPdf, ConvertImageToPdf
15
- from convert_stream.pdf.pdf_to_image import ConvertPdfToImages
11
+ from convert_stream.convert.image_to_pdf import LibImageToPdf, ConvertImageToPdf
12
+ from convert_stream.convert.pdf_to_image import ConvertPdfToImages
16
13
  from soup_files import File, Directory, ProgressBarAdapter
17
14
 
18
15
 
19
16
  class ImageStream(CollectionImages):
20
17
 
21
- def __init__(self, images: list[ImageObject]) -> None:
18
+ def __init__(self, images: list[ImageObject] = None) -> None:
22
19
  super().__init__(images)
23
20
 
24
21
  def add_image_bytes(self, bt: bytes) -> None:
@@ -39,7 +36,7 @@ class PdfStream(object):
39
36
  ) -> None:
40
37
  self.dpi = dpi
41
38
  self.progress: ProgressBarAdapter = pbar
42
- self.collection_pages: CollectionPagePdf = CollectionPagePdf([])
39
+ self.collection_pages: CollectionPagePdf = CollectionPagePdf()
43
40
  self.collection_images: CollectionImages = CollectionImages([], lib_img=lib_img)
44
41
  self.collection_images.set_pbar(self.progress)
45
42
  self.collection_pages.set_pbar(self.progress)
@@ -132,25 +129,25 @@ class PdfStream(object):
132
129
  return _doc
133
130
 
134
131
  def thresold(self, *, land_scape: bool = False, a4: bool = False) -> DocumentPdf:
135
- if self.collection_images.length == 0:
136
- images: list[ImageObject] = []
137
- else:
138
- images: list[ImageObject] = self.collection_images.copy()
139
132
 
140
133
  if not self.collection_pages.is_empty:
141
134
  # Converter as páginas PDF em imagens.
142
135
  conv_pdf_to_img: ConvertPdfToImages = self.convert_pdf_to_images
143
- images.extend(
144
- conv_pdf_to_img.to_images(dpi=self.dpi, lib_image=self.lib_img),
145
- )
146
- if len(images) == 0:
136
+ _images: list[ImageObject] = conv_pdf_to_img.to_images(dpi=self.dpi, lib_image=self.lib_img)
137
+ _collection = CollectionImages(_images)
138
+ else:
139
+ _collection = CollectionImages()
140
+
141
+ if self.collection_images.length > 0:
142
+ _collection.add_images(self.collection_images)
143
+ if _collection.length == 0:
147
144
  raise ValueError('Adicione imagens para prosseguir!')
148
- if land_scape:
149
- for img in images:
150
- img.set_landscape()
151
- for i in images:
152
- i.set_threshold_gray()
153
- conv_img_to_pdf = ConvertImageToPdf(CollectionImages(images), lib_img_to_pdf=self.lib_img_to_pdf)
145
+
146
+ for num, i in enumerate(_collection):
147
+ if land_scape:
148
+ _collection[num].set_landscape()
149
+ _collection[num].set_threshold_black(max_value=255)
150
+ conv_img_to_pdf = ConvertImageToPdf(_collection, lib_img_to_pdf=self.lib_img_to_pdf)
154
151
  return conv_img_to_pdf.to_document(a4=a4)
155
152
 
156
153
  def to_files_images(
@@ -163,7 +160,7 @@ class PdfStream(object):
163
160
  raise ValueError('Adicione imagens e/ou documentos para prosseguir!')
164
161
  self.progress.start()
165
162
 
166
- image_stream = ImageStream([])
163
+ image_stream = ImageStream()
167
164
  image_stream.set_pbar(self.progress)
168
165
  if not self.collection_images.is_empty:
169
166
  image_stream.add_images(self.collection_images)
@@ -4,17 +4,16 @@
4
4
  Módulo para trabalhar com imagens
5
5
  """
6
6
  from __future__ import annotations
7
-
8
7
  import os.path
9
8
  from typing import Union
10
9
  from abc import ABC, abstractmethod
11
- from soup_files import File, Directory, InputFiles, LibraryDocs, ProgressBarAdapter
10
+ from soup_files import File, Directory, InputFiles, LibraryDocs, ProgressBarAdapter, TextProgress
12
11
  from io import BytesIO
13
12
  import numpy as np
14
13
  from scipy.ndimage import uniform_filter
15
14
  from sheet_stream.type_utils import get_hash_from_bytes, MetaDataFile, MetaDataItem
16
- from convert_stream.mod_types.enums import LibImage, RotationAngle
17
- from convert_stream.mod_types.table_types import ListItems
15
+ from convert_stream.mod_types.enums import RotationAngle
16
+ from sheet_stream import ListItems
18
17
  from convert_stream.mod_types.modules import (
19
18
  MOD_IMG_PIL, ModuleImage, DEFAULT_LIB_IMAGE,
20
19
  cv2, MatLike, Image, ImageFilter, LibImage
@@ -500,16 +499,28 @@ class ImageObject(object):
500
499
 
501
500
  class CollectionImages(ListItems):
502
501
 
503
- def __init__(self, images: list[ImageObject], *, lib_img: LibImage = LibImage.OPENCV) -> None:
502
+ def __init__(self, images: list[ImageObject] = None, *, lib_img: LibImage = LibImage.OPENCV) -> None:
504
503
  """
505
504
  Gerir uma lista de Imagens
506
505
  :type images: list[ImageObject]
507
506
  """
508
507
  super().__init__(images)
509
508
  self.lib_img: LibImage = lib_img
510
- self.pbar: ProgressBarAdapter = ProgressBarAdapter()
509
+ self.__pbar: TextProgress = TextProgress()
510
+ self.set_list_type(ImageObject)
511
511
  self.__count: int = 0
512
512
 
513
+ @property
514
+ def pbar(self) -> ProgressBarAdapter:
515
+ return self.__pbar.pbar
516
+
517
+ @pbar.setter
518
+ def pbar(self, pbar: ProgressBarAdapter) -> None:
519
+ self.__pbar.pbar = pbar
520
+
521
+ def set_list_type(self, cls_type=object):
522
+ super().set_list_type(ImageObject)
523
+
513
524
  def clear(self) -> None:
514
525
  super().clear()
515
526
  self.__count = 0
@@ -533,12 +544,12 @@ class CollectionImages(ListItems):
533
544
 
534
545
  def add_files_image(self, files: list[File]) -> None:
535
546
  self.pbar.start()
536
- max_num: int = len(files)
547
+ self.__pbar.total = len(files)
548
+ self.__pbar.start = 0
549
+ self.__pbar.text = 'Adicionando imagem'
550
+
537
551
  for num, f in enumerate(files):
538
- self.pbar.update(
539
- ((num+1) / max_num) * 100,
540
- f'Adicionando imagem: [{num+1} de {max_num}]'
541
- )
552
+ self.__pbar.set_update()
542
553
  self.append(ImageObject.create_from_file(f, lib_image=self.lib_img))
543
554
  self.pbar.stop()
544
555
 
@@ -559,7 +570,7 @@ class CollectionImages(ListItems):
559
570
  max_num = self.length
560
571
  img: ImageObject
561
572
  for n, img in enumerate(self):
562
- if img.metadata.file_path is not None:
573
+ if (img.metadata.file_path is not None) and (img.metadata.file_path != ''):
563
574
  filename = f'{os.path.basename(img.metadata.file_path)}-{n}.png'
564
575
  else:
565
576
  filename = f'{img.metadata.name}-{n}.png'
@@ -611,9 +622,9 @@ class ProcessImageScanner(object):
611
622
 
612
623
  def select_doc(self) -> ImageObject | None:
613
624
  """
614
- Detecta e recorta automaticamente a área do documento principal
615
- (texto ou folha digitalizada) em uma imagem.
616
- Retorna um novo ImageObject contendo apenas o recorte detectado.
625
+ Deteta e recorta automaticamente a área do documento principal
626
+ (texto ou folha digitalizada) em imagem.
627
+ Retorna um novo ImageObject contendo apenas o recorte detetado.
617
628
  """
618
629
  # Converte para matriz OpenCV
619
630
  img_cv: np.ndarray = cv2.imdecode(self.image.to_numpy(), cv2.IMREAD_COLOR)
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env python3
2
+
3
+ from __future__ import annotations
4
+ from .enums import (
5
+ RotationAngle, LibImage, LibPdfToImage, LibPDF, LibImageToPdf
6
+ )
7
+
8
+ __all__ = [
9
+ 'RotationAngle', 'LibPDF',
10
+ 'LibImageToPdf', 'LibPdfToImage', 'LibImage',
11
+ ]
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env python3
2
+ from enum import Enum
3
+
4
+
5
+ class LibPdfToImage(Enum):
6
+ """Enumerar as bibliotecas externas que convertem PDF em imagem"""
7
+ PDF_TO_IMG_FITZ = 'fitz'
8
+ NOT_IMPLEMENTED = 'null'
9
+
10
+
11
+ class LibImageToPdf(Enum):
12
+
13
+ IMAGE_TO_PDF_FITZ = 'fitz'
14
+ IMAGE_TO_PDF_CANVAS = 'canvas'
15
+ IMAGE_TO_PDF_PIL = 'pil'
16
+ NOT_IMPLEMENTED = 'null'
17
+
18
+
19
+ class LibPDF(Enum):
20
+
21
+ PYPDF = 'pypdf'
22
+ FITZ = 'fitz'
23
+ NOT_IMPLEMENTED = 'null'
24
+
25
+
26
+ class LibImage(Enum):
27
+
28
+ PIL = 'pil'
29
+ OPENCV = 'opencv'
30
+ NOT_IMPLEMENTED = 'null'
31
+
32
+
33
+ class RotationAngle(Enum):
34
+
35
+ ROTATION_90 = 90
36
+ ROTATION_180 = 180
37
+ ROTATION_270 = 270
@@ -29,15 +29,15 @@ try:
29
29
  from cv2.typing import MatLike
30
30
  MOD_IMG_OPENCV = True
31
31
  except ImportError:
32
- MatLike = FakeType
32
+ MatLike = object
33
33
 
34
34
  try:
35
35
  from PIL import Image
36
36
  from PIL import ImageOps, ImageFilter
37
37
  MOD_IMG_PIL = True
38
38
  except ImportError:
39
- Image = FakeType
40
- Image.Image = FakeType
39
+ Image = object
40
+ Image.Image = object
41
41
 
42
42
  if MOD_IMG_OPENCV and MOD_IMG_PIL:
43
43
  ModuleImage: TypeAlias = Union[MatLike, Image.Image]
@@ -50,7 +50,7 @@ elif MOD_IMG_PIL:
50
50
  DEFAULT_LIB_IMAGE = LibImage.PIL
51
51
  else:
52
52
  DEFAULT_LIB_IMAGE = LibImage.NOT_IMPLEMENTED
53
- ModuleImage = FakeType
53
+ ModuleImage: TypeAlias = Union[MatLike, Image]
54
54
 
55
55
  #=================================================================#
56
56
  # Módulos para PDF fitz e pypdf
@@ -90,8 +90,8 @@ elif MOD_PYPDF:
90
90
  ModDocPdf = Union[PdfWriter]
91
91
  DEFAULT_LIB_PDF = LibPDF.PYPDF
92
92
  else:
93
- ModPagePdf = FakeType # fallback para runtime
94
- ModDocPdf = FakeType
93
+ ModPagePdf = Union[PageObject, fitz.Page]
94
+ ModDocPdf = Union[fitz.Document, PdfWriter]
95
95
  DEFAULT_LIB_PDF = LibPDF.NOT_IMPLEMENTED
96
96
 
97
97
  #=================================================================#
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env python3
2
+ from .pdf_page import PageDocumentPdf
3
+ from .pdf_document import (
4
+ DocumentPdf, CollectionPagePdf, SearchableTextPdf, ABCDocument,
5
+ MOD_FITZ, MOD_PYPDF, ModDocPdf,
6
+ )
7
+
8
+ __all__ = [
9
+ 'DocumentPdf', 'CollectionPagePdf', 'PageDocumentPdf',
10
+ 'SearchableTextPdf', 'ModDocPdf', 'ABCDocument', 'MOD_PYPDF', 'MOD_FITZ',
11
+ ]
12
+
@@ -9,14 +9,10 @@ from io import BytesIO
9
9
  from typing import Union
10
10
  import pandas as pd
11
11
  from soup_files import File, Directory, LibraryDocs, InputFiles, ProgressBarAdapter, JsonConvert
12
- from sheet_stream.type_utils import (
13
- get_hash_from_bytes, MetaDataFile, MetaDataItem
12
+ from sheet_stream import (
13
+ ListItems, HeadCell, HeadValues, ColumnsTable, TableDocuments, ListColumnBody, ListString,
14
+ MetaDataItem, MetaDataFile, get_hash_from_bytes,
14
15
  )
15
-
16
- from sheet_stream.type_utils import (
17
- ListItems, HeadCell, HeadValues, ColumnsTable, concat_table_documents, TableDocuments
18
- )
19
- from convert_stream.mod_types.table_types import DictTextTable, ColumnBody
20
16
  from convert_stream.mod_types.enums import LibPDF
21
17
  from convert_stream.mod_types.modules import (
22
18
  DEFAULT_LIB_PDF, ModDocPdf, PdfWriter, PdfReader, fitz, MOD_FITZ, MOD_PYPDF
@@ -25,6 +21,33 @@ from convert_stream.pdf.pdf_page import PageDocumentPdf
25
21
  from convert_stream.text import show_warning, FindText
26
22
 
27
23
 
24
+ def concat_table(list_map: list[TableDocuments]) -> TableDocuments:
25
+ if len(list_map) < 1:
26
+ return TableDocuments.create_void_dict()
27
+ _columns: HeadValues = list_map[0].columns
28
+ list_values: list[ListColumnBody] = []
29
+ col: ListColumnBody
30
+ i: HeadCell
31
+ # Criar colunas vazias
32
+ for i in _columns:
33
+ list_values.append(
34
+ ListColumnBody(i, ListString([]))
35
+ )
36
+ text_table: TableDocuments
37
+ # Adicionar os valores as colunas/tabelas
38
+ for text_table in list_map:
39
+ for col in list_values:
40
+ col.extend(
41
+ text_table[col.col_name]
42
+ )
43
+ final_tb = TableDocuments(list_values)
44
+ column_keys = final_tb.get_column(ColumnsTable.KEY)
45
+ for n, v in enumerate(column_keys):
46
+ column_keys[n] = f'{n}'
47
+ final_tb[ColumnsTable.KEY] = column_keys
48
+ return final_tb
49
+
50
+
28
51
  class SearchableTextPdf(object):
29
52
  """
30
53
 
@@ -43,7 +66,7 @@ class SearchableTextPdf(object):
43
66
  """
44
67
  def __init__(self, silent: bool = False):
45
68
  self.silent = silent
46
- self.elements: dict[str, ColumnBody] = DictTextTable.create_void_dict()
69
+ self.elements: TableDocuments = TableDocuments.create_void_dict()
47
70
 
48
71
  def __repr__(self):
49
72
  return f'SearchableTextPdf: {self.elements}'
@@ -194,9 +217,9 @@ class ImplementDocumentFitz(ABCDocument):
194
217
  """
195
218
  Implementação usando a biblioteca fitz.
196
219
  """
197
- def __init__(self, mod_doc_pdf: ModDocPdf):
220
+ def __init__(self, mod_doc_pdf: fitz.Document):
198
221
  super().__init__(mod_doc_pdf)
199
- self.mod_doc_pdf: ModDocPdf = mod_doc_pdf
222
+ self.mod_doc_pdf: fitz.Document = mod_doc_pdf
200
223
  self.lib_pdf: LibPDF = LibPDF.FITZ
201
224
 
202
225
  def lenght(self) -> int:
@@ -534,7 +557,7 @@ class DocumentPdf(object):
534
557
  show_warning(f'{e}')
535
558
  return _values
536
559
 
537
- def _create_map(self, page: PageDocumentPdf, *, separator: str = '\n') -> DictTextTable:
560
+ def _create_map(self, page: PageDocumentPdf, *, separator: str = '\n') -> TableDocuments:
538
561
  """
539
562
  @rtype: pd.DataFrame
540
563
  """
@@ -545,7 +568,7 @@ class DocumentPdf(object):
545
568
  _values = txt_page.split(separator)
546
569
 
547
570
  if not self.metadata.file_path.is_empty:
548
- return DictTextTable.create_from_values(
571
+ return TableDocuments.create_from_values(
549
572
  _values,
550
573
  page_num=f'{page.number_page}',
551
574
  file_type='.pdf',
@@ -553,7 +576,7 @@ class DocumentPdf(object):
553
576
  dir_path=self.metadata.dir_path,
554
577
  )
555
578
  else:
556
- return DictTextTable.create_from_values(
579
+ return TableDocuments.create_from_values(
557
580
  _values,
558
581
  page_num=f'{page.number_page}',
559
582
  file_type='.pdf',
@@ -562,15 +585,16 @@ class DocumentPdf(object):
562
585
  )
563
586
 
564
587
  def to_dict(self, separator: str = '\n') -> TableDocuments:
565
- list_data: list[DictTextTable] = []
588
+ list_data: list[TableDocuments] = []
566
589
  pages: list[PageDocumentPdf] = self.to_pages()
567
590
 
591
+ _mp: TableDocuments
568
592
  for page_pdf in pages:
569
- _mp: DictTextTable = self._create_map(page_pdf, separator=separator)
593
+ _mp = self._create_map(page_pdf, separator=separator)
570
594
  list_data.append(_mp)
571
595
  if len(list_data) == 0:
572
- return DictTextTable.create_void_dict()
573
- return concat_table_documents(list_data)
596
+ return TableDocuments.create_void_dict()
597
+ return concat_table(list_data)
574
598
 
575
599
  def to_data(self, separator: str = '\n') -> pd.DataFrame:
576
600
  return pd.DataFrame.from_dict(self.to_dict(separator=separator))
@@ -685,9 +709,10 @@ class CollectionPagePdf(ListItems):
685
709
  """
686
710
  Gerir uma coleção de páginas PDF.
687
711
  """
688
- def __init__(self, pages: list[PageDocumentPdf]) -> None:
712
+ def __init__(self, pages: list[PageDocumentPdf] = None) -> None:
689
713
  super().__init__(pages)
690
714
  self.pbar: ProgressBarAdapter = ProgressBarAdapter()
715
+ self.set_list_type(PageDocumentPdf)
691
716
 
692
717
  @property
693
718
  def name(self) -> str | None:
@@ -695,6 +720,9 @@ class CollectionPagePdf(ListItems):
695
720
  return None
696
721
  return self[0].__hash__()
697
722
 
723
+ def set_list_type(self, cls_type=PageDocumentPdf):
724
+ super().set_list_type(PageDocumentPdf)
725
+
698
726
  def set_pbar(self, p: ProgressBarAdapter):
699
727
  self.pbar = p
700
728
 
@@ -6,11 +6,8 @@
6
6
  from __future__ import annotations
7
7
  from abc import ABC, abstractmethod
8
8
  import pandas as pd
9
-
9
+ from sheet_stream import ListString, TableDocuments
10
10
  from convert_stream.mod_types.enums import LibPDF
11
- from convert_stream.mod_types.table_types import (
12
- DictTextTable, ListString
13
- )
14
11
  from convert_stream.mod_types.modules import (
15
12
  ModPagePdf, PageObject, fitz
16
13
  )
@@ -230,10 +227,16 @@ class PageDocumentPdf(object):
230
227
  return ListString([])
231
228
  return ListString(txt.split(separator))
232
229
 
233
- def to_dict(self, separator: str = '\n') -> DictTextTable:
230
+ def to_dict(self, separator: str = '\n') -> TableDocuments:
231
+ """
232
+ Converte o texto da página em tabela/dicionário
233
+ """
234
234
  _values = self.to_list(separator)
235
- return DictTextTable.create_from_values(
236
- _values, page_num=f'{self.number_page}', file_type='.pdf'
235
+ return TableDocuments.create_from_values(
236
+ _values,
237
+ page_num=f'{self.number_page}',
238
+ file_type='.pdf',
239
+ file_path=self.metadata.file_path
237
240
  )
238
241
 
239
242
  def to_map(self, separator: str = '\n') -> pd.DataFrame:
@@ -246,9 +249,9 @@ class PageDocumentPdf(object):
246
249
  fd = FindText(self.to_string(), separator=separator)
247
250
  return fd.find(text, iqual=iqual, case=case)
248
251
 
249
- def find_all(self, text: str, *, separator: str = '\n', iqual: bool = False, case: bool = True) -> list[str]:
252
+ def find_all(self, text: str, *, separator: str = '\n', iqual: bool = False, case: bool = True) -> ListString:
250
253
  fd = FindText(self.to_string(), separator=separator)
251
- return fd.find_all(text, iqual=iqual, case=case)
254
+ return ListString(fd.find_all(text, iqual=iqual, case=case))
252
255
 
253
256
  def get_width(self) -> float:
254
257
  return self.implement_page_pdf.get_width()
@@ -3,12 +3,11 @@
3
3
  from __future__ import annotations
4
4
  from io import BytesIO
5
5
  from soup_files import File, Directory, InputFiles, LibraryDocs
6
-
7
6
  from convert_stream import PageDocumentPdf
8
7
  from convert_stream.text.find_text import FindText
9
8
  from convert_stream.pdf.pdf_document import SearchableTextPdf, DocumentPdf
10
- from convert_stream.mod_types.table_types import ColumnsTable
11
9
  from convert_stream.image import ImageObject
10
+ from sheet_stream import ColumnsTable, TableDocuments
12
11
 
13
12
 
14
13
  class PdfFinder(object):
@@ -8,4 +8,5 @@ from sheet_stream import ConvertStringDate, fmt_col_to_date
8
8
  __all__ = [
9
9
  'ConvertStringDate', 'print_title', 'print_line', 'fmt_col_to_date',
10
10
  'show_info', 'Colors', 'show_error', 'show_warning', 'FindText',
11
+ 'FindStrings',
11
12
  ]
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: convert_stream
3
- Version: 2.4.3
3
+ Version: 2.5
4
4
  Summary: Manipulação de documentos PDF e Imagens. Converter, Ler, rotacionar exportar etc.
5
5
  Author: Bruno Chaves
6
6
  Requires-Python: >=3.11
7
7
  Description-Content-Type: text/markdown
8
- Requires-Dist: soup_files>=1.4
8
+ Requires-Dist: soup_files>=1.4.2
9
9
  Requires-Dist: PyMuPDF
10
10
  Requires-Dist: scipy
11
11
  Requires-Dist: reportlab
@@ -15,7 +15,7 @@ Requires-Dist: pandas
15
15
  Requires-Dist: Pillow>=11.3.0
16
16
  Requires-Dist: opencv-python
17
17
  Requires-Dist: requests>=2.32.4
18
- Requires-Dist: sheet_stream
18
+ Requires-Dist: sheet_stream>=0.1.3
19
19
 
20
20
  # Configuração instalação:
21
21
  pip3 install -r requirements.txt
@@ -15,12 +15,9 @@ convert_stream/image/img_object.py
15
15
  convert_stream/mod_types/__init__.py
16
16
  convert_stream/mod_types/enums.py
17
17
  convert_stream/mod_types/modules.py
18
- convert_stream/mod_types/table_types.py
19
18
  convert_stream/pdf/__init__.py
20
- convert_stream/pdf/image_to_pdf.py
21
19
  convert_stream/pdf/pdf_document.py
22
20
  convert_stream/pdf/pdf_page.py
23
- convert_stream/pdf/pdf_to_image.py
24
21
  convert_stream/text/__init__.py
25
22
  convert_stream/text/find_text.py
26
23
  convert_stream/text/terminal.py
@@ -1,4 +1,4 @@
1
- soup_files>=1.4
1
+ soup_files>=1.4.2
2
2
  PyMuPDF
3
3
  scipy
4
4
  reportlab
@@ -8,4 +8,4 @@ pandas
8
8
  Pillow>=11.3.0
9
9
  opencv-python
10
10
  requests>=2.32.4
11
- sheet_stream
11
+ sheet_stream>=0.1.3
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "convert_stream"
7
- version = "2.4.3"
7
+ version = "2.5"
8
8
  authors = [
9
9
  { name="Bruno Chaves"},
10
10
  ]
@@ -14,7 +14,7 @@ readme = "README.md"
14
14
  requires-python = ">=3.11"
15
15
 
16
16
  dependencies = [
17
- "soup_files>=1.4",
17
+ "soup_files>=1.4.2",
18
18
  "PyMuPDF",
19
19
  "scipy",
20
20
  "reportlab",
@@ -24,7 +24,7 @@ dependencies = [
24
24
  "Pillow>=11.3.0",
25
25
  "opencv-python",
26
26
  "requests>=2.32.4",
27
- "sheet_stream",
27
+ "sheet_stream>=0.1.3",
28
28
  ]
29
29
 
30
30
  [tool.setuptools]
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env python3
2
- #
3
- from __future__ import annotations
4
- from .enums import (
5
- RotationAngle, ColumnsTable, LibImage, LibPdfToImage, LibPDF, LibImageToPdf
6
- )
7
- from .table_types import DictTextTable
8
-
9
-
10
- __all__ = [
11
- 'DictTextTable', 'RotationAngle', 'LibPDF',
12
- 'LibImageToPdf', 'LibPdfToImage', 'LibImage',
13
- ]