Beispiel #1
0
def get_pages(html):
    document = html.render(enable_hinting=True, stylesheets=[STYLESHEET])
    for page in document.pages:
        png_bytes, width, height = document.copy([page]).write_png()
        data_url = 'data:image/png;base64,' + (
            base64_encode(png_bytes).decode('ascii').replace('\n', ''))
        yield width, height, data_url, page.links, page.anchors
Beispiel #2
0
def get_pages(html):
    document = html.render(enable_hinting=True, stylesheets=[STYLESHEET])
    for page in document.pages:
        png_bytes, width, height = document.copy([page]).write_png()
        data_url = 'data:image/png;base64,' + (
            base64_encode(png_bytes).decode('ascii').replace('\n', ''))
        yield width, height, data_url, page.links, page.anchors
Beispiel #3
0
 def png_to_img(self, png, width, height, **kw):
     """Generate a data url image tag
     """
     data_url = "data:image/png;base64," + (
         base64_encode(png).decode("ascii").replace("\n", ""))
     img = IMG_TAG_TEMPLATE.safe_substitute(
         width=width, height=height, data=data_url, **kw)
     return img
Beispiel #4
0
def get_pages(html):
    document, png_pages = html.get_png_pages([STYLESHEET], _with_document=True)
    for page, (width, height, png_bytes) in izip(document.pages, png_pages):
        links = []
        anchors = []
        find_links(page, links, anchors)
        data_url = 'data:image/png;base64,' + (
            base64_encode(png_bytes).decode('ascii').replace('\n', ''))
        yield width, height, data_url, links, anchors
Beispiel #5
0
 def png_to_img(self, png, width, height):
     """Generate a data url image tag
     """
     data_url = 'data:image/png;base64,' + (
         base64_encode(png).decode('ascii').replace('\n', ''))
     img = """<div class='report'>
                 <img src='{2}' style='width: {0}px; height: {1}px'/>
               </div>""".format(width, height, data_url)
     return img
Beispiel #6
0
def get_pages(html):
    for width, height, png_bytes, page in html.get_png_pages(
            [STYLESHEET], _with_pages=True):
        links = []
        anchors = []
        find_links(page, links, anchors)
        data_url = 'data:image/png;base64,' + (
            base64_encode(png_bytes).decode('ascii').replace('\n', ''))
        yield width, height, data_url, links, anchors
Beispiel #7
0
def get_pages(html):
    for page in html.render(enable_hinting=True, stylesheets=[STYLESHEET]):
        links = []
        anchors = []
        find_links(page._page_box, links, anchors)
        surface = pages_to_image_surface([page])
        width = surface.get_width()
        height = surface.get_height()
        png_bytes = surface_to_png(surface)
        data_url = 'data:image/png;base64,' + (
            base64_encode(png_bytes).decode('ascii').replace('\n', ''))
        yield width, height, data_url, links, anchors
Beispiel #8
0
def get_pages(html):
    for page in html.render(enable_hinting=True, stylesheets=[STYLESHEET]):
        links = []
        anchors = []
        find_links(page._page_box, links, anchors)
        surface = pages_to_image_surface([page])
        width = surface.get_width()
        height = surface.get_height()
        png_bytes = surface_to_png(surface)
        data_url = 'data:image/png;base64,' + (
            base64_encode(png_bytes).decode('ascii').replace('\n', ''))
        yield width, height, data_url, links, anchors