100% found this document useful (3 votes)
19 views

(Ebook) Beginning JavaScript for Adobe Acrobat: A non-programmer's Guide by John Deubert ISBN 9780985051204, 0985051205 instant download

The document is an eBook titled 'Beginning JavaScript for Adobe Acrobat' by John Deubert, aimed at non-programmers who want to learn JavaScript for enhancing Adobe Acrobat forms. It covers various topics including form field validation, dynamic controls, and database interaction, providing step-by-step guidance. Additionally, it includes links to other recommended eBooks related to Adobe Acrobat and JavaScript.

Uploaded by

rufydury5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
19 views

(Ebook) Beginning JavaScript for Adobe Acrobat: A non-programmer's Guide by John Deubert ISBN 9780985051204, 0985051205 instant download

The document is an eBook titled 'Beginning JavaScript for Adobe Acrobat' by John Deubert, aimed at non-programmers who want to learn JavaScript for enhancing Adobe Acrobat forms. It covers various topics including form field validation, dynamic controls, and database interaction, providing step-by-step guidance. Additionally, it includes links to other recommended eBooks related to Adobe Acrobat and JavaScript.

Uploaded by

rufydury5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

(Ebook) Beginning JavaScript for Adobe Acrobat:

A non-programmer's Guide by John Deubert ISBN


9780985051204, 0985051205 download

https://ebooknice.com/product/beginning-javascript-for-adobe-
acrobat-a-non-programmer-s-guide-34822746

Explore and download more ebooks at ebooknice.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

(Ebook) Adobe Acrobat 8 for Windows and Macintosh: Visual QuickStart


Guide by John Deubert ISBN 0321470796

https://ebooknice.com/product/adobe-acrobat-8-for-windows-and-
macintosh-visual-quickstart-guide-2128232

(Ebook) Adobe Acrobat 7 Official JavaScript Reference by Adobe Systems


Inc. ISBN 0321409736

https://ebooknice.com/product/adobe-acrobat-7-official-javascript-
reference-2127580

(Ebook) Enhancing Adobe Acrobat Forms with JavaScript (2nd Edition) by


Jennifer Harder ISBN 9781484294697, 1484294696

https://ebooknice.com/product/enhancing-adobe-acrobat-forms-with-
javascript-2nd-edition-50618312

(Ebook) Enhancing Adobe Acrobat Forms with JavaScript : Take Your


Forms to the Next Level! by Jennifer Harder ISBN 9781484294703,
148429470X

https://ebooknice.com/product/enhancing-adobe-acrobat-forms-with-
javascript-take-your-forms-to-the-next-level-50742088
(Ebook) Adobe Acrobat 6 PDF For Dummies by Greg Harvey ISBN 0764537601

https://ebooknice.com/product/adobe-acrobat-6-pdf-for-dummies-2087374

(Ebook) The Ultimate Guide to Adobe® Acrobat® DC, 2nd edition for PC &
Mac by Daniel J. Siegel, Pamela A. Myers ISBN 9781641058933,
1641058935

https://ebooknice.com/product/the-ultimate-guide-to-adobe-acrobat-
dc-2nd-edition-for-pc-mac-54191854

(Ebook) Adobe Acrobat 5: The Professional User’s Guide by Donna L.


Baker (auth.) ISBN 9781430211006, 9781590590232, 1430211008,
1590590236

https://ebooknice.com/product/adobe-acrobat-5-the-professional-users-
guide-4592392

(Ebook) Adobe Acrobat 9 PDF Bible by Ted Padova ISBN 9780470379196,


0470379197

https://ebooknice.com/product/adobe-acrobat-9-pdf-bible-1546570

(Ebook) How to Do Everything Adobe Acrobat X by Doug Sahlin ISBN


0071752935

