More Advanced Base Class for Exporters

More advanced base class

You probably want to implement your exporter on top of this base class. The default methods just print to stdout.

EXAMPLES:

>>> from quill.exporter.base2 import ExporterBase2
>>> ExporterBase2().book(sample_book)    
Beginning export
Title is set to Example Notebook
UUID is set to 1fd6a485-33ed-4a45-a5a1-e06e55fdca57
Creation time set to 2012-12-09 14:57:25
Last modification time set to 2012-12-09 14:57:25
New page, aspect ratio 0.707
Draw image at (0.13,0.605):(0.455,0.739)
Draw line from (0.175,0.532) to (0.629,0.442)
Draw line from (0.169,0.433) to (0.632,0.528)
Draw pen stroke with 40 points
Draw pen stroke with 8 points
Draw pen stroke with 59 points
Draw pen stroke with 31 points
Draw pen stroke with 44 points
Draw pen stroke with 36 points
Draw pen stroke with 22 points
Draw pen stroke with 9 points
Draw pen stroke with 6 points
Draw pen stroke with 18 points
Draw pen stroke with 21 points
...
Draw pen stroke with 17 points
Draw pen stroke with 14 points
Draw pen stroke with 34 points
Draw pen stroke with 11 points
Draw pen stroke with 18 points
Draw pen stroke with 11 points
Draw pen stroke with 11 points
Draw pen stroke with 4 points
Draw pen stroke with 28 points
Draw pen stroke with 32 points
Draw pen stroke with 29 points
Draw pen stroke with 21 points
New page, aspect ratio 0.707
Draw pen stroke with 12 points
Draw pen stroke with 30 points
Draw pen stroke with 26 points
Draw pen stroke with 50 points
Draw pen stroke with 54 points
New page, aspect ratio 0.707
Ending export

>>> ExporterBase2().book(sample_book_xoj)    
Beginning export
Title is set to Example_Notebook
UUID is set to ...
Creation time set to ...
Last modification time set to ...
New page, aspect ratio 0.707
Draw image at (0.13,0.605):(0.455,0.739)
Draw line from (0.175,0.532) to (0.629,0.442)
Draw line from (0.169,0.433) to (0.632,0.528)
Draw pen stroke with 40 points
Draw pen stroke with 8 points
Draw pen stroke with 59 points
Draw pen stroke with 31 points
Draw pen stroke with 44 points
Draw pen stroke with 36 points
Draw pen stroke with 22 points
Draw pen stroke with 9 points
Draw pen stroke with 6 points
Draw pen stroke with 18 points
Draw pen stroke with 21 points
...
Draw pen stroke with 17 points
Draw pen stroke with 14 points
Draw pen stroke with 34 points
Draw pen stroke with 11 points
Draw pen stroke with 18 points
Draw pen stroke with 11 points
Draw pen stroke with 11 points
Draw pen stroke with 4 points
Draw pen stroke with 28 points
Draw pen stroke with 32 points
Draw pen stroke with 29 points
Draw pen stroke with 21 points
New page, aspect ratio 0.707
Draw pen stroke with 12 points
Draw pen stroke with 30 points
Draw pen stroke with 26 points
Draw pen stroke with 50 points
Draw pen stroke with 54 points
New page, aspect ratio 0.707
Ending export
class quill.exporter.base2.ExporterBase2[source]

Bases: quill.exporter.base.ExporterBase

begin_export()[source]

Hook to be called at the beginning of the export process.

You should override this method in your own exporter to set it up. This method returns nothing.

book(book)[source]

Export the notebook.

Parameters:book – the notebook to export, instance of Book

Warning

You should not have to override this method, it defers drawing to the other methods.

creation_time(ctime, ctime_millis)[source]

Set the notebook creation time.

Parameters:
  • ctime (datetime) – the creation time as python object
  • ctime_millis (integer) – the creation time as milliseconds

This method will be called before the first empty page (see new_page()) is inserted. You should override this method to save it in your exported document.

end_export()[source]

Called at the beginning of the export process.

You should override this method in your own exporter to tear it down. This method returns nothing.

image(image)[source]

Add an image to the current page.

Parameters:image – the image to export, instance of Image

You should override this method to draw the image on the most recently added page. This method will only be called after an empty page (see new_page()) has been inserted.

line(line)

Add a straight line to the current page.

Parameters:line – the line to export, instance of Line

You should override this method to draw the pen stroke on the most recently added page. This method will only be called after an empty page (see new_page()) has been inserted.

modification_time(mtime, mtime_millis)[source]

Set the notebook last-modified time.

Parameters:
  • mtime (datetime) – the last modification time as python object
  • mtime_millis (integer) – the last modification time as milliseconds

This method will be called before the first empty page (see new_page()) is inserted. You should override this method to save it in your exported document.

new_page(page)[source]

Add a new empty page to the exported document.

Parameters:page – the page to export, instance of Page

You should override this method to add a new empty page with the specified aspect ratio and background to your document.

page(page)[source]

Export a page

Parameters:page – the page to export, instance of Page

Warning

You should not have to override this method, it defers drawing to the other methods.

stroke(stroke)[source]

Add a pen stroke to the current page.

Parameters:stroke – the pen stroke to export, instance of Stroke

You should override this method to draw the pen stroke on the most recently added page. This method will only be called after an empty page (see new_page()) has been inserted.

title(title)[source]

Set the title.

Parameters:title (string) – the notebook title

This method will be called before the first empty page (see new_page()) is inserted. You should override this method to save it in your exported document.

uuid(uuid)[source]

Set the notebook UUID.

Parameters:uuid (string) – the notebook UUID

This method will be called before the first empty page (see new_page()) is inserted. You should override this method to save it in your exported document.

Previous topic

Base Class for Exporters

Next topic

Draw to a Cairo Context

This Page