PJSCRIPT(1)

NAME
pjscript - PDF scripting language

SYNOPSIS
pjscript script [argument ...]

DESCRIPTION
pjscript is a scripting language for creating or modifying PDF files. It is not intended as a general purpose language for developing PDF, but is meant to be generated programmatically from some other language as a means of dynamic creation of PDF documents. pjscript processes the file, script, as a pjscript program and passes any arguments (argument ...) to the program. Before pjscript begins executing a program, it creates in memory an empty PDF document containing a single blank page. The program may modify and save this document, or it may read a PDF file from disk and use that as a starting point. The pjscript grammar is very simple. Each line can have either a statement or a comment. A statement consists of a command followed by some data. The command and data are separated by white space. A comment consists of a # symbol followed by text. Several commands make use of values stored in variables. All variables are represented internally as strings, although they often contain numerical data. At the beginning of program execution, the command line arguments passed to pjscript (argument ...) are stored in the variables "arg0", "arg1", etc. The following section lists commands and the format of their associated data, along with a description of each command:

$x data
    This stores the string data in variable x. data may be optionally enclosed in quotation marks.

=x y
    This retrieves the value of variable y and copies it into variable x.

?x  This writes the value of variable x to standard output.

+x data
    This increments the value of variable x by data. Both data and the value of x must be numeric.

appendpage
    This appends a blank page to the end of the PDF document currently in memory. It stores the page number of the new page in the variable "page".

appendpdf
    This reads a PDF document from a file and appends it to the document currently in memory. The variable "file" specifies the file name. The document information section (Info dictionary) of the document being read does not replace that of the document in memory.

deletepage
    This deletes a page from the PDF document currently in memory. The variable "page" specifies the page number of the page to delete. After this command is executed, the pages are renumbered. Note that this command will fail if there is only one page in the document.

drawline
    This draws a line onto the PDF document currently in memory. The variable "linewidth" specifies the line width. "x0" and "y0" specify the coordinates of one endpoint; "x1" and "y1" the other.

drawtext
    This draws text onto the PDF document currently in memory. The variable "text" specifies the text to draw. Several other variables are used as well: "font" is the font to use, "fontsize" is the point size of the font, "page" is the number of the page to draw on, and "x" and "y" are the coordinates on the page.

dump
    This writes the name and value of all assigned variables to standard output in no particular order. It is mainly useful for debugging.

getinfo
    This gets the value of a field in the document information section (Info dictionary) of the PDF document currently in memory. The variable "key" specifies which field to get, and it can be "Author", "CreationDate", "ModDate", "Creator", "Producer", "Title", "Subject", or "Keywords". The retrieved value is stored in variable "text".

initxy
    This copies the value of variable "xinit" into the variable "x" and copies the value of variable "yinit" into the variable "y". This is normally used to reset the drawing position to the upper left-hand corner of the page.

newpdf
    This clears the PDF document currently in memory and starts over with an empty document containing a single blank page.

nextxy
    This copies the value of variable "xinit" into the variable "x" and decrements the value of "y" by the value of "fontsize" (i.e. y = y - fontsize). The point is to move the drawing position to the beginning of the next line on the page. If, as a result of this, "y" becomes less than "ylimit", then "page" is incremented by one (and a blank page is automatically appended if "page" is now greater than the number of pages in the document), and "y" is reset to "yinit". The purpose of this is to allow wrapping of text onto the next page.

print data
    This writes the string data to standard output. data may be optionally enclosed in quotation marks.

println data
    This writes the string data followed by a newline to standard output. data may be optionally enclosed in quotation marks.

readpdf
    This reads a PDF document from a file, replacing the document currently in memory. The variable "file" specifies the file name.

setinfo
    This sets the value of a field in the document information section (Info dictionary) of the PDF document currently in memory. The variable "key" specifies which field to set, and it can be "Author", "CreationDate", "ModDate", "Creator", "Producer", "Title", "Subject", or "Keywords". The variable "text" specifies the value to assign.

writepdf
    This writes to a file the PDF document currently in memory. The variable "file" specifies the file name.

NOTES
Whenever a new page is created, the orientation and page size are determined by the variable "mediabox". In the current version, the supported values are "letter-portrait", "letter-landscape", "legal-portrait", and "legal-landscape". Also, the value of "yinit" is automatically adjusted when the page is first created. For all coordinates, the origin defaults to the lower left-hand corner of the page.

AUTHOR
Nassib Nassar <nassar@etymon.com>