-
Notifications
You must be signed in to change notification settings - Fork 569
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
Pdf doesn't include images #552
Comments
Could you try converting first to Do you run into the same error? We don't support pdf export from general HTML markup in markdown cells. I'm not sure if this is within or outside the purview of our intended coverage area. |
I think the issue here is that our PDF conversion produces latex in a temporary directory, and then runs xelatex on it there. It extracts images embedded in the notebook to a location where it can refer to them, but it doesn't copy images referenced from Markdown cells to a matching location in the temporary directory, so the references to them in the generated Latex break. See also #52. |
@mpacer you are right once I get the latex file i can compile it manually with my latex compiler with no issues. I guess It confirms @takluyver explanation. Why don't we have access to |
Great question! i'll make a PR and we'll find out.
…On Wed, Mar 22, 2017 at 9:26 AM, Alexandre Couedelo < ***@***.***> wrote:
@mpacer <https://github.com/mpacer> you are right once I get the latex
file i can compile it manually with my latex compiler with no issues. I
guess It confirms @takluyver <https://github.com/takluyver> explanation.
Why don't we have access to download as latex via the file menu? Is this
intentional?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#552 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACXg6P9g_pgRrGez90ig_kJf34XX3O7vks5roUukgaJpZM4Mi84L>
.
|
@xNok So made a PR, Specifically, the This happens to be part of a more general project I'm going to be working on re: better in browser conversion capabilities. Keep an eye out for my PRs on the notebook repo in the coming weeks for updates. edit: Corrected earlier mistakes |
Correction — the LaTeX file will grab outputs and instead with download a zip if there are outputs. I just didn't realise that my test notebook for this didn't have any output images. |
Please see the following code of auto generated Latex file created by Jupyter Notebook (ipynb) file. You can open the .tex extension file in the editor and go to the line 32 or 33 where you will find the bold line and comment it out. Your problem will be partially solved. Hope it solves your problem, mine is solved and i generated pdf from latex including graphics. |
Hi, Background:
How I solved it:
My guess:
|
In case it helps people out, a surprisingly works-great workaround for this issue is to use the Print Preview, then save that to a .pdf. That's:
Plots, images, everything, should be in there no problem Another note: an additional benefit of this method is that is automatically handles text wrapping. The .pdf from latex does not do text wrapping in the code cells Updated to prefer Print Preview rather than saving to .html. The latter may have issues embedding external images, but not the former |
@peteflorence Print Preview doesn't work for me for a full slide deck, it will only prepare a pdf of the slide being viewed. nbconvert would/should produce the full deck. |
In my case, I added a .png file using a website URL. Currently it does not work. Hope my comment helps. |
Thank you so much! Solved my issue by deleting "./" |
Hi, I succeed to include image when converting ipynb to pdf. However, some funny thing showed up, the image doesn't belong where they're supposed to be. Like, the picture I insert in the first markdown cell shows up in the next md cell or somewhere strange. I don't quite know about latex, so I haven't consider manually edit the tex file, I wonder if there is any easy solution? Much thanks |
@1uciusy I think I have a solution: add
somewhere to the top of the latex file, but after the Ultimately, I think that issue is worth a bug report of it's own. I'll working on submitting some of my fixes some one of my other repos back to nbconvert and this will be one of them. |
Interestingly, if the latex file to be manually converted to a pdf is created by using the JupyterLab File>Export Notebook As... conversion. TeXworks will not find any embedded .png files. I advise to always create the latex files in the command line as:
|
nbconvert --to latex
|
see mpacer's comment on mar 20 2017 above, support for general html in markdown cells is not guaranteed |
Hi! I am also using
and "lose" the markup included images, e.g.,
is not included at all in the tex document. What I did not get from the current discussion:
I use the export on a large number of lecture scripts and have some sed-based postprocessing of the LaTeX files, so I would really appreciate some way to export the file information into the tex file (even if it were commented out, then I could include it myself via sed). Thanks a lot, best regards Edit: I found a way around the issue. Ugly, but at least it works. I add to my markup text and replace it then afterwards using sed:
|
@SebastianSager re 1 we got image export working using matplotlib image |
I fixed it by converting: to: All the comments by @mpacer and @kangwonlee are spot on and were very helpful. I'm just adding this example because I missed those on my first pass. I'm hoping this will help somebody in the future if they are scanning this issue. |
Some of theses issues are a real pain to fix in nbconvert. I'm planning to get some fixes in for the 6.0 release that will help with some, but no one's really spending the significant time to refactor and address some of the fundamental issues causing these (many aren't even in jupyter). If someone has some time and a will to dig into the topic I'll gladly help review / advise where I can / know what's wrong, but I and the other current maintainers are unlikely to find the time to solve all of these for some time. |
Hi, Since the browser support is very good for IPFS and beyond this "technical issue", thing will become much simpler to organize and allocate. I think this could be a great investment in the portability of notebooks in general, if for instance IPFS will get included. |
IPFS based file scheme is a pretty experimental concept, probably would be a challenge to adopt across jupyter projects as a whole. The underlying issue is with associated assets in different contexts. Filesystems have 60+ years of established precedent that we should still be trying to make usable. The main issue is with the dependent tools being so working directory constrained that they're inflexible to setting working directories / accessing relative file paths in a consistent manner. They make a lot of assumptions that don't hold up well for nbconvert's execution model. |
I am facing the same issue anyone has a solution or workaround? |
Same issue here. None of the solutions above works for me. Also by doing this in a Markdown cell: \begin{figure}[h!]
\includegraphics{myImage.png}
\end{figure} the exported PDF does not show any image, but an empty blank space instead, by the look of it exactly of the size of the referenced image. It seems they have an open issue for this: |
For anyone experiencing this issue I found what seems to be a workaround after none of the above did. Download the notebook as an HTML file. Move the HTML file to a directory where ALL of your pictures are and make sure you are just using either ./ or just the image name. Then open the HTML doc Press Ctrl+p and save to PDF |
This is still a problem in version 6.0.7. The workaround of converting to latex then building it myself is working fine though. |
That did the trick for me too! Thanks for sharing! |
This worked for me too. Thank you |
For me it was the extra
For me it had an extra |
Hello, are there any news on this issue ? |
Any fix to this? |
There are a few workarounds available: TLDR: This should work when you export to pdf And this should work with webPDF export (last comment) |
In my case I needed to use the html
from IPython.display import display, Image
display(Image(filename="image_directory/my_image.png", width=700))
{
"tags": [
"remove_input"
]
}
jupyter nbconvert --to pdf MyNotebook.ipynb --TagRemovePreprocessor.remove_input_tags remove_input The pdf should now contain the image! |
There may have been progress on that issue, see #1079. Let's hope the fix will be available in the next release of nbconvert. As of nbconvert-7.4.0, this problem was still present. |
When exporting to PDF it does not include images inserted via markdown
When using the markdown
![Description](pb1.png)
I got this error:When using the image html tag
<img src=\"pb1-bfs.png\"/>
I got no image as an outputEverything is displayed correctly in the notebook for both case.
The text was updated successfully, but these errors were encountered: