Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Add Images as a Link #759

Open
siddydutta opened this issue Apr 15, 2024 · 1 comment
Open

Cannot Add Images as a Link #759

siddydutta opened this issue Apr 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@siddydutta
Copy link

Describe the Bug

Wrapping an <img> with the <a> tag seems to have no effect. Hence, cannot add images as links.

Minimal Example to Reproduce

from xhtml2pdf import pisa

source_html = """<html>
<body>
<a href="http://www.stackoverflow.com">
    <img src="https://dummyimage.com/1038x450/000/0011ff&text=sample+image"/>
</a>
</body>
</html>"""
output_filename = "output.pdf"
result_file = open(output_filename, "w+b")
pisa.CreatePDF(
    source_html,
    dest=result_file)
result_file.close()

Expected Behavior

The image should be a hyperlink.

Actual Behavior

The image is not a hyperlink.

Additional Information

There is a hacky solution: https://stackoverflow.com/questions/32833922/unable-to-create-an-image-hyperlink-with-xhtml2pdf/35300776#35300776 for this, but it does not work with a larger image size.

System Information

OS version: macOS Sonoma 14.4.1
Python version: 3.8
XHTML2PDF version: 0.2.15

@siddydutta siddydutta added the bug Something isn't working label Apr 15, 2024
@siddydutta siddydutta changed the title Bug: Cannot Add Images as a Link Cannot Add Images as a Link Apr 15, 2024
@capripio
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants