100% found this document useful (6 votes)
37 views

Download Full Beginning JavaScript for Adobe Acrobat A non programmer s Guide John Deubert PDF All Chapters

Adobe

Uploaded by

fujancalipu5
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (6 votes)
37 views

Download Full Beginning JavaScript for Adobe Acrobat A non programmer s Guide John Deubert PDF All Chapters

Adobe

Uploaded by

fujancalipu5
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

Download the full version of the ebook at ebookname.

com

Beginning JavaScript for Adobe Acrobat A non


programmer s Guide John Deubert

https://ebookname.com/product/beginning-javascript-for-
adobe-acrobat-a-non-programmer-s-guide-john-deubert/

OR CLICK BUTTON

DOWNLOAD EBOOK

Download more ebook instantly today at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Adobe Acrobat 8 for Windows and Macintosh Visual


QuickStart Guide 1st Edition John Deubert

https://ebookname.com/product/adobe-acrobat-8-for-windows-and-
macintosh-visual-quickstart-guide-1st-edition-john-deubert/

ebookname.com

Ivor Horton s Beginning Visual C 2010 Wrox Programmer to


Programmer 1st Edition Ivor Horton

https://ebookname.com/product/ivor-horton-s-beginning-
visual-c-2010-wrox-programmer-to-programmer-1st-edition-ivor-horton/

ebookname.com

Learning JavaScript Design Patterns A JavaScript and React


Developer s Guide 2nd Edition Adnan Osmani

https://ebookname.com/product/learning-javascript-design-patterns-a-
javascript-and-react-developer-s-guide-2nd-edition-adnan-osmani/

ebookname.com

Saints and Sinners A History of the Popes Fourth Edition


Eamon Duffy

https://ebookname.com/product/saints-and-sinners-a-history-of-the-
popes-fourth-edition-eamon-duffy/

ebookname.com
Northwest Coast Indian Art An Analysis of Form 50th
Anniversary Edition Bill Holm

https://ebookname.com/product/northwest-coast-indian-art-an-analysis-
of-form-50th-anniversary-edition-bill-holm/

ebookname.com

Handbook of Energy Audits Sixth Edition Albert Thumann

https://ebookname.com/product/handbook-of-energy-audits-sixth-edition-
albert-thumann/

ebookname.com

The George Gershwin Reader Readers on American Musicians


1St Edition Edition Robert Wyatt

https://ebookname.com/product/the-george-gershwin-reader-readers-on-
american-musicians-1st-edition-edition-robert-wyatt/

ebookname.com

Worlds of Music An Introduction to the Music of the World


s Peoples Fifth Edition Jeff Todd Titon

https://ebookname.com/product/worlds-of-music-an-introduction-to-the-
music-of-the-world-s-peoples-fifth-edition-jeff-todd-titon/

ebookname.com

The Sociology of Gender and the Family Middle Class


Families 1st Edition Colin Bell

https://ebookname.com/product/the-sociology-of-gender-and-the-family-
middle-class-families-1st-edition-colin-bell/

ebookname.com
Cardiovascular Disease in the Elderly 4th Edition Wilbert
S. Aronow

https://ebookname.com/product/cardiovascular-disease-in-the-
elderly-4th-edition-wilbert-s-aronow/

ebookname.com
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–
QED 1. Welcome to JavaScript
For what it’s worth, my favorite programmers’ editor on the Mac is TextWrangler (www.barebones.com); it
is a first-rate editor and completely free, omigawd. Among Windows text editors, I’m rather fond of TextPad
(www.textpad.com); it’s relatively inexpensive shareware and well worth the money.

JavaScript References
This book is a non-programmer’s introduction to using JavaScript within Adobe Acrobat; it offers full
coverage of neither the JavaScript language nor a complete description of the ins and outs of the Figure 1.12 You can tell Acrobat to use an external editor when typing or modifying
implementation of JavaScript that resides in Adobe Acrobat. When you are done with this book, you will JavaScript code.
have two other references you can use to further your studies.

Client-Side JavaScript Reference


There are myriad books on JavaScript, as I said at the start of this chapter. However, the official JavaScript
definition is presented in a web-resident document called the Client-side JavaScript Reference, which resides
on Oracle’s website, here.

Figure 1.13 shows a part of a page from the Reference. As you can see, this is not intended to be fun reading;
it’s a reference, not a tutorial. Still, if you want to learn the complete set of features that are built into the
JavaScript language (as opposed to the Acrobat version of it), this is the place to go.

Acrobat JavaScript Guide


The full description of all of the things you can do with JavaScript in Acrobat is presented in a document
available from Adobe’s Developer website: the JavaScript for Acrobat API Reference or “JSAPI,” from now on
(Figure 1.14, next page). This is the technical specification of all of the object types available to your JavaScript
programs within Acrobat. There is also an excellent on-line version available through Adobe’s Developer website.

Figure 1.13 The Client-side JavaScript Reference is a web site


that presents the formal definition of the JavaScript language.
It is very useful, if not very fun to read.

–14–
QED 1. Welcome to JavaScript
Like the Client-Side Reference, the JSAPI is a technical specification, not a document you would willingly read
from one end to the other. It gives a detailed description of every JavaScript object type available in Acrobat

x
and the properties and methods of each. Where the book you are
Note
reading presents a series of examples of how to carry out specific
The JSAPI is available as a Kindle book from
tasks in JavaScript, the JSAPI describes everything you can do in amazon.com.
Acrobat with JavaScript.

To give you a bit of the flavor of the ­JSAPI, Figure 1.15 shows a screenshot of the complete description of the
app object’s beep method. I shall be making occasional r­ eferences to the JSAPI throughout this book.

Figure 1.14 The JavaScript for A


­ crobat API Reference
is the f­ormal technical document that lays out the
how Acrobat’s J­avaScript implementation works.

Figure 1.15 The description of the app object’s beep method is a good
example of the type of description provided for every object., method, and
property in the JavaScript for Acrobat API Reference.

–15–
QED Chapter 2
Page and Document JavaScripts

There are five broad types of JavaScripts in Acrobat, each differing in where it’s used in the Acrobat ­document.
What We’ll Learn in this Chapter
■ Form Field JavaScripts are attached to form fields. As we saw in the previous chapter, Form Field scripts are In this chapter, we’ll learn how to:
associated with events that occur with a form field: Mouse Down, On Focus, and so on. ■ Run a JavaScript when a document opens
■ Document JavaScripts are associated with the opening of the Acrobat file. Acrobat executes these when ■ Run a JavaScript when a document closes
the document is first opened. ■ Run a JavaScript when entering or leaving a page
■ Document Action JavaScripts are executed when one of a set of predefined events happens with the ■ Using JavaScript variables
­Acrobat file: the file closes, is saved, and so on.

■ Page JavaScripts are associated with a particular page. You can provide scripts that Acrobat will execute
when the user enters that page, leaves that page, or both.

■ Application JavaScripts are scripts that are executed by Acrobat when the application first opens. These
can perform a variety of interesting tasks, such as add items to the Acrobats menus. We won’t be talking
about application scripts in this book, because their use is specialized and infrequent; they’ll be a topic for
an eventual book 2.

We discussed Form Field JavaScripts in Chapter 1. In this chapter, we’ll look at how to write the other three
types of scripts.

The Project
(Files: JSAcro_Ch02_Example_Start.pdf, JSAcro_Ch02_Example_Final.pdf )

Our sample file for this chapter is the pet store catalog pictured in Figure 2.1. In the course of our discussion,
we’ll add examples of Document, Document Action, and Page JavaScripts to this file.

Figure 2.1 In this chapter, we are going to add several scripts


to this pdf document.

–16–
QED 2. Page and Document JavaScripts
The JavaScript Tools Panel
Several of the JavaScript-related tools we’ll be using in this chapter reside in the JavaScript panel in the
­Acrobat X Tools pane (Figure 2.2).

If you examine your own copy of Acrobat, you’ll probably find the JavaScript panel is missing; A ­ crobat Figure 2.2 The Javascript
doesn’t show this panel by default. (This is reasonable; the vast majority of Acrobat users don’t have anything panel lives in the Tools
pane. It is initially hidden.
to do with JavaScript and would be appalled at the prospect.) Before we can proceed further in this book,
we need to make the panel visible, thusly: The tiny icon in the upper-
right corner, just above
To make the JavaScript panel visible: the panels displays a

x Note
drop-down menu when
1 Make the Tools pane visible by clicking its name in the
clicked (Figure 2.3).
Acrobat X toolbar. Acrobat 9 doesn’t have a Tools pane. All of
the JavaScript commands in this chapter reside in
2 Click the tiny icon at the top of the Tools pane and select the Advanced>Document Processing submenu.
JavaScript in the resulting pop-up menu (­Figure 2.3).

The JavaScript panel will become visible in the Tools pane. It will be available to your copy of Acrobat X until
you deselect it again.

Document JavaScripts
Document JavaScripts are executed by Acrobat upon opening the document to which they're attached. This is
a convenient way to present the reader with an initial “splash screen” or to carry out some other start-up ­activity
when the user opens your pdf file. You may attach as many Document JavaScripts to an Acrobat file as you wish.

As an example, we’ll add a Document JavaScript to our ­catalog that displays a greeting when the reader
opens the document (Figure 2.4).
Figure 2.3 Make the JavaScript panel visible by selecting it from the
To attach a Document JavaScript to an Acrobat document: Tools pane’s pop-up menu.

Start with the document open in Acrobat.

1 In the JavaScript panel, click the Document JavaScripts tool (back in Figure 2.2). Figure 2.4 We’ll start
by adding a Document
Acrobat will display the Document JavaScript dialog box (Figure 2.5 , next page). JavaScript that displays an
admittedly unattractive
2 Type a name for your script into the Script Name field. “welcome” message when
the pdf document opens.

–17–
QED 2. Page and Document JavaScripts
This can be any name you wish, although descriptive is
better than cryptic; we’ll name our script “­Welcome,”
since that’s what it does.

3 Click the Add button.

Acrobat will present you with the JavaScript Editor


window (Figure 2.6). Note that this window appears with
some JavaScript code already entered into the text field.
This code is the starting point for a J­avaScript function
definition; since we’re not going to be defining a function,
Figure 2.6 The JavaScript Editor window provides you with a simple text
you can delete this initial code. ­editor into which you may type your JavaScript.
4 Type your JavaScript into the text field (Figure 2.7, next page). Figure 2.5 The Document JavaScripts dialog box lets you
attach JavaScripts to your document.
In our case, the script will be a single line, as follows:
app.alert("Welcome to the 1-Off Pets catalog!", 3)

This JavaScript displays the alert shown back in Figure 2.4. The app object’s alert method displays an
alert window with the specified text. The 3 indicates the kind of icon that should appear in the alert. We’ll
look at this method in more detail in Chapter 4. (You may recall we discussed the app object in C ­ hapter 1.) Figure 2.7 Type your JavaScript into the text field of the JavaScript Editor.

Remember that JavaScript is case sensitive; your upper- and lower-case letters should match the line above.

5 Click ok to back out of the JavaScript Editor and return to the Document JavaScripts dialog box.

The dialog box will now show our Window script in its list of scripts (Figure 2.8). If you click on the
script in the list, the dialog box displays the code in the lower text field, as in the figure.

6 Click the Close button to exit the Document Scripts dialog box; you will now be back at your Acrobat
page. That’s it! We’ve created our Document JavaScript. Figure 2.8 Our
Welcome script is now
7 Try it out by saving the Acrobat file, closing it, and then reopening it. Acrobat should display the alert we listed in the D
­ ocument
saw in Figure 2.4. JavaScripts dialog
box. Click on the script
name and its text will
appear in the lower
text field.

–18–
Random documents with unrelated
content Scribd suggests to you:
Reverend and very dear Sir,

T HOUGH at this distance of time and place, yet I do not forget our
solemn and mournful parting. Blessed be God, there is a time
coming, when these cutting trials will be over. I long, I long for it,
and yet when fresh doors of usefulness are opening, I am content to
stay below. This I trust is the case at present in Virginia. The
prospect is promising indeed. People have flocked from all parts to
hear the word, and arrows of conviction have fled, and I believe
stuck fast. Seed sown several years ago, hath sprung up and
brought forth fruit. Doth not the Lord of the harvest by this say, “Go
forward.” Do, my dear Sir, help me by your prayers; I want to have
my tardy pace quickened. I am now forty years old. Surely it is high
time to awake out of sleep. I doubt not but this will find you and
yours all alive for Jesus. Being straitened for time, I must beg you to
remember me in the most tender manner to all dear, very dear
friends as they come in your way, and accept the same for your
whole self, from, reverend and very dear Sir,

Your most affectionate, obliged friend, brother, and servant


in our common Lord,

G. W.

LETTER MLXXIII.
To Mr. F――.

Virginia, January 17, 1755.

My dear Mr. F――,

I HOPE that this will find you safely arrived at Philadelphia, from
your northward expedition, and ready to come further
southwards. This leaves me in my last Virginia stage, near the
borders of North-Carolina. People as I came along have been very
willing to attend on my feeble labours, and I hope that some real
good hath been done. If this be effected, it matters little how the
labourer himself may be sometimes fatigued.

His presence doth my pains beguile,

And makes the wilderness to smile.

Lovely delusion this! Living, dying, and after death I hope to be


