Skip to content

This script repairs a pdf file generated by **pdfroff** which has misaligned co-ordinates for its bookmarks and anchor link. The key value to adjust here is the numbers in the string $1+50. Unlike a previous version of the script, this script generates everything necessary from the original PDF file and deletes all working files when done.

License

Notifications You must be signed in to change notification settings

TDavLinguist/pdfroff_bookmarks_fix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

So, a very efficient way to try to write things is using Pandoc, which allows a user to write something in Markdown format and then convert it to a variety of markup languages, such as LaTeX, HTML, or even (g/t)roff. As I’m not very adept at LaTeX nor groff, I decided to try making a PDF from Markdown with pdfroff as my engine. The PDF rendered as expected, but I noticed that links and bookmarks were all positioned lower than they should be.

It turns out that Pandoc doesn’t compress the PDF files, so I was able to actually view the source code of the PDF. Playing around with the coordinates of the bookmarks, I was able to deduce that 38px North is all I would need to position the bookmarks properly. So, I tried to figure out how to do that.

What this script does

This script repairs a pdf file generated by pdfroff which has misaligned co-ordinates for its bookmarks and anchor link. The key value to adjust here is the numbers in the string $1+50. Unlike a previous version of the script, this script generates everything necessary from the original PDF file and deletes all working files when done.

Usage

I wrote this script for my Linux system, so I think any UNIX-based system should be able to run the script, as long as the original pdf file is uncompressed with a program such as pdftk.

Just mark the script as executable...

chmod +x pdfroff_bookmarks_fix.sh

and then run the script with the PDF as the first argument

./pdfroff_bookmarks_fix.sh foo.pdf

The output should be foo_adjust.pdf

If the bookmarks still don't align perfectly with the coordinates of the paragraphs, just make adjustments to the number 50 in the string $1+50 and try again.

Examples

Please check out the two files included in the ./example directory. bookmarks.pdf was generated with Pandoc using the pdfroff compiler and its bookmark coordinates are wrong. bookmarks_adjust.pdf is the PDF generated by this script with the proper bookmark coordinates.

About

This script repairs a pdf file generated by **pdfroff** which has misaligned co-ordinates for its bookmarks and anchor link. The key value to adjust here is the numbers in the string $1+50. Unlike a previous version of the script, this script generates everything necessary from the original PDF file and deletes all working files when done.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages