Jekyll plugin for embedding PDF files to any page or post

Ruby


Introduction

Jekyll PDF Embed is a ruby gem for Jekyll static site generator. It allows user to easily embed external or local PDF files to any page or blog post.

Installation

RubyGems

Add this line to your Gemfile:

group :jekyll_plugins do
  gem "jekyll-pdf-embed"
end

And then execute:

$ bundle

Alternatively install the gem yourself as:

$ gem install jekyll-pdf-embed

and put this in your _config.yml

plugins:
  - jekyll-pdf-embed

GitHub RubyGems registry

Install from the command line (you can put any version you want, check the latest):

$ gem install jekyll-pdf-embed --version "1.1.1" --source "https://rubygems.pkg.github.com/mihajlonesic" 

Alternatively, install via Gemfile:

source "https://rubygems.pkg.github.com/mihajlonesic" do
  gem "jekyll-pdf-embed", "1.1.1"
end 

Usage

Your file must end with .pdf, .ppt or .pptx. Everyting else is forbidden.

Basic

You can use external PDF files

 {% pdf "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" %}

or local

 {% pdf "/files/pdf/sample.pdf" %}

Use front matter

---
pdf_file: "/files/pdf/sample.pdf"
---

 {% pdf {{ page.pdf_file }} %}

Parameters

Use no_link to hide link to pdf file (‘View PDF’ header)

 {% pdf "/files/pdf/sample.pdf" no_link %}

Use width and/or height parameters to size the container. Default values are width=100% and height=650px.
Order does not matter, and can be used in combination with no_link parameter.

 {% pdf "/files/pdf/sample.pdf" width=350px height=500px %}

Presentation

You can also embed PowerPoint presentations!

 {% pdf "http://img.labnol.org/di/PowerPoint.ppt" %}

Result

CLICK HERE FOR MORE EXAMPLES

The embedded pdf output

PDF output without link

Custom size

PowerPoint presentation