Files
the_information_nexus/tech_docs/pdf_creation.md

9.3 KiB
Raw Permalink Blame History

In addition to Pandoc and LaTeX, there are several other CLI tools that can help you create, convert, and customize PDFs with similar capabilities. Here are some notable alternatives:

1. wkhtmltopdf

wkhtmltopdf is a command-line tool that converts HTML and CSS documents to PDF using the Webkit rendering engine. Its useful for generating PDFs from web pages or HTML content.

Installation:

sudo apt-get install wkhtmltopdf

Usage:

wkhtmltopdf input.html output.pdf

2. Prince

Prince is a powerful tool for converting HTML and CSS to PDF with a high degree of accuracy and customization options. Its particularly useful for producing print-quality documents.

Installation and Usage: You need to download and install Prince from its official website, as its not typically available via package managers.

Usage:

prince input.html -o output.pdf

3. WeasyPrint

WeasyPrint is a visual rendering engine for HTML and CSS that can output to PDF. Its written in Python and can be installed via pip.

Installation:

pip install weasyprint

Usage:

weasyprint input.html output.pdf

4. TeXShop

TeXShop is a TeX editor and previewer for macOS, useful for creating LaTeX documents. While its more of an editor than a CLI tool, its helpful for LaTeX-based workflows.

Installation: Download from the official website.

5. PDFtk (PDF Toolkit)

PDFtk is a versatile tool for manipulating PDF documents. It can merge, split, encrypt, decrypt, and watermark PDFs.

Installation:

sudo apt-get install pdftk

Usage:

pdftk input1.pdf input2.pdf cat output output.pdf

6. Ghostscript

Ghostscript is an interpreter for PostScript and PDF files. Its very powerful for converting and manipulating PDF files.

Installation:

sudo apt-get install ghostscript

Usage:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf input.ps

7. Apache FOP (Formatting Objects Processor)

Apache FOP is a print formatter driven by XSL formatting objects (XSL-FO). It can convert XML data to PDF and other formats.

Installation and Usage: Download from the official website.

Usage:

fop input.fo output.pdf

8. PDFjam

PDFjam is a small collection of shell scripts that provide a simple interface to some of the functionality of the pdfpages package for PDF document merging, splitting, and more.

Installation:

sudo apt-get install pdfjam

Usage:

pdfjam input.pdf --outfile output.pdf

Comparison of Tools

Tool Input Formats Output Formats Key Features
Pandoc Markdown, HTML, LaTeX PDF, DOCX, HTML, etc Versatile document converter
wkhtmltopdf HTML, CSS PDF HTML to PDF conversion using Webkit engine
Prince HTML, CSS PDF High-quality PDF rendering from HTML/CSS
WeasyPrint HTML, CSS PDF Python-based HTML to PDF conversion
TeXShop LaTeX PDF LaTeX editor for macOS
PDFtk PDF PDF PDF manipulation (merge, split, etc.)
Ghostscript PostScript, PDF PDF Powerful PDF processing
Apache FOP XML (XSL-FO) PDF, PS XML to PDF conversion using XSL-FO
PDFjam PDF PDF Simple PDF manipulation

Each tool has its strengths and use cases. Depending on your specific needs, you may choose one or more of these tools to create, convert, and manipulate PDFs effectively.


Certainly! Heres a more detailed guide to creating a visually appealing PDF using CLI tools on Linux, with a focus on using Markdown, LaTeX, and Pandoc.

Step-by-Step Guide to Creating a Visually Appealing PDF

Creating a polished PDF using command-line tools on Linux involves several steps, from writing your content in Markdown to customizing the PDF with LaTeX. Follow these steps to create a visually engaging PDF.

Step 1: Write Your Content in Markdown

Markdown is a lightweight markup language that's easy to read and write. First, create a Markdown file (schedule.md) with your content:

---
title: "Cisco Live 2024 Las Vegas Transportation Schedule"
author: "Cisco"
date: "June 2-6, 2024"
geometry: margin=1in
header-includes:
    - \usepackage{fancyhdr}
    - \pagestyle{fancy}
    - \fancyhead[L]{Cisco Live 2024}
    - \fancyhead[R]{Las Vegas}
    - \fancyfoot[C]{\thepage}
---

# Hotels Within Walking Distance to Mandalay Bay Convention Center
- Delano
- Four Seasons
- Luxor

# Shuttle Schedule

## Saturday, June 1
- 2:30 p.m. - 7:30 p.m.

