1
0
mirror of synced 2024-11-25 10:44:23 +01:00

Scale for PDF is now parametrable

This commit is contained in:
jvoisin 2018-03-19 23:51:35 +01:00
parent 8f44616366
commit 47c5d8b486

View File

@ -28,6 +28,7 @@ class PDFParser(abstract.AbstractParser):
def __init__(self, filename): def __init__(self, filename):
super().__init__(filename) super().__init__(filename)
self.uri = 'file://' + os.path.abspath(self.filename) self.uri = 'file://' + os.path.abspath(self.filename)
self.__scale = 2
def remove_all(self): def remove_all(self):
""" """
@ -48,10 +49,10 @@ class PDFParser(abstract.AbstractParser):
page_width, page_height = page.get_size() page_width, page_height = page.get_size()
logging.info("Rendering page %d/%d", pagenum + 1, pages_count) logging.info("Rendering page %d/%d", pagenum + 1, pages_count)
img_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(page_width)*2, int(page_height)*2) img_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(page_width) * self.__scale, int(page_height) * self.__scale)
img_context = cairo.Context(img_surface) img_context = cairo.Context(img_surface)
img_context.scale(2, 2) img_context.scale(self.__scale, self.__scale)
page.render_for_printing(img_context) page.render_for_printing(img_context)
img_context.show_page() img_context.show_page()