Der Code von der "tkdocview" Seite sieht so aus, nur als beispiel! In dieser wird ja die pdf kompremiert und dadurch ist die Qualität nicht so gut.
Code: Alles auswählen
from tkinter import *
from tkdocviewer import *
# Create a root window
root = Tk()
# Create a DocViewer widget
v = DocViewer(root)
v.pack(side="top", expand=1, fill="both")
# Display some document
v.display_file("example.pdf")
# Start Tk's event loop
root.mainloop()
Code: Alles auswählen
def render_page(self, page_num):
"""Render the specified page of the input file."""
base, ext = os.path.splitext(self.input_path)
if ext.lower() != ".pdf":
raise BackendError("Only PDF files are supported.")
# Resolution for Ghostscript rendering
if PIL and self.enable_downscaling:
gs_res = hr_dpi
else:
gs_res = gs_dpi
# Ghostscript command line
gs_args = [gs_exe,
"-q",
"-r{0}".format(gs_res),
"-dBATCH",
"-dNOPAUSE",
"-dNOSAFER",
"-dPDFSettings=/SCREEN",
"-dPrinted=false",
"-dTextAlphaBits=4",
"-dGraphicsAlphaBits=4",
"-dCOLORSCREEN",
"-dDOINTERPOLATE",
# Newer versions of Ghostscript support the -sPageList
# option, but our user's version might not have it.
# This approach is clumsier, but backwards-compatible.
"-dFirstPage={0}".format(page_num),
"-dLastPage={0}".format(page_num),
# Raw PPM is the only full-color image format that all
# versions of Tk are guaranteed to support.
"-sDEVICE=ppmraw",
"-sOutputFile=-",
self.input_path]
# Call Ghostscript to render the PDF
image_data = self._check_output(gs_args)
if PIL and self.enable_downscaling:
page_bytes = io.BytesIO(image_data)
page_image = PIL.Image.open(page_bytes)
# Scale down the output from Ghostscript
w, h = page_image.size
return page_image.resize((w * gs_dpi // hr_dpi,
h * gs_dpi // hr_dpi),
resample=PIL.Image.BICUBIC)
else:
# Return the image data from Ghostscript directly
return image_data
Wenn ich in der Gostscript.py diesen bereich ändere
Code: Alles auswählen
if PIL and self.enable_downscaling:
gs_res = hr_dpi
else:
gs_res = gs_dpi #<- in hr_dpi
Ziel für mich sollte sein die .pdf in einer vorgegebene von mir vorgegebene Auflösung zu rendern!
Danke!