Fixes for PDF DPI Detection

This commit is contained in:
Samuel Mehrbrodt 2014-04-09 12:48:12 +02:00
parent 5e9d9a3cd0
commit a82a13d2ed
3 changed files with 13 additions and 11 deletions

View File

@ -495,14 +495,14 @@ class SlideController(DisplayController, RegistryProperties):
self.on_theme_display(False)
self.on_hide_display(False)
def service_previous(self):
def service_previous(self, field=None):
"""
Live event to select the previous service item from the service manager.
"""
self.keypress_queue.append(ServiceItemAction.Previous)
self._process_queue()
def service_next(self):
def service_next(self, field=None):
"""
Live event to select the next service item from the service manager.
"""

View File

@ -204,19 +204,19 @@ class PdfDocument(PresentationDocument):
log.debug(' '.join(e.cmd))
log.debug(e.output)
# Extract the pdf resolution from output, the format is " Size: x: <width>, y: <height>"
width = 0
height = 0
width = 0.0
height = 0.0
for line in runlog.splitlines():
try:
width = int(re.search('.*Size: x: (\d+\.?\d*), y: \d+.*', line.decode()).group(1))
height = int(re.search('.*Size: x: \d+\.?\d*, y: (\d+\.?\d*).*', line.decode()).group(1))
width = float(re.search('.*Size: x: (\d+\.?\d*), y: \d+.*', line.decode()).group(1))
height = float(re.search('.*Size: x: \d+\.?\d*, y: (\d+\.?\d*).*', line.decode()).group(1))
break
except AttributeError:
pass
continue
# Calculate the ratio from pdf to screen
if width > 0 and height > 0:
width_ratio = size.right() / float(width)
height_ratio = size.bottom() / float(height)
width_ratio = size.right() / width
height_ratio = size.bottom() / height
# return the resolution that should be used. 72 is default.
if width_ratio > height_ratio:
return int(height_ratio * 72)

View File

@ -122,8 +122,10 @@ class PresentationDocument(object):
a file, e.g. thumbnails
"""
try:
shutil.rmtree(self.get_thumbnail_folder())
shutil.rmtree(self.get_temp_folder())
if os.path.exists(self.get_thumbnail_folder()):
shutil.rmtree(self.get_thumbnail_folder())
if os.path.exists(self.get_temp_folder()):
shutil.rmtree(self.get_temp_folder())
except OSError:
log.exception('Failed to delete presentation controller files')