Skip to content

HTML to image with playwright-python #18118

@DTHerrera

Description

@DTHerrera

Hello, When making a screenshot the image is generated with a gray section on the right side, is it possible to delete it or that it is not part of the image that is generated with the screenshot? (attached file with the image)

ScreenShot_Playwright-python.pptx

if this is possible as it would be?

The code that generates this image is as follows:

from playwright.sync_api import sync_playwright
with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    urlpage = url_for('profile.riesgoimg')
    print(f'urlpage: {urlpage}')
    page.goto("http://localhost:5000/profile/riesgoimg")
    page.locator(".nk-content-body").screenshot(path=f'example-{p.chromium.name}.png')
    screenshot_bytes = page.screenshot()
    print(f'IMG Base64: {base64.b64encode(screenshot_bytes).decode()}')
    browser.close()

regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions