Display pdf image in markdown - html

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.

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: Download PDF.</p>
</embed>
</object>

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.

Related

How can I directly embed audio that I have uploaded to OneDrive into HTML using the <audio> element?

I would like to know how I can directly embed an audio file that I have uploaded to OneDrive in HTML using the <audio> element.
I know there's always an Embed button in OneDrive, but I don't want that. That really only provides a big rectangle-shaped thing with a music icon and the filename, and when I click that, I'm still redirected to OneDrive. How can I really embed this using the HTML <audio> element?
I actually already tried the Copy Audio Location menu item from Firefox's context menu. It gave me a link that worked in the Dreamweaver's Live Preview (in the split view), but it didn't work in any other browser, including Firefox and Chrome.
I would like to use pure HTML to do this, i.e. no JavaScript.
Does anyone know how to do this? Thanks!
You can probably do it this way:
Get the direct link to the file:
how to do it:
Open OneDrive and Copy Embed Code
Paste the Embed Code and Modify:
Now paste the embed code you copied in a notepad or a text editor. This code looks like this one – <iframe src="https://onedrive.live.com/embed?cid=FA476CAFF1A7E75C&resid=FA476CAFF1A7E75C%21122&authkey=AN_axXpcOy7Zfl8" width="98" height="120" frameborder="0" scrolling="no"></iframe>. You have to modify this code, remove everything except source URL of the file https://onedrive.live.com/embed?cid=FA476CAFF1A7E75C&resid=FA476CAFF1A7E75C%21122&authkey=AN_axXpcOy7Zfl8 and then just replace embed with download to get direct/permanent link. After this modification, the link should look like this – https://onedrive.live.com/download?cid=FA476CAFF1A7E75C&resid=FA476CAFF1A7E75C%21122&authkey=AN_axXpcOy7Zfl8
That’s the OneDrive direct or native link
Use this link in the audio tag:
<audio src="https://onedrive.live.com/download?cid=FA476CAFF1A7E75C&resid=FA476CAFF1A7E75C%21122&authkey=AN_axXpcOy7Zfl8"></audio>
I mean provide into src the link you get from OneDrive.

Embedding json file to display in markdown (GIthub pages+jekyll)

