Skip to content

Instantly share code, notes, and snippets.

#
# systemd unit file for CentOS 7, Ubuntu 15.04
#
# Customize this file based on your bundler location, app directory, etc.
# Put this in /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
# Run:
# - systemctl enable hypdf
# - systemctl {start,stop,restart} hypdf
#
[Unit]
@redfield
redfield / hypdf_svg_to_pdf.rb
Created January 3, 2014 10:46
Converting SVG to PDF using HyPDF
require 'hypdf'
require 'open-uri'
require 'base64'
# SVG file from wikipedia article
svg = open('http://upload.wikimedia.org/wikipedia/commons/1/12/%D0%9F%D1%80%D0%B8%D0%BC%D0%B5%D1%80_%D1%87%D0%B5%D1%80%D1%82%D0%B5%D0%B6%D0%B0_%D0%B2_SVG_%D1%84%D0%BE%D1%80%D0%BC%D0%B0%D1%82%D0%B5.svg').read
# Embedding SVG to HTML via <img> tag
html = "<html><img src='data:image/svg+xml;base64,#{Base64.encode64(svg)}'></html>"
@redfield
redfield / hypdf_python_example.py
Created October 12, 2013 08:39
Example python application for HyPDF
import requests # http://docs.python-requests.org/
from flask import Flask # http://flask.pocoo.org/
from flask import request
app = Flask(__name__)
# Make request to the HyPDF and upload the created file to the AWS S3 in an asynchronous style.
@app.route("/")
def index():
params = {'user': 'HYPDF_USER', 'password': 'HYPDF_PASSWORD', 'test': 'true', 'content': '<html><body>Test</body</html>', 'bucket': 'hypdf_test', 'key': 'hypdf_test.pdf', 'public': 'true', 'callback': 'http://yoursite.com/pdf_complete'}
r = requests.post('https://www.hypdf.com/htmltopdf', data=params)
var FormData = require('form-data'),
fs = require("fs");
var form = new FormData();
form.append('user', 'HYPDF_USER');
form.append('password', 'HYPDF_PASSWORD');
form.append('test', 'true');
form.append('bucket', 'hypdf_test');
form.append('key', 'hypdf_test.pdf');
form.append('public', 'true');
@redfield
redfield / HyPDF_fonts
Created August 30, 2013 03:44
List of all HyPDF fonts
Andale Mono
Arial Black
Arial
Century Schoolbook L
Comic Sans MS
Courier New
DejaVu Sans Mono
DejaVu Sans
DejaVu Serif
Dingbats

Ruby/Rails

  1. Install HyPDF addon with your plan

    $ heroku addons:add hypdf:giga

  2. Add HyPDF credentials to your local .env file

    $ heroku config -s | grep HYPDF_ >> .env