2
from pdf_exporter import PdfWriter, PdfExporterMultiDoc, get_pdf_prefs
4
from gettext import gettext as _
5
from gettext import ngettext
6
import gourmet.gtk_extras.dialog_extras as de
7
import gourmet.gglobals as gglobals
8
from gourmet.convert import FRACTIONS_NORMAL
14
def print_file_with_windows (filename):
16
# http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html#shellexecute
17
if de.getBoolean(label=_('Print'),
18
sublabel=_('Ready to print your recipe through the PDF file %s. Unfortunately, we have no print preview - shall we go ahead and print?')%filename):
19
win32api.ShellExecute(
27
d = de.MessageDialog(label=_('Print job sent'),
28
sublabel=_("Print job has been sent. If something goes wrong, you can open the PDF file and try printing again."))
30
d = de.MessageDialog(label=_('Print job cancelled'),
31
sublabel=_("If you'd like, you can open the PDF file.")
33
b = gtk.Button(stock=gtk.STOCK_JUMP_TO)
34
b.connect('clicked',lambda *args: gglobals.launch_url(filename))
35
d.vbox.pack_end(b,expand=False); b.show()
40
def __init__ (self, rd, recs, mult=1, dialog_title=_("Print Recipes"),
41
dialog_parent=None, **kwargs):
42
filename = tempfile.mktemp('.pdf')
43
pdf_args = get_pdf_prefs()
44
kwargs['pdf_args']=pdf_args
45
e = PdfExporterMultiDoc(rd,recs,filename, **kwargs)
47
print_file_with_windows(filename)
48
#show_disappointing_message()
49
#debug('printing not supported; showed dialog',0)
51
class SimpleWriter (PdfWriter):
53
def __init__ (self, file=None, dialog_parent=None, show_dialog=True):
54
self.filename = tempfile.mktemp('.pdf')
55
self.outfile = open(self.filename,'wb')
56
#PdfWriter.__init__(self)
57
self.setup_document(self.outfile,
59
'page_layout':(ngettext('%s Column','%s Columns',2)%2),
66
print_file_with_windows(self.filename)
68
if __name__ == '__main__':
70
sw.write_header("This is a big heading")
71
sw.write_paragraph("""This is a paragraph.
72
This is perhaps a silly sort of paragraph to write, but I'm in the mood for silly paragraphs.
73
In fact, I'm in the mood for extraordinarily silly paragraphs. Paragraphs so silly they go on and on and on and on and (not being tired continuing) on and so forth until (by now the reader tiring) they take a sudden left turn, careening around the bend (passing colorless, sleeping, furious green ideas), plummetting downward (toward what or whom I don't know, whether or not there is a netherworld being among the many things, such as the existence of fairies, which escape my knowledge), falling fast and furious until hitting that final (cliched) rock bottom and returning upward.
74
This is my final paragraph.""")
75
sw.write_subheader("Foo")
76
sw.write_paragraph("This is the section named foo. "*12)
77
sw.write_subheader("Final Section")
78
sw.write_paragraph("And this is the final section." * 3)