possessed of it. I have seen your Epitaph. Believe on Jesus, and get a
feeling possession of God in your heart, and you cannot possibly be
disappointed of your expected second edition, finely corrected, and
infinitely amended. Verbum sapienti sat est. I could say more, but
time is short. Glad shall I be to wait on you and Mr. H―― at the
Orphan-house. I send you both my cordial respects, and praying that
you may have what good Colonel G――r once wished me, “A thriving
soul in a healthy body,” I subscribe myself, my dear Sir,

Your affectionate, obliged friend and ready servant,

G. W.

LETTER MLXXIV.
To Mr. ――.

Virginia, in Hanover County, January 23, 1755.

My very dear Jonathan,


T HAT ever-loving and ever-lovely Redeemer that owned my feeble
labours in the northward, still continues to bless and succeed
me in my journey southward. I have not been here a week, and
have had the comfort of seeing many impressed under the word
every day. Two churches have been opened, and a third (Richmond)
I am to preach in to-morrow. Prejudices I find do subside, and some
of the rich and great begin to think favourably of the work of God.
Several of the lower class have been with me acknowledging what
the Lord of all Lords did for them, when I was here before. O that I
may be humbly thankful, and improve every smile to quicken my
tardy pace, and make me all alive for Jesus! About this day month, I
hope to reach Georgia; from thence, I intend writing to you again.
But be where I will, dear Boston is much upon my heart. This may
serve as a proof that you and yours are not forgotten. Indeed and
indeed I often think of, and pray for you from my inmost soul.
Blessed be God, that we can meet at the throne of grace! Jesus sits
thereon, even Jesus our advocate, our God, and our All. You must
add to my obligations, by continuing to pray, that I may begin to
love and serve him in earnest, and thus you will appear a Jonathan
indeed, to,

Yours most affectionately in our common Lord,

G. W.

LETTER MLXXV.
To Mrs. C――.

Charles-Town, March 3, 1755.

Dear Mrs. C――,


T HROUGH divine goodness we arrived here last Wednesday
afternoon, on Thursday Mr. E―― was solemnly ordained, and
on Friday Andrew H――n and his wife, and R――, came in a
schooner from Port-Royal. I believe they will settle here.—The trials I
have met with on various accounts, have brought my old vomitings
upon me, and my soul hath been pierced with many sorrows.—But I
believe, (Lord help my unbelief!) that all is intended for my good.—
Amidst every thing, I am comforted at the present situation of
Bethesda.—I hope you will love and walk in love, and the children
also grow in years and grace.—I purpose sending all the things by
Mr. R――n, who comes shortly by water. Then I purpose writing to
dear Mr. Dixon and others, and hope by that time to be determined
what course I shall steer. O that it may be heaven-wards, go where I
will! This I know will be your prayer, and the prayer of the rest of my
dear family in my behalf.—I pray for you all night and day.—I would
have you write to Mr. H――t by the bearer, who is an experimental
Baptist preacher from the northward.—O that he may say
something, that may do my dear family some good.—Mr. Z――y will
be with you in about three weeks. The Lord be with you all. Hoping
to write again ere long, and wishing you all much of his presence,
that is better than life, I subscribe myself, dear Mrs. C――,

Your most assured friend, brother, and servant in Christ


Jesus,

G. W.

LETTER MLXXVI.
To the Same.

Charles-Town, March 17, 1755.


Dear Mrs. C――,

H AD I wings like a dove, how often would I have fled to Bethesda


since my departure from it. I could almost say, that the few
last hours I was there, were superior in satisfaction to any hours I
ever enjoyed. But I must go about my heavenly Father’s business.—
For this, I am a poor but willing pilgrim, and give up all that is near
and dear to me on this side eternity.—This week I expect to embark
in the Friendship, Captain Ball; but am glad of the letters from
Bethesda before I go.—They made me weep, and caused me to
throw myself prostrate before a prayer-hearing and promise-keeping
God.—He will give strength, he will give power. Fear not; you are
now I believe where the Lord would have you be, and all will be
well.—I repose the utmost confidence in you, under God, and verily
believe that I shall not be disappointed of my hope.—I should have
been glad if the apples had been sent in the boat; they would have
been useful in the voyage.—But Jesus can stay me with better
apples.—May you and all my dear family have plenty of these! I
imagine it will not be long before I return from England. Now
Bethesda would be pleasant. God make it more and more so to you
and to all. I can only recommend you in the most endearing manner
to the ever-blessed Jesus, and my unworthy vile self to your
continual prayers, as being, dear Mrs. C――,

Yours most affectionately in our blessed Lord,

G. W.

P. S. I hope that one of the players is snatched as a brand out of


the burning. Grace! grace!

LETTER MLXXVII.
To the Reverend Mr. G――.

London, May 10, 1755.

Reverend and very dear Sir,

T HE love which I owe and bear to you for the Lord Jesus Christ’s
sake, constrains me to send you a few lines immediately upon
my arrival at my native country.—I arrived at New-haven in Sussex
the 8th instant, after a six weeks passage. Hither the cloud seemed
to move, though I must own that I left America with regret.—Never
was the door opened wider in those parts for preaching the
everlasting gospel, than now.—Perhaps this may shorten my stay at
home, but future things belong to Jesus. It is not in man to direct his
steps.—Prepare us, O Lord, for whatever thou hast prepared for us! I
hear, you have met with changes since my departure.—What have
we to do to expect any thing else? Dear Mr. M――n!—Whither is he
gone? Where Jesus reigns, and where, through rich and sovereign
grace, even ill and hell deserving I, hope ere long to be.—Hasten,
glorious Emmanuel, that wished-for time!—If your dear yoke-fellow
is also gone, she I trust is happy too.—Sequar, etsi non passibus
æquis.—You will write soon, and send me some news about the
upper world.—This is scarce worth a thought.—I hope my dear host
and hostess, Mr. S――, Mrs. M――, and all friends are well.—I can
only send them and you my hearty love, and beg the continuance of
your prayers for, very dear Sir,

Yours, &c.

G. W.

LETTER MLXXVIII.
To Lady H――n.

London, May 13, 1755.

Ever-honoured Madam,

S INCE I put my letter into the office on Saturday night, I have


