Unable to create an image hyperlink with xhtml2pdf - xhtml2pdf

Consider the following code:
from xhtml2pdf import pisa
if __name__=="__main__":
source_HTML = """<html>
<body>
<a href="http://www.stackoverflow.com">
<img src="http://i.stack.imgur.com/uQFNA.png"/>
</a>
<a href="http://www.stackoverflow.com">
<p>Stackoverflow</p>
</a>
</body>
</html>"""
output_filename = "output.pdf"
# open output file for writing (truncated binary)
result_file = open(output_filename, "w+b")
# convert HTML to PDF
pisa.CreatePDF(
source_HTML,
dest=result_file)
result_file.close()
The html should render both an hyperlink image and a hyperlink text, but xhtml2pdf renders the image without the hyperlink and the text with the hyperlink. Is this an issue with the code above or a limitation/bug with the library? Thanks in advance for any help with the above issue.

I found a way to get this too work but it is not very good.
You can add a before and after the img inside the A tag. And then set the font-size on the A tag to be the height of the image and then also set text-decoration to none.
So like I said this works but is not a great solution. I searched issues on xhtml2pdf's github page and cannot find anyone else with this issue.

Related

How to show complex html files in flutter

I have created a html doc using GOOGLE DOCS to use in my flutter app.
But It is not working in flutter..It displays a blank screen instead of that html file .
How Can I display html files made with GOOGLE DOCS???
please help me?
you can use this plugin
[https://pub.dev/packages/flutter_html#-readme-tab-][1]
you can add HTML text in Html widget and it renders Html Text like this
Html(
data: """
<div>
<div id="header_set">
<h1>Header 1</h1>
<h2>Header 2</h2>
<h3>Header 3</h3>
<h4>Header 4</h4>
<h5>Header 5</h5>
<h6>Header 6</h6>
<hr />
Below hr
<b>Bold</b>
</div>
""");

TYPO3 Image From Extension

I'm a typo newbie, and was wondering, how I can make the following code work in my HTML Template file:
<img src="EXT:extension-name/Resources/Public/Images/Logo/logo-white.png" alt="logo.png">
Looking forward to your anwers, thanks.
This cannot be done in an HTML file but within a Fluid template file you should use the uri.resource viewhelper:
<img src="{f:uri.resource(path: 'Images/Logo/logo-white.png')}" alt="Actual explanation of the logo content">
If used within an Extbase plugin there is nothing else to do.
For templates using the FLUIDTEMPLATE content object you'll need to set the extension name, for example with an extensionName: 'MyExt' as argument:
<img src="{f:uri.resource(path: 'Images/Logo/logo-white.png', extensionName: 'MyExt')}" alt="Actual explanation of the logo content">
Alternatively use controllerExtensionName in your TypoScript setup.

Tinymce as email editor - image preview with CID

I am using Tinymce as an email editor. When inserting an embedded image as attachment, the images are inserted as:
<img src="cid:mycid#sth" />
This works for the email sending part - but of course not for the editor. The image is not displayed...
Question: Is there a "content" and "display" layer in Tinymce where I can hook into?
My goal is to save the content as
<img src="cid:mycid#sth" />
and transform it in the editor window as
<img src="/mypreview/image/2000" />
I am using Tinymce 4.
The editor relies on the browser for the rendering of HTML so anything like your <img src="cid:mycid#sth" /> won't render in the editor - its simply not valid HTML.
What you can do is rely on data-xxx attributes in HTML to store the data you really want and transform the HTML when you go to load it into TinyMCE.
For example...
When someone inserts the image you could create the following HTML
<img data-src="cid:mycid#sth" src="/mypreview/image/2000" />
...this would allow the editor to actually render an image while you still keep the data you need. When you save the content you can strip out the existing src data and copy the data-src content back into the src if that is what your app needs for its server side processing.
If someone edits the content you can just reverse the process and change the src back to HTML that TinyMCE can render.

Tumblr Photo Caption within Container

I have a blog theme which does not include captions in photo posts. I have been successful with plugging in {block:Caption} {Caption} {/block:Caption} before {/block:Photo}, but the caption seems to be floating on the background and not inside the post box as seen below:
How do I include the caption to be apart of the same box as the date?
Any help is appreciated!
It would be much easier if you posted the relevant code here. I don't know what theme you are using but if you take a look at this site http://www.tumblr.com/docs/en/custom_themes you'll see that dates are rendered by {block:Date} {/block:Date}, {Timestamp}, {DayOfYear} etc. Take a look and see which one suits you theme. When you have found it, simply Ctrl + F in you code and find where in your HTML code the date box is rendered and then put the {block:Caption} {Caption} {/block:Caption} inside.

Correct img tag

I'd like to ask you which img tag is right:
<img src="http://i.imgur.com/r5wwImhb.jpg">
or
<img src="http://i.imgur.com/r5wwImhb.jpg"/>
Thank you.
It depends on if you are using HTML or XHTML. The first one is correct in HTML and the second one in XHTML.
According to the first search result for <img> tag on w3schools:
In HTML the <img> tag has no end tag.
In XHTML the <img> tag must be properly closed.