Display PDF in GitHub Markdown
Asked Answered
H

2

20

This is quite similar to what is being asked in this post, but the post does not seem to work for GitHub's parsed Markdown.

Simply put, let us say I have a PDF in a GitHub repository. Is there any way to render/embed that in a markdown file that is in the repository (e.g. the README.md file)?

I would also be open to having the PDF in a location other than GitHub and linking to it from the markdown file if that is what is required to make this work.

Herriot answered 25/10, 2020 at 7:38 Comment(9)
I think there is no way to directly render the pdf but you can embed pdf's imagePungy
@at-in If the PDF could be embed, then that would work as well.Herriot
I did some more googling but didn't find any way to preview the pdf directly in readme but you can preview it in github pagesPungy
And for readme or any other markdown file you can embed image of the pdf but not the pdf.Pungy
I've added an answer stating the same things I said here. I'll update it if in future github provides a way to do this.Pungy
Does this answer your question? PDF to Github Flavored MarkdownPungy
@at-in Not quite. For the requirements given to me, it all had to be contained in the view of the Markdown file. So, I had to convert the PDF into a bunch of PNGs and put links to them in the markdown for previewing directly.Herriot
Oh then I don't think there is any other way to do this yet(?), I'll update this answer if I find anything :)Pungy
I found that taking a screenshot snip of the PDF and saving it as a JPEG works just fine. Incidentally, if you're using Visio and try to export to a JPEG directly, it crops the margins completely down to the content, which looks ugly in the README panel in my opinion. Either use my suggestion above, or insert transparent elements into the corners of the Visio document before exporting it so that it doesn't crop down to the content.Intitule
P
7

Currently there is no way to preview a pdf in github markdown, however you can embed an image of the pdf.

Edit
From here:

The best you can do is a greasemonkey extension which would allow you to call a pdf viewer, like the recent pdf.js (a Portable Document Format (PDF) viewer that is built with HTML5.), allowing you to view a pdf entirely online, without any pdf plugin installed.

Pungy answered 25/10, 2020 at 11:27 Comment(2)
Just to clarify, do you mean embedding the pages of the PDF as some kind of image format such as PNGs?Herriot
Yes, you can convert the pages of pdf in different images or the whole pdf into a single image.Pungy
T
4

As far as I know, this is not possible on GitHub.

However, you can upload it as a file in the same repository and then add a link to it with a relative path.

[Some title here](FILE_NAME.pdf)
Testa answered 15/1, 2023 at 15:57 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.