[pygtk] "Export to PDF"
Marco Antonio Islas Cruz
markuz at islascruz.org
Tue Oct 23 01:26:45 WST 2012
On Oct 22, 2012, at 12:14 PM, Ajay Garg <ajaygargnsit at gmail.com> wrote:
>
> a)
> Can the dialog, that asks for the printer-to-be-used, be avoided too? (Because I just wish to export to PDF, nothing else).
As an example
filename = './ultimafactura.pdf'
po.set_export_filename(filename)
action = gtk.PRINT_OPERATION_ACTION_EXPORT
response = po.run(action)
where 'po' is the print Operation, you need to set the action gtk.PRINT_OPERATION_ACTION_EXPORT and set your filename, then just run the print operation, since it is not gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG it will not show the dialog, and it is not gtk.PRINT_OPERATION_ACTION_PRINT either it will not send the print to the selected printer (in case you selected a printer).
>
>
> b)
> I understand that the page would need to be "drawn" in memory, if we were to export an image.
> However, is that required for a text-document too?
Yes, you have to draw, this is the hard part when printing, You can just populate your cairo surface but if you want to have a pretty formatted text you'll need to draw it. Please note, you are not exactly drawing in the same sense than drawing a circle or a rectangle, you'll need to use pango to create the text forms and attach them to the Cairo surface
>
> c)
> Also, I am still a bit unclear on the backend code.
> You mean to say that "only" GTK has the backend code, and Cairo/Pango are just to handle the drawing part?
* Gtk is the one that gives you the print operation, also, responsible for the events and all that stuff.
* Cairo is the one in charge to draw, it gives you canvas, context and other stuff to "draw"
* Pango handle pretty text, also, is the interface for your text to be handled by Cairo.
Marco Antonio Islas Cruz
markuz at islascruz.org
marco.islas at gmail.com
<-- linux because I'm free -->
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.daa.com.au/pipermail/pygtk/attachments/20121022/30a3c382/attachment.html>
More information about the pygtk
mailing list