heard that your Ladyship was gone to Ashby, and therefore
make bold to trouble your Ladyship with a few more lines. They
leave me safely arrived at my desired port, and endeavouring to
begin to do something for him, who hath loaded me with his
benefits, and still continues to smile upon my feeble labours. Glad
am I to hear, that so many have lately been stirred up to preach a
crucified Saviour. Surely that scripture must be fulfilled, “and many
of the priests also were obedient to the word.” The work is of God,
and therefore must prosper. Blessed be his great name, for
continuing to hold your Ladyship as a star in his right-hand. May you
shine more and more till the perfect day! I find your Ladyship still
delights to do good. The late benefaction for Bethesda came very
opportunely; God will provide! That institution begins to rise. But I
cannot descend to particulars now; ere long I hope to wait on your
Ladyship at Bristol. My first circuit is to be in the west. Hoping to be
favoured soon with a line to acquaint me of your Ladyship’s welfare,
and earnestly praying that your Ladyship and honoured relations
may be filled with all the fulness of God, I beg leave to subscribe
myself, ever-honoured Madam,

Your Ladyship’s, &c.

G. W.

LETTER MLXXIX.
To the Marquis of L――.

London, May 14, 1755.

B EING but lately arrived in my native country, I take the first


opportunity of returning your Lordship thanks for your great
zeal in promoting the welfare of New Jersey college. Surely it is the
purest seminary that I have known. Your Lordship’s name is precious
in America, and children yet unborn will be bound to bless God for
what you have done. I think, if the degree of Doctor of divinity could
be procured for Mr. A―― B――, their present worthy president, it
would still make an addition to the honours of the college. He is a
most excellent man; your Lordship will not be offended at my
making the motion. Blessed be God, in various places abroad, the
gospel runs and is glorified. In Virginia a wide and effectual door is
opened. The Indian mission can never I think come upon a proper
establishment, till some lands are purchased, and the Indians
brought to live together upon them. The plan that was laid, I
mentioned to Mr. D―― some months ago, and ere now, I suppose
your Lordship hath seen it. O for that happy time, when the
kingdoms of the earth shall become the kingdoms of the Lord and of
his Christ! Blessed Emmanuel, may thy temple be built in
troublesome times! But I forget myself. Your Lordship will excuse my
freedom. I am writing to one who delights to serve the Redeemer’s
interest. That your Lordship may have the continued honour of
confessing him upon earth, and be confessed by him after death in
the kingdom of heaven, is and shall be the prayer of, my Lord,

Your Lordship’s most dutiful, obliged, and ready servant for


Christ’s sake,

G. W.
LETTER MLXXX.
To Lady H――n.

London, May 27, 1755.

Ever-honoured Madam,

I T hath given me great concern, that I have not been able till now,
to acknowledge your Ladyship’s most kind letter. I could almost
say, excess of business at my first coming over hath prevented me;
but to make the most of it, I do but little, and that little in so bad a
way, that if it was not for the compleat and all-sufficient
righteousness of the everlasting, ever-lovely Jesus, I could not lift up
my guilty head. And yet what a blessed week have we had! Surely,
sinners have come like a cloud, and fled like doves to the windows.
In about a fortnight, I hope to take the field in Gloucestershire, and
shall endeavour to make all possible dispatch in the west, in order to
wait on your Ladyship in my northern visit. Help me, thou friend of
sinners, to be nothing, and to say nothing, that thou mayest say and
do every thing, and be my all in all!—What a happiness is it to be
absorbed and swallowed up in God? To have no schemes, no views,
but to promote the common salvation. This be my happy lot! Your
Ladyship will still add to my innumerable obligations, by praying for
me. How shall I express my gratitude?—Tears trickle from my eyes,
whilst I am thinking of your Ladyship’s condescending to patronize
such a dead dog as I am. But it is because I belong to Jesus. He will,
he will reward your Ladyship openly. Ever-honoured Madam excuse
me. Tears flow too fast for me to write on. I must go and speak to
God for you and yours, as being, ever-honoured Madam,
Your Ladyship’s most dutiful, obliged, and ready servant for
Christ’s sake,

G. W.

LETTER MLXXXI.
To Governor B――.

London, June 6, 1755.

Much-honoured Sir,

W HILST I remain myself where you are called to sojourn, in this


dying world, I trust your Excellency will never be forgotten by
unworthy me. You see, honoured Sir, where a poor but willing
pilgrim is tossed now. Just this day month did I arrive in this
metropolis, where, glory, glory be to the great head of the church!
The word hath still free course. The poor despised Methodists are as
lively as ever, and in several churches the gospel is now preached
with power. Many in Oxford are awakened to the knowledge of the
truth, and I have heard almost every week of some fresh minister or
another, that seems determined to know nothing but Jesus Christ,
and him crucified. This, I am persuaded, is the best news I can send
to your Excellency. This, must necessarily rejoice your heart, which I
know pants after nothing more, than the enlargement of the
Mediator’s kingdom. Ere long, your utmost thirsting shall be
satisfied, you shall see Jesus; you shall see him as he is: O Gloriam
quantam et qualem! God give me patience to wait till my appointed
change comes! But would it not be a shame to go to heaven without
scarce beginning to do something for the blessed Redeemer? He
that searches the heart and trieth the reins, knows full well, how
often I cry out, “my leanness, my leanness!” God be praised, next
week I hope to go on my country range. I hope that your Excellency
will have a heart given you to pray for me, whilst life lasts, and after
death I doubt not but the glorious Emmanuel will reward you before
men and angels, for all your works of faith, and labours of love,
which you have done for the church in general, and particularly for
all favours conferred on, honoured, much-honoured Sir,

Your Excellency’s most dutiful, obliged, and ready servant


for Christ’s sake,

G. W.

LETTER MLXXXII.
To Mr. C――.

London, June 7, 1755.

Reverend and dear Sir,

J UST now I was informed that the bag is to be taken away this
afternoon; hurried therefore as I am, you must have a few lines.
—And why? Because I love and honour you for Jesus Christ’s sake.
Will it not rejoice you to hear that his glorious gospel gets ground
apace. Several of the clergy, both in town and country, have been
lately stirred up to preach Christ crucified, in the demonstration of
the spirit and with power. This excites the enmity of the old serpent,
which discovers itself in various shapes. The greatest venom is spit
out against Mr. R――n, who having been reputed a great scholar, is
now looked upon and treated as a great fool; because made wise
himself, and earnestly desirous that others also should be made wise
to eternal salvation. Methinks I hear you say, O happy folly! May this
blessed leaven diffuse and spread itself through the whole nation!
The prospect is promising. Many students at Oxford are earnestly
learning Christ. Dear Mr. H――y hath learnt and preached him some
years; his loving and truly catholic heart chearfully complied with the
motion about your future correspondence. As for myself, I can only
say “that less than the least of all,” must be my motto still. I labour
but feebly, and yet, O amazing condescension! Jesus owns and
succeeds such feeble labours. People still continue to flock to the
gospel, like doves to the windows. Next week I begin to take my
country range. Be so good, my dear Sir, to add to my obligations, by
continuing to remember a poor but willing pilgrim, and to salute all
my dear friends as they come in your way. I hope, Mr. A―― (to
whom I send cordial respects) goes hand in hand with you, striving
together for the faith and the practice of the gospel.—Glorious strife
this! I do not forget the books I promised to look out for.—I have
spoken to Mr. H――, but he says they are very difficult to be
procured. I would write to the Chief Justice, but suppose he is at the
northward. Will you be pleased to accept of my Lisbon letters, to be
disposed of as you think proper? My little communion-book is not yet
come out. God be praised, that there is a time coming when we shall
need books and ordinances no more, but shall be admitted into an
uninterrupted communion and fellowship with the blessed Trinity for
evermore. The Lord ripen us for that blissful state! I must bid you
farewel. Be pleased to excuse the length of this, as being occasioned
by the love unfeigned which is due to you from, reverend and dear
Sir,

Yours most affectionately in our common Lord,

G. W.

LETTER MLXXXIII.
To Mr. P――.
London, June 12, 1755.

Dear Nat.,

I THINK every thing is now procured that was in the


memorandums. I would have sent the children’s cloaths, &c. but
they could not be got ready; you will therefore have them by
another opportunity. I am glad to hear by your last, that the children
go on well in their learning. Let this encourage you to go on, and
who knows, but by and by they may learn Christ? Such power
belongs only unto God. I am quite satisfied in your present employ,
and doubt not (if you are cloathed with humility, as I trust you will
be) but God will bless and delight to honour you. To have our own
mother’s children angry with and despise us, if sanctified, is a good
preservative against self-love, and self-complacency: it puts us more
upon the watch, and drives us nearer to God. This be your happy lot!
As for your affair with Mr. C――, I can only say, you have my leave
to act as you think best. —Shew thy will, O God, and give power to
perform it! To A―― W―― and his wife, I have allowed twenty
pounds per annum, till they have a place, or get into business. God
knows, I can little afford it; but I can as yet trust on him, who
feedeth the ravens, and hath promised to supply all my wants. O
that the Lord of all Lords may keep you all at Bethesda of one heart
and one mind, and give you to send me such news, as may gladden
my frequently burdened (though I hope disinterested) mind; and
cause me to go on with more chearfulness and joy! Thanks be to
God, my feeble labours on this side the water, are owned and
succeeded. People seem to be as lively as ever. I hope the time will
come, when Bethesda also shall blossom like a rose. We wait for thy
salvation O Lord; make no long tarrying our Lord and our God! My
dear Nat. farewel. Feed Christ’s lambs, and he will feast thy soul.—
Look upon his work as its own wages, and he will richly repay thee
for all thy care. I charge you, and all, to continue wrestling in prayer
for me, as being, dear Nat.

Your assured friend and ready servant, for Christ’s sake,


G. W.

LETTER MLXXXIV.
To Mrs. C――.

London, June 13, 1755.

Dear Mrs. C――,

I WROTE to you amidst a great throng of business, a few days ago,


by a Carolina ship. I am now retired to Mr. C――’s, in order to
send you a few lines more. Matters about Mr. ―― and his wife, have
happened as might be expected; it is my lot to be a pelican. But all
will be well at last; I know who will stand on my side. Thanks be to
God for Jesus Christ! He upholds me, and daily succeeds my feeble,
but I trust honest labours, and that to me is all in all. I hope you will
write often. What your brother hath written, I know not. I believe
you are where God would have you to be, and I pray him night and
day to make you more and more a mother in Israel. Ere this comes
to hand, I hope you will have received the things from the
northward. However it fares with me at home, fain would I care for
my dear friends and family abroad. God will provide! This is my
comfort. Much depends on your success in the silk, but more on my
family’s increasing in the knowledge of Jesus. O that this may be
their happy case! O that the Lord of all Lords may feed you in that
wilderness! He is good to us here. We have golden seasons at the
tabernacle, and several ministers preach Christ in the churches. This
makes my call abroad still more clear. Though I have not yet entered
upon my country range, methinks I could set out for America to-
morrow. What is time, relations, and even the enjoyment of God’s
people, compared with the unmixed, uninterrupted joys of an happy
eternity! Here I could enlarge, and on this dwell, but must away. Ere
long I hope to write to you again, and in the mean while beg leave
to subscribe myself, dear Mrs. C――,

Your most assured friend, and willing servant, for Christ’s


sake,

G. W.

LETTER MLXXXV.
To Mr. G――.

Bristol, June 27, 1755.

Reverend and dear Sir,

E VER since I received your last kind letter, I have been so


perpetually engaged in preaching, travelling, and a multiplicity
of other business, that I have not been able to answer it till now. In
London the word runs and is glorified, and every day almost we
have heard of fresh ministers of our national church being called out,
and spirited up to preach the truth as it is in Jesus. This is my first
excursion: I came through Gloucestershire, where the fields were
white, ready unto harvest. Thrice last Lord’s-day, many many
thousands attended on the word preached, and I believe a divine
power accompanied it. That is all in all.—People in this place hear as
for eternity. Next week I shall travel further westward; but whether I
can see Scotland this summer, the Redeemer only knows. But
whether absent or present, you, my dear Sir, and my other Scotch
friends, have my poor prayers night and day, that your souls and
bodies may prosper and be in health. O that God may hear you for
unworthy me! I long, I long to do something for Jesus. Glad would I
be to serve the church of Christ any way. If you remember, I hinted
to you something about getting a Doctor’s degree for President Burr;
since that I wrote to the Marquis of L――n. His Lordship writes thus:
“The university of Edinburgh desire of me to obtain some account of
Mr. Aaron Burr’s literature, or performances: this I hope you will do,
and a diploma will be immediately transmitted.” By this post, I shall
write what I know of the President, but I would have you and Mr.
E―― write also, immediately to the Marquis. Surely he is the most
worthy, ingenious, diligent, and truly christian President of his age,
now in the world. He hath published something lately to animate our
people against the common enemy. I have it at London, and hope
you have it with you. If so, be pleased to transmit it to the Marquis.
I shall mention it, and so do you, to his Lordship. Adieu, my very
dear Sir, adieu. I must away. May the glorious Emmanuel bless and
prosper you and yours, and all the dear followers of the Lamb! I
cannot forget you, and hope never shall, whilst I have strength to
subscribe, what indeed I am, my very dear friend,

Yours, &c. in our common Lord.

G. W.

LETTER MLXXXVI.
To the Marquis of L――.

Bristol, June 27, 1755.

My Lord,

H OW shall I express my gratitude to your Lordship, for


condescending to answer my poor letter, and so readily
concurring with the motion made in it, for a degree being procured
for my worthy friend? The great Head of the church will bless and
reward your Lordship for it. Never was there a man in the world,
that could be more safely recommended as a scholar, and a truly
christian minister of the gospel, and a laborious prudent President of
a college, than Mr. Aaron Burr.—He was educated at Yale College in
Connecticut, New England; and for his pregnant abilities, and many
years well approved piety, was unanimously chosen to succeed the
Reverend Mr. D―― in the care of New-Jersey college. It would have
delighted your Lordship, to have seen how gloriously he filled the
chair last year, at the New-Jersey commencement. His Latin oration
was beautifully elegant, and was delivered with an unaffected, yet
striking energy and pathos. As a preacher, disputant, and head of a
college, he shines in North America; and the present prosperity of
the New Jersey college, is, under God, greatly owing to his learning,
piety, and conduct. The students revere and love him. Your Lordship
might have testimonials enough from good Governor B――r, Mr.
Jonathan Edwards, cum multis aliis. And I believe, they would all
concur in saying, “that of his age (now upwards of forty) there is not
a more accomplished deserving President in the world.” As for any
thing of his in print, that can be referred to, I cannot say, unless it
be a little pamphlet lately published, in which he hath animated the
people against the common enemy, and discovered a close
attachment to the interest of our rightful sovereign King George.
May the King of kings long preserve his important and precious life!
This piece of Mr. Burr’s I have at London, and hope it is in Scotland.
I just now wrote to Mr. G―― of Glasgow, who, together with Mr.
J―― E――, I suppose will write to your Lordship concerning Mr.
Burr. I wish the diploma may be transmitted against the next
commencement. It will endear your Lordship more and more to the
good people of America. May the Lord of all lords vouchsafe your
Lordship a good degree in the kingdom of heaven! O for the lowest
place there! It will be abundantly too high for such an unworthy
wretch as I am: but his name and nature is Love. He still vouchsafes
to employ me, and still continues to countenance my feeble labours.
At London we have enjoyed golden seasons, and in the country the
fields are white ready unto harvest. O that we may be helped to
bear the heat and burden of every day! That your Lordship may live
long to do much for Christ, and be at last gathered like a ripe shock
of corn into his heavenly garner, is the earnest prayer of, my Lord,

Your Lordship’s most dutiful, obliged, and ready servant for


Christ’s sake,

G. W.

LETTER MLXXXVII.
To Mr. Thomas J――.

Bristol, June 27, 1755.

My dear Thomas,

Y OUR treatment of me at Honslow, put me in mind of Joseph’s


steward, who put his brothers money, unknown to them, into
their sacks mouth. Well! Jesus takes notice of all help vouchsafed his
servants, and will not forget those who assist them in their
pilgrimage for his great name’s sake. You and yours then will not be
forgotten:—and God forbid that I should cease praying for you both.
The Searcher of hearts knows that I love you both in the bowels of
Jesus Christ; and my heart’s desire night and day is, that you may be
rich, yea very rich towards God. Such are durable riches. Every thing
else is less than vanity itself. Thanks be to God for such an
unspeakable gift! This supports me in my pilgrimage, and makes me
go on my way rejoicing. Thousands and thousands flocked in
Gloucestershire; and here the congregations fall little short of those
at London. The blessed Redeemer shews us his stately steps. O that
we may feel his renovating, sin-subduing, heart-refining power more
and more! So shall we approve ourselves to be his disciples, who
hath said, that those “whom the Son of man makes free, are free
indeed.” Adieu. The Lord be with you and yours. My love to Mr.
W――, Mr. K――, &c. I forget none of you. I pray the Lord of all
lords to keep you unspotted from the world, and entreat you not to
forget

Yours, &c.

G. W.

LETTER MLXXXVIII.
To Lady H――.

London, July 11, 1755.

Ever-honoured Madam,

Y ESTERDAY about noon, after being worn down with travelling,


and preaching twice and thrice a day in Gloucestershire, at
Bath and Bristol, a gracious and never-failing Providence brought me
to town, where I had the pleasure of receiving two kind, very kind
and undeserved letters from your Ladyship’s hand. Had I the least
leisure or strength, I should have written a letter of condolence to
your Ladyship from Bristol. There I heard of the death of good Lady
Ann, and was glad to find that Miss W―― bore the news of it with
so much composure. Alas! how many have your Ladyship lived to
see go before you! An earnest this, I hope, that you are to live to a
good old age, and be more and more a mother in Israel. A short, but
sweet character. God knows how long I am to drag this crazy load,
my body, along. Blessed be his holy name, I have not one
attachment to this inferior earth. I am sick of myself, sick of the
world, sick of the church, and am panting daily after the full
enjoyment of my God. John C―― is now added to the happy
number of those who are called to see him as he is. I do not envy,
but I want to follow after him. Give me patience, holy Jesus, to wait
till my appointed time shall come. In the mean while, if it be thy holy
will, improve me to promote, in some small degree, thy glory and
the good of souls! Thanks be to his adorable majesty, the fields at
Bristol and Kingswood were whiter, and more ready to harvest than
for many years last past. Was the new Tabernacle at Bristol as large
as that in London, it would be filled. Thrice last Sunday, and twice
the Sunday before, I preached in the fields to many, many
thousands. The youngest of the Miss W――’s, and little Miss H――
attended twice, and again by six on the Sunday morning. At Bath we
had good seasons; good Lady G――, Mrs. B――, G――, Miss H――,
&c. were very hearty, and God was with us of a truth. Mr. T――’s
wife, of Cornwall, is dead, and my brother hath been very ill of a
fever; but they tell me (and he doth himself) that the blessed Jesus
hath visited his soul. If so, his journey hither will be a happy one.
Lord, help me to pray, and not to faint! O for an humble, thankful
heart! I am now looking up for direction what course to steer next. I
suppose it will be northward. I wish your Ladyship’s plan may do;
but I fear the parts about your Ladyship are too cold. O how
unworthy of such a guest! Well, honoured, ever-honoured Madam, in
the New-Jerusalem, your Ladyship will have company enough. There
the Redeemer shall hold up before the mighty and the noble, and let
them see what almighty, rich, and sovereign grace could do. Be
pleased, my good Lady, to excuse the length of this. Gratitude
always gives motion to my pen, when writing to your Ladyship. I am
ashamed, that I have not so much as a pepper-corn to offer as an
humble tribute. Jesus, the ever-loving, the altogether lovely Jesus
must pay you all. I must away to preach the everlasting gospel. O
how unworthy of such a divine employ! Pardon, honoured Madam,
this poor, and too prolix scribble, and assure yourself, that neither
your Ladyship nor family are ever forgotten by

Your Ladyship’s most dutiful, unworthy, but ready servant


for Christ’s sake,
G. W.

LETTER MLXXXIX.
To the Reverend Mr. H――n.

London, July 25, 1755.

My dear Friend,

I RECEIVED your kind letter, and have since heard of your removal
from Indian land. I cannot help commending you for it, since I
know various places, where you might do as much good in a week,
as in those parts for years. Poor Indian land! I fear thou hast had
thy call! May Jesus secure the remaining few, and be their refuge
from every impending storm! O my dear friend, you and I shall find
more and more, that we must be made perfect by sufferings. If we
do not meet them in our younger days, we shall certainly have them
in the decline of life. Trials, at such a season, are like the finishing
strokes of the Limner’s pencil. They serve, in the hands of the holy
Spirit, to compleat the new creature, and make it fit for heaven.
Happy they who can say, “He knoweth the way that I take:” when
they are tried, they shall come forth like gold. God only knows what
a trying season lies before us. It is to be feared, that we are upon
the eve of a bloody war. O that the war between Michael and the
Dragon may go on! The prospect is promising. Several ministers
preach Christ boldly; and as for my own poor feeble labours, the
blessed Jesus vouchsafes to crown them with success. So many
paths lie open, that I can scarce tell which to take first. Through
frequent preaching and travelling, and a multiplicity of business, I
have been so weakened, that I am obliged to retire for a little
relaxation, and to get leisure to write you these few lines. May they
find you and yours rejoicing in tribulation, and increasing with all the
increase of God! I commend you, and all enquiring friends, to the
care of Him, who never faileth those who trust in him, and entreat
the continuance of your prayers in behalf of, my dear friend,

Yours, &c. in our common Lord,

G. W.

LETTER MXC.
To Mrs. C――.

London, July 25, 1755.

Dear Mrs. C――,

I WRITE this from Mr. C――’s, whither I have retired for a little
relaxation, and to get leisure to write a few letters. Your brother
is just gone from me, and would send you his hearty love if he knew
of my writing. T―― is gone to Plymouth, and Miss L―― is sick of a
fever (though I hope not dangerously) at Lewisham. Mrs. W――,
one of the conference, I buried last Tuesday; and am longing for
that happy time when this frail tabernacle shall be also laid in the
silent grave. It hath tottered lately more than ever, and yet the
Redeemer vouchsafes so to comfort me within, that methinks I am
not yet to die, but live and declare the works of the Lord. O that I
may begin to begin to do something for my God! I am afraid we are
at the eve of a war: but fear not. Bethesda especially, I believe, will
be hid under the shadow of the Redeemer’s wings. Whilst I have
persons there (as I think is the case now) that act with a single eye,
I am persuaded it will be like the burning bush. Pray remember me
to all in the kindest manner. I hope to write when the childrens
cloaths are ready. We have blessed seasons at Tabernacle. I have
met with some outward as well as inward trials; but this is my
comfort, “The Lord knoweth the way that I take. When I am tried I
shall come forth like gold.” O that faith and patience may have their
perfect work in this sin-sick soul! Desire dear Nat, Mr. Dix, &c. not to
be uneasy, because I do not write now; it is impracticable. Night and
day you are all upon my heart, and I long to hear how you go on.
My blessing attends you all, even you and the children. Surely, was I
retired from public work, feeding Christ’s lambs should be my
constant employ. But alas! I must be in the front of the battle. Lord
Jesus, magnify thy strength in my weakness, or I shall deny thee and
desert my post! Pray hard all of you, I intreat you, for me, and let
me know all your wants. I will labour night and day to have them
supplied, and will pray the great Shepherd and Bishop of souls to
pay you blessed wages. I know you will be content with such a
paymaster. I commend you all to his never-failing mercy, as being,
dear Mrs. C――,

Your most sincere and cordial friend and willing servant for
Christ’s sake,

G. W.

LETTER MXCI.
To Lady ――.

Norwich, August 9, 1755.

Elect Lady,

H OW glad was I some time ago to receive a letter from your


Ladyship! How glad am I now to sit down to answer it, and
thereby renew a correspondence, which to me was always profitable
and delightful! Shall I wish your Ladyship joy? Of what? Not barely
of your additional estate and honour, but of your having an
opportunity, with your noble Lord, of moving in a superior orb, and
letting your light shine more before men. The Lord of all lords only
knows, how I love and honour you both; though I have not written,
yet I have not ceased praying for you and yours these many years.
Your honoured family on both sides, must always be dear to me.
What Bethels, what gates of heaven have we been in together,
whilst engaged in social prayer, and reading and opening the lively
oracles of God! Had I wings, gladly would I fly to see your Ladyship’s
dear little growing family: but God only knows, whether I shall be
able to reach Scotland this year. I am now at Norwich, where there
hath undoubtedly been a glorious work of God. Twice a day, both
gentle and simple flock to hear the word, and I think it comes with
power. Lord, what am I? In London, I think, our people are as lively
as ever; in Bristol they are the same; and as for America, words
cannot express the glorious scenes that opened in various parts,
especially at Boston in New-England. The tide ran full as high as
ever your Ladyship knew it at Edinburgh, or in any part of Scotland.
This I know is the best news I can send to your Ladyship; for what
news, comparatively speaking, is worth hearing, except that which
concerns the kingdom of God? What beauties worth admiring, but
the beauties of Jesus Christ? What riches worth possessing, but the
substantial and durable riches of the divine life? What honour worth
acquiring, but that honour which cometh from God? May these be
the beauties, these the riches, these the honours of you and your
noble Lord! I assure your Ladyship that my heart springs when I
think of him, or write his name. I truly loved the father, I as truly
and most affectionately respect and love the son. God almighty bless
you both, and give you grace to keep yourselves unspotted from the
world! Glad shall I be to see his Lordship in town. In the mean
while, I hope his Lordship, and the honourable family where you are,
will accept not of bare compliments, but unfeigned and most cordial
acknowledgments and respects. May the great physician of souls
vouchsafe to give you all thriving souls in healthy bodies! I am glad
to hear good Lady D―― is well. My obligations to her, and all your
honoured family, are very great. Be pleased to accept this poor
pepper-corn, which, except my poor prayers, is all the
acknowledgment that can be made by, my good Lady,

Your Ladyship’s most dutiful, obliged, and ready servant for


Christ’s sake,

G. W.

LETTER MXCII.
To Mr. J―― W――.

Norwich, August 9, 1755.

Reverend and dear Sir,

T ILL Tuesday evening, I knew no more of coming to Norwich than


