예제 #1
0
파일: page.py 프로젝트: chrisz/paperwork
    def __render_img(self, factor):
        # TODO(Jflesch): In a perfect world, we shouldn't use ImageSurface.
        # we should draw directly on the GtkImage.window.cairo_create() context.
        # It would be much more efficient.

        width = int(factor * self.size[0])
        height = int(factor * self.size[1])

        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
        ctx = cairo.Context(surface)
        ctx.scale(factor, factor)
        self.pdf_page.render(ctx)
        return surface2image(surface)
예제 #2
0
    def __render_img(self, factor):
        # TODO(Jflesch): In a perfect world, we shouldn't use ImageSurface.
        # we should draw directly on the GtkImage.window.cairo_create()
        # context. It would be much more efficient.

        width = int(factor * self.size[0])
        height = int(factor * self.size[1])

        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
        ctx = cairo.Context(surface)
        ctx.scale(factor, factor)
        self.pdf_page.render(ctx)
        return surface2image(surface)
예제 #3
0
파일: doc.py 프로젝트: waytai/paperwork
    def refresh(self):
        # make the preview

        tmp = "%s.%s" % (os.tempnam(None,
                                    "paperwork_export_"), self.valid_exts[0])
        path = self.__save(tmp, pages=(0, 1))

        # reload the preview

        pdfdoc = Poppler.Document.new_from_file(("file://%s" % path),
                                                password=None)
        assert (pdfdoc.get_n_pages() > 0)

        pdfpage = pdfdoc.get_page(0)
        pdfpage_size = pdfpage.get_size()

        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(pdfpage_size[0]),
                                     int(pdfpage_size[1]))
        ctx = cairo.Context(surface)
        pdfpage.render(ctx)
        img = surface2image(surface)

        self.__preview = (path, img)
예제 #4
0
파일: doc.py 프로젝트: kryskool/paperwork
    def refresh(self):
        # make the preview

        tmp = "%s.%s" % (os.tempnam(None, "paperwork_export_"),
                         self.valid_exts[0])
        path = self.__save(tmp, pages=(0, 1))

        # reload the preview

        pdfdoc = Poppler.Document.new_from_file(
            ("file://%s" % path), password=None)
        assert(pdfdoc.get_n_pages() > 0)

        pdfpage = pdfdoc.get_page(0)
        pdfpage_size = pdfpage.get_size()

        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
                                     int(pdfpage_size[0]),
                                     int(pdfpage_size[1]))
        ctx = cairo.Context(surface)
        pdfpage.render(ctx)
        img = surface2image(surface)

        self.__preview = (path, img)