https://ebooknice.com/product/how-to-do-everything-adobe-
acrobat-x-2219606
switch (itemPicked) {
{
Statement.nextRow() case "See close-up":
ar row = gStatement.getRow() this.pageNum = 2
opulateFields(row) var gHelpText = [

Beginning
ostMessage("") “What’s your full name?”,
“Where do you live?”,
break
case "About the artis

JavaScript “What is it you’re hoping to do here?”,


this.pageNum = 6
break

for if (pwd == "axolotl") {


this.submitForm("http://www.langerhans.com/submit.js", false, true)

Adobe Acrobat®
app.beep()
app.alert("Your order has been submitted.")
A non-programmer’
}
s guide
else {
if (pwd != null)
app.alert("That is not the password!\n\n
¬ (Hint: it’s a small, rather repulsive amphibian.)")
}

var re7Digits = /^(\d{3})(\d{4})$/

E
var re10Digits = /^(\d{3})(\d{3})(\d{4})$/

John Deubert
if (re7Digits.test(event.value))
QDGuides
var orderInfoTemplate = this.getTempla
var addressTemplate = this.getTemplate
Quality Electronic Documentation
event.value = RegExp.$1 + "-" + RegExp.$2 from Acumen Training

else if (re10Digits.test(event.value)) –1–


QED
Dedication
For (in order of descending height) Barbara, Elizabeth, Gigi, and Julia.

Beginning JavaScript for Adobe Acrobat


John Deubert
Copyright © 2012 John Deubert

ISBN-13: 978-0-9850512-0-4
ISBN-10: 0-985-05120-5

Version 1.1

To report errors, send a note to [email protected]

Notice of Rights
All rights reserved. This book may not be redistributed to another computer.

Notice of Liability
The information in this book is distributed “as is,” without warranty. While every precaution has been taken
in the preparation of the book, the author shall not have any liability to any person or entity with respect to
any loss or damage caused or alleged to be caused directly or indireclty by the instructions contained in this
book or by the computer software and hardwre products described in it.

Trademarks
Trademarks are used throughout this book. Rather than put a trademark symbol in every occurrence of a
trademarked name, we aver that we are using the names in an editorial fashion only and to the benefit of the
trademark owner with no intention of infringement of the trademark.

Adobe Acrobat is a trademark of Adobe Systems Incorporated.

–i–
QED Beginning JavaScript for Adobe Acrobat
Table of Contents

0 Introduction iii 10 Keystroke Checking with Regular Expressions 77


In which we point you to the sample files and thank you for buying the book In which we learn how to use regular expressions to efficiently examine text.

1 Welcome to JavaScript 1 11 Field Validation with Regular Expressions 84


In which we look over the book and establish some ground rules In which we use regular expressions to validate user’s text input.

2 Page and Document JavaScripts 16 12 Formatting Text Fields with Regular Expressions 94
In which we learn the basics of creating and editing JavaScripts in Acrobat. In which we use regular expressions to automatically re-format user’s text input.

3 Form Field Highlighting 23 13 Alerts and Dialog Boxes 100


In which we learn about JavaScript variables and the On Focus and On Blur events. In which we learn to display messages to the user.

4 Checking Acrobat Version 28 14 JavaScript Functions 108


In which we learn about the if & else commands and how to display an alert. In which we learn to assign a name to frequently-used pieces of JavaScript code.

5 Calculating Form Fields 33 15 Creating Pop-up Menus 119


In which we learn how to make a form field calculate its own value. In which we learn to create pop-up menus in your forms.
6 Auto-Entering Form Data 45 16 Blinking Buttons, Spinning Stars, and Other Simple Animation 131
In which we learn how to use arrays and automatically set a field’s value. In which we learn to create animated doo-dads on your pdf pages.

7 Roll-Over Help 51 17 Interacting with Databases 141


In which we learn how to present help text to the user. In which we learn the basics of sql and how Acrobat works with databases.

8 Dynamic Form Fields 58 18 Reading and Writing a Database 154


In which we learn how to make fields appear and disappear. In which we learn to load our form fields’ contents from a database.

9 Dynamic Controls with Templates 69 19 Where to Go from Here 173


In which we learn how to use templates to make entire pages appear dynamically. In which we list some other sources of JavaScript learnin’.

–ii–
QED Chapter 0
Introduction

Welcome to Acrobat JavaScript.

You are about to open a new chapter in your work with Acrobat forms. In reading this book, you will learn
how to add features and abilities to your forms that are not otherwise possible: roll-over help, automatic text
field formatting, database connectivity, and more will all become routine parts of your form design. You will
also learn a programming language, perhaps your first: JavaScript. Even if you’ve never had a hankering to
write software and sling code, you’ll find JavaScript an important arrow in your quiver; it’s supremely useful,
relatively easy, and surprisingly fun.

Of course, you don’t need JavaScript skill to create an Acrobat form; you’ve no doubt been doing perfectly
well for quite some time without it. However, a knowledge of JavaScript adds immeasurably to your ability
to make your forms look and behave exactly as you want. JavaScript will open to you a world of possibility
whose scope is hard to overstate. Sufficient to say that the knowledge and techniques you will learn in this
book will allow your forms to take on a sophistication that is otherwise completely impossible.

If this sounds like hyperbole, think again. It’s true.

This Book

What this book is


This e-book is a non-programmer’s guide to the JavaScript programming language as used in Adobe Acrobat;
it teaches you, step-by-step, how to add specific features to your Acrobat forms and, in so doing, teaches you
about the JavaScript language.

If you are an experienced Acrobat form designer, but have never written a line of programming code in your
life (and pretty much wanted to keep it that way), then this book is written for you. Together we’ll explore
programming concepts while learning how to add features to your Acrobat forms: we discuss arrays while
creating a dynamic list of prices; we talk about case statements while creating a pop-up menu; we teach a
form to check the version of Acrobat on which it’s running and, along the way, talk about if–else constructs.

When you’re done with the book, you will be in good shape to read more formal books on JavaScript and to
make use of Adobe’s technical specification of Acrobat JavaScript.

–iii–
QED About the Book
What this book isn’t
This book is not a complete reference to the JavaScript language or to using JavaScript in Acrobat. JavaScript
is a broad and deep language and is capable of much that we don’t discuss here.

The purpose of this book is to bootstrap you to a point where you can learn the rest of the language’s
abilities on your own; it assumes you are an experienced Acrobat forms designer, but have little or no
experience with computer programming languages. If you are already comfortable with Objective C, Java, or
other programming language, this book will be paced too slowly for you; you should go directly to Adobe’s
Acrobat JavaScript Object Specification.

Also, this book does not teach you how to make form fields and other components of Acrobat forms;
I assume you have reasonable experience with the mechanics of designing and creating forms.

Mac or Windows?
With one exception the examples in this book will work with either the Macintosh or Windows version of
Adobe Acrobat. The exception is the pair of chapters on Acrobat database connectivity, which is available
only in Windows. Otherwise, the Mac and Windows versions of Acrobat work identically, except for minor
differences dialog box labelling, etc. Illustrations in this book are taken from both versions of Acrobat.

How to use this book


The first two chapters of this book present basic information and terminology and must be read before
attempting the rest. The remaining chapters are probably best read in order, since learning a programming
language is inevitably a cumulative activity. Nonetheless, Chapters 3-19 are designed so that one can usefully
read them in any order; if you need to add roll-over help to a form, feel free to skip to Chapter 7 and see
how to do it. Just don’t be surprised if you find yourself having to go back to earlier chapters to clarify
references to mysterious terminology.

Some chapters need to be read in order; for example, the discussion of regular expressions is spread across
Chapters 10, 11, and 12 and they must be read in that order to be sensible at all. Most chapters, however, are
intended to be semi-independent.

All of the chapters, however, assume you have read Chapters 1 and 2.

–iv–
QED About the Book
Reading the book on-screen
Being an e-book, Beginning JavaScript for Adobe Acrobat is distributed electronically; its pages are designed
to be easily read on-screen. Since it’s distributed as a self-contained pdf file, you can read the book on nearly
any computer or tablet. It turns out that the page size works particularly well on a 768x1024 screen, such as
that of the iPad; that’s probably a coincidence.

The pdf file has been “enabled” for commenting in Adobe Reader, so you should be able to make notes to
yourself on the pages in either the full Acrobat or Reader.

URL links within the book are all “live” and will open the appropriate page in your default web browser.

Printing the book


Many people (myself included) prefer to read technical tutorials on paper. To that end, feel free to print
Beginning JavaScript; it works very well printed two-up and double-sided (Figure 0.1).

Sharing the book


I’d rather you didn’t, really. Beginning JavaScipt is reasonably priced and I’m hoping to write additional books
on this and other topics. However, I do need to be able to make at least a minimal living at it. So, if your
friends or colleagues want to read the book, encourage them to buy their very own copy. They’ll feel good
about themselves.

Registering the book


E-books are similar to software; in particular, it is possible for an author to update an e-book, improving
explanations, fixing the grammar, killing typos, and eliminating flat-out errors. (This particular e-book, of
course, has neither errors nor tpyos.)

If you register your book purchase (go to www.acumentraining.com/QEDGuides/qedregister.html), you’ll Figure 0.1 This book’s page size works well printed two-up on A4 or
American Letter-size paper.
be notified whenever there is a new update for your book. It’s worth doing.

–v–
QED About the Book
Online Resources
There are two sources of information that are specifically intended to be used with this book.

Sample Files and Support


Each chapter in this book is built around one or two sample forms to which we add JavaScripts to complete the
chapter’s goals. Each sample form has two files associated with it:

■ The complete, functioning form, with all JavaScripts in place. This shows you how the form is supposed to
behave and allows you to inspect the chapter’s JavaScripts in place. This version of the form has a filename
ending with “end.”

■ A version of the form with all form fields and other elements in place, but no JavaScripts attached. Use
this version if you want to follow along while reading the chapter, writing, debugging, and executing the
JavaScripts as you go. The file for this version of the form will have a name ending in “start.”

The sample form files are available for downloading at www.acumentraining.com/QEDGuides/acrojs.html. This
web page is also where you will find errata, update information, and other useful information.
Figure 0.2 Each issue of the Acumen Journal has an Acrobat-related article; many of
these are about JavaScript usage.
Acumen Journal
The Acumen Journal (Figure 0.2) is a free periodical that I produce three or four times per year. Each issue has
an article on advanced Acrobat usage and many of these are about JavaScript. The back issues make a good
supplemental to the topics in this book; there are more than 60 issues accumulated since I began writing the
Journal back in 2000. You can download them at www.acumentraining.com/acumenjournal.html.

If you wish to be notified when a new issue of the Journal comes out, there is a link on the Acumen Journal
web page to an appropriate form.

Thank You
Finally, thank you for buying this book or looking at the sample chapters. Either way, you are participating in
an ongoing experiment in publishing.

–vi–
QED Chapter 1
Welcome to JavaScript

Periodically in life, you learn something that broadens your world immeasurably, revealing an expanse of
What We’ll Learn in this Chapter
new experience, problems, opportunities, play, and work. Whole worlds that had invisibly surrounded
In this chapter, we’ll learn:
you ­suddenly appear, providing a new space to explore. Reading, sex, driving, children, all bring with them
­concerns, interests, and interactions that had been previously inaccessible and unsuspected. ■ What’s a JavaScript?

In its own small way, learning JavaScript will be just such a threshold event in your professional life. If you’ve ■ Types of JavaScript
been working with Acrobat for any length of time, you’ve probably gotten pretty good at it and have ■ Attaching a JavaScript to a form field
­become quite comfortable at creating forms, adding music, creating slide shows, and all the other features
■ JavaScript objects, data types, and syntax
Acrobat offers.
■ JavaScript errors and the debugger
This book introduces the New World. A knowledge of JavaScript allows you to do things within Acrobat that
■ How to use your own text editor with Acrobat
far exceed what you’ve done so far: You can interface with databases; add your own pop-up menus; create
JavaScripts
forms with sophisticated, interactive interfaces; and implement form fields that can look up p ­ rices and other
data. These are only a few of the things you can do within your Acrobat documents using ­Java­Script. The
­extent to which you can manipulate your Acrobat files is vastly greater with JavaScript skills than without.

Hence, this book.

Here you will learn how to accomplish a variety of useful tasks in Acrobat using JavaScript. Along the way, you
will learn a great deal about JavaScript, programming, and Adobe Acrobat.

What You Should Know Already


This book assumes you have reasonably extensive experience in working with Acrobat and creating A ­ crobat
forms. In particular, I assume you know how to create forms in Acrobat; you should be able to create a form
field, set its properties, and assign actions to it. If you feel vaguely uneasy about any of these tasks, you may
want to run right off and buy a book on the subject (see the sidebar on the next page).

Beyond that, this book does not assume any knowledge of programming; you will learn the programming
skills you need as we proceed through our examples.

Again, this book is intended for programming novices; if you are an experienced programmer, you may it to
be paced slower than you’d like. Experienced programmers may do better to just go to a more-advanced
book to learn JavaScript (there are myriad such books, though they all teach JavaScript in the context of web
pages) and then look at Adobe’s JavaScript reference site to see how to apply it to Acrobat.

–1–
QED 1. Welcome to JavaScript
What Version of Acrobat Should You Have? Books on Acrobat Forms
Although this e-book presumes you are working with Acrobat XI, the current version, it works equally well Although there are a number of books that will teach you how
with Acrobat X, whose interface is nearly identical. The instructions we step through will nearly all apply to to create Acrobat forms., most of them are out of print. The only
Acrobat 9, as well. Where there is a large difference in Acrobat 9, I’ll provide a note on what you should do extant book is:
in the earlier software. • PDF Forms Using Acrobat and LiveCycle Designer Bible
Ted Padova and Angie Okamoto
What Is JavaScript? Ted Padova is the king of the “Bible” style books and this
volume shows why.
JavaScript is a programming language. The term “programming language” often induces jitters in n­ ewcomers,
but, conceptually, it’s not very scary: A programming language is a language that is used to describe the There are other books specific to Acrobat forms that, though
steps involved in carrying out some task. In Acrobat, these tasks include moving to a particular page of a out of print, are still available if you look around. In particular, my
own old book is still available, though it’s getting pretty long in
­document, sending data to a database, and calculating a form field value. Carrying out the steps described
the tooth, I admit:
by a ­JavaScript is referred to as executing the program.
• Creating Forms in Adobe Acrobat – John Deubert
As a programming language, JavaScript’s most significant characteristic is that it’s simple enough that many
Finally, any reasonably complete book on Adobe Acrobat will
­applications use it as their built-in scripting language. Web browsers can all interpret JavaScripts embedded
have at least a chapter or two on creating forms. This includes my
in Web pages, and, particular to our topic, Acrobat can execute JavaScripts attached to form fields, pages,
own book:
and pdf files.
• Adobe Acrobat X: Visual Quickstart Guide – John Deubert
Like any language, JavaScript has its own vocabulary (words that have meaning) and syntax (rules by which
• Acrobat X Classroom in a Book – Adobe Creative Team
you make statements with those words). Learning JavaScript, therefore, has much in common with learning a
human language, such as Spanish or German, only it’s much easier. JavaScript is vastly simpler than any human • Acrobat X PDF Bible – Ted Padova
language: there are no metaphors, no literally nonsensical idioms, no synonyms, no subtle shades of ­meaning. These are all available through Amazon.com, as is pretty much
Just very precise statements telling Acrobat to do something very specific. everything in the world.

JavaScript in Acrobat
Acrobat allows you to create five different kinds of JavaScripts:

■ Form Field JavaScripts are attached to form fields. Acrobat executes the script when a particular event
occurs in that form field, such as a button click. Most JavaScripts in Acrobat are attached to form fields.

■ Page JavaScripts are executed when the user moves to or leaves a particular page in the Acrobat ­document.

■ Document JavaScripts are executed when the Acrobat Document opens.

■ Document Action JavaScripts are executed user opens, closes, saves, or prints a document.

■ Application JavaScripts are executed when Acrobat launches.

–2–
QED 1. Welcome to JavaScript
We shall talk about Page, Document, and Document Action JavaScripts in Chapter 2; we won’t be discussing
application JavaScripts at all in this book. For now, let’s look at how you type in and use a Form Field JavaScript.

Our First JavaScript


Let’s start exploring our new world by adding a simple JavaScript to the button in Figure 1.1.

This form consists of a set of flash cards that are intended to be printed double-sided and then used to quiz
students on vocabulary terms. Our pdf file has only a few flash cards; each card has a button that takes u­ sers
to an order form they can use to purchase the complete set of cards. We are going to add a JavaScript to
the Order Form button that takes the user to the order form, located on the last page of the Acrobat file
(­Figure 1.2).

As will be true throughout this book, there are two versions of this form on the JavaScript for Acrobat web page:

■ JSAcro_Ch01_Example_Final.pdf is the full form, complete with all relevant JavaScripts.


Figure 1.1 We’re going to add a JavaScript to the “Order
■ JSAcro_Ch01_Example_Start.pdf, the “raw” version, lacks the chapter’s JavaScripts so that you may type in Form” ­button in this form.
the ­Java­Script yourself if you wish.

These are available at www.acumentraining.com/QEDGuides/acrojs.html.

Figure 1.2 The Order Form button’s Java­Script will move


the user to the pdf file’s final page, which is the order form.

Where Do the Sample Files Live?


Remember that all of the sample files in this eBook are available
at www.acumentraining.com/QEDGuides/acrojs.html.

–3–
QED 1. Welcome to JavaScript
Attaching a JavaScript to a Form Field
As a reminder of something you may already know, let’s step through the process of attaching a Java­Script to
a button, in this case our Order Form button.
Figure 1.3 Enter Form Editor mode by
To attach a JavaScript to a button: clicking the Edit button in the Forms

x Note
panel.
Start with the form open in Adobe Acrobat and the Tools
pane exposed. Acrobat 9 doesn’t have a Tools pane, but
it does have a Forms menu. To get to the Form
1 In the Tools pane’s Forms panel, click on the Edit tool Editor, select Forms > Add or Edit Fields. Having
(Figure 1.3). done this, you can follow the steps exactly as listed.

Acrobat will enter Form Editor mode, displaying all of the


form fields on the current page as a set of r­ ectangles and replacing the usual three Tasks panes with
a single Forms pane (Figure 1.4). Note in the fi­ gure that our form has only one field on its first page, a
pushbutton field with the name ­btnOrderForm.

2 Double-click the Order Form button.

Acrobat will present you with the Field Properties dialog box (Figure 1.5). Figure 1.4 Acrobat’s Form Editor mode gives you a Forms pane, new
­toolbars, and presents each form field as a rectangle with handles..
3 Click on the Actions tab.

You will now be looking at the set of controls that specify what
should happen when you click on this ­button (Figure 1.6).

4 In the Select Trigger pop-up menu, select Mouse Up.

This tells Acrobat that this button’s action should trigger when
the mouse button is released after clicking in the b­ utton. (See
the sidebar, at right.)

5 In the Select Action pop-up menu, select Run a ­Java­Script and


then click the Add button.
Figure 1.5 Double-clicking on the ­button yields the Button
Acrobat will present you with the JavaScript Editor, a dialog ­Properties dialog box.
box with a simple text editor (­Figure 1.7 , next page). This is
where you type in the JavaScript that should be associated with the Order Form button.
Figure 1.6 The Actions tab of the Button Properties dialog box is where
we specify what should happen when the user clicks our button.

–4–
QED 1. Welcome to JavaScript
6 Type your JavaScript into the text field of this dialog box. Form Field Events
In the case of our order form, the JavaScript is a two-line The Select Trigger pop-up menu, shown in Figure
­program that moves the user’s view of the document to 1.6, offers six form field events to which you can
the page containing the order form and then causes the ­attach an action:
user’s computer to beep: ■ Mouse Down occurs when the user presses the
mouse button with the pointer in the form field.
this.pageNum = 6
app.beep() ■ Mouse Up occurs when the user clicks on the
field and then releases the mouse button with
Type these lines into the text-editing field exactly as the mouse pointer still in the field.
above, making sure to match upper and lowercase. The Figure 1.7 The JavaScript Editor window is a simple text editor that you
first line of code says, “In this document, set the ­current ■ Mouse Enter occurs when the mouse pointer
will use to type in your JavaScripts.
first rolls over the form field.
page number to 6.” The second line tells the Acrobat
­application to beep. ■ Mouse Exit occurs when the mouse pointer rolls
out of the form field.
7 Click the ok button of the JavaScript Editor and the Close
■ On Focus occurs when the user clicks on or tabs
button of the Field Properties dialog box to return to the
into the form field, so that it becomes the target
Acrobat form.
for keyboard or other input.
You are now looking at the Acrobat flash card page with ■ On Blur occurs when the user tabs out of a form
the Form tool still selected, as in Figure 1.4. field or clicks on some other form field, so that
our field is no longer the target for user input.
8 Exit the Form Editor by clicking the Close Form Editing (Blur is the opposite of Focus, of course.)
button in the Forms pane (Figure 1.8).
The Field Properties dialog box, Figure 1.6, lets you
You are now back where you started, looking at your associate one or more A ­ ctions (a ­­­Java­Script action,
Figure 1.8 You exit the Form Editor by clicking Close Form Editing button.
document page. in our case) with any of these events.
This button is in the Forms pane in Acrobat X (above right) and above the
pane in the newer Acrobat XI (above left).
So, now try it out. Click the Order Form button, and Acrobat
will move to the order form page and then beep.

JavaScript Objects
Our two-line JavaScript makes use of two JavaScript objects. A JavaScript object is the representation of some
piece of data within your JavaScript program. Before your program can manipulate or examine a form field, it
must first create an object that represents that field. Most of the things you can manipulate in ­JavaScript (pages,
signatures, database connections, and so on) are represented in your program as objects.

In our sample program, this refers to a Doc object. A Doc object represents an open Acrobat file to your
JavaScript program; you use this object to change pages, save the document, and otherwise manipulate the

–5–
QED 1. Welcome to JavaScript
document from within your program. The word this in our sample JavaScript refers particularly to the A ­ crobat
document in which our JavaScript resides (the Flash Cards file, in our case); think of it as short for this document.

The word app is an App object, a reference to the Acrobat application being used to view the current
­document. You use an App object to tell the Acrobat application to do something: open a file, put up an
alert dialog box, or, in our case, beep.

Commonly used JavaScript object types include:

■ Annot represents an annotation (for example, a “sticky note”) in the current document.

■ App represents the Acrobat application being used to view the current document.

■ Connection represents a connection to an external database.

■ Doc represents an open Acrobat document.

■ Field represents a form field.

■ Sound represents a sound embedded in the current document.


Data Types
Object properties
The Data Type column of Table 1.1 lists the type of ­information
JavaScript objects are analogous to physical objects in the world around us, such as books, vases, and dogs. associated with each of the properties it lists. Computer
Every real-world object possesses a set of characteristics that define it (such as, for a dog, color, tail length, ­programming, including JavaScript, uses special terms to p­ recisely
and number of fleas). describe types of data. Here are the terms commonly used in
JavaScript:
The characteristics of a JavaScript object are referred to as that object’s properties. These are elements of an ■ Integer is a whole number, such as 1, 2, 87, or -6293.
object that our JavaScript programs can examine and change as needed. Each type of object has a set of
properties that characterize it; for example, Doc objects have, among other things, a title, a current page ■ Floating Point is a number with a fractional part, such as 1.7,
-842.9011, 1024.0. Note that the fractional part may be zero, as
number, an author, and a number of pages (see Table 1.1).
in 1024.0; in this case, the floating point number has the same
Table 1.1 Document Object Properties (Partial) value as an integer, though internally it is still a floating point
number. Floating point numbers are often referred to as “floats.”
Property Data Type Description
author String The person who wrote the document ■ Boolean is an entity that can have two values: true or false.
Boolean data are used to describe characteristics that can
fileSize Integer The size of the PDF file, in bytes
have only two states. (For example, the spayed property in
numPages Integer The number of pages in the document
our dog object is a Boolean value; a dog either is or isn’t.)
pageNum Integer The page number currently visible to the user
■ String is text, that is, a “string of characters.”
title String The name of the document.

–6–
QED 1. Welcome to JavaScript
The phrase this.pageNum addresses the pageNum property of the Document object; this property is the “Program” vs. “Script” vs. “Code”
page number the document is currently displaying to the user. Our program moves the user to the ­order
Here are three closely related terms that we’ll be using
form page by setting the current document’s pageNum property to the order form’s page number:
throughout this book.
this.pageNum = 6
■ A program is a general term for a series of instructions that
Some observations about this page number assignment: tell a computer in detail how to carry out a particular task. In
general, a program is a stand-alone set of instructions, such as
■ You address the property of an object by naming both the object and the property, joined by a period: an ­application.

object-name.property-name ■ A script is a program that is intended to manipulate and run


within another program. JavaScript is a scripting l­anguage,
■ The equal sign in the line of code above is an assignment command; it sets the value of something. In our ­because you use it to control the behavior of another
case, it sets the current document’s page number to 6. ­program, such as Acrobat or FireFox.

■ Code is the term applied to the set of instructions that


■ JavaScript is case-sensitive. Upper- and lowercases are distinct; our program would have failed if we had
make up a program. Your JavaScript program is made up of
typed This.PageNum.
­JavaScript code.
■ Acrobat internally numbers a document’s pages starting at zero; the seven pages in our Acrobat file are
numbered zero through six. Thus, when our JavaScript set the pageNum property to 6, it was moving us to
the last page in the document.

Object methods
A method is a command that is associated with a JavaScript object. Just as a dog can be given commands
(“Sit,” “Heel,” “Spit that out this instant!”), JavaScript objects have commands that they can carry out. The set of
commands is different for each type of object. For example, Table 1.2 lists some of the commands the app
object knows how to execute.

Table 1.2 App Object Methods


Method Arguments Description
beep Play the system’s “beep” sound
alert String Put up an alert dialog box with the specified text
goBack Go to the previous view
goForward Go to the next view
newDoc Open a new, blank Acrobat document
openDoc String Open an Acrobat file. The string argument
­contains the name of the file

–7–
QED 1. Welcome to JavaScript
In our Order Form JavaScript, we executed (“called”) the app object’s beep method:
app.beep()

Note that we call an object’s method in the same way that we refer to one of its properties: the object
name, a “dot,” and the method name. The method name is followed by parentheses enclosing the method’s
arguments; let’s talk about what those are.

Arguments and Return Values


Some methods need additional information in order to carry out their task; for example, the openDoc
­method listed in Table 1.2 needs to know the name of the file you want to open. Information handed to a
method is called an “argument” to that method. The openDoc method takes a filename as its argument; this
information, surrounded by parentheses, must follow the method name. An invocation of openDoc looks
something like this:
app.openDoc("TermPaper.pdf")

The above JavaScript statement would open an Acrobat file named TermPaper.pdf. Note that our earlier call
to app.beep had empty parentheses because the method doesn’t take any arguments; you still need the
parentheses, though.

Sometimes when you give a dog a command, you expect the dog to give you something back: the ­command,
“Fetch the stick, boy!” should yield a stick in your hand (along with some gratuitous drool). S­ imilarly, many
JavaScript methods have a return value, some piece of data they give back to the JavaScript program.
The openDoc method we invoked above actually returns a Doc object representing the newly opened
­document, though our single-line use of ­openDoc just ignores it. We shall look at return values in much more
detail in the next chapter.

Named Arguments
Generally, you must supply arguments to a method in a certain order; the app object’s alert method, which
we’ll talk about in detail in the next chapter, wants a string and an icon code:
app.alert("Woah! Somethin' weird just happened!",2)

The string and the integer must be supplied in that order so that JavaScript can identify them.

However, you can also pass arguments to a method by name. The Acrobat JavaScript Guide (described at the
end of this chapter) defines a name associated with each of the arguments a method requires; in the case of
app.alert, the names are cMsg and nIcon.

–8–
QED 1. Welcome to JavaScript
You can supply these arguments, in any order, using the following call to the method:
app.alert({cIcon: 2, cMsg:"Woah! Somethin' weird just happened" })

Note that we have braces within the method’s parentheses and within those we have our method arguments.
Each argument is represented by the name of the argument, a colon, and then the argument’s value; the
arguments are separated by commas.

This is not as concise as passing the arguments by position, but it is clearer as to the purpose of each of the
arguments. (Our first call to app.alert, for example, gives no clue to the purpose of the 2.) Also, passing
arguments by name give you great flexibility in formatting your code. In particular, you can place line breaks
within the argument list and supply the arguments in any order; our previous example could have been written
app.alert({ cIcon: 2,
cMsg: "Woah! Somethin' weird just happened" })

In this book, we shall pass arguments by position; we’ll use argument names only when it’s necessary—usually
for clarity—to a particular JavaScript example. I shall, however, often supply the names of the arguments when
describing methods so that you can use them if you wish.

Usually, there’s no overwhelming reason to do so.

JavaScript Program Syntax


Here we must discuss a couple of short topics regarding how JavaScript commands are put together into a program.

JavaScript Statements
A JavaScript program—any computer program—consists of a series of statements, each of which carries out
one step in the overall task. Our sample program consists of two statements: a page assignment and a call to
the app object’s beep method.
this.pageNum = 6
app.beep

Usually, each line within a JavaScript program will contain a single JavaScript statement, as in our program. You
can put more than one statement on a line, separated by semicolons. Our two-line program could have been
written on a single line:
this.pageNum = 6; app.beep

–9–
QED 1. Welcome to JavaScript
Why would you do this? Purely for esthetics; some people just prefer to combine very simple statements
­together. I recommend against this practice; most programs are much easier to read if you have only one
statement per line.

If you read other people’s JavaScripts, you may notice that many programmers put semicolons at the end of
every line in their program:
this.pageNum = 6;
app.beep;

This doesn’t hurt anything, but it’s unnecessary. Most of them do it out of habit; JavaScript looks very much
like the programming languages C and C++, both of which require that all statements end with s­ emicolons.
You can leave out the semicolons.

JavaScript Text
JavaScript programs are simply text files; you can write them with any text editor or word processor and then
copy and paste them into the Acrobat JavaScript Editor dialog box. In fact, ­Acrobat lets you specify an e­ xternal
editor that should be used for editing your JavaScripts; we’ll discuss how to do this at the end of the chapter.

By the way, space and tab characters within a JavaScript line have no particular meaning in JavaScript. You can
use them as you wish to format your program. This is a purely visual issue; you want to format your Java­Script
code so that it’s easy to read.

Use whitespace characters lavishly! Reading program code is tedious at best; a program can be nearly
­undecipherable if the programmer has not formatted the code for easy reading. This is an important enough
issue that I shall be providing formatting tips for many of the JavaScript constructs we use in this book.

JavaScript Comments
JavaScript code can be pretty cryptic. Puzzling over someone else’s code (or even your own code from six
months ago), trying to figure out exactly what it’s trying to do, can be tedious. As a courtesy to others looking
at your code and as an aid to your future self, it is very important to place comments in your JavaScript code.

A JavaScript comment is text in your code that is ignored by the JavaScript “machine.” The purpose is to let
you place your own notes to be read by human beings examining the code.

–10–
QED 1. Welcome to JavaScript
JavaScript recognizes (that is, ignores) two kinds of comments:

■ Single-line comments start with a double slash (//) and extend to the end of the current line in the
­JavaScript code. These are intended for brief comments.
// This is a single-line comment.

■ Block comments start with a /* and end with a */. Between these two delimiters can be as much text as
you wish, spread out over as many lines as you wish within the JavaScript file. Use this for longer comments.
/* Here we have a block comment.
This text will be completely ignored
until we end the comment, right here. */

An Example
Consider the following, uncommented JavaScript from later in this book:
var txtField = event.target
txtField.fillColor = color.red
txtField.textColor = color.white

Since we have not yet discussed these commands, the exact purpose of this script and how it carries out that
purpose is very unclear, although it does seem to have something to do with color.

On the other hand, if we include comments in the code, then it becomes possible for someone unfamiliar
with the program to at least know what the intent of the program is and generally what it’s doing:
/* This program changes the background and text color of
a text field when the user tabs into or clicks in the
field. */
var txtField = event.target // Get a reference to the text field
txtField.fillColor = color.red // Set the background to red
txtField.textColor = color.white // Set the text color to white

This version of the program is much clearer, even to someone new to the code.

Comments are a Force for Good in programming. Any script more complex than a couple of lines should
include comments that describe what it does and how it works.

All of the examples in the rest of this book will be heavily commented to make them as comprehensible as possible.

You’re welcome.

–11–
QED 1. Welcome to JavaScript
JavaScript Errors
In the (ahem) rare event that you have an error in your JavaScript—you misspelled a variable name, ­mis-copied
a piece of code, and so on—you will be faced with the task of figuring out what is wrong with your code,
a process known as debugging. Acrobat left to itself treats these errors quietly; if the code fails, Acrobat
just aborts the script; to all appearances, clicking on the button did nothing at all, although there was really
a failed script h­ appening beneath the hood. This isn’t useful for debugging; if a JavaScript fails, we’d like to
know about it and, ­furthermore, be told what went wrong, so we can fix it.

To get this diagnostic information about failed scripts, we need to enable something called the JavaScript Debugger.

The JavaScript Debugger


The JavaScript Debugger is a window that presents information about JavaScripts executing in your A ­ crobat
document (Figure 1.9). In particular, the Debugger presents diagnostic information about errors in your
­Java­Scripts, allowing you to figure out why they are misbehaving.

With the JavaScript Debugger enabled, whenever one of your JavaScripts fails, Acrobat will open the
D­ebugger with an error message (“ReferenceError,” in Figure 1.9). This will allow you to determine what went
wrong and what to do about it.

Error messages can be somewhat cryptic at first, but with time and familiarity they become useful. The most
common messages you are likely to see are the following:

■ Reference Error: XXX is not defined

This indicates that you misspelled something; the name “xxx” (or whatever) is not one that JavaScript Figure 1.9 The JavaScript Debugger window presents information about errors in
knows. Remember that JavaScript is case-sensitive; there is a difference between app (which JavaScript your JavaScript, as well as providing a variety of other tools.
knows) and App (which it doesn’t know).

■ Syntax Error

This means that JavaScript could not make sense of something in the code. This usually means you omitted
­something (a comma, a number, a parenthesis) from your script. An example of a syntax error would be
app.alert("Hi, Mom", 3

This line is missing its closing parenthesis.

The set of possible error messages is very large, though most are pretty hard to provoke. Just sit tight, read
the message, and carefully examine the aberrant JavaScript code for misspellings and omissions.

–12–
QED 1. Welcome to JavaScript
Enabling the JavaScript Debugger
You enable the JavaScript debugger in the Preferences of your copy of Acrobat. Open your Acrobat
­preferences and select JavaScript in the long list of preference categories (Figure 1.10). All of the checkboxes
in the JavaScript Debugger section should be selected, as in the figure.

Using Your Own Text Editor


The text editor built into Acrobat’s JavaScript Editor (see Figure 1.7) is pretty minimal. It lets you type in your
JavaScript, but it has no particularly fancy editing capabilities. For short JavaScripts, this is not important; when
typing long, complex scripts, however, you will miss having a fully featured text editor.

You can ask Acrobat to use text editing software of your choice to edit your JavaScripts. Having told A
­ crobat
Figure 1.10 You enable the JavaScript debugger in your Acrobat preferences. Select
what editor you want to use, it will automatically launch this software when you click on the Add or Edit
all of the checkboxes in the Debugger section, as above.
­button in the Document JavaScripts dialog box (Figure 1.11).

To set this up, you must specify in Acrobat’s Preferences the editor you wish to use for working with Java­Scripts.

To specify a text editor to use when editing JavaScripts:

Start with Acrobat open.

1 On the Mac, select Acrobat>Preferences; in Windows, select Edit>Preferences.

Acrobat will present you with its Preferences dialog box (Figure 1.12, next page).

2 Select JavaScript in the list of Preferences categories.

The Preferences dialog box will display the controls that affect Acrobat’s JavaScript support, as in Figure 1.12.

3 Among the JavaScript Editor controls, at the bottom of the dialog box, select Use External JavaScript ­Editor.
Figure 1.11 Acrobat will launch your external text editor whenever you click the Ad
4 Click the Choose (Windows) or Browse (Mac) button and then navigate to the .exe or .app file for the
or Edit button in the Document JavaScripts dialog box.
editor you want to use when editing JavaScripts.

5 Click the ok button.

That’s all there is to it. Now, when you edit a JavaScript, Acrobat will automatically launch your text e­ ditor.
Type your JavaScript code into the text editor’s window, save the text, and then close the editor. Your
­JavaScript will be automatically entered into Acrobat.

–13–
Exploring the Variety of Random
Documents with Different Content
writings to Voltaire; and Voltaire applauded, as if Frederic had been
Racine and Bossuet in one. One of his Royal Highness’s
performances was a refutation of Machiavelli. Voltaire undertook to
convey it to the press. It was entitled the Anti-Machiavel, and was
an edifying homily against rapacity, perfidy, arbitrary government,
unjust war, in short, against almost every thing for which its author
is now remembered among men.
The old King uttered now and then a ferocious growl at the
diversions of Rheinsberg. But his health was broken; his end was
approaching, and his vigour was impaired. He had only one pleasure
left, that of seeing tall soldiers. He could always be propitiated by a
present of a grenadier of six feet four or six feet five; and such
presents were from time to time judiciously offered by his son.
Early in the year 1740, Frederic William met death with a firmness
and dignity worthy of a better wiser man; and Frederic, who had just
completed his twenty-eighth year, became King of Prussia. His
character was little understood. That he had good abilities, indeed,
no person who had talked with him, or corresponded with him, could
doubt. But the easy, Epicurean life which he had led, his love of
good cookery and good wine, of music, of conversation, of light
literature, led many to regard him as a sensual and intellectual
voluptuary. His habit of canting about moderation, peace, liberty,
and the happiness which a good mind derives from the happiness of
others, had imposed on some who should have known better. Those
who thought best of him expected a Telemachus after Fénélon’s
pattern. Others predicted the approach of a Medicean age, an age
propitious to learning and art, and not unpropitious to pleasure.
Nobody had the least suspicion that a tyrant of extraordinary military
and political talents, of industry more extraordinary still, without fear,
without faith, and without mercy, had ascended the throne. The
disappointment of Falstaff at his old boon-companion’s coronation
was not more bitter than that which awaited some of the inmates of
Rheinsberg. They had long looked forward to the accession of their
patron, as to the event from which their own prosperity and
greatness was to date. They had at last reached the promised land,
the land which they had figured to themselves as flowing with milk
and honey; and they found it a desert. “No more of these fooleries,”
was the short, sharp admonition given by Frederic to one of them. It
soon became plain that, in the most important points, the new
sovereign bore a strong family likeness to his predecessor. There
was indeed a wide difference between the father and the son as
respected extent and vigour of intellect, speculative opinions,
amusements, studies, outward demeanour. But the groundwork of
the character was the same in both. To both were common the love
of order, the love of business, the military taste, the parsimony, the
imperious spirit, the temper irritable even to ferocity, the pleasure in
the pain and humiliation of others. But these propensities had in
Frederic William partaken of the general unsoundness of his mind,
and wore a very different aspect when found in company with the
strong and cultivated understanding of his successor. Thus, for
example, Frederic was as anxious as any prince could be about the
efficiency of his army. But this anxiety never degenerated into a
monomania, like that which led his father to pay fancy prices for
giants. Frederic was as thrifty about money as any prince or any
private man ought to be. But he did not conceive, like his father, that
it was worth while to eat unwholesome cabbages for the sake of
saving four or five rixdollars in the year. Frederic was, we fear, as
malevolent as his father; but Frederic’s wit enabled him often to
show his malevolence in ways more decent than those to which his
father resorted, and to inflict misery and degradation by a taunt
instead of a blow. Frederic, it is true, by no means relinquished his
hereditary privilege of kicking and cudgelling. His practice, however,
as to that matter, differed in some important respects from his
father’s. To Frederic William, the mere circumstance that any
persons whatever, men, women, or children, Prussians or foreigners,
were within reach of his toes and of his cane, appeared to be a
sufficient reason for proceeding to belabour them. Frederic required
provocation as well as vicinity; nor was he ever known to inflict this
paternal species of correction on any but his born subjects; though
on one occasion M. Thiebault had reason, during a few seconds, to
anticipate the high honour of being an exception to this general rule.
The character of Frederic was still very imperfectly understood
either by his subjects or by his neighbours, when events occurred
which exhibited it in a strong light. A few months after his accession
died Charles the Sixth, Emperor of Germany, the last descendant, in
the male line, of the House of Austria.
Charles left no son, and had, long before his death, relinquished
all hopes of male issue. During the latter part of his life, his principal
object had been to secure to his descendants in the female line the
many crowns of the house of Hapsburg. With this view, He had
promulgated a new law of succession, widely celebrated throughout
Europe under the name of the Pragmatic Sanction. By virtue of this
law, his daughter, the Archduchess Maria Theresa, wife of Francis of
Loraine, succeeded to the dominions of her ancestors. No sovereign
has ever taken possession of a throne by a clearer title. All the
politics of the Austrian cabinet had, during twenty years, been
directed to one single end, the settlement of the succession. From
every person whose rights could be considered as injuriously
affected, renunciations in the most solemn form had been obtained.
The new law had been ratified by the Estates of all the kingdoms
and principalities which made up the great Austrian monarchy.
England, France, Spain, Russia, Poland, Prussia, Sweden, Denmark,
the Germanic body, had bound themselves by treaty to maintain the
Pragmatic Sanction. That instrument was placed under the
protection of the public faith of the whole civilised world.
Even if no positive stipulations on this subject had existed, the
arrangement was one which no good man would have been willing
to disturb. It was a peaceable arrangement. It was an arrangement
acceptable to the great population whose happiness was chiefly
concerned. It was an arrangement which made no change in the
distribution of power among the states of Christendom. It was an
arrangement which could be set aside, only by means of a general
war; and, if it were set aside the effect would be, that the
equilibrium of Europe would be deranged, that the loyal and patriotic
feelings of millions would be cruelly outraged, and that great
provinces which had been united for centuries would be torn from
each other by main force.
The sovereigns of Europe were, therefore, bound by every
obligation which those who are intrusted with power over their
fellow-creatures ought to hold most sacred, to respect and defend
the rights of the Archduchess. Her situation and her personal
qualities were such as might be expected to move the mind of any
generous man to pity, admiration, and chivalrous tenderness. She
was in her twenty-fourth year. Her form was majestic, her features
beautiful, her countenance sweet and animated, her voice musical,
her deportment gracious and dignified. In all domestic relations she
was without reproach. She was married to a husband whom she
loved, and was on the point of giving birth to a child, when death
deprived her of her father. The loss of a parent, and the new cares
of empire, were too much for her in the delicate state of her health.
Her spirits were depressed, and her cheek lost its bloom. Yet it
seemed that she had little cause for anxiety. It seemed that justice,
humanity, and the faith of treaties would have their due weight, and
that the settlement so solemnly guaranteed would be quietly carried
into effect. England, Russia, Poland, and Holland, declared in form
their intention to adhere to their engagements. The French ministers
made a verbal declaration to the same effect. But from no quarter
did the young Queen of Hungary receive stronger assurances of
friendship and support than from the King of Prussia.
Yet the King of Prussia, the Anti-Machiavel, had already fully
determined to commit the great crime of violating his plighted faith,
of robbing the ally whom he was bound to defend, and of plunging
all Europe into a long, bloody, and desolating war; and all this for no
end whatever, except that he might extend his dominions, and see
his name in the gazettes. He determined to assemble a great army
with speed and secrecy, to invade Silesia before Maria Theresa
should be apprised of his design, and to add that rich province to his
kingdom.
We will not condescend to refute at length the pleas which the
compiler of the Memoirs before us has copied from Doctor Preuss.
They amount to this, that the house of Brandenburg had some
ancient pretensions to Silesia, and had in the previous century been
compelled, by hard usage on the part of the Court of Vienna, to
waive those pretensions. It is certain that, whoever might originally
have been in the right, Prussia had submitted. Prince after prince of
the house of Brandenburg had acquiesced in the existing
arrangement. Nay, the Court of Berlin had recently been allied with
that of Vienna, and had guaranteed the integrity of the Austrian
states. Is it not perfectly clear that, if antiquated claims are to be set
up against recent treaties and long possession, the world can never
be at peace for a day? The laws of all nations have wisely
established a time of limitation, after which titles, however
illegitimate in their origin, cannot be questioned. It is felt by
everybody, that to eject a person from his estate on the ground of
some injustice committed in the time of the Tudors would produce
all the evils which result from arbitrary confiscation, and would make
all property insecure. It concerns the commonwealth—so runs the
legal maxim—that there be an end of litigation. And surely this
maxim is at least equally applicable to the great commonwealth of
states; for in that commonwealth litigation means the devastation of
provinces, the suspension of trade and industry, sieges like these of
Badajoz and St. Sebastian, pitched fields like those of Eylau and
Borodino. We hold that the transfer of Norway from Denmark to
Sweden was an unjustifiable proceeding; but would the king of
Denmark be therefore justified in landing, without any new
provocation, in Norway, and commencing military operations there?
The king of Holland thinks, no doubt, that he was unjustly deprived
of the Belgian provinces. Grant that it were so. Would he, therefore,
be justified in marching with an army on Brussels? The case against
Frederic was still stronger, inasmuch as the injustice of which he
complained had been committed more than a century before. Nor
must it be forgotten that he owed the highest personal obligations to
the house of Austria. It may be doubted whether his life had not
been preserved by the intercession of the prince whose daughter he
was about to plunder.
To do the King justice, he pretended to no more virtue than he
had. In manifestoes he might, for form’s sake, insert some idle
stories about his antiquated claim on Silesia; but in his conversations
and Memoirs he took a very different tone. His own words are:
“Ambition, interest, the desire of making people talk about me,
carried the day; and I decided for war.”
Having resolved on his course, he acted with ability and vigour. It
was impossible wholly to conceal his preparations; for throughout
the Prussian territories regiments, guns, and baggage were in
motion. The Austrian envoy at Berlin apprised his court of these
facts, and expressed a suspicion of Frederic’s designs; but the
ministers of Maria Theresa refused to give credit to so black an
imputation on a young prince who was known chiefly by his high
professions of integrity and philanthropy. “We will not,” they wrote,
“we cannot, believe it.”
In the mean time the Prussian forces had been assembled.
Without any declaration of war, without any demand for reparation,
in the very act of pouring forth compliments and assurances of
good-will, Frederic commenced hostilities. Many thousands of his
troops were actually in Silesia before the Queen of Hungary knew
that he had set up any claim to any part of lier territories. At length
he sent her a message which could be regarded only as an insult.
If she would but let him have Silesia, he would, he said, stand by
her against any power which should try to deprive her of her other
dominions; as if he was not already bound to stand by her, or as if
his new promise could be of more value than the old one.
It was the depth of winter. The cold was severe, and the roads
heavy with mire. But the Prussians pressed on. Resistance was
impossible. The Austrian army was then neither numerous nor
efficient. The small portion of that army which lay in Silesia was
unprepared for hostilities. Glogau was blockaded: Breslau opened its
gates; Ohlau was evacuated. A few scattered garrisons still held out;
but the whole open country was subjugated: no enemy ventured to
encounter the King in the field; and, before the end of January,
1741, he returned to receive the congratulations of his subjects at
Berlin.
Had the Silesian question been merely a question between
Frederic and Maria Theresa, it would be impossible to acquit the
Prussian King of gross perfidy. But when we consider the effects
which his policy produced, and could not fail to produce, on the
whole community of civilised nations, we are compelled to
pronounce a condemnation still more severe. Till he began the war,
it seemed possible, even probable, that the peace of the world
would be preserved. The plunder of the great Austrian heritage was
indeed a strong temptation; and in more than one cabinet ambitious
schemes were already meditated. But the treaties by which the
Pragmatic Sanction had been guaranteed were express and recent.
To throw all Europe into confusion for a purpose clearly unjust, was
no light matter. England was true to her engagements. The voice of
Fleury had always been for peace. He had a conscience. He was now
in extreme old age, and was unwilling, after a life which, when his
situation was considered, must be pronounced singularly pure, to
carry the fresh stain of a great crime before the tribunal of his God.
Even the vain and unprincipled Belle-Isle, whose whole life was one
wild day-dream of conquest and spoliation, felt that France, hound
as she was by solemn stipulations, could not, without disgrace, make
a direct attack on the Austrian dominions. Charles, Elector of
Bavaria, pretended that he had a right to a large part of the
inheritance which the Pragmatic Sanction gave to the Queen of
Hungary; but he was not sufficiently powerful to move without
support. It might, therefore, not unreasonably be expected that,
after a short period of restlessness, all the potentates of
Christendom would acquiesce in the arrangements made by the late
Emperor. But the selfish rapacity of the King of Prussia gave the
signal to his neighbours. His example quieted their sense of shame.
His success led them to underrate the difficulty of dismembering the
Austrian monarchy. The whole world sprang to arms. On the head of
Frederic is all the blood which was shed in a war which raged during
many years and in every quarter of the globe, the blood of the
column of Fontenoy, the blood of the mountaineers who were
slaughtered at Culloden. The evils produced by his wickedness were
felt in lands where the name of Prussia was unknown; and, in order
that he might rob a neighbour whom he had promised to defend,
black men fought on the coast of Coromandel, and red men scalped
each other by the Great Lakes of North America. Silesia had been
occupied without a battle; but the Austrian troops were advancing to
the relief of the fortresses which still held out. In the spring Frederic
rejoined his army. He had seen little of war, and had never
commanded any great body of men in the field. It is not, therefore,
strange that his first military operations showed little of that skill
which, at a later period, was the admiration of Europe. What
connoisseurs say of some pictures painted by Raphael in his youth,
may be said of this campaign. It was in Frederic’s early bad manner.
Fortunately for him, the generals to whom he was opposed were
men of small capacity. The discipline of his own troops, particularly
of the infantry was unequalled in that age; and some able and
experienced officers were at hand to assist him with their advice. Of
these, the most distinguished was Field-Marshal Schwerin, a brave
adventurer of Pomeranian extraction, who had served half the
governments in Europe, had borne the commissions of the States
General of Holland and of the Duke of Mecklenburg, had fought
under Marlborough at Blenheim, and had been with Charles the
Twelfth at Bender.
Frederic’s first battle was fought at Molwitz; and never did the
career of a great commander open in a more inauspicious manner.
His army was victorious. Not only, however, did he not establish his
title to the character of an able general; but he was so unfortunate
as to make it doubtful whether he possessed the vulgar courage of a
soldier. The cavalry, which he commanded in person, was put to
flight. Unaccustomed to the tumult and carnage of a field of battle,
he lost his self-possession, and listened too readily to those who
urged him to save himself. His English grey carried him many miles
from the field, while Schwerin, though wounded in two places,
manfully upheld the day. The skill of the old Field-Marshal and the
steadiness of the Prussian battalions prevailed; and the Austrian
army was driven from the field with the loss of eight thousand men.
The news was carried late at night to a mill in which the King had
taken shelter. It gave him a bitter pang. He was successful; but he
owed his success to dispositions which others had made, and to the
valour of men who had fought while he was flying. So unpromising
was the first appearance of the greatest warrior of that age.
The battle of Molwitz was the signal for a general explosion
throughout Europe. Bavaria took up arms. France, not yet declaring
herself a principal in the war, took part in it as an ally of Bavaria. The
two great statesmen to whom mankind had owed many years of
tranquillity, disappeared about this time from the scene, but not till
they had both been guilty of the weakness of sacrificing their sense
of justice and their love of peace to the vain hope of preserving their
power. Fleury, sinking under age and infirmity, was borne down by
the impetuosity of Belle-Isle. Walpole retired from the service of his
ungrateful country to his woods and paintings at Houghton; and his
power devolved on the daring and eccentric Carteret. As were the
ministers, so were the nations. Thirty years during which Europe
had, with few interruptions, enjoyed repose, had prepared the public
mind for great military efforts. A new generation had grown up,
which could not remember the siege of Turin or the slaughter of
Malplaquet; which knew war by nothing but its trophies; and which,
while it looked with pride on the tapestries at Blenheim, or the
statue in the Place of Victories, little thought by what privations, by
what waste of private fortunes, by how many bitter tears, conquests
must be purchased.
For a time fortune seemed adverse to the Queen of Hungary.
Frederic invaded Moravia. The French and Bavarians penetrated into
Bohemia, and were there joined by the Saxons. Prague was taken.
The Elector of Bavaria was raised by the suffrages of his colleagues
to the Imperial throne, a throne which the practice of centuries had
almost entitled the House of Austria to regard as a hereditary
possession.
Yet was the spirit of the haughty daughter of the Cæsars
unbroken. Hungary was still hers by an unquestionable title; and
although her ancestors had found Hungary the most mutinous of all
their kino-doms, she resolved to trust herself to the fidelity of a
people, rude indeed, turbulent, and impatient of oppression, but
brave, generous, and simple-hearted. In the midst of distress and
peril she had given birth to a son, afterwards the Emperor Joseph
the Second. Scarcely had she risen from her couch, when she
hastened to Presburg. There, in the sight of an innumerable
multitude, she was crowned with the crown and robed with the robe
of St. Stephen. No spectator could restrain his tears when the
beautiful young mother, still weak from child-bearing, rode, after the
fashion of her fathers, up the Mount of Defiance, unsheathed the
ancient sword of state, shook it towards north and south, east and
west, and with a glow on her pale face challenged the four corners
of the world to dispute her rights and those of her boy. At the first
sitting of the Diet she appeared clad in deep mourning for her father,
and in pathetic and dignified words implored her people to support
her just cause. Magnates and deputies sprang up, half drew their
sabres, and with eager voices vowed to stand by her with their lives
and fortunes. Till then her firmness had never once forsaken her
before the public eye; but at that shout she sank down upon her
throne, and wept aloud. Still more touching was the sight when, a
few days later, she came before the estates of her realm, and held
up before them the little Archduke in her arms. Then it was that the
enthusiasm of Hungary broke forth into that war-cry which soon
resounded throughout Europe, “Let us die for our King, Maria
Theresa!”
In the mean time, Frederic was meditating a change of policy. He
had no wish to raise France to supreme power on the Continent, at
the expense of the house of Hapsburg. His first object was to rob
the Queen of Hungary. His second object was that, if possible,
nobody should rob her but himself. He had entered into
engagements with the powers leagued against Austria; but these
engagements were in his estimation of no more force than the
guarantee formerly given to the Pragmatic Sanction. His plan now
was to secure his share of the plunder by betraying his accomplices.
Maria Theresa was little inclined to listen to any such compromise;
but the English government represented to her so strongly the
necessity of buying off Frederic, that she agreed to negotiate. The
negotiation would not, however, have ended in a treaty, had not the
arms of Frederic been crowned with a second victory. Prince Charles
of Loraine, brother-in-law to Maria Theresa, a bold and active,
though unfortunate general, gave battle to the Prussians at
Chotusitz, and was defeated. The King was still only a learner of the
military art. He acknowledged, at a later period, that his success on
this occasion was to be attributed, not at all to his own generalship,
but solely to the valour and steadiness of his troops. He completely
effaced, however, by his personal courage and energy, the stain
which Molwitz had left on his reputation.
A peace, concluded under the English mediation, was the fruit of
this battle. Maria Theresa ceded Silesia: Frederic abandoned his
allies: Saxony followed his example; and the Queen was left at
liberty to turn her whole force against France and Bavaria. She was
everywhere triumphant. The French were compelled to evacuate
Bohemia, and with difficulty effected their escape. The whole line of
their retreat might be tracked by the corpses of thousands who had
died of cold, fatigue and hunger. Many of those who reached their
country carried with them the seeds of death. Bavaria was overrun
by bands of ferocious warriors from that bloody debatable land
which lies on the frontier between Christendom and Islam. The
terrible names of the Pandoor, the Croat, and the Hussar, then first
became familiar to western Europe. The unfortunate Charles of
Bavaria, vanquished by Austria, betrayed by Prussia, driven from his
hereditary states, and neglected by his allies, was hurried by shame
and remorse to an untimely end. An English army appeared in the
heart of Germany, and defeated the French at Dettingen. The
Austrian captains already began to talk of completing the work of
Marlborough and Eugene, and of compelling France to relinquish
Alsace and the Three Bishoprics.
The Court of Versailles, in this peril, looked to Frederic for help. He
had been guilty of two great treasons: perhaps he might be induced
to commit a third. The Duchess of Chateauroux then held the chief
influence over the feeble Lewis. She determined to send an agent to
Berlin; and Voltaire was selected for the mission. He eagerly
undertook the task; for, while his literary fame filled all Europe, he
was troubled with a childish craving for political distinction, He was
vain, and not without reason, of his address, and of his insinuating
eloquence; and he flattered himself that he possessed boundless
influence over the King of Prussia. The truth was that he knew, as
yet, only one corner of Frederic’s character. He was well acquainted
with all the petty vanities and affectations of the poetaster; but was
not aware that these foibles were united with all the talents and
vices which lead to success in active life, and that the unlucky
versifier who pestered him with reams of middling Alexandrines, was
the most vigilant, suspicious, and severe of politicians.
Voltaire was received with every mark of respect and friendship,
was lodged in the palace, and had a seat daily at the royal table.
The negotiation was of an extraordinary description. Nothing can be
conceived more whimsical than the conferences which took place
between the first literary man and the first practical man of the age,
whom a strange weakness had induced to exchange their parts. The
great poet would talk of nothing but treaties and guarantees, and
the great King of nothing but metaphors and rhymes. On one
occasion Voltaire put into his Majesty’s hands a paper on the state of
Europe, and received it back with verses scrawled on the margin. In
secret they both laughed at each other. Voltaire did not spare the
King’s poems; and the King has left on record his opinion of
Voltaire’s diplomacy. “He had no credentials,” Says Frederic, “and the
whole mission was a joke, a mere farce.” But what the influence of
Voltaire could not effect, the rapid progress of the Austrian arms
effected. If it should be in the power of Maria Theresa and George
the Second to dictate terms of peace to France, what chance was
there that Prussia would long retain Silesia? Frederic’s conscience
told him that he had acted perfidiously and inhumanly towards the
Queen of Hungary. That her resentment was strong she had given
ample proof; and of her respect for treaties he judged by his own.
Guarantees, he said, were mere filigree, pretty to look at, but too
brittle to bear the slightest pressure. He thought it his safest course
to ally himself closely to France, and again to attack the Empress
Queen. Accordingly, in the autumn of 1744, without notice, without
any decent pretext, he recommenced hostilities, inarched through
the electorate of Saxony without troubling himself about the
permission of the Elector, invaded Bohemia, took Prague, and even
menaced Vienna.
It was now that, for the first time, he experienced the inconstancy
of fortune. An Austrian army under Charles of Loraine threatened his
communications with Silesia. Saxony was all in arms behind him. He
found it necessary to save himself by a retreat. He afterwards owned
that his failure was the natural effect of his own blunders. No
general, he said, had ever committed greater faults. It must be
added, that to the reverses of this campaign he always ascribed his
subsequent successes. It was in the midst of difficulty and disgrace
that he caught the first clear glimpse of the principles of the military
art.
The memorable year 1745 followed. The war raged by sea and
land, in Italy, in Germany, and in Flanders; and even England, after
many years of profound internal quiet, saw, for the last time, hostile
armies set in battle array against each other. This year is memorable
in the life of Frederic, as the date at which his noviciate in the art of
war may be said to have terminated. There have been great captains
whose precocious and self-taught military skill resembled intuition.
Coudé, Clive, and Napoleon are examples. But Frederic was not one
of these brilliant portents. His proficiency in military science was
simply the proficiency which a man of vigorous faculties makes in
any science to which he applies his mind with earnestness and
industry. It was at Hohenfriedberg that he first proved how much he
had profited by his errors, and by their consequences. His victory on
that day was chiefly due to his skilful dispositions, and convinced
Europe that the prince who, a few years before, had stood aghast in
the rout of Molwitz, had attained in the military art a mastery
equalled by none of his contemporaries, or equalled by Saxe alone.
The victory of Hohenfriedberg was speedily followed by that of Sorr.
In the mean time, the arms of France had been victorious in the
Low Countries. Frederic had no longer reason to fear that Maria
Theresa would be able to give law to Europe, and he began to
meditate a fourth breach of his engagements. The court of Versailles
was alarmed and mortified. A letter of earnest expostulation, in the
handwriting of Lewis, was sent to Berlin; but in vain. In the autumn
of 1745, Frederic made peace with England, and, before the close of
the year, with Austria also. The pretensions of Charles of Bavaria
could present no obstacle to an accommodation. That unhappy
prince was no more; and Francis of Loraine, the husband of Maria
Theresa, was raised, with the general assent of the Germanic body,
to the Imperial throne.
Prussia was again at peace; but the European war lasted till, in
the year 1718, it was terminated by the treaty of Aix-la-Chapelle. Of
all the powers that had taken part in it, the only gainer was Frederic.
Not only had he added to his patrimony the fine province of Silesia:
he had, by his unprincipled dexterity, succeeded so well in
alternately depressing the scale of Austria and that of France, that
he was generally regarded as holding the balance of Europe, a high
dignity for one who ranked lowest among kings, and whose great-
grandfather had been no more than a Margrave. By the public, the
King of Prussia was considered as a politician destitute alike of
morality and decency, insatiably rapacious, and shamelessly false;
nor was the public much in the wrong. He was at the same time
allowed to be a man of parts, a rising general, a shrewd negotiator
and administrator. Those qualities wherein he surpassed all mankind,
were as yet unknown to others or to himself; for they were qualities
which shine out only on a dark ground. His career had hitherto, with
little interruption, been prosperous; and it was only in adversity, in
adversity which seemed without hope or resource, in adversity which
would have overwhelmed even men celebrated for strength of mind,
that his real greatness could be shown.
He had, from the commencement of his reign, applied himself to
public business after a fashion unknown among kings. Lewis the
Fourteenth, indeed, had been his own prime minister, and had
exercised a general superintendence over all the departments of the
government; but this was not sufficient for Frederic. He was not
content with being his own prime minister: He would be his own sole
minister. Under him there was no room, not merely for a Richelieu or
a Mazarin, but for a Colbert, a Louvois, or a Torey. A love of labour
for its own sake, a restless and insatiable longing to dictate, to
intermeddle, to make his power felt, a profound scorn and distrust of
lus fellow-creatures, made him unwilling to ask counsel, to confide
important secrets, to delegate ample powers. The highest
functionaries under his government were mere clerks, and were not
so much trusted by him as valuable clerks are often trusted by the
heads of departments. He was his own treasurer, his own
commander-in-chief, his own intendant of public works, his own
minister for trade and justice, for home affairs and foreign affairs,
his own master of the horse, steward, and chamberlain. Matters of
which no chief of an office in any other government would ever hear
were, in this singular monarchy, decided by the King in person. If a
traveller wished for a good place to see a review, he had to write to
Frederic, and received next day from a royal messenger, Frederic’s
answer signed by Fredericks own hand. This was an extravagant, a
morbid activity. The public business would assuredly have been
better done if each department had been put under a man of talents
and integrity, and if the King-had contented himself with a general
control. In this manner the advantages which belong to unity of
design, and the advantages which belong to the division of labour,
would have been to a great extent combined. But such a system
would not have suited the peculiar temper of Frederic. He could
tolerate no will, no reason, in the state, save his own. He wished for
no abler assistance than that of penmen who had just understanding
enough to translate and transcribe, to make out his scrawls, and to
put his concise Yes and No into an official form. Of the higher
intellectual faculties, there is as much in a copying machine, or a
lithographic press, as he required from a secretary of the cabinet.
His own exertions were such as were hardly to be expected from a
human body or a human mind. At Potsdam, his ordinary residence,
he rose at three in summer and four in winter. A page soon
appeared, with a large basket full of all the letters which had arrived
for the King by the last courier, despatches from ambassadors,
reports from officers of revenue, plans of buildings, proposals for
draining marshes, complaints from persons who thought themselves
aggrieved, applications from persons who wanted titles, military
commissions and civil situations. He examined the seals with a keen
eye; for he was never for a moment free from the suspicion that
some fraud might be practised on him. Then he read the letters,
divided them into several packets, and signified his pleasure,
generally by a mark, often by two or three words, now and then by
some cutting epigram. By eight he had generally finished this part of
his task. The adjutant-general was then in attendance, and received
instructions for the day as to all the military arrangements of the
kingdom. Then the King went to review his guards, not as kings
ordinarily review their guards, but with the minute attention and
severity of an old drill-sergeant. In the mean time the four cabinet
secretaries had been employed in answering the letters on which the
King had that morning signified his will. These unhappy men were
forced to work all the year round like negro slaves in the time of the
sugar-crop. They never had a holiday. They never knew what it was
to dine. It was necessary that, before they stirred, they should finish
the whole of their work. The King, always on his guard against
treachery, took from the heap a handful of letters at random, and
looked into them to see whether his instructions had been exactly
followed. This was no bad security against foul play on the part of
the secretaries; for if one of them were detected in a trick, he might
think himself fortunate if he escaped with five years of imprisonment
in a dungeon. Frederic then signed the replies, and all were sent off
the same evening.
The general principles on which this strange government was
conducted, deserve attention. The policy of Frederic was essentially
the same as his father’s; but Frederic, while he carried that policy to
lengths to which his father never thought of carrying it, cleared it at
the same time from the absurdities with which his father had
encumbered it. The King’s first object was to have a great, efficient,
and well-trained army. He had a kingdom which in extent and
population was hardly in the second rank of European powers; and
yet he aspired to a place not inferior to that of the sovereigns of
England. France, and Austria. For that end it was necessary that
Prussia should be all sting. Lewis the Fifteenth, with five times as
many subjects as Frederic, and more than five times as large a
revenue, had not a more formidable army. The proportion which the
soldiers in Prussia bore to the people seems hardly credible. Of the
males in the vigour of life, a seventh part were probably under arms;
and this great force had, by drilling, by reviewing, and by the
unsparing use of cane and scourge, been taught to perform all
evolutions with a rapidity and a precision which would have
astonished Villars or Eugene. The elevated feelings which are
necessary to the best kind of army were then wanting to the
Prussian service. In those ranks were not found the religious and
political enthusiasm which inspired the pikemen of Cromwell, the
patriotic ardour, the thirst of glory, the devotion to a great leader,
which inflamed the Old Guard of Napoleon. But in all the mechanical
parts of the military calling, the Prussians were as superior to the
English and French troops of that day as the English and French
troops to a rustic-militia.
Though the pay of the Prussian soldier was small, though every
rixdollar of extraordinary charge was scrutinised by Frederic with a
vigilance and suspicion such as Mr. Joseph Hume never brought to
the examination of an army estimate, the expense of such an
establishment was, for the means of the country, enormous. In order
that it might not be utterly ruinous, it was necessary that every
other expense should be cut down to the lowest possible point.
Accordingly Frederic, though his dominions bordered on the sea, had
no navy. He neither had nor wished to have colonies. His judges, his
fiscal officers, were meanly paid. His ministers at foreign courts
walked on foot, or drove shabby old carriages till the axletrees gave
way. Even to his highest diplomatic agents, who resided at London
and Paris, he allowed less than a thousand pounds sterling a year.
The royal household was managed with a frugality unusual in the
establishments of opulent subjects, unexampled in any other palace.
The King loved good eating and drinking, and during great part of
his life took pleasure in seeing his table surrounded by guests; yet
the whole charge of his kitchen was brought within the sum of two
thousand pounds sterling a year. He examined every extraordinary
item with a care which might be thought to suit the mistress of a
boarding house better than a great prince. When more than four
rixdollars were asked of him for a hundred oysters, he stormed as if
He had heard that one of his generals had sold a fortress to the
Empress Queen. Not a bottle of Champagne was uncorked without
his express order. The game of the royal parks and forests, a serious
head of expenditure in most kingdoms, was to him a source of
profit. The whole was farmed out: and though the farmers were
almost ruined by their contract, the King would grant them no
remission. His wardrobe consisted of one fine gala dress, which
lasted him all his life; of two or three old coats fit for Monmouth
Street, of yellow waistcoats soiled with snuff, and of huge boots
embrowned by time. One taste alone sometimes allured him beyond
the limits of parsimony, nay, even beyond the limits of prudence, the
taste for building. In all other things his economy was such as we
might call by a harsher name, if we did not reflect that his funds
were drawn from a heavily taxed people, and that it was impossible
for him, without excessive tyranny, to keep up at once a formidable
army and a splendid court.
Considered as an administrator, Frederic had undoubtedly many
titles to praise. Order was strictly maintained throughout his
dominions. Property was secure. A great liberty of speaking and of
writing was allowed. Confident in the irresistible strength derived
from a great army, the King looked down on malcontents and
libellers with a wise disdain; and gave little encouragement to spies
and informers. When he was told of the disaffection of one of his
subjects, he merely asked, “How many thousand men can he bring
into the field?” He once saw a crowd staring at something on a wall.
He rode up, and found that the object of curiosity was a scurrilous
placard against himself. The placard had been posted up so high
that it was not easy to read it. Frederic ordered his attendants to
take it down and put it lower. “My people and I,” he said, “have
come to an agreement which satisfies us both. They are to sav what
they please, and I am to do what I please.” No person would have
dared to publish in London satires on George the Second
approaching to the atrocity of those satires on Frederic, which the
booksellers at Berlin sold with impunity. One bookseller sent to the
palace a copy of the most stinging lampoon that perhaps was ever
written in the world, the Memoirs of Voltaire, published by
Beaumarchais, and asked for his majesty’s orders. “Do not advertise
it in an offensive manner,” said the King, “but sell it by all means. I
hope it will pay you well.” Even among statesmen accustomed to the
license of a free press, such steadfastness of mind as this is not very
common.
It is due also to the memory of Frederic to say that he earnestly
laboured to secure to his people the great blessing of cheap and
speedy justice. He was one of the first rulers who abolished the cruel
and absurd practice of torture. No sentence of death, pronounced by
the ordinary tribunals, was executed without his sanction; and his
sanction, except in cases of murder, was rarely given. Towards his
troops he acted in a very different manner. Military offences were
punished with such barbarous scourging that to be shot was
considered by the Prussian soldier as a secondary punishment.
Indeed, the principle which pervaded Frederic’s whole policy was
this, that the more severely the army is governed, the safer it is to
treat the rest of the community with lenity. Religious persecution
was unknown under his government, unless some foolish and unjust
restrictions which lay upon the Jews may be regarded as forming an
exception. His policy with respect to the Catholics of Silesia
presented an honourable contrast to the policy which, under very
similar circumstances, England long followed with respect to the
Catholics of Ireland. Every form of religion and irreligion found an
asylum in his states. The scoffer whom the parliaments of France
had sentenced to a cruel death, was consoled by a commission in
the Prussian service. The Jesuit who could show his face nowhere
else, who in Britain was still subject to penal laws, who was
proscribed by France, Spain, Portugal, and Naples, who had been
given up even by the Vatican, found safety and the means of
subsistence in the Prussian dominions.
Most of the vices of Frederic’s administration resolve themselves
into one vice, the spirit of meddling. The indefatigable activity of his
intellect, his dictatorial temper, his military habits, all inclined him to
this great fault. He drilled his people as he drilled his grenadiers.
Capital and industry were diverted from their natural direction by a
crowd of preposterous regulations. There was a monopoly of coffee,
a monopoly of tobacco, a monopoly of refined sugar. The public
money, of which the King was generally so sparing, was lavishly
spent in ploughing bogs, in planting mulberry-trees amidst the sand,
in bringing sheep from Spain to improve the Saxon wool, in
bestowing prizes for fine yarn, in building manufactories of porcelain,
manufactories of carpets, manufactories of hardware, manufactories
of lace. Neither the experience of other rulers, nor his own, could
ever teach him that something more than an edict and a grant of
public money was required to create a Lyons, a Brussels, or a
Birmingham.
For his commercial policy, however, there was some excuse. He
had on his side illustrious examples and popular prejudice.
Grievously as he erred, he erred in company with his age. In other
departments his meddling was altogether without apology. He
interfered with the course of justice as well as with the course of
trade; and set up his own crude notions of equity against the law as
expounded by the unanimous voice of the gravest magistrates. It
never occurred to him that men whose lives were passed in
adjudicating on questions of civil right were more likely to form
correct opinions on such questions than a prince whose attention
was divided among a thousand objects, and who had never read a
law-book through. The resistance opposed to him by the tribunals
inflamed him to fury. He reviled his Chancellor. He kicked the shins
of his Judges. He did not, it is true, intend to act unjustly. He firmly
believed that he was doing right, and defending the cause of the
poor against the wealthy. Yet this well-meant meddling probably did
far more harm than all the explosions of his evil passions during the
whole of his long reign. We could make shift to live under a
debauchee or a tyrant; but to be ruled by a busy-body is more than
human nature can bear.
The same passion for directing and regulating appeared in every
part of the King’s policy. Every lad of a certain station in life was
forced to go to certain schools within the Prussian dominions. If a
young Prussian repaired, though but for a few weeks, to Leyden or
Gottingen for the purpose of study, the offence was punished with
civil disabilities, and sometimes with the confiscation of property.
Nobody was to travel without the royal permission. If the permission
were granted, the pocket-money of the tourist was fixed by royal
ordinance. A merchant might take with him two hundred and fifty
rixdollars in gold, a noble was allowed to take four hundred; for it
may be observed, in passing, that Frederic studiously kept up the old
distinction between the nobles and the community. In speculation,
he was a French philosopher, but in action, a German prince. He
talked and wrote about the privileges of blood in the style of Sieves;
but in practice no chapter in the empire looked with a keener eye to
genealogies and quarterings.
Such was Frederic the Ruler. But there was another Frederic, the
Frederic of Rheinsberg, the fiddler and flute-player, the poetaster
and metaphysician. Amidst the cares of state the Kino; had retained
his passion for music, for reading, for writing, for literary society. To
these amusements he devoted all the time that he could snatch from
the business of war and government; and perhaps more light is
thrown on his character by what passed during his hours of
relaxation, than by his battles or his laws.
It was the just boast of Schiller that, in his country, no Augustus,
no Lorenzo, had watched over the infancy of poetry. The rich and
energetic language of Luther, driven by the Latin from the schools of
pedants, and by the French from the palaces of kings, had taken
refuge among the people. Of the powers of that language Frederic
had no notion. He generally spoke of it, and of those who used it,
with the contempt of ignorance. His library consisted of French
books; at his table nothing was heard but French conversation. The
associates of his hours of relaxation were, for the most part,
foreigners. Britain furnished to the royal circle two distinguished
men, born in the highest rank, and driven by civil dissensions from
the land to which, under happier circumstances, their talents and
virtues might have been a source of strength and glory. George
Keith, Earl Marischal of Scotland, had taken arms for the house of
Stuart in 1715; and his younger brother James, then only seventeen
years old, had fought gallantly by his side. When all was lost they
retired together to the Continent, roved from country to country,
served under various standards, and so bore themselves as to win
the respect and good-will of many who had no love for the Jacobite
cause. Their long wanderings terminated at Potsdam; nor had
Frederic any associates who deserved or obtained so large a share
of his esteem. They were not only accomplished men, but nobles
and warriors, capable of serving him in war and diplomacy, as well
as of amusing him at supper. Alone of all his companions they
appear never to have had reason to complain of his demeanour
towards them. Some of those who knew the palace best pronounced
that Lord Marischal was the only human being whom Frederic ever
really loved.
Italy sent to the parties at Potsdam the ingenious and amiable
Algarotti, and Bastiani, the most crafty, cautions, and servile of
Abbés. But the greater part of the society which Frederic had
assembled round him, was drawn from France. Maupertuis had
acquired some celebrity by the journey which he had made to
Lapland, for the purpose of ascertaining, by actual measurement,
the shape of our planet. He was placed in the chair of the Academy
of Berlin, a humble imitation of the renowned academy of Paris.
Baculard D’Arnaud, a young poet, who was thought to have given
promise of great things, had been induced to quit his country, and to
reside at the Prussian Court. The Marquess D’Argens was amoung
the King’s favourite companions, on account, as it should seem, of
the strong opposition between their characters. The parts of
D’Argens were good, and his manners those of a finished French
gentleman; but his whole soul was dissolved in sloth, timidity, and
self-indulgence. His was one of that abject class of minds which are
superstitious without being religious. Hating Christianity with a
rancour which made him incapable of rational inquiry, unable to see
in the harmony and beauty of the universe the traces of divine
power and wisdom, he was the slave of dreams and omens, would
not sit down to table with thirteen in company, turned pale if the salt
fell towards him, begged his guests not to cross their knives and
forks on their plates, and would not for the world commence a
journey on Friday. His health was a subject of constant anxiety to
him. Whenever his head ached or his pulse beat quick, his dastardly
fears and effeminate precautions were the jest of all Berlin. All this
suited the King’s purpose admirably. He wanted somebody by whom
he might be amused, and whom he might despise. When he wished
to pass half an hour in easy polished conversation, D’Argens was an
excellent companion; when he waited to vent his spleen and
contempt, D’Argens was an excellent butt.
With these associates, and others of the same class, Frederic
loved to spend the time which he could steal from public cares. He
wished his supper-parties to be gay and easy. He invited his guests
to lay aside all restraint, and to forget that he was at the head of a
hundred and sixty thousand soldiers, and was absolute master of the
life and liberty of all who sat at meat with him. There was, therefore,
at these parties the outward show of ease. The wit and learning of
the company were ostentatiously displayed. The discussions on
history and literature were often highly interesting. But the absurdity
of all the religion known among men was the chief topic of
conversation; and the audacity with which doctrines and names
venerated throughout Christendom were treated on these occasions
startled even persons accustomed to the society of French and
English freethinkers. Real liberty, how ever, or real affection, was in
this brilliant society not to be found. Absolute kings seldom have
friends: and Frederic’s faults were such as, even where perfect
equality exists, make friendship exceedingly precarious. He had
indeed many qualities, which, on a first acquaintance, were
captivating. His conversation was lively; his manners, to those whom
he desired to please, were even caressing No man could flatter with
more delicacy. No man succeeded more completely in inspiring those
who approached him with vague hopes of some great advantage
from his kindness. But under this fair exterior he was a tyrant,
suspicious, disdainful, and malevolent. He had one taste which may
be pardoned in a boy, but, which when habitually and deliberately
indulged by a man of mature age and strong understanding, is
almost invariably the sign of a bad heart, a taste for severe practical
jokes. If a courtier was fond of dress, oil was flung over his richest
suit. If he was fond of money, some prank was invented to make
him disburse more than he could spare. If he was hypochondriacal,
he was made to believe that he had the dropsy. If he had
particularly set his heart on visiting a place, a letter was forged to
frighten him from going thither. These things, it may be said, are
trifles. They are so; but they are indications, not to be mistaken, of a
nature to which the sight of human suffering and human
degradation is an agreeable excitement.
Frederic had a keen eye for the foibles of others, and loved to
communicate his discoveries. He had some talent for sarcasm, and
considerable skill in detecting; the sore places where sarcasm would
be most acutely felt. His vanity, as well as his malignity, found
gratification in the vexation and confusion of those who smarted
under his caustic jests. Yet in truth his success on these occasions
belonged quite as much to the king as to the wit. We read that
Commodus descended, sword in hand, into the arena against a
wretched gladiator, armed only with a foil of lead, and, after
shedding the blood of the helpless victim, struck medals to
commemorate the inglorious victory. The triumphs of Frederic in the
war of repartee were of much the same kind. How to deal with him
was the most puzzling of questions. To appear constrained in his
presence was to disobey his commands, and to spoil his amusement.
Yet if his associates were enticed by his graciousness to indulge in
the familiarity of a cordial intimacy, he was certain to make them
repent of their presumption by some cruel humiliation. To resent his
affronts was perilous; yet not to resent them was to deserve and to
invite them. In his view, those who mutinied were insolent and
ungrateful; those who submitted were curs made to receive bones
and kickings with the same fawning patience. It is, indeed, difficult
to conceive how any thing short of the rage of hunger should have
induced men to bear the misery of being the associates of the Great
King. It was no lucrative post. His Majesty was as severe and
economical in his friendships as in the other charges of his
establishment, and as unlikely to give a rixdollar too much for his
guests as for his dinners. The sum which he allowed to a poet or a
philosopher was the very smallest sum for which such poet or
philosopher could be induced to sell himself into slavery; and the
bondsman might think himself fortunate, if what had been so
grudgingly given was not, after years of suffering, rudely and
arbitrarily withdrawn.
Potsdam was, in truth, what it was called by one of its most
illustrious inmates, the Palace of Alcina. At the first glance it seemed
to be a delightful spot, where every intellectual and physical
enjoyment awaited the happy adventurer. Every new comer was
received with eager hospitality, intoxicated with battery, encouraged
to expect prosperity and greatness. It was in vain that a long;
succession of favourites who had entered that abode with delight
and hope, and who, after a short term of delusive happiness, had
been doomed to expiate their folly by years of wretchedness and
degradation, raised their voices to warn the aspirant who
approached the charmed threshold. Some had wisdom enough to
discover the truth early, and spirit enough to fly without looking
back; others lingered on to a cheerless and unhonoured old age. We
have no hesitation in saying that the poorest author of that time in
London, sleeping on a bulk, dining in a cellar, with a cravat of paper,
and a skewer for a shirt-pin, was a happier man than any of the
literary inmates of Frederic’s court.
But of all who entered the enchanted garden in the inebriation of
delight, and quitted it in agonies of rage and shame, the most
remarkable was Voltaire. Many circumstances had made him
desirous of finding a home at a distance from his country. His fame
had raised him up enemies. His sensibility gave them a formidable
advantage over him. They were, indeed, contemptible assailants. Of
all that they wrote against him, nothing has survived except what he
has himself preserved. But the constitution of his mind resembled
the constitution of those bodies in which the slightest scratch of a
bramble, or the bite of a gnat, never fails to fester. Though his
reputation was rather raised than lowered by the abuse of such
writers as Fréron and Desfontaines, though the vengeance which he
took on Fréron and Desfontaines was such, that scourging branding,
pillorying, would have been a trifle to it, there is reason to believe
that they gave him far more pain than he ever gave them. Though
he enjoyed during his own lifetime the reputation of a classic,
though he was extolled by his contemporaries above all poets,
philosophers, and historians, though his works were read with as
much delight and admiration at Moscow and Westminster, at
Florence and Stockholm, as at Paris itself, he was yet tormented by
that restless jealousy which should seem to belong only to minds
burning with the desire of fame, and yet conscious of impotence. To
men of letters who could by no possibility be his rivals, he was, if
they behaved well to him, not merely just, not merely courteous, but
often a hearty friend and a munificent benefactor. But to every writer
who rose to a celebrity approaching his own, he became either a
disguised or an avowed enemy. He slily depreciated Montesquieu
and Buffon. He publicly, and with violent outrage, made war on
Rousseau. Nor had he the art of hiding his feelings under the
semblance of good humour or of contempt. With all his great
talents, and all his long experience of the world, he had no more
self-command than a petted child or a hysterical woman. Whenever
he was mortified, he exhausted the whole rhetoric of anger and
sorrow to express his mortification. His torrents of bitter words, his
stamping and cursing, his grimaces and his tears of rage, were a rich
feast to those abject natures, whose delight is in the agonies of
powerful spirits and in the abasement of immortal names. These
creatures had now found out a way of galling him to the very quick.
In one walk, at least, it had been admitted by envy itself that he was
without, a living competitor. Since Racine had been laid among the
great men whose dust made the holy precinct of Port Royal holier,
no tragic poet had appeared who could contest the palm with the
author of Zaire, of Alzire, and of Merope. At length a rival was
announced. Old Crébillon, who, many years before, had obtained
some theatrical success, and who had long been forgotten, came
forth from his garret in one of the meanest lanes near the Rue St.
Antoine, and was welcomed by the acclamations of envious men of
letters, and of a capricious populace. A thing called Catiline, which
He had written in his retirement, was acted with boundless
applause. Of this execrable piece it is sufficient to say, that the plot
turns on a love affair, carried on in all the forms of Scudery, between
Catiline, whose confidant is the Prætor Lentulus, and Tullia, the
daughter of Cicero. The theatre resounded with acclamations. The
king pensioned the successful poet; and the coffeehouses
pronounced that Voltaire was a clever man, but that the real tragic
inspiration, the celestial fire which had glowed in Corneille and
Racine, was to be found in Crébillon alone.
The blow went to Voltaire’s heart. Had his wisdom and fortitude
been in proportion to the fertility of his intellect, and to the brilliancy
of his wit, he would have seen that it was out of the power of all the
puffers and detractors in Europe to put Catiline above Zaire; but he
had none of the magnanimous patience with which Milton and
Bentley left their claims to the unerring judgment of time. He
eagerly engaged in an undignified competition with Crebillon, and
produced a series of plays on the same subjects which his rival had
treated. These pieces were coolly received. Angry with the court,
angry with the capital, Voltaire began to find pleasure in the
prospect of exile. His attachment for Madame du Châtelet long
prevented him from executing his purpose. Her death set him at
liberty; and he determined to take refuge at Berlin.
To Berlin he was invited by a series of letters, couched in terms of
the most enthusiastic friendship and admiration. For once the rigid
parsimony of Frederic seemed to have relaxed. Orders, honourable
offices, a liberal pension, a well-served table, stately apartments
under a royal roof, were offered in return for the pleasure and
honour which were expected from the society of the first wit of the
age. A thousand louis were remitted for the charges of the journey.
No ambassador setting out from Berlin for a court of the first rank,
had ever been more amply supplied. But Voltaire was not satisfied.
At a later period, when he possessed an ample fortune, he was one
of the most liberal of men; but till his means had become equal to
his wishes, his greediness for lucre was unrestrained either by
justice or by shame. He had the effrontery to ask for a thousand
louis more, in order to enable him to bring his niece, Madame Denis,
the ugliest of coquettes, in his company. The indelicate rapacity of
the poet produced its natural effect on the severe and frugal King.
The answer was a dry refusal. “I did not,” said his Majesty, “solicit
the honour of the lady’s society.” On this, Voltaire went off into a
paroxysm of childish rage. “Was there ever such avarice? He has
hundreds of tubs full of dollars in his vaults, and haggles with me
about a poor thousand louis.” It seemed that the negotiation would
be broken off; but Frederic, with great dexterity, affected
indifference, and seemed inclined to transfer his idolatry to Baculard
D’Arnaud. His Majesty even wrote some bad verses, of which the
sense was, that Voltaire was a setting sun, and that D’Arnaud was
rising. Good-natured friends soon carried the lines to Voltaire. He
was in his bed. He jumped out in his shirt, danced about the room
with rage, and sent for his passport and his post-horses. It was not
difficult to foresee the end of a connection which had such a
beginning.
It was in the year 1750 that Voltaire left the great capital, which
he was not to see again till, after the lapse of near thirty years, he
returned, bowed down by extreme old age, to die in the midst of a
splendid and ghastly triumph. His reception in Prussia was such as
might well have elated a less vain and excitable mind. He wrote to
his friends at Paris, that the kindness and the attention with which
he had been welcomed surpassed description, that the King was the
most amiable of men, that Potsdam was the paradise of
philosophers. He was created chamberlain, and received, together
with his gold key, the cross of an order, and a patent ensuring to him
a pension of eight hundred pounds sterling a year for life. A hundred
and sixty pounds a year were promised to his niece if she survived
him. The royal cooks and coachmen were put at his disposal. He was
lodged in the same apartments in which Saxe had lived, when, at
the height of power and glory, he visited Prussia. Frederic, indeed,
stooped for a time even to use the language of adulation. He
pressed to his lips the meagre hand of the little grinning skeleton,
whom he regarded as the dispenser of immortal renown. He would
add, he said, to the titles which he owed to his ancestors and his
sword, another title, derived from his last and proudest acquisition.
His style should run thus:—Frederic, King of Prussia, Margrave of
Brandenburg, Sovereign Duke of Silesia, Possessor of Voltaire. But
even amidst the delights of the honeymoon, Voltaire’s sensitive
vanity began to take alarm. A few days after his arrival, he could not
help telling his niece that the amiable King had a trick of giving a sly
scratch with one hand, while patting and stroking with the other.
Soon came hints not the less alarming, because mysterious. “The
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like