MCPcopy Index your code
hub / github.com/clips/pattern / PDFPage

Class PDFPage

pattern/web/pdf/pdfparser.py:224–276  ·  view source on GitHub ↗

An object that holds the information about a page. A PDFPage object is merely a convenience class that has a set of keys and values, which describe the properties of a page and point to its contents. Attributes: doc: a PDFDocument object. pageid: any Python object that

Source from the content-addressed store, hash-verified

222## PDFPage
223##
224class PDFPage(object):
225
226 """An object that holds the information about a page.
227
228 A PDFPage object is merely a convenience class that has a set
229 of keys and values, which describe the properties of a page
230 and point to its contents.
231
232 Attributes:
233 doc: a PDFDocument object.
234 pageid: any Python object that can uniquely identify the page.
235 attrs: a dictionary of page attributes.
236 contents: a list of PDFStream objects that represents the page content.
237 lastmod: the last modified time of the page.
238 resources: a list of resources used by the page.
239 mediabox: the physical size of the page.
240 cropbox: the crop rectangle of the page.
241 rotate: the page rotation (in degree).
242 annots: the page annotations.
243 beads: a chain that represents natural reading order.
244 """
245
246 def __init__(self, doc, pageid, attrs):
247 """Initialize a page object.
248
249 doc: a PDFDocument object.
250 pageid: any Python object that can uniquely identify the page.
251 attrs: a dictionary of page attributes.
252 """
253 self.doc = doc
254 self.pageid = pageid
255 self.attrs = dict_value(attrs)
256 self.lastmod = resolve1(self.attrs.get('LastModified'))
257 self.resources = resolve1(self.attrs['Resources'])
258 self.mediabox = resolve1(self.attrs['MediaBox'])
259 if 'CropBox' in self.attrs:
260 self.cropbox = resolve1(self.attrs['CropBox'])
261 else:
262 self.cropbox = self.mediabox
263 self.rotate = (self.attrs.get('Rotate', 0)+360) % 360
264 self.annots = self.attrs.get('Annots')
265 self.beads = self.attrs.get('B')
266 if 'Contents' in self.attrs:
267 contents = resolve1(self.attrs['Contents'])
268 else:
269 contents = []
270 if not isinstance(contents, list):
271 contents = [ contents ]
272 self.contents = contents
273 return
274
275 def __repr__(self):
276 return '<PDFPage: Resources=%r, MediaBox=%r>' % (self.resources, self.mediabox)
277
278
279## PDFDocument

Callers 1

get_pagesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…