Skip to content

Instantly share code, notes, and snippets.

View DocumentAlchemy's full-sized avatar

Document Alchemy DocumentAlchemy

View GitHub Profile
@DocumentAlchemy
DocumentAlchemy / powerpoint-to-pdf
Last active March 15, 2019 09:08
Shell script using https://documentalchemy.com API to convert a PowerPoint file into a PDF.
#!/bin/bash
# powerpoint-to-pdf <PPT-FILE> [<PDF-FILE>]
# Uses <https://documentalchemy.com/> to convert a PowerPoint document to PDF.
# SET YOUR DOCUMENT ALCHEMY API KEY HERE (OR PASS AS AN ENV VAR).
# SIGN UP AT <https://documentalchemy.com/> TO GET YOUR FREE API KEY.
DA_API_KEY=${DA_API_KEY:-"EDs2UQEprGn9aD4vg6HCPhFvgQFDahQgRzzIfocJ"}
# PRINT USAGE MESSAGE
show_help() {
@DocumentAlchemy
DocumentAlchemy / add-cover.sh
Created April 23, 2016 14:31
Add a cover page to one or more PDF documents using curl and https://documentalchemy.com/
#!/bin/bash
# Adds a cover page to one or more PDF documents.
# USAGE: add-cover.sh <COVER-PAGE> <FILES>
#
# EXAMPLE: add-cover.sh cover.pdf doc/*.pdf
# This is your DocumentAlchemy API key. It may be set via the
# environment variable named `DA_API_KEY`.
@DocumentAlchemy
DocumentAlchemy / add-cover.sh
Created April 20, 2016 06:30
Shell script to join PDF documents - add a "cover page" to one or more PDF documents using curl and https://documentalchemy.com/
#!/bin/bash
# Adds a cover page to one or more PDF documents.
# USAGE: add-cover.sh <COVER-PAGE> <FILES>
#
# EXAMPLE: add-cover.sh cover.pdf doc/*.pdf
# This is your DocumentAlchemy API key. It may be set via the
# environment variable named `DA_API_KEY`.
@DocumentAlchemy
DocumentAlchemy / combine-pdf-example.sh
Created April 19, 2016 07:54
Example of a curl command to join two PDF documents using <https:/documentalchemy.com/>
curl -H "Authorization: da.key=403l1zh3dkbakyb9" \
-X POST \
-F "document=@TITLE-PAGE.PDF" \
-F "document=@DOC_BODY.PDF" \
https://documentalchemy.com/api/v1/documents/-/rendition/combined.pdf \
-o "combined.pdf"
@DocumentAlchemy
DocumentAlchemy / md2x.sh
Last active April 19, 2016 04:03
Convert Markdown to HTML, PDF or MS Word (DOCX) from the command line using https://documentalchemy.com/
#!/bin/bash
# Converts a Markdown file into an HTML, PDF or Microsoft Word document
# USAGE: md2x.sh <MARKDOWN-FILE> <FORMAT>
#
# EXAMPLE: md2x.sh README.md pdf
# This is your DocumentAlchemy API key. It may be set via the
# environment variable named `DA_API_KEY`.
# (See <https://documentalchemy.com/> to get one of your own.)
@DocumentAlchemy
DocumentAlchemy / extract-images.sh
Created April 19, 2016 04:02
Shell script that extracts all images from PDF, PPT/X, DOC/X and XLS/X documents
#!/bin/bash
# Extracts images from Microsoft Office or PDF files using the DocumentAlchemy API.
# USAGE: extract-images.sh <FILES>
#
# EXAMPLE: extract-images.sh MyDeck.pptx *.doc
# A ZIP archive containing the extracted images (if any) will be
# created for each document submitted.
@DocumentAlchemy
DocumentAlchemy / extract-image-example.sh
Created April 19, 2016 03:51
Example of curl command to extract images from MS Office or PDF documents using DocumentAlchemy
curl -H "Authorization: da.key=403l1zh3dkbakyb9" \
-X POST --form "document=@MY-DECK.PPTX" \
https://documentalchemy.com/api/v1/document/-/rendition/images.zip \
-o "IMAGES-FROM-MY-DECK.ZIP"
@DocumentAlchemy
DocumentAlchemy / resize-image.sh
Created April 19, 2016 01:14
Shell script that will resizes one or more images to a fixed width using the DocumentAlchemy API
#!/bin/bash
# Resizes one or more images to a fixed width using the DocumentAlchemy API
# USAGE: resize.sh <NEW-WIDTH> <FILES>
#
# EXAMPLE: resize.sh 180 images/*.png
# The generated files will have the same name (and location) as their source
# image, but with '-resized' inserted between the filename and the extension.
@DocumentAlchemy
DocumentAlchemy / resize-image-example-curl.sh
Last active April 19, 2016 00:58
An example of using curl and the DocumentAlchemy API to resize an image.
# Example of using curl and the DocumentAlchemy API to render a
# scale an image to fixed width while preserving the orignal
# aspect ratio.
# This particular example will work with PNG and JPEG files,
# and convert any input JPEG documents to PNG.
# See <https://documentalchemy.com/> for more information about
# DocumentAlchemy's document conversion and processing capabilities.
@DocumentAlchemy
DocumentAlchemy / md2pdf-example.sh
Last active April 18, 2016 00:26
Example of using curl and DocumentAlchemy to render a Markdown file as a PDF document via the command line.
# Example of using curl and the DocumentAlchemy API to render a
# Markdown document as a PDF.
# There are several parameters that can be used to control the
# structure and format of the generated PDF document that are
# not included in this simple example. See the DocumentAlchemy
# API documentation at <https://documentalchemy.com/api-doc> for
# more information about these options.
#
# See <https://documentalchemy.com/> for more information about