#
# Copyright (C) 1998-2000 Etymon Systems, Inc. <http://www.etymon.com/>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#

# This is a sample script to demonstrate pjscript.
# It takes one argument, which specifies the name of the output file.

# This prints a message:
println "This is a sample script to demonstrate pjscript."

# Command line arguments are stored in the variables 'arg0', 'arg1', etc.
# Dumping the variables will show this:
dump

println "Drawing some text..."

# We start out by default with a single blank page.

# This sets the value of the variable 'page' to be "1":
# (All variables are strings, and quotation marks are optional.)
$page 1

# This sets the value of the variable 'text':
$text "This is text on page 1."

$font Courier
$fontsize 10
$x 172
$y 650

# This draws text on the screen, using values of the variables,
# 'page', 'x', 'y', 'font', 'fontsize', and 'text':
drawtext

# This appends a page to the document and stores the page number of
# the new page in the 'page' variable.
appendpage

$y 650
$text "This is an appended page!"
drawtext

$font Helvetica-Bold
$fontsize 12

# This initializes the variables 'x' and 'y' to the values of 'xinit'
# and 'yinit':
initxy

$text "This is the top of the page."
drawtext
$y 90
$text "This is at the bottom and should wrap to a new page..."
drawtext

$text "This should wrap to a new page at some point..."

# This sets the variables 'x' and 'y' to the next line.  The value of
# 'x' is set to 'xinit', and 'y' is set to (y - fontsize).  Then 'y' is
# compared to 'ylimit' and if (y < ylimit) then we advance to the next
# page (and a new page is appended if necessary), and 'y' is reset to
# 'yinit'.  In other words, if advancing to the next line puts us
# beyond ylimit, then we automatically wrap to the next page.
nextxy

drawtext
nextxy
drawtext
nextxy
drawtext
nextxy
$text "This should be on a new page."
drawtext

# This copies the value of the variable 'arg0' into the variable 'file':
=file arg0

print "Writing file "

# This prints the value of the variable 'file':
?file

println "..."

# This writes a PDF file using the file name in variable 'file':
writepdf

###################################################################
# Other commands not demonstrated

# This reads a PDF file using the file name in variable 'file'.
# Commands that come after this can modify and save the resultant
# document.
#readpdf

# This command clears any PDF document in memory and starts over with
# an empty document containing a single blank page:
#newpdf

# Please see the pjscript man page for additional commands.
