Module document.koptinterface
Interface to k2pdfoptlib backend.
Functions
Functions
- KoptInterface:createContext (doc, pageno, bbox)
-
Get reflow context.
Parameters:
- doc
- pageno
- bbox Now koptcontext keeps track of its dst bitmap reflowed by libk2pdfopt. So there is no need to check background context when creating new context.
- KoptInterface:getAutoBBox (doc, pageno)
-
Auto detect bbox.
Parameters:
- doc
- pageno
- KoptInterface:getSemiAutoBBox (doc, pageno)
-
Detect bbox within user restricted bbox.
Parameters:
- doc
- pageno use manual bbox
- KoptInterface:getCachedContext (doc, pageno)
-
Get cached koptcontext for a certain page.
If the context doesn't exist in cache, make a new context and reflow the src page immediately, or wait for the background thread with reflowed context.
Parameters:
- doc
- pageno
- KoptInterface:getPageDimensions (doc, pageno, zoom, rotation)
-
Get page dimensions.
Parameters:
- doc
- pageno
- zoom
- rotation
- KoptInterface:getRFPageDimensions (doc, pageno, zoom, rotation)
-
Get reflowed page dimensions.
Parameters:
- doc
- pageno
- zoom
- rotation
- KoptInterface:getCoverPageImage (doc)
-
Get first page image.
Parameters:
- doc
- KoptInterface:renderReflowedPage (doc, pageno, rect, zoom, rotation)
-
Render reflowed page into tile cache.
Inherited from common document interface.
Parameters:
- doc
- pageno
- rect
- zoom
- rotation
- KoptInterface:renderOptimizedPage (doc, pageno, rect, zoom, rotation, hinting)
-
Render optimized page into tile cache.
Inherited from common document interface.
Parameters:
- doc
- pageno
- rect
- zoom
- rotation
- hinting
- KoptInterface:hintReflowedPage (doc, pageno, zoom, rotation, gamma, hinting)
-
Render reflowed page into cache in background thread.
This method returns immediately, leaving the precache flag on in context. Subsequent usage of this context should wait for the precache flag off by calling self:waitForContext(kctx)
Inherited from common document interface.
Parameters:
- doc
- pageno
- zoom
- rotation
- gamma
- hinting
- KoptInterface:drawContextPage (doc, target, x, y, rect, pageno, zoom, rotation)
-
Draw cached tile pixels into target blitbuffer.
Inherited from common document interface.
Parameters:
- doc
- target
- x
- y
- rect
- pageno
- zoom
- rotation
- KoptInterface:getReflowedTextBoxes (doc, pageno)
-
Get text boxes in reflowed page via rectmaps in koptcontext.
Parameters:
- doc
- pageno
- KoptInterface:getNativeTextBoxes (doc, pageno)
-
Get text boxes in native page via rectmaps in koptcontext.
Parameters:
- doc
- pageno
- KoptInterface:getReflowedTextBoxesFromScratch (doc, pageno)
-
Get text boxes in reflowed page via optical method.
Done by OCR pre-processing in Tesseract and Leptonica.
Parameters:
- doc
- pageno
- KoptInterface:getNativeTextBoxesFromScratch (doc, pageno)
-
Get text boxes in native page via optical method.
Done by OCR pre-processing in Tesseract and Leptonica.
Parameters:
- doc
- pageno
- KoptInterface:getPageBlock (doc, pageno, x, y)
-
Get page regions in native page via optical method.
Parameters:
- doc
- pageno
- x
- y
- KoptInterface:getOCRWord (doc, pageno, wbox)
-
Get word from OCR providing selected word box.
Parameters:
- doc
- pageno
- wbox
- KoptInterface:getReflewOCRWord (doc, pageno, rect)
-
Get word from OCR in reflew page.
Parameters:
- doc
- pageno
- rect
- KoptInterface:getNativeOCRWord (doc, pageno, rect)
-
Get word from OCR in native page.
Parameters:
- doc
- pageno
- rect
- KoptInterface:getOCRText (doc, pageno, tboxes)
-
Get text from OCR providing selected text boxes.
Parameters:
- doc
- pageno
- tboxes
- KoptInterface:getWordFromBoxes (boxes, pos)
-
Get word and word box around
pos
.Parameters:
- boxes
- pos
- KoptInterface:getTextFromBoxes (boxes, pos0, pos1)
-
Get text and text boxes between
pos0
andpos1
.Parameters:
- boxes
- pos0
- pos1
- KoptInterface:getWordFromPosition (doc, pos)
-
Get word and word box from
doc
position.Parameters:
- doc
- pos
- KoptInterface:getWordFromReflowPosition (doc, boxes, pos)
-
Get word and word box from position in reflowed page.
Parameters:
- doc
- boxes
- pos
- KoptInterface:getWordFromNativePosition (doc, boxes, pos)
-
Get word and word box from position in native page.
Parameters:
- doc
- boxes
- pos
- KoptInterface:getLinkFromPosition (doc, pageno, pos)
-
Get link from position in screen page.
Parameters:
- doc
- pageno
- pos
- KoptInterface:nativeToReflowPosTransform (doc, pageno, pos)
-
Transform position in native page to reflowed page.
Parameters:
- doc
- pageno
- pos
- KoptInterface:reflowToNativePosTransform (doc, pageno, abs_pos, rel_pos)
-
Transform position in reflowed page to native page.
Parameters:
- doc
- pageno
- abs_pos
- rel_pos
- KoptInterface:getTextFromPositions (doc, pos0, pos1)
-
Get text and text boxes from screen positions.
Parameters:
- doc
- pos0
- pos1
- KoptInterface:getTextFromReflowPositions (doc, native_boxes, pos0, pos1)
-
Get text and text boxes from screen positions for reflowed page.
Parameters:
- doc
- native_boxes
- pos0
- pos1
- KoptInterface:getTextFromNativePositions (doc, native_boxes, pos0, pos1)
-
Get text and text boxes from screen positions for native page.
Parameters:
- doc
- native_boxes
- pos0
- pos1
- KoptInterface:getPageBoxesFromPositions (doc, pageno, ppos0, ppos1)
-
Get text boxes from page positions.
Parameters:
- doc
- pageno
- ppos0
- ppos1
- KoptInterface:comparePositions (doc, ppos1, ppos2)
-
Compare positions within one page.
Returns 1 if positions are ordered (if ppos2 is after ppos1), -1 if not, 0 if same.
Positions of the word boxes containing ppos1 and ppos2 are compared.
Parameters:
- doc
- ppos1
- ppos2
- KoptInterface:nativeToPageRectTransform (doc, pageno, rect)
-
Get page rect from native rect.
Parameters:
- doc
- pageno
- rect
- KoptInterface:logReflowDuration (pageno, dur)
-
Log reflow duration.
Parameters:
- pageno
- dur