Phoenix Logo

phoenix_title wx.lib.pdfviewer.viewer.pypdfProcessor

Create an instance of this class to open a PDF file, process the contents of every page using PyPDF2 then render each one on demand


class_hierarchy Class Hierarchy

Inheritance diagram for class pypdfProcessor:


method_summary Methods Summary

__init__  
AddBitmap Add wx.Bitmap from data, processed by filters.
ConvertCMYK Convert CMYK values (0 to 1.0) in operand to nearest RGB.
DrawFile Build set of drawing commands from PDF contents. Ideally these could be drawn
DrawPath Stroke and/or fill the defined path depending on operator.
DrawTextItem Draw a text item.
DrawTextString Draw a text string. Word spacing only works for horizontal text.
FetchFonts Return the standard fonts in current page or form
InlineImage operand contains an image
InsertXObject XObject can be an image or a ‘form’ (an arbitrary PDF sequence).
ProcessOperators Interpret each operation in opslist and return in drawlist.
Progress This function is called at regular intervals during Drawfile
RenderPage Render the set of pagedrawings
SetFont Returns wx.Font instance from supplied pdf font information.

api Class API



class pypdfProcessor(object)

Create an instance of this class to open a PDF file, process the contents of every page using PyPDF2 then render each one on demand


Methods



__init__(self, parent, fileobj, showloadprogress)


AddBitmap(self, data, width, height, filters)

Add wx.Bitmap from data, processed by filters.



ConvertCMYK(self, operand)

Convert CMYK values (0 to 1.0) in operand to nearest RGB.



DrawFile(self, frompage, topage)

Build set of drawing commands from PDF contents. Ideally these could be drawn straight into a PseudoDC and the visible section painted directly into scrolled window, but we need to be able to zoom and scale the output quickly without having to rebuild the drawing commands (slow). So build our own command lists, one per page, into self.pagedrawings.



DrawPath(self, path, action)

Stroke and/or fill the defined path depending on operator.



DrawTextItem(self, textitem, f)

Draw a text item.

Parameters:
  • textitem – the item to draw
  • f – the font to use for text extent measuring


DrawTextString(self, text)

Draw a text string. Word spacing only works for horizontal text.

Parameters:text (string) – the text to draw


FetchFonts(self, currentobject)

Return the standard fonts in current page or form



InlineImage(self, operand)

operand contains an image



InsertXObject(self, name)

XObject can be an image or a ‘form’ (an arbitrary PDF sequence).



ProcessOperators(self, opslist, pdf_fonts)

Interpret each operation in opslist and return in drawlist.



Progress(self, ptype, value)

This function is called at regular intervals during Drawfile



RenderPage(self, gc, pageno, scale=None)

Render the set of pagedrawings In a pdf file, bitmaps are treated as being of unit width and height and are scaled via a previous ConcatTransform containing the corresponding width and height as scale factors. wx.GraphicsContext/Cairo appear not to respond to this so scaling is removed from transform and width & height are added to the Drawbitmap call.



SetFont(self, pdfont, size)

Returns wx.Font instance from supplied pdf font information.