-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch printing from reportlab+poppler to cairo #708
Comments
For what it's worth, the printing actually allows different plugins. It's Reportlab is elegant, well supported, used by lots of web apps and other So, in short, I would recommend we:
That's my 2 cents anyway. I'm hesitant to put a lot of time into rewriting Tom On Mon, Mar 11, 2013 at 7:06 PM, Bernhard Reiter
|
I know about the option to have multiple printing plugins. Still, I guess this is something that'd rather confuse the average user who "just wants to print" -- normally rather using a fancy than a simple text layout. I think I can understand you wouldn't like to give up a convenient and established toolkit such as ReportLab, particulary if this involved redundant re-implementing (though if we did this in cairo, we could maybe re-use e.g. the star drawing code for the rating widget, if we ported that to cairo, too). I also believe that poppler seems quite well maintained, but again, pypoppler unfortunately isn't. I'm curious about the Gtk print library code you mentioned. Has that ever been part of gourmet? (A quick search for commits containing strings "reportlab" or "PrintOperation" didn't turn up anything.) If you can still find that code, I'd like to at least try out if we can make a reportlab/poppler-free, cairo/pango-only printing plugin as a 3rd alternative, maybe even in a branch for now. TBH, I haven't yet looked into pdf_exporter.py or the reportlab API very deeply, but I think that pango does have some useful high-level typesetting features too, doesn't it? BTW, just stumbled across WeasyPrint, which seems to use cairo+pango to render HTML+CSS into PDF. |
It looks from the ChangeLog like the move to the current printing setup The printing code used to be in src/lib/exporters/gnomeprinter.py Here's some info on gnomeprint: Attached are the two gnomeprint-related files from the 0.14.10 release. It's beyond my git-foo to recover these files using git, so I just grabbed Tom On Tue, Mar 12, 2013 at 6:28 AM, Bernhard Reiter
|
Another source on this topic: |
Thanks! I'll take a look at it. FYI, I managed to restore src/lib/exporters/gnomeprinter.py from git by searching the string "gnomeprint" in the git log, locating the commit where src/lib/exporters/gnomeprinter.py had been deleted, and then checking out that file from that commit's predecessor, by
|
FWIW, cairo doesn't produce hyperlinks in PDF (yet), but we could use https://github.com/Kozea/WeasyPrint/blob/master/weasyprint/pdf.py to post-process the cairo-generated PDF. |
Just caught onto this thread. I would hesitate to rewrite printing to depend on Cairo, partly because I Also, ReportLab is really very nice and makes it trivial to do multiple If there's an issue with dependencies, maybe that's a packaging bug rather My 2 cents. Tom On Sun, Sep 1, 2013 at 3:21 AM, Bernhard Reiter [email protected]:
|
(FWIW, I started porting the old gnomeprinter.py exporter to the new plugin interface and Gtk.PrintOperation a couple of days ago in a local branch. So far, I can print the recipe image and need to investigate printing text paragraphs next.) I'm okay with considering this a packaging bug, but then again, as far as Windows is concerned, we're our own packagers, so we're the ones who're supposed to fix it. (Printing on Windows to me seems to be one of the most requested features that people are currently missing, see recent questions on Launchpad.) I tried to build pypoppler Windows binaries a while ago already and failed. There hasn't been any pypoppler release in almost 4 years. So to me, it seems logical to resort to Gtk (which includes Cairo) as we're depending on it already. Conceptually, I think this is somewhat equivalent to resuscitating lprprinter, which AFAIK also doesn't require any extra dependencies, but IIRC can only offer much less appealing layout. I wouldn't really want that to be the only printing option for Windows users. I also think that cairo and pango are at least somewhat more advanced than gnomeprint was -- dealing with font settings seems to be something that pango nowadays can do quite well, but admittedly, it's the first time I'm using it in a software project. So what's your stance on this question -- how do we enable our Windows users to print their recipes? |
Just found pypdflib, which seems to be some sort of high-level abstraction layer based on cairo and pango. We might want to give it a try -- the last commit to their git repo was in 2012. (edit: 2012, not 2010) |
Fair enough. I haven't tried building popler on Windows, so perhaps I Tom On Sun, Sep 1, 2013 at 6:16 PM, Bernhard Reiter [email protected]:
|
Sent from Windows Mail |
I think we should reorganize the way we print. AFAICS, we're currently using reportlab to create a PDF, render it via poppler to a cairo graphics context (GC), which is then printed via
gtk.PrintOperation
. This involves relying on two external dependencies, with the additional issue that poppler's Python bindings are not too actively maintained, and only inofficial binaries exist for Windows, where I haven't managed to get printing to work yet -- see issue #337.I think we could drop both poppler and reportlab dependencies by just using cairo directly to draw to a GC which we can then (again by use of
gtk.PrintOperation
) either export as PDF, or print.(BTW, given that most users will consider printing somewhat of a "core" feature, I believe it shouldn't be part of a plugin but part of Gourmet core.)
Update (2014-02-23): Work for a cairo based plugin is underway in the cairo-print branch. Currently, its biggest issues yet to be solved are:
Alternatively, poppler will become available again once we switch from PyGTK to PyGObject, as it's part of the PyGObject/GTK+3 Windows bundle.
The text was updated successfully, but these errors were encountered: