There's more...

Since PostScript files are not as popular as other file formats, you might want to convert the generated file from PostScript to a more familiar format such as PDF.

To do so, you need a third-party software, such as Ghostscript, which is distributed under GNU's Affero General Public License (AGPL). Ghostscript's interpreter and renderer utilities can be invoked from your program to automatically convert the PostScript result to PDF.

Download and install the latest version of the software from https://www.ghostscript.com/download/gsdnld.html and add the bin and lib folders of the installation into your operating system path.

Then, modify your Tkinter application to call the ps2pdf program as a subprocess and remove the output.ps file when it finish its execution, as follows:

import os
import subprocess
import tkinter as tk

class App(tk.Tk):
# ...

def render_canvas(self):
output_filename = "output.ps"
self.canvas.postscript(file=output_filename, colormode="color")
process = subprocess.run(["ps2pdf", output_filename, "output.pdf"],
shell=True)
os.remove(output_filename)

 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset