-
Notifications
You must be signed in to change notification settings - Fork 58
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
Render iframes as an image when exporting to PDF #4052
Comments
This will be extremely useful. I currently use Typora to make some reports using a custom monitoring system that render charts, this charts aren't dynamic but since they are rendered using CSR Apache Echarts Canvas I am unable to see when exporting to PDF, the only solution I see is by first making an image of the Iframe container and then inserting it to Typora. It will be useful to have this feature in Typora, hope this feature is planned at least |
I currently have a similar solution since Typora doesn't have another way of showing generated graphs of maths functions. I embed a desmos.com graph, but it's still not converting it to an image when exporting. I would really like this, or the ability to generate maths functions within Typora itself. See #5714. |
A workaround, in case anyone still needs:
<script>
document.querySelectorAll('my-iframe').forEach(function(e) {
var iframe = document.createElement('iframe');
Array.prototype.slice.call(e.attributes).forEach(function(attribute) {
iframe.setAttribute(attribute.name, attribute.value);
});
p.parentNode.replaceChild(iframe, e);
});
</script>
The nested iframe will provide a preview during editing, but will be removed after export. The custom element will be converted to an iframe by our script, which should render properly in the PDF. Note: better use local html file because it seems that Typora does not always wait for iframe to finish loading. |
I'm using some javascript libraries to make charts within my document right now, and I'm happy using iframes and pointing to a file as a sort of asset to generate them. It works perfectly fine within Typora or when exporting HTML, however for obvious reasons the iframe goes missing when exporting to PDF. I would like the iframe to be rendered and embedded into the PDF file in some way instead.
Some possible issues I can think of:
Apologies if there's an existing way of doing something similar that I don't know of. Thanks in advance!
The text was updated successfully, but these errors were encountered: