Hi
You could use fpdf to convert text to pdf as per:
------------------------------------
import fpdf
text = """The earliest known appearance of the phrase is from The
Boston Journal. In an article titled "Current Notes" in the
February 10, 1885, morning edition, the phrase is mentioned as a
good practice sentence for writing students: "A favorite copy set
by writing teachers for their pupils is the following, because it
contains every letter of the alphabet: 'A quick brown fox jumps
over the lazy dog.'"[1] Dozens of other newspapers published the
phrase over the next few months, all using the version of the
sentence starting with "A" rather than "The".[2] The earliest
known use of the phrase in its modern form (starting with "The")
is from the 1888 book Illustrative Shorthand by Linda Bronson.[3]
The modern form (starting with "The") became more common despite
the fact that it is slightly longer than the original (starting
with "A")."""
pdf = fpdf.FPDF(orientation="P", unit="mm", format="A4")
pdf.set_font("courier", "", 10)
pdf.set_auto_page_break(True, margin=5)
pdf.add_page()
pdf.multi_cell(180, 5, txt=text)
pdf.output("test.pdf", "F")
--------------------------------------
Regards
Paul Malherbe
On 18/06/2019 12:09, Vasilis Vlachoudis
wrote:
Thanks Michael,
not exactly what I was looking for.
I am investigating how difficult is to write my own ps exporter,
based on the Canvas postscript source code.
Vasilis
________________________________________
From: Tkinter-discuss [[email protected]] on behalf of Michael Lange [[email protected]]
Sent: Tuesday, June 18, 2019 11:16
To: [email protected]
Subject: Re: [Tkinter-discuss] Text to postscript
Hi,
On Mon, 17 Jun 2019 12:16:49 +0000
Vasilis Vlachoudis <[email protected]> wrote:
Hi all,
Canvas has this nice method to convert it to postscript, which is
perfect for printing. Is there something similar for Text(), I could
not find anything internal but if there is something external to
convert to html, ps, pdf it would be nice.
maybe you could use tkimg to create a "screenshot" of the widget in
postscript format.
To enable tkimg's "window" handler once it's installed you just need to do
something like
root.tk.call('package', 'require', 'img::window')
early in your code.
IIRC by default tkimg's "window" handler will include only the visible
part of the widget, but here:
https://wiki.tcl-lang.org/page/Img
George Petasis posted a recipe that seems to be able to capture the whole
contents of a canvas widget. I don't know how well this actually works
though and if it can be done with a Text widget in the same fashion.
Best regards
Michael
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
History tends to exaggerate.
-- Col. Green, "The Savage Curtain", stardate 5906.4
_______________________________________________
Tkinter-discuss mailing list
[email protected]
https://mail.python.org/mailman/listinfo/tkinter-discuss
_______________________________________________
Tkinter-discuss mailing list
[email protected]
https://mail.python.org/mailman/listinfo/tkinter-discuss