View pdf reports in a scrolled window. Contents are read from PDF file and rendered in a GraphicsContext. Show visible window contents as quickly as possible then read the whole file and build the set of drawing commands for each page. This can take time for a big file or if there are complex drawings eg. ReportLab’s colour shading inside charts. Originally read in a thread but navigation is limited until whole file is ready, so now done in main thread with a progress bar, which isn’t modal so can still do whatever navigation is possible as the content availability increases.
__init__ | |
AddBitmap | Add wx.Bitmap from data, processed by filters |
CachePage | When page takes a ‘long’ time to render, save its contents out of |
CalculateDimensions | Compute the required buffer sizes to hold the viewed rectangle and |
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 | |
DrawTextString | word spacing only works for horizontal text (??) |
FetchFonts | Return the standard fonts in current page or form |
GoPage | |
InlineImage | operand contains an image |
InsertXObject | XObject can be an image or a ‘form’ (an arbitrary PDF sequence) |
LoadFile | Read pdf file using pypdf. Assume all pages are same size, for now. |
OnEraseBackground | Does this need to be handled? |
OnIdle | Redraw on resize |
OnPaint | Refresh visible window with bitmap contents |
OnResize | Buffer size change due to client area resize. |
OnScroll | Recalculate and redraw visible area. CallAfter is essential for coordination. |
Print the pdf. | |
ProcessOperators | Interpret each operation in opslist and return in drawlist |
Progress | This function is called at regular intervals during Drawfile |
Render | Recalculate dimensions as client area may have been scrolled or resized. |
RenderPage | Render the set of pagedrawings |
RenderPageBoundaries | Show non-page areas in grey |
Save | A pdf-only Save. |
SetFont | Returns wx.Font instance from supplied pdf font information |
SetZoom | Positive integer or floating zoom scale will render the file at corresponding |
View pdf reports in a scrolled window. Contents are read from PDF file and rendered in a GraphicsContext. Show visible window contents as quickly as possible then read the whole file and build the set of drawing commands for each page. This can take time for a big file or if there are complex drawings eg. ReportLab’s colour shading inside charts. Originally read in a thread but navigation is limited until whole file is ready, so now done in main thread with a progress bar, which isn’t modal so can still do whatever navigation is possible as the content availability increases.
Add wx.Bitmap from data, processed by filters
When page takes a ‘long’ time to render, save its contents out of self.pdc and re-use it to minimise jerky scrolling
Compute the required buffer sizes to hold the viewed rectangle and the range of pages visible. Override force flag and set true if the current set of rendered pages changes
Convert CMYK values (0 to 1.0) in operand to nearest RGB
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 roll our own command lists, one per page, into self.pagedrawings.
Stroke and/or fill the defined path depending on operator
word spacing only works for horizontal text (??)
Return the standard fonts in current page or form
operand contains an image
XObject can be an image or a ‘form’ (an arbitrary PDF sequence)
Read pdf file using pypdf. Assume all pages are same size, for now.
Parameters: | pdf_file – can be either a string holding a filename path or a file-like object. |
---|
Does this need to be handled?
Redraw on resize
Refresh visible window with bitmap contents
Buffer size change due to client area resize.
Recalculate and redraw visible area. CallAfter is essential for coordination.
Print the pdf.
Parameters: |
|
---|
Interpret each operation in opslist and return in drawlist
This function is called at regular intervals during Drawfile
Recalculate dimensions as client area may have been scrolled or resized. The smallest unit of rendering that can be done is the pdf page. So render the drawing commands for the pages in the visible rectangle into a buffer big enough to hold this set of pages. For each page, use gc.Translate to render wrt the pdf origin, which is at the bottom left corner of the page. Force re-creating the page buffer only when client view moves outside it.
Render the set of pagedrawings In pdf file, bitmaps are treated as being of unit width and height and are scaled appropriately in X and Y. Cairo can handle this but not wx.GraphicsContext (although it should in theory) or wx.DC,
Show non-page areas in grey
A pdf-only Save.
Returns wx.Font instance from supplied pdf font information
Positive integer or floating zoom scale will render the file at corresponding size where 1.0 is “actual” point size (1/72”). -1 fits page width and -2 fits page height into client area Redisplay the current page(s) at the new size