## Sunday, June 2
- 6:30 a.m. - 9:00 a.m.
- 9:00 a.m. - 4:00 p.m.
- 4:00 p.m. - 7:30 p.m.

## Monday, June 3
- 6:30 a.m. - 10:30 a.m.
- 10:30 a.m. - 5:00 p.m.
- 5:00 p.m. - 7:30 p.m.

## Tuesday, June 4
- 6:30 a.m. - 9:00 a.m.
- 9:00 a.m. - 4:00 p.m.
- 4:00 p.m. - 7:30 p.m.

## Wednesday, June 5
- 6:30 a.m. - 9:00 a.m.
- 9:00 a.m. - 4:00 p.m.
- 4:00 p.m. - 7:00 p.m.

## Thursday, June 6
- 6:30 a.m. - 9:00 a.m.
- 9:00 a.m. - 1:00 p.m.
- 1:00 p.m. - 3:30 p.m.

# Cisco Live Celebration Shuttle
- 7:15 p.m. - 11:30 p.m.
- Continuous shuttle between Allegiant Stadium and the following hotels:
    - Mandalay Bay / Delano / Four Seasons - Boarding at Shark Reef Lot
    - MGM Grand / MGM Signature - Boarding at Top Golf Exit
    - Luxor - Boarding at Tour Bus Area South Las Vegas Blvd

---

_**Accessible transportation is available at shuttle stops during hours of operation. Please call 619-727-1908 at least 90 minutes in advance of your pick-up time to make arrangements.**_

---

# Shuttle Route Map

![Shuttle Route Map](shuttle-route-map.png)

Step 2: Create a LaTeX Template

LaTeX is a powerful typesetting system that's great for creating structured and visually appealing documents. Create a LaTeX template (template.tex) to define the style and layout of your PDF:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{hyperref}
\geometry{a4paper, margin=1in}
\pagestyle{fancy}
\fancyhead[L]{Cisco Live 2024}
\fancyhead[R]{Las Vegas}
\fancyfoot[C]{\thepage}
\titleformat{\section}
  {\color{blue}\normalfont\Large\bfseries}
  {\thesection}{1em}{}
\titleformat{\subsection}
  {\color{blue}\normalfont\large\bfseries}
  {\thesubsection}{1em}{}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,
    urlcolor=cyan,
    pdftitle={Cisco Live 2024 Schedule},
    pdfpagemode=FullScreen,
}

\title{Cisco Live 2024 Las Vegas Transportation Schedule}
\author{Cisco}
\date{June 2-6, 2024}

\begin{document}

\maketitle
\tableofcontents
\newpage

$body$

\end{document}

Step 3: Convert Markdown to PDF Using Pandoc

Pandoc is a universal document converter that can transform your Markdown file into a beautifully formatted PDF using your LaTeX template. First, ensure you have Pandoc and LaTeX installed:

sudo apt-get install pandoc texlive-full

Next, use the following command to convert your Markdown file to a PDF:

pandoc schedule.md -o schedule.pdf --template=template.tex --pdf-engine=xelatex

Enhancements and Customizations

To make your PDF more engaging, you can incorporate various LaTeX packages and features.

  1. Custom Fonts: LaTeX allows you to use custom fonts for better typography. Add the fontspec package to your template:

    \usepackage{fontspec}
    \setmainfont{Arial}
    \setsansfont{Helvetica}
    
  2. Including Images: You can add images to your Markdown file, and they will be rendered in the PDF:

    ![Shuttle Route Map](shuttle-route-map.png)
    
  3. Creating Tables: Use Markdown syntax to create tables. Pandoc will convert them to LaTeX tables:

    | Time          | Event             |
    |---------------|-------------------|
    | 6:30 a.m.     | Shuttle Starts    |
    | 9:00 a.m.     | Morning Break     |
    
  4. Hyperlinks: Add hyperlinks to your document using Markdown syntax:

    [Cisco Live](https://www.ciscolive.com)
    
  5. Advanced Graphics: LaTeX provides powerful tools for creating graphics and diagrams. For example, you can use the tikz package for custom graphics:

    \usepackage{tikz}
    

Example Commands to Install Required Tools

If you haven't already installed Pandoc and LaTeX, use the following commands to install them:

sudo apt-get install pandoc texlive-full

Final Thoughts

Experiment with different LaTeX packages and customizations to achieve the desired look and feel for your document. With Pandoc and LaTeX, you can create highly professional and visually appealing PDFs from simple Markdown files, making your documents both functional and aesthetically pleasing.