I have a Github page, which uses, of course, Jekyll. I have already embedded there pdf file that I have in the system with this code:
<object data="img/mypdf.pdf" type="application/pdf" width="1000px" height="800px">
</object>
Now I need to preview the json file in a similar way, but I can`t find a way for it to work. I have already this:
<a href="docs/myjson.json" download>Click to open (or right-click and "Save link as") </a>
I would like to avoid copying the content and pasting it on the page every time. It would be much easier if the content from json file is embedded and it would "preview" on the page every time myjson.json is replaced. Can you help me?

How to make GoogleBot recognize embedded object in HTML?

<object width="900" height="900" data="https://docs.google.com/gview?embedded=true&url=http://example.com/mydoc.pdf"></object>
I embed PDF on my site using the above code. The GoogleBot does not "see" the pdf embedded. The page has no other visual content on it except a link to download the same PDF. I want the bot to read the PDF and want the page to show up in SERP.
Will it work? If not, what are the options?

Embed PDF in mobile browsers

I have the code below which is a perfect solution to what I need, which would essentially be embedding any of JPG, GIF, PNG or PDF files in my webpages. It works perfectly in PC browsers, but a critical requirement for the pages is to have them compatible in mobile browsers due to its target users.
<iframe src="uploads/test1.pdf" width="auto" height="auto"> </iframe>
Although image files work fine, PDF files are opened separately in the mobile browser and not embedded inline in the web page. What would be an alternative solution or implementation to this?
You can use PDFJs library. Using just JS you can render pdf files.
Please , check here : https://mozilla.github.io/pdf.js/
One simple option is that the the object element provides a fallback, so you can do:
<object data='some.pdf'>
<p>Oops! Your browser doesn't support PDFs!</p>
<p>Download Instead</p>
</object>
Then, when the mobile browser can't get the item, it'll just show this and you'll be all set, kinda.
Here is my solution to this problem.
<object data="mypdf.pdf" type="application/pdf" frameborder="0" width="100%" height="600px" style="padding: 20px;">
<embed src="https://drive.google.com/file/d/1CRFdbp6uBDE-YKJFaqRm4uy9Z4wgMS7H/preview?usp=sharing" width="100%" height="600px"/>
</object>
Explanation:
<object> tag has a feature that when it is unable to load item, it loads the content inside itself i.e tag.
Since object tag cannot load on mobile view, therefore on mobile devices, embed tag will become active.
Q) Why can't we directly use tag for all cases?
You can actually, but since the embed tag is loading file from
drive, it does not gives any user controls for the pdf that we see
with object tag (zoom, page no., etc.). So our code will give the user pdf view controls atleast in the desktop mode instead of not giving any controls at all.
Q) Direct drive links don't work....so why this solution?
In the above google drive URL, view is changed to preview.
drive.google.com/file/d/1CRFdbp6uBDE-YKJFaqRm4uy9Z4wgMS7H/view?usp=sharing
becomes,
drive.google.com/file/d/1CRFdbp6uBDE-YKJFaqRm4uy9Z4wgMS7H/preview?usp=sharing
So, we can make direct drive links work with this little modification
Google Docs viewer offers a feature, that lets you embed PDF files and PowerPoint presentations on a web page.
<iframe src="https://docs.google.com/viewer?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:100%; height:650px;" frameborder="0"></iframe>
replace the URL(http://infolab.stanford.edu/pub/papers/google.pdf) with your own address, It's worked for me but it takes more time to load on
src:http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html?utm_source=pocket_mylist
The only way I have found, which allows you to embed pdf is using Google drive, then select the menu button once you have opened your file, and select get embed code, you can only use a Google drive or Google docs reference. And you must also turn public sharing on otherwise others won't be able to view it without permission.
Using Adobe PDF Embed API solved my problem.
Adobe PDF Embed API
I ran into the same issue. As a new developer, I wasn't aware that mobile browsers have issues embedding PDF files in iframes. I am now... lol
I racked my resources trying to get this to work when it dawned on me that mobile browsers do not have an issue displaying PNG files in a new window. So, in my infinite wisdom, I opened the PDF files in Gimp 2.0 then exported them as PNG files. And then I created buttons for the user to click and now it opens the graphic instead of trying to embed the PDF.
Looks like this:
<input class="AG" id="UnityBtn" type="button" value="Unity" onclick="location.href='../Meeting_Info/Unity.png'" />
I don't know if this is possible for you, but it worked beautifully for me.
Use an object tag with a iframe tag inside your object tags.
The object data can be a pdf or png file by changing the type and can use any link you want stored wherever, however the I frame is the one which will be loaded for mobiles which has to be a link from Google drive or Google docs you also need to allow the files to be shared public otherwise others won't be able to view them.
I would share the code but this site has some rubbish rules about code and won't let me share them so I'll leave you to Google how object and iframe tags work by viewing better sites that actually wants the help from developers.
Have fun guys!

Embed PDF in HTML

I need to embed a PDF document inside an HTML page. The PDF is dynamically generated, i.e., not a static file, but rather a byte-array generated using a PDF toolkit (in my case, "Apache PDFBox"). I have a Java Web app.
From what I understand, there are 2 ways to embed a PDF: using the OBJECT and IFRAME tags.
The <object> tag does not work for me. When I have a dynamically-generated source, it takes 20 sec. to render. I'm not sure if that is a problem of the Acrobat Reader plugin, but I have not been able to get around this strange behavior.
The <iframe> tag works fine and displays the PDF. But here's the problem: My PDF has a Submit button which submits the form. After I submit the form, I need to re-display the PDF with some kind of status message. The form output goes to the same frame. Thus, I get a Frame-inside-a-Frame. There is no way to break out of the current frame, because I don't have access to the <form> tag. The form is contained inside the PDF and Acrobat takes care of submitting the form. If I have extra elements in my frame, such as a text message, I will get cascading frames.
Any ideas how to resolve this?
<object data="myfile.pdf" type="application/pdf" width="100%" height="100%">
<p>It appears you don't have a PDF plugin for this browser.
No biggie... you can <a href="myfile.pdf">click here to
download the PDF file.</a></p>
</object>
for more details and examples.. visit this URL: http://pdfobject.com/markup/index.php