INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Return unit vector of a point. | def unit(self):
"""Return unit vector of a point."""
s = self.x * self.x + self.y * self.y
if s < 1e-5:
return Point(0,0)
s = math.sqrt(s)
return Point(self.x / s, self.y / s) |
Return unit vector of a point with positive coordinates. | def abs_unit(self):
"""Return unit vector of a point with positive coordinates."""
s = self.x * self.x + self.y * self.y
if s < 1e-5:
return Point(0,0)
s = math.sqrt(s)
return Point(abs(self.x) / s, abs(self.y) / s) |
Return the distance to a rectangle or another point. | def distance_to(self, *args):
"""Return the distance to a rectangle or another point."""
if not len(args) > 0:
raise ValueError("at least one parameter must be given")
x = args[0]
if len(args) > 1:
unit = args[1]
else:
unit = "px"
u = ... |
Replace rectangle with its finite version. | def normalize(self):
"""Replace rectangle with its finite version."""
if self.x1 < self.x0:
self.x0, self.x1 = self.x1, self.x0
if self.y1 < self.y0:
self.y0, self.y1 = self.y1, self.y0
return self |
Check if rectangle area is empty. | def isEmpty(self):
"""Check if rectangle area is empty."""
return self.x0 == self.x1 or self.y0 == self.y1 |
Check if rectangle is infinite. | def isInfinite(self):
"""Check if rectangle is infinite."""
return self.x0 > self.x1 or self.y0 > self.y1 |
Extend rectangle to include point p. | def includePoint(self, p):
"""Extend rectangle to include point p."""
if not len(p) == 2:
raise ValueError("bad sequ. length")
self.x0, self.y0, self.x1, self.y1 = TOOLS._include_point_in_rect(self, p)
return self |
Extend rectangle to include rectangle r. | def includeRect(self, r):
"""Extend rectangle to include rectangle r."""
if not len(r) == 4:
raise ValueError("bad sequ. length")
self.x0, self.y0, self.x1, self.y1 = TOOLS._union_rect(self, r)
return self |
Restrict self to common area with rectangle r. | def intersect(self, r):
"""Restrict self to common area with rectangle r."""
if not len(r) == 4:
raise ValueError("bad sequ. length")
self.x0, self.y0, self.x1, self.y1 = TOOLS._intersect_rect(self, r)
return self |
Replace rectangle with its transformation by matrix m. | def transform(self, m):
"""Replace rectangle with its transformation by matrix m."""
if not len(m) == 6:
raise ValueError("bad sequ. length")
self.x0, self.y0, self.x1, self.y1 = TOOLS._transform_rect(self, m)
return self |
Check if intersection with rectangle x is not empty. | def intersects(self, x):
"""Check if intersection with rectangle x is not empty."""
r1 = Rect(x)
if self.isEmpty or self.isInfinite or r1.isEmpty:
return False
r = Rect(self)
if r.intersect(r1).isEmpty:
return False
return True |
Check if quad is rectangular. | def isRectangular(self):
"""Check if quad is rectangular.
"""
# if any two of the 4 corners are equal return false
upper = (self.ur - self.ul).unit
if not bool(upper):
return False
right = (self.lr - self.ur).unit
if not bool(right):
return False
... |
Check if quad is empty retangle. If rectangular, we are done (not empty).
But all 4 points may still be on one line. We check this out here.
In that case all 3 lines connecting corners to ul will have same angle with
x-axis. | def isEmpty(self):
"""Check if quad is empty retangle. If rectangular, we are done (not empty).
But all 4 points may still be on one line. We check this out here.
In that case all 3 lines connecting corners to ul will have same angle with
x-axis.
"""
if self.isRectangular... |
Replace quad by its transformation with matrix m. | def transform(self, m):
"""Replace quad by its transformation with matrix m."""
if len(m) != 6:
raise ValueError("bad sequ. length")
self.ul *= m
self.ur *= m
self.ll *= m
self.lr *= m
return self |
Validate the class entries. | def _validate(self):
"""Validate the class entries.
"""
checker = (self._check0, self._check1, self._check2, self._check3,
self._check4, self._check5)
if not 0 <= self.field_type <= 5:
raise NotImplementedError("unsupported widget type")
if type(sel... |
Ensure the font name is from our list and correctly spelled. | def _adjust_font(self):
"""Ensure the font name is from our list and correctly spelled.
"""
fnames = [k for k in Widget_fontdict.keys()]
fl = list(map(str.lower, fnames))
if (not self.text_font) or self.text_font.lower() not in fl:
self.text_font = "helv"
i = ... |
Extract font name, size and color from default appearance string (/DA object). Equivalent to 'pdf_parse_default_appearance' function in MuPDF's 'pdf-annot.c'. | def _parse_da(self):
"""Extract font name, size and color from default appearance string (/DA object). Equivalent to 'pdf_parse_default_appearance' function in MuPDF's 'pdf-annot.c'.
"""
if not self._text_da:
return
font = "Helv"
fsize = 0
col = (0, 0, 0)
... |
close(self) | def close(self):
"""close(self)"""
if self.isClosed:
raise ValueError("operation illegal for closed doc")
if hasattr(self, '_outline') and self._outline:
self._dropOutline(self._outline)
self._outline = None
self._reset_page_refs()
self.metada... |
loadPage(self, number=0) -> Page | def loadPage(self, number=0):
"""loadPage(self, number=0) -> Page"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
val = _fitz.Document_loadPage(self, number)
if val:
val.thisown = True
val.par... |
Return number of embedded files. | def embeddedFileCount(self):
"""Return number of embedded files."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document_embeddedFileCount(self) |
Delete embedded file by name. | def embeddedFileDel(self, name):
"""Delete embedded file by name."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document_embeddedFileDel(self, name) |
Retrieve embedded file information given its entry number or name. | def embeddedFileInfo(self, id):
"""Retrieve embedded file information given its entry number or name."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document_embeddedFileInfo(self, id) |
Change an embedded file given its entry number or name. | def embeddedFileUpd(self, id, buffer=None, filename=None, ufilename=None, desc=None):
"""Change an embedded file given its entry number or name."""
return _fitz.Document_embeddedFileUpd(self, id, buffer, filename, ufilename, desc) |
Retrieve embedded file content by name or by number. | def embeddedFileGet(self, id):
"""Retrieve embedded file content by name or by number."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document_embeddedFileGet(self, id) |
Embed a new file. | def embeddedFileAdd(self, buffer, name, filename=None, ufilename=None, desc=None):
"""Embed a new file."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document_embeddedFileAdd(self, buffer, name, filename, ufi... |
Convert document to PDF selecting page range and optional rotation. Output bytes object. | def convertToPDF(self, from_page=0, to_page=-1, rotate=0):
"""Convert document to PDF selecting page range and optional rotation. Output bytes object."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document_conv... |
_getMetadata(self, key) -> char * | def _getMetadata(self, key):
"""_getMetadata(self, key) -> char *"""
if self.isClosed:
raise ValueError("operation illegal for closed doc")
return _fitz.Document__getMetadata(self, key) |
Re-layout a reflowable document. | def layout(self, rect=None, width=0, height=0, fontsize=11):
"""Re-layout a reflowable document."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
val = _fitz.Document_layout(self, rect, width, height, fontsize)
self._... |
Make page bookmark in a reflowable document. | def makeBookmark(self, pno=0):
"""Make page bookmark in a reflowable document."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document_makeBookmark(self, pno) |
Find page number after layouting a document. | def findBookmark(self, bookmark):
"""Find page number after layouting a document."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document_findBookmark(self, bookmark) |
Delete an object given its xref. | def _deleteObject(self, xref):
"""Delete an object given its xref."""
if self.isClosed:
raise ValueError("operation illegal for closed doc")
return _fitz.Document__deleteObject(self, xref) |
Decrypt document with a password. | def authenticate(self, password):
"""Decrypt document with a password."""
if self.isClosed:
raise ValueError("operation illegal for closed doc")
val = _fitz.Document_authenticate(self, password)
if val: # the doc is decrypted successfully and we init the outline
... |
save(self, filename, garbage=0, clean=0, deflate=0, incremental=0, ascii=0, expand=0, linear=0, pretty=0, decrypt=1) -> PyObject * | def save(self, filename, garbage=0, clean=0, deflate=0, incremental=0, ascii=0, expand=0, linear=0, pretty=0, decrypt=1):
"""save(self, filename, garbage=0, clean=0, deflate=0, incremental=0, ascii=0, expand=0, linear=0, pretty=0, decrypt=1) -> PyObject *"""
if self.isClosed or self.isEncrypted:
... |
Copy page range ['from', 'to'] of source PDF, starting as page number 'start_at'. | def insertPDF(self, docsrc, from_page=-1, to_page=-1, start_at=-1, rotate=-1, links=1):
"""Copy page range ['from', 'to'] of source PDF, starting as page number 'start_at'."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
if id... |
Write document to a bytes object. | def write(self, garbage=0, clean=0, deflate=0, ascii=0, expand=0, linear=0, pretty=0, decrypt=1):
"""Write document to a bytes object."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
if self.pageCount < 1:
raise V... |
_newPage(self, pno=-1, width=595, height=842) -> PyObject * | def _newPage(self, pno=-1, width=595, height=842):
"""_newPage(self, pno=-1, width=595, height=842) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
val = _fitz.Document__newPage(self, pno, width, height)
... |
Build sub-pdf with page numbers in 'list'. | def select(self, pyliste):
"""Build sub-pdf with page numbers in 'list'."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
val = _fitz.Document_select(self, pyliste)
self._reset_page_refs()
self.initData()
... |
Return list of glyphs and glyph widths of a font. | def _getCharWidths(self, xref, bfname, ext, ordering, limit, idx=0):
"""Return list of glyphs and glyph widths of a font."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document__getCharWidths(self, xref, bfname... |
_getPageObjNumber(self, pno) -> PyObject * | def _getPageObjNumber(self, pno):
"""_getPageObjNumber(self, pno) -> PyObject *"""
if self.isClosed:
raise ValueError("operation illegal for closed doc")
return _fitz.Document__getPageObjNumber(self, pno) |
Show fonts or images used on a page. | def _getPageInfo(self, pno, what):
"""Show fonts or images used on a page."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
val = _fitz.Document__getPageInfo(self, pno, what)
x = []
for v in val:
i... |
extractFont(self, xref=0, info_only=0) -> PyObject * | def extractFont(self, xref=0, info_only=0):
"""extractFont(self, xref=0, info_only=0) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document_extractFont(self, xref, info_only) |
Extract image which 'xref' is pointing to. | def extractImage(self, xref=0):
"""Extract image which 'xref' is pointing to."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document_extractImage(self, xref) |
_delToC(self) -> PyObject * | def _delToC(self):
"""_delToC(self) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
val = _fitz.Document__delToC(self)
self.initData()
return val |
_addFormFont(self, name, font) -> PyObject * | def _addFormFont(self, name, font):
"""_addFormFont(self, name, font) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document__addFormFont(self, name, font) |
_getOLRootNumber(self) -> PyObject * | def _getOLRootNumber(self):
"""_getOLRootNumber(self) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document__getOLRootNumber(self) |
_getNewXref(self) -> PyObject * | def _getNewXref(self):
"""_getNewXref(self) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document__getNewXref(self) |
_delXmlMetadata(self) -> PyObject * | def _delXmlMetadata(self):
"""_delXmlMetadata(self) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document__delXmlMetadata(self) |
_getXrefString(self, xref, compressed=1) -> PyObject * | def _getXrefString(self, xref, compressed=1):
"""_getXrefString(self, xref, compressed=1) -> PyObject *"""
if self.isClosed:
raise ValueError("operation illegal for closed doc")
return _fitz.Document__getXrefString(self, xref, compressed) |
_getTrailerString(self, compressed=1) -> PyObject * | def _getTrailerString(self, compressed=1):
"""_getTrailerString(self, compressed=1) -> PyObject *"""
if self.isClosed:
raise ValueError("operation illegal for closed doc")
return _fitz.Document__getTrailerString(self, compressed) |
_getXrefStream(self, xref) -> PyObject * | def _getXrefStream(self, xref):
"""_getXrefStream(self, xref) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document__getXrefStream(self, xref) |
_updateObject(self, xref, text, page=None) -> PyObject * | def _updateObject(self, xref, text, page=None):
"""_updateObject(self, xref, text, page=None) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document__updateObject(self, xref, text, page) |
_updateStream(self, xref=0, stream=None, new=0) -> PyObject * | def _updateStream(self, xref=0, stream=None, new=0):
"""_updateStream(self, xref=0, stream=None, new=0) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document__updateStream(self, xref, stream, new... |
_setMetadata(self, text) -> PyObject * | def _setMetadata(self, text):
"""_setMetadata(self, text) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document__setMetadata(self, text) |
Retrieve a list of fonts used on a page. | def getPageFontList(self, pno):
"""Retrieve a list of fonts used on a page.
"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
if self.isPDF:
return self._getPageInfo(pno, 1)
return [] |
Retrieve a list of images used on a page. | def getPageImageList(self, pno):
"""Retrieve a list of images used on a page.
"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
if self.isPDF:
return self._getPageInfo(pno, 2)
return [] |
Copy a page to before some other page of the document. Specify 'to = -1' to copy after last page. | def copyPage(self, pno, to=-1):
"""Copy a page to before some other page of the document. Specify 'to = -1' to copy after last page.
"""
pl = list(range(len(self)))
if pno < 0 or pno > pl[-1]:
raise ValueError("'from' page number out of range")
if to < -1 or to > pl[-... |
Move a page to before some other page of the document. Specify 'to = -1' to move after last page. | def movePage(self, pno, to = -1):
"""Move a page to before some other page of the document. Specify 'to = -1' to move after last page.
"""
pl = list(range(len(self)))
if pno < 0 or pno > pl[-1]:
raise ValueError("'from' page number out of range")
if to < -1 or to > pl... |
Delete a page from the document. First page is '0', last page is '-1'. | def deletePage(self, pno = -1):
"""Delete a page from the document. First page is '0', last page is '-1'.
"""
pl = list(range(len(self)))
if pno < -1 or pno > pl[-1]:
raise ValueError("page number out of range")
if pno >= 0:
pl.remove(pno)
else:
... |
Delete pages from the document. First page is '0', last page is '-1'. | def deletePageRange(self, from_page = -1, to_page = -1):
"""Delete pages from the document. First page is '0', last page is '-1'.
"""
pl = list(range(len(self)))
f = from_page
t = to_page
if f == -1:
f = pl[-1]
if t == -1:
t = pl[-1]
... |
Remove a page from document page dict. | def _forget_page(self, page):
"""Remove a page from document page dict."""
pid = id(page)
if pid in self._page_refs:
self._page_refs[pid] = None |
Invalidate all pages in document dictionary. | def _reset_page_refs(self):
"""Invalidate all pages in document dictionary."""
if self.isClosed:
return
for page in self._page_refs.values():
if page:
page._erase()
page = None
self._page_refs.clear() |
bound(self) -> PyObject * | def bound(self):
"""bound(self) -> PyObject *"""
CheckParent(self)
val = _fitz.Page_bound(self)
val = Rect(val)
return val |
run(self, dw, m) -> PyObject * | def run(self, dw, m):
"""run(self, dw, m) -> PyObject *"""
CheckParent(self)
return _fitz.Page_run(self, dw, m) |
Add 'Line' annot for points p1 and p2. | def addLineAnnot(self, p1, p2):
"""Add 'Line' annot for points p1 and p2."""
CheckParent(self)
val = _fitz.Page_addLineAnnot(self, p1, p2)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
return val |
Add a 'sticky note' at position 'point'. | def addTextAnnot(self, point, text):
"""Add a 'sticky note' at position 'point'."""
CheckParent(self)
val = _fitz.Page_addTextAnnot(self, point, text)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
... |
Add a 'handwriting' as a list of list of point-likes. Each sublist forms an independent stroke. | def addInkAnnot(self, list):
"""Add a 'handwriting' as a list of list of point-likes. Each sublist forms an independent stroke."""
CheckParent(self)
val = _fitz.Page_addInkAnnot(self, list)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
s... |
Add a 'rubber stamp' in a rectangle. | def addStampAnnot(self, rect, stamp=0):
"""Add a 'rubber stamp' in a rectangle."""
CheckParent(self)
val = _fitz.Page_addStampAnnot(self, rect, stamp)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
... |
Add a 'FileAttachment' annotation at location 'point'. | def addFileAnnot(self, point, buffer, filename, ufilename=None, desc=None):
"""Add a 'FileAttachment' annotation at location 'point'."""
CheckParent(self)
val = _fitz.Page_addFileAnnot(self, point, buffer, filename, ufilename, desc)
if not val: return
val.thisown = True
... |
Strike out content in a rectangle or quadrilateral. | def addStrikeoutAnnot(self, rect):
"""Strike out content in a rectangle or quadrilateral."""
CheckParent(self)
val = _fitz.Page_addStrikeoutAnnot(self, rect)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
... |
Underline content in a rectangle or quadrilateral. | def addUnderlineAnnot(self, rect):
"""Underline content in a rectangle or quadrilateral."""
CheckParent(self)
val = _fitz.Page_addUnderlineAnnot(self, rect)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
... |
Wavy underline content in a rectangle or quadrilateral. | def addSquigglyAnnot(self, rect):
"""Wavy underline content in a rectangle or quadrilateral."""
CheckParent(self)
val = _fitz.Page_addSquigglyAnnot(self, rect)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val... |
Highlight content in a rectangle or quadrilateral. | def addHighlightAnnot(self, rect):
"""Highlight content in a rectangle or quadrilateral."""
CheckParent(self)
val = _fitz.Page_addHighlightAnnot(self, rect)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
... |
Add a 'Rectangle' annotation. | def addRectAnnot(self, rect):
"""Add a 'Rectangle' annotation."""
CheckParent(self)
val = _fitz.Page_addRectAnnot(self, rect)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
return val |
Add a 'Circle' annotation. | def addCircleAnnot(self, rect):
"""Add a 'Circle' annotation."""
CheckParent(self)
val = _fitz.Page_addCircleAnnot(self, rect)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
return val |
Add a 'Polyline' annotation for a sequence of points. | def addPolylineAnnot(self, points):
"""Add a 'Polyline' annotation for a sequence of points."""
CheckParent(self)
val = _fitz.Page_addPolylineAnnot(self, points)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = v... |
Add a 'Polygon' annotation for a sequence of points. | def addPolygonAnnot(self, points):
"""Add a 'Polygon' annotation for a sequence of points."""
CheckParent(self)
val = _fitz.Page_addPolygonAnnot(self, points)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
... |
Add a 'FreeText' annotation in rectangle 'rect'. | def addFreetextAnnot(self, rect, text, fontsize=12, fontname=None, color=None, rotate=0):
"""Add a 'FreeText' annotation in rectangle 'rect'."""
CheckParent(self)
val = _fitz.Page_addFreetextAnnot(self, rect, text, fontsize, fontname, color, rotate)
if not val: return
val.thiso... |
Add a form field. | def addWidget(self, widget):
"""Add a form field.
"""
CheckParent(self)
doc = self.parent
if not doc.isPDF:
raise ValueError("not a PDF")
widget._validate()
# Check if PDF already has our fonts.
# If none insert all of them in a new object and store t... |
loadLinks(self) -> Link | def loadLinks(self):
"""loadLinks(self) -> Link"""
CheckParent(self)
val = _fitz.Page_loadLinks(self)
if val:
val.thisown = True
val.parent = weakref.proxy(self) # owning page object
self._annot_refs[id(val)] = val
if self.parent.isPDF:
... |
Points to first annotation on page | def firstAnnot(self):
"""Points to first annotation on page"""
CheckParent(self)
val = _fitz.Page_firstAnnot(self)
if val:
val.thisown = True
val.parent = weakref.proxy(self) # owning page object
self._annot_refs[id(val)] = val
return val |
Delete annot if PDF and return next one | def deleteAnnot(self, fannot):
"""Delete annot if PDF and return next one"""
CheckParent(self)
val = _fitz.Page_deleteAnnot(self, fannot)
if val:
val.thisown = True
val.parent = weakref.proxy(self) # owning page object
val.parent._annot_refs[id(val)] ... |
Retrieve position of /CropBox. Return (0,0) for non-PDF, or no /CropBox. | def CropBoxPosition(self):
"""Retrieve position of /CropBox. Return (0,0) for non-PDF, or no /CropBox."""
CheckParent(self)
val = _fitz.Page_CropBoxPosition(self)
val = Point(val)
return val |
Retrieve width, height of /MediaBox. | def MediaBoxSize(self):
"""Retrieve width, height of /MediaBox."""
CheckParent(self)
val = _fitz.Page_MediaBoxSize(self)
val = Point(val)
if not bool(val):
r = self.rect
val = Point(r.width, r.height)
return val |
_showPDFpage(self, fz_srcpage, overlay=1, matrix=None, xref=0, clip=None, graftmap=None, _imgname=None) -> PyObject * | def _showPDFpage(self, fz_srcpage, overlay=1, matrix=None, xref=0, clip=None, graftmap=None, _imgname=None):
"""_showPDFpage(self, fz_srcpage, overlay=1, matrix=None, xref=0, clip=None, graftmap=None, _imgname=None) -> PyObject *"""
return _fitz.Page__showPDFpage(self, fz_srcpage, overlay, matrix, xref,... |
_insertImage(self, filename=None, pixmap=None, stream=None, overlay=1, matrix=None, _imgname=None, _imgpointer=None) -> PyObject * | def _insertImage(self, filename=None, pixmap=None, stream=None, overlay=1, matrix=None, _imgname=None, _imgpointer=None):
"""_insertImage(self, filename=None, pixmap=None, stream=None, overlay=1, matrix=None, _imgname=None, _imgpointer=None) -> PyObject *"""
return _fitz.Page__insertImage(self, filename... |
_insertFont(self, fontname, bfname, fontfile, fontbuffer, set_simple, idx, wmode, serif, encoding, ordering) -> PyObject * | def _insertFont(self, fontname, bfname, fontfile, fontbuffer, set_simple, idx, wmode, serif, encoding, ordering):
"""_insertFont(self, fontname, bfname, fontfile, fontbuffer, set_simple, idx, wmode, serif, encoding, ordering) -> PyObject *"""
return _fitz.Page__insertFont(self, fontname, bfname, fontfil... |
_getTransformation(self) -> PyObject * | def _getTransformation(self):
"""_getTransformation(self) -> PyObject *"""
CheckParent(self)
val = _fitz.Page__getTransformation(self)
val = Matrix(val)
return val |
Remove an annot from reference dictionary. | def _forget_annot(self, annot):
"""Remove an annot from reference dictionary."""
aid = id(annot)
if aid in self._annot_refs:
self._annot_refs[aid] = None |
Invalidate / delete all annots of this page. | def _reset_annot_refs(self):
"""Invalidate / delete all annots of this page."""
for annot in self._annot_refs.values():
if annot:
annot._erase()
self._annot_refs.clear() |
tintWith(self, red, green, blue) | def tintWith(self, red, green, blue):
"""tintWith(self, red, green, blue)"""
if not self.colorspace or self.colorspace.n > 3:
print("warning: colorspace invalid for function")
return
return _fitz.Pixmap_tintWith(self, red, green, blue) |
Set the pixel at (x,y) to the integers in sequence 'color'. | def setPixel(self, x, y, color):
"""Set the pixel at (x,y) to the integers in sequence 'color'."""
return _fitz.Pixmap_setPixel(self, x, y, color) |
irect(self) -> PyObject * | def irect(self):
"""irect(self) -> PyObject *"""
val = _fitz.Pixmap_irect(self)
val = IRect(val)
return val |
uri(self) -> PyObject * | def uri(self):
"""uri(self) -> PyObject *"""
val = _fitz.Outline_uri(self)
if val:
nval = "".join([c for c in val if 32 <= ord(c) <= 127])
val = nval
else:
val = ""
return val |
Rectangle containing the annot | def rect(self):
"""Rectangle containing the annot"""
CheckParent(self)
val = _fitz.Annot_rect(self)
val = Rect(val)
return val |
Update the appearance of an annotation. | def update(self, fontsize=0.0, text_color=None, border_color=None, fill_color=None, rotate=-1):
"""Update the appearance of an annotation."""
if self.type[0] == ANNOT_WIDGET:
print("Use updateWidget method for form fields.")
return False
val = _fitz.Annot_update(self, f... |
setLineEnds(self, start, end) | def setLineEnds(self, start, end):
"""setLineEnds(self, start, end)"""
CheckParent(self)
return _fitz.Annot_setLineEnds(self, start, end) |
Update annotation attached file. | def fileUpd(self, buffer=None, filename=None, ufilename=None, desc=None):
"""Update annotation attached file."""
CheckParent(self)
return _fitz.Annot_fileUpd(self, buffer, filename, ufilename, desc) |
next(self) -> Annot | def next(self):
"""next(self) -> Annot"""
CheckParent(self)
val = _fitz.Annot_next(self)
if val:
val.thisown = True
val.parent = self.parent # copy owning page object from previous annot
val.parent._annot_refs[id(val)] = val
return val |
getPixmap(self, matrix=None, colorspace=None, alpha=0) -> Pixmap | def getPixmap(self, matrix=None, colorspace=None, alpha=0):
"""getPixmap(self, matrix=None, colorspace=None, alpha=0) -> Pixmap"""
CheckParent(self)
return _fitz.Annot_getPixmap(self, matrix, colorspace, alpha) |
_setBorder(self, border, doc, xref) -> PyObject * | def _setBorder(self, border, doc, xref):
"""_setBorder(self, border, doc, xref) -> PyObject *"""
return _fitz.Link__setBorder(self, border, doc, xref) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.