-
Notifications
You must be signed in to change notification settings - Fork 2
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
Images in markdown do not get pulled in #25
Comments
markdown-pdf by default uses the current folder ( The image file in To use absolute file pathes, set the In your code this change will be like this: pdf.add_section(Section(md, root='')) |
That doesn't seem to work. I also moved the markdown and image file local to the python script and that doesn't seem to work either. The markdown comes in ok, no image. |
I can pull an image into it's own section on it's own. Without being inside markdown. |
Sorry to be a problem child. This is a very useful library and I really appreciate your work. |
Sorry, I really didn’t notice that in Intro.md you use markdown-pdf is designed to handle Try changing the code for the image in Intro.md to the following: [Steep Rocky- Oak/Juniper/Woodland in foreground. Loamy Bottomland-San Saba River in background](titletest1.jpeg) And place the file |
Tried that. Still no luck. |
You can try the example from the readme yourself. The generated pdf will contain an embedded image with the Python logo. You need to clone the markdown-pdf repository to your host, open a console window, go to the root directory of the project (where the README.md file is located) and run python makepdf.py README.md markdown_pdf.pdf A markdown_pdf.pdf file will be created in this directory. If successful, this will be a good starting point for writing the code you need. |
I have successfully gotten the example to work without a problem. That's how I started. Inserting an image into the pdf using the library works fine. But if the image is referenced in the markdown file, even using a markdown reference and not html, it does not make it into the pdf. Even if the image correctly displays when previewing the markdown in a browser. The markdown:
Image rendering correctly when referenced in markdown: Resulting pdf: |
If using a referenced image is just not included in the current functionality, fine. I accept that. I just wanted to make sure it was not a bug. |
Hi, I know this is an older issue but I was having the same problem and I found a solution: I needed to add the full path to the image file in the So my code in my specific project is
|
Yes, the root argument is intended for cases where the embedded image files are not located in the current directory. |
I am using markdown-pdf to pull in several existing markdown files with embedded images and write them to a single pdf. The separate markdowns display the images (with either a relative or absolute path) correctly. But, when I read them into the library with pdf.add_section the markdown comes in fine and converts to a pdf file but the image is not included.
Code:
`from markdown_pdf import MarkdownPdf
from markdown_pdf import Section
create pdf
pdf = MarkdownPdf(toc_level=2)
add section
pdf.add_section(Section("# Catchment ID 44193\n"))
add 2nd section from markdown file
md = open('./markdown/Intro.md', 'r', newline='', encoding='utf-8-sig').read()
pdf.add_section(Section(md))
set pdf properties
pdf.meta["title"] = "LOCA Report"
pdf.meta["author"] = "Tyson Broad"
save pdf
pdf.save("./src/python/md2pdf_test3.pdf")
`
Image of the local markdown displaying image correctly:
Problematic markdown text attached.
Intro.md
Output PDF attached.
md2pdf_test3.pdf
The text was updated successfully, but these errors were encountered: