MCPcopy
hub / github.com/ArtifexSoftware/pdf2docx / Page

Class Page

pdf2docx/page/Page.py:51–211  ·  view source on GitHub ↗

Object representing the whole page, e.g. margins, sections.

Source from the content-addressed store, hash-verified

49
50
51class Page(BasePage):
52 '''Object representing the whole page, e.g. margins, sections.'''
53
54 def __init__(self, id:int=-1,
55 skip_parsing:bool=True,
56 width:float=0.0,
57 height:float=0.0,
58 header:str=None,
59 footer:str=None,
60 margin:tuple=None,
61 sections:Sections=None,
62 float_images:BaseCollection=None):
63 '''Initialize page layout.
64
65 Args:
66 id (int, optional): Page index. Defaults to -1.
67 skip_parsing (bool, optional): Don't parse page if True. Defaults to True.
68 width (float, optional): Page width. Defaults to 0.0.
69 height (float, optional): Page height. Defaults to 0.0.
70 header (str, optional): Page header. Defaults to None.
71 footer (str, optional): Page footer. Defaults to None.
72 margin (tuple, optional): Page margin. Defaults to None.
73 sections (Sections, optional): Page contents. Defaults to None.
74 float_images (BaseCollection, optional): Float images in th is page. Defaults to None.
75 '''
76 # page index
77 self.id = id
78 self.skip_parsing = skip_parsing
79
80 # page size and margin
81 super().__init__(width=width, height=height, margin=margin)
82
83 # flow structure:
84 # Section -> Column -> Blocks -> TextBlock/TableBlock
85 # TableBlock -> Row -> Cell -> Blocks
86 self.sections = sections or Sections(parent=self)
87
88 # page header, footer
89 self.header = header or ''
90 self.footer = footer or ''
91
92 # floating images are separate node under page
93 self.float_images = float_images or BaseCollection()
94
95 self._finalized = False
96
97
98 @property
99 def finalized(self): return self._finalized
100
101
102 def store(self):
103 '''Store parsed layout in dict format.'''
104 res = {
105 'id' : self.id,
106 'width' : self.width,
107 'height' : self.height,
108 'margin' : self.margin,

Callers 2

load_pagesMethod · 0.90
restoreMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…