the child unborn. Had I been well enough, and my private
business permitted, I should have been some miles in my way
towards ♦ Donnington park. This I told Mr. H――ly, and acquainted
him with every step; he should have written himself, and not retailed
our conversation. As I expect to be in town some time next week, I
choose to defer writing more till we have a personal interview. My
time is too precious to be employed in hearkening to, or vindicating
of myself against, the false and invidious insinuations of narrow and
low-life informers. Never was I more satisfied of my call to any
place, than of my present call to Norwich. The Redeemer knows the
way that I take. I came hither purely for his glory, without the least
design to make a party for myself, or to please or displease any
other party whatsoever. In this way, and in this spirit, through his
divine assistance, I hope to go on. Blessed be his name, I trust my
feeble labours have not been in vain. Sin, I hope, hath been
prevented, errors detected, sinners convicted, saints edified, and my
own soul sweetly refreshed. But I must add no more. That Jesus may
give us all a right judgment in all things, and keep all parties
whatsoever from giving a wrong touch to the ark, is and shall be the
constant prayer of, reverend and dear Sir,

Yours most affectionately in our common Lord,

G. W.

♦ “Dunnington” replaced with “Donnington”

LETTER MXCIII.
To Doctor R――.

London, August 20, 1755.

Honoured and very dear Sir,

A S long as God is pleased to hold my soul in life, and I hear that


you also are in the land of the living, I shall always think it my
bounden duty to thank, and pray for you. Surely you have been to
me, honoured Sir, a father and a friend. Be pleased to accept
repeated acknowledgments for all favours conferred on me at
college, and the great care you took to prepare me for the ministry
of the church. Alas! I am ashamed of my unfruitfulness, and wonder
that the blessed Redeemer continues to improve me at all. But his
name and nature is Love. He hath once more brought me safe over
the mighty waters, and hath vouchsafed to own my poor feeble
labours in yonder new world. The Orphan-house, blessed be his
name, is on a good footing, and I trust will prove a nursery for
church and state, when my head is laid in the silent grave. I am
waiting daily for my discharge, and long to be at home. Be pleased
to add to my innumerable obligations, by continuing to pray for me.
I retain my old name, being the chief of sinners, and less than the
least of all saints, but, honoured and very dear Sir,

Your most obliged, dutiful son and servant,

G. W.

LETTER MXCIV.
To ――.

London, August 26, 1755.

My dear Friends,

I RECEIVED both your kind letters, and likewise one from Mr.
W――, and last night a long one from Mr. C――; but alas! I have
no time for controversy. To their own Master they must both either
stand or fall. All I can say in your present circumstances, is, “that
you had best make a trial, and let matters for a while stand as they
are.” I have sent letters, if possible, to prevent the spreading, at
least the publishing any further tales. In the mean while, my dear
friends, do you strengthen yourselves in the Lord your God. The
cause is his; you honestly, I believe, embarked in it for his great
name’s sake, and he will help you out of all. When I see Mr. R――r, I
shall speak to him again. But to-morrow I must away to the
northward. Follow me, I entreat you, with your prayers, and assure
yourselves, that you and yours, and the dear people of Norwich, will
not be forgotten by me. If ever the Redeemer, in his good
providence, should bring me thither again, I can then converse with
Mr. W―― and C―― face to face;—but I beg to be excused from
writing, when I think by so doing I can do no service. The Lord
cloathe us all with humility, and give us all true simplicity and godly
sincerity! Then we need fear nothing. Blessed be his name, we have
golden seasons here. Blessed be his name, if any good was done by
my poor feeble labours in your city. To Him, who delights to shew
himself strong in behalf of those who are of an upright heart, be all
the glory. If I know any thing of myself, I want to supplant none, but
to strengthen the hands of all that preach and live Christ Jesus. In his
great name, and with repeated thanks for all favours, I subscribe
myself, my very dear friends,

Yours most affectionately,

G. W.

LETTER MXCV.
To Miss P――.

Weston-Favell, August 30, 1755.

Dear Miss,

A FEW days past, as I was going into the Tabernacle to read


letters, yours came to hand; immediately I read it among the
rest, and you and my other dear New-England friends had the
prayers of thousands. But how did I wish to be transported to
America! How did I long to stir up all against the common enemy,
and to be made instrumental in doing my dear country some little
service! But surely God sent me over at this juncture, and therefore I
hope to be resigned. Already, blessed be his name, he hath
vouchsafed to own my feeble labours in London, Gloucestershire,
Bristol, Bath, and Norwich. I have been at the last place very lately,
and notwithstanding offences have come, there hath been a glorious
work begun, and is now carrying on. The Polite and Great seem to
hear with much attention, and I scarce ever preached a week
together with greater freedom. Praise the Lord, O my soul! I am now
going my northern circuit, and perhaps may take a trip to Ireland. O
what a pity is it, that we have but one body and one soul for Jesus
Christ! I write this from dear Mr. H――’s, who sends kind love to all
his dear New-England friends, and earnestly begs the continuance of
their prayers. He is now writing another volume upon sanctification:
that, you say, dear Miss, is what you want. That is what the ever-
loving, ever-lovely Jesus longs to give. Out of his fulness we are all to
receive even grace for grace. But how slow are we to believe! Lord, I
believe, help my unbelief! must be my language still. I thank your
honoured father for the kind present of the sermons, charter, &c. I
see you are resolved to increase my obligations, till they amount to a
prodigious sum. My blessed Master must pay you all. O that I may
be remembered before him; night and day, in public and in private!
Dear New-England, dear Boston lies upon my heart; surely the Lord
will not give it over into the enemies hand. He hath too many
praying ministers and praying people there, for such a dreadful
catastrophe. Immediately upon hearing of your late defeat, I
preached from those words, “When the enemy comes in like a flood,
then the spirit of the Lord lifts up a standard against him.” This we
shall find true in a temporal and spiritual sense.

Blest is faith that trusts Christ’s power,

Blest are saints that wait his hour.

I could enlarge, but must away. My heart is full for dear New-
England, and I must go to God and vent it. I can only send you and
your honoured parents, and all your religious associates, and all
enquiring friends, ten thousand thanks for all favours, and beg them
never to cease praying for, dear Miss,
Their and your assured and ready servant for Christ’s sake,

G. W.

LETTER MXCVI.
To Lady P――.

Weston-Favell, August 30, 1755.

Dear Madam,

T HOUGH Providence prevented my seeing you again, yet you have


been much upon my heart. As a proof of it, be pleased to
accept of these few hasty lines. I find you are once more called to
give up your honoured husband for his country’s good. That God
whom you serve, will richly reward you for such a sacrifice, and be
better to you than seven husbands. I long, I long to hear that he is
returned victorious. He is gone upon a good cause, and under the
conduct of the best general, even the Captain of our salvation. To
him I am praying night and day for the temporal and spiritual
welfare of dear, never to be forgotten New-England. Courage, dear
Madam, courage:—a few more partings, a few more changes, a few
more heart-breakings, heart-purifying trials, and we shall be safe
landed. That you and yours, dear Madam, may have a triumphant
entrance administered to you into the heavenly kingdom, is and shall
be the hearty prayer of, dear Madam,

Your Ladyship’s obliged and ready servant, &c.

G. W.

You might also like