Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display pdf image in markdown

Tags:

html

markdown

Is this possible? Everything I'm google leads me to converting markdown to PDF. But I want to display a PDF image in a markdown file. This is my example:

![hustlin_erd](erd.pdf)

If i use a regular image, it works just fine. Also I'm aware of converting PDF to image.

like image 738
Andrew Kim Avatar asked Sep 29 '16 18:09

Andrew Kim


People also ask

Can markdown display a PDF?

Markdown itself doesn't have a mechanism for embedding a PDF. However, Markdown accepts raw HTML in its input and passes it through unaltered.

How do I show an image in markdown?

Images can be added to any markdown page using the following markdown syntax: ![ alt text for screen readers](/path/to/image. png "Text to show on mouseover") .

How do I view a PDF in Github readme?

Currently there is no way to preview a pdf in github markdown, however you can embed an image of the pdf. From here: The best you can do is a greasemonkey extension which would allow you to call a pdf viewer, like the recent pdf.

How do I convert a PDF to markdown?

Save PDF as Markdown in PythonRead PDF file from the local drive, then simply save it as Markdown, specifying the required file format by MD extension. For both PDF reading and MD writing you can use fully qualified filenames. The output MD content and formatting will be identical to the original PDF document.


Video Answer


2 Answers

Markdown itself doesn't have a mechanism for embedding a PDF. However, Markdown accepts raw HTML in its input and passes it through unaltered. So the question you might want to ask is: How would you embed a PDF in HTML? In other words, what HTML would one use to have a browser display a PDF embedded in an HTML page? You would just include that HTML in your Markdown document.

You can find lots of suggestions in answers to the question: Recommended way to embed PDF in HTML?. For example, this answer provides a nice solution with a fallback for older browsers (all credit goes to Suneel Omrey):

<object data="http://yoursite.com/the.pdf" type="application/pdf" width="700px" height="700px">
    <embed src="http://yoursite.com/the.pdf">
        <p>This browser does not support PDFs. Please download the PDF to view it: <a href="http://yoursite.com/the.pdf">Download PDF</a>.</p>
    </embed>
</object>
like image 96
Waylan Avatar answered Oct 13 '22 10:10

Waylan


I have found a better way by using xfun R package.

xfun::embed_file("homework.pdf")

This will embed your pdf file in the output of the Rmarkdown. MOre information can be seen via link.

I hope you will enjoy this.

like image 20
gbganalyst Avatar answered Oct 13 '22 09:10

gbganalyst