Setting PDF View Options with pdfmark

Applies To: PDF Manipulation

Using the pdfmark syntax, you can add a lot of features to existing PDF documents. In a previous post I showed you how to apply pdfmark to PDF documents using GhostScript from the command line. In this post, I’ll show you how to set the View Options using this same technique.

View Options control the default display for a PDF document when it is opened. You are able to set the zoom levels, the starting page, and determine what features of the interface are already visible.

The following pdfmark will apply View Options to a PDF document:

[ /PageMode /UseOutlines
  /Page 1
  /View [/Fit]
  /DOCVIEW pdfmark

Here’s a breakdown of what’s happening:

  • represents the start of a new pdfmark “command” (you can have multiple commands in a single file)
  • /PageMode defines the page mode display (see table below for options)
  • /Page defines which page number (starting with 1) to start on
  • /View defines the zoom level the document will start with (see below for details)
  • /DOCVIEW pdfmark defines the “command” as View Options (/DOCVIEW) and is the end of the “command”

Page Modes

The /PageMode option determines the starting state for the PDF document. None of the options disable any features (so a user can still turn them on in the interface).

  • /UseNone – Document displays without bookmarks or thumbnails visible
  • /UseOutlines – Document displays with the bookmarks visible
  • /UseThumbs – Document displays with the thumbnails visible
  • /FullScreen – Document displays in full screen mode

View Magnification

The starting zoom level for a PDF document is set using the /View option. There are a ton of options here (see page 11 of the Cooking up Enhanced PDF with pdfmark Recipes eBook by Lynn Mead for more examples). But here are the most common values:

  • [/Fit] – Fits the page to the window (the whole page is visible)
  • [/FitH top] – Fits the width of the page to the window, replace top with a number
    • The top value is the distance from the page origin to the top of the window (offset) e.g. [/FitH 32]
  • [/FitH -32768] – Fits the width of the page to the window (top value is automatic)
  • [/FitV left] – Fits the height of the page to the window, replace left with a number
    • The left value is the distance in from the page origin to the left edge of the window (offset) e.g. [/FitV -17]
  • [/XYZ left top zoom] – Gives a specific origin offset and zoom level, replace left, top, and zoom with either a number or the word null e.g. [/XYZ 3 5 10] or [/XYZ null null 0]
    • The left value is the distance in from the page origin to the left edge of the window (offset)
    • The top value is the distance from the page origin to the top of the window (offset)
    • The zoom level is the magnification (0-100)

Applying the View Options to a PDF Document

As a reminder, pdfmark is just put in a text file and then applied using GhostScript with the following command:

gswin64c -o [outputfilename] -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress [originalPDFfilename] [pdfmarkfillename]

For additional details about how to get this all quickly setup, see my previous post Applying pdfmark to PDF Documents Using GhostScript.

2 thoughts on “Setting PDF View Options with pdfmark

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s