Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@shreve
Last active August 5, 2023 06:44
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shreve/0b73d9dcb7ff11336188 to your computer and use it in GitHub Desktop.
Save shreve/0b73d9dcb7ff11336188 to your computer and use it in GitHub Desktop.
Example of adding PDF metadata (bookmarks / ToC) with Ghostscript
[ /Title (Elementary Differential Equations)
/Author (Edwards & Penney)
/DOCINFO pdfmark
[ /Title (Contents)
/Page 6
/OUT pdfmark
[ /Count -8
/Title (1. First-Order Differential Equations)
/Page 14
/OUT pdfmark
[ /Title (1.1: Differential Equations and Mathematical Models) /Page 14 /OUT pdfmark
[ /Title (1.2: Integrals as General and Particular Solutions) /Page 23 /OUT pdfmark
[ /Title (1.3: Slope Fields and Solution Curves) /Page 32 /OUT pdfmark
[ /Title (1.4: Separable Equations and Applications) /Page 45 /OUT pdfmark
[ /Title (1.5: Linear First-Order Equations) /Page 59 /OUT pdfmark
[ /Title (1.6: Substitution Methods and Exact Equations) /Page 72 /OUT pdfmark
[ /Title (1.7: Population Models) /Page 87 /OUT pdfmark
[ /Title (1.8: Acceleration-Velocity Models) /Page 98 /OUT pdfmark
[ /Count -8
/Title (2. Linear Equations of Higher Order)
/Page 113
/OUT pdfmark
[ /Title (2.1: Introduction: Second-Order Linear Equations) /Page 113 /OUT pdfmark
[ /Title (2.2: General Solutions of Linear Equations) /Page 126 /OUT pdfmark
[ /Title (2.3: Homogeneous Equations with Constant Coefficients) /Page 137 /OUT pdfmark
[ /Title (2.4: Mechanical Vibrations) /Page 148 /OUT pdfmark
[ /Title (2.5: Nonhomogeneous Equations and Undetermined Coefficients) /Page 161 /OUT pdfmark
[ /Title (2.6: Forced Oscillations and Resonance) /Page 175 /OUT pdfmark
[ /Title (2.7: Electrical Circuits) /Page 186 /OUT pdfmark
[ /Title (2.8: Endpoint Problems and Eigenvalues) /Page 193 /OUT pdfmark
[ /Count -6
/Title (3. Power Series Methods)
/Page 207
/OUT pdfmark
[ /Title (3.1: Introduction and Review of Power Series) /Page 207 /OUT pdfmark
[ /Title (3.2: Series Solutions Near Ordinary Points) /Page 220 /OUT pdfmark
[ /Title (3.3: Regular Singular Points) /Page 231 /OUT pdfmark
[ /Title (3.4: Method of Frobenius: The Exceptional Cases) /Page 246 /OUT pdfmark
[ /Title (3.5: Bessel's Equation) /Page 261 /OUT pdfmark
[ /Title (3.6: Applications of Bessel Functions) /Page 270 /OUT pdfmark
[ /Count -6
/Title (4. Laplace Transform Methods)
/Page 279
/OUT pdfmark
[ /Title (4.1: Laplace Transforms and Inverse Transforms) /Page 279 /OUT pdfmark
[ /Title (4.2: Transformation on Initial Value Problems) /Page 290 /OUT pdfmark
[ /Title (4.3: Translation and Partial Fractions) /Page 302 /OUT pdfmark
[ /Title (4.4: Derivatives, Integrals, and Products of Transforms) /Page 310 /OUT pdfmark
[ /Title (4.5: Periodic and Piecewise Continuous Input Functions) /Page 317 /OUT pdfmark
[ /Title (4.6: Impulses and Delta Functions) /Page 329 /OUT pdfmark
[ /Count -8
/Title (5. Linear Systems of Differential Equations)
/Page 339
/OUT pdfmark
[ /Title (5.1: First-Order Systems and Applications) /Page 339 /OUT pdfmark
[ /Title (5.2: The Method of Elimination) /Page 351 /OUT pdfmark
[ /Title (5.3: Matrices and Linear Systems) /Page 360 /OUT pdfmark
[ /Title (5.4: The Eigenvalue Method for Homogeneous Systems) /Page 379 /OUT pdfmark
[ /Title (5.5: Second-Order Systems and Mechanical Applications) /Page 394 /OUT pdfmark
[ /Title (5.6: Multiple Eigenvalue Solutions) /Page 406 /OUT pdfmark
[ /Title (5.7: Matrix Exponentials and Linear Systems) /Page 420 /OUT pdfmark
[ /Title (5.8: Nonhomogeneous Linear Systems) /Page 433 /OUT pdfmark
[ /Count -4
/Title (6. Numerical Methods)
/Page 443
/OUT pdfmark
[ /Title (6.1: Numerical Approximation: Euler's Method) /Page 443 /OUT pdfmark
[ /Title (6.2: A Closer Look at the Euler Method) /Page 455 /OUT pdfmark
[ /Title (6.3: The Runge-Kutta Method) /Page 466 /OUT pdfmark
[ /Title (6.4: Numerical Methods for Systems) /Page 477 /OUT pdfmark
[ /Count -6
/Title (7. Nonlinear Systems and Phenomena)
/Page 493
/OUT pdfmark
[ /Title (7.1: Equilibrium Solutions and Stability) /Page 493 /OUT pdfmark
[ /Title (7.2: Stability and the Phase Plane) /Page 501 /OUT pdfmark
[ /Title (7.3: Linear and Almost Linear Systems) /Page 513 /OUT pdfmark
[ /Title (7.4: Ecological Models: Predators and Competitors) /Page 526 /OUT pdfmark
[ /Title (7.5: Nonlinear Mechanical Systems) /Page 539 /OUT pdfmark
[ /Title (7.6: Chaos in Dynamical Systems) /Page 555 /OUT pdfmark
[ /Count -7
/Title (Answers to Selected Problems)
/Page 586
/OUT pdfmark
[ /Title (Chapter 1) /Page 586 /OUT pdfmark
[ /Title (Chapter 2) /Page 595 /OUT pdfmark
[ /Title (Chapter 3) /Page 600 /OUT pdfmark
[ /Title (Chapter 4) /Page 604 /OUT pdfmark
[ /Title (Chapter 5) /Page 608 /OUT pdfmark
[ /Title (Chapter 6) /Page 621 /OUT pdfmark
[ /Title (Chapter 7) /Page 623 /OUT pdfmark
[ /Title (Index) /Page 638 /OUT pdfmark
#!/usr/bin/env bash
# Requires Ghostscript
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=out.pdf ./pdfmarks ./elementary-differential-equations-6e.pdf
@alogic0
Copy link

alogic0 commented Nov 15, 2018

Thank you for useful example. My addition for those who want to write titles with non-ASCII symbols. Make a replacement in this way

/Title (Алгебра)

to the

/Title <FEFF0410043B04330435043104400430>

The hex string is a result of

echo -n '(Алгебра)' | sed 's/^(//;s/)$//' | iconv -t utf-16 | od -x -A none | tr -d ' \n' | sed 's/./\U&/g;s/^/</;s/$/>/'

It's a UTF-16BE sequence with BOM (FEFF) at the beginning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment