Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : PostScript document creation

PostScript document creation

Introduction

This module allows to create PostScript documents. It has many similarities with the pdf extension. Actually the API is almost identical and one can in many cases just replace the prefix of each function from pdf_ to ps_. This also works for functions which has no meaning in the PostScript document (like adding hyperlinks) but will have an effect if the document is converted to PDF.

Documents created by this extension are sometimes even superior to documents created with the pdf extension, because pslib's text rendering functions can handle kerning, hyphenation and ligatures which results in much better output of boxed text.

Requirements

You need at least PHP 4.3.0 and pslib >= 0.1.12. The ps library (pslib) is available at » http://pslib.sourceforge.net/.

Installation

A short installation note: just type

$ pecl install ps

in your console.

Runtime Configuration

This extension has no configuration directives defined in php.ini.

Resource Types

This extension defines a PostScript document resource returned by ps_new().

Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

The following two tables lists all constants defined by the ps extension.

Table 271. Contants for line caps

Name Meaning
ps_LINECAP_BUTT  
ps_LINECAP_ROUND  
ps_LINECAP_SQUARED  


Table 272. Contants for line joins

Name Meaning
ps_LINEJOIN_MITER  
ps_LINEJOIN_ROUND  
ps_LINEJOIN_BEVEL  


Contact Information

If you have comments, bugfixes, enhancements for either this extension or pslib then please drop me a mail » steinm@php.net. Any help is very welcome.

Table of Contents

ps_add_bookmark — Add bookmark to current page
ps_add_launchlink — Adds link which launches file
ps_add_locallink — Adds link to a page in the same document
ps_add_note — Adds note to current page
ps_add_pdflink — Adds link to a page in a second pdf document
ps_add_weblink — Adds link to a web location
ps_arc — Draws an arc counterclockwise
ps_arcn — Draws an arc clockwise
ps_begin_page — Start a new page
ps_begin_pattern — Start a new pattern
ps_begin_template — Start a new template
ps_circle — Draws a circle
ps_clip — Clips drawing to current path
ps_close_image — Closes image and frees memory
ps_close — Closes a PostScript document
ps_closepath_stroke — Closes and strokes path
ps_closepath — Closes path
ps_continue_text — Continue text in next line
ps_curveto — Draws a curve
ps_delete — Deletes all resources of a PostScript document
ps_end_page — End a page
ps_end_pattern — End a pattern
ps_end_template — End a template
ps_fill_stroke — Fills and strokes the current path
ps_fill — Fills the current path
ps_findfont — Loads a font
ps_get_buffer — Fetches the full buffer containig the generated PS data
ps_get_parameter — Gets certain parameters
ps_get_value — Gets certain values
ps_hyphenate — Hyphenates a word
ps_include_file — Reads an external file with raw PostScript code
ps_lineto — Draws a line
ps_makespotcolor — Create spot color
ps_moveto — Sets current point
ps_new — Creates a new PostScript document object
ps_open_file — Opens a file for output
ps_open_image_file — Opens image from file
ps_open_image — Reads an image for later placement
ps_open_memory_image — Takes an GD image and returns an image for placement in a PS document
ps_place_image — Places image on the page
ps_rect — Draws a rectangle
ps_restore — Restore previously save context
ps_rotate — Sets rotation factor
ps_save — Save current context
ps_scale — Sets scaling factor
ps_set_border_color — Sets color of border for annotations
ps_set_border_dash — Sets length of dashes for border of annotations
ps_set_border_style — Sets border style of annotations
ps_set_info — Sets information fields of document
ps_set_parameter — Sets certain parameters
ps_set_text_pos — Sets position for text output
ps_set_value — Sets certain values
ps_setcolor — Sets current color
ps_setdash — Sets appearance of a dashed line
ps_setflat — Sets flatness
ps_setfont — Sets font to use for following output
ps_setgray — Sets gray value
ps_setlinecap — Sets appearance of line ends
ps_setlinejoin — Sets how contected lines are joined
ps_setlinewidth — Sets width of a line
ps_setmiterlimit — Sets the miter limit
ps_setoverprintmode — Sets overprint mode
ps_setpolydash — Sets appearance of a dashed line
ps_shading_pattern — Creates a pattern based on a shading
ps_shading — Creates a shading for later use
ps_shfill — Fills an area with a shading
ps_show_boxed — Output text in a box
ps_show_xy2 — Output text at position
ps_show_xy — Output text at given position
ps_show2 — Output a text at current position
ps_show — Output text
ps_string_geometry — Gets geometry of a string
ps_stringwidth — Gets width of a string
ps_stroke — Draws the current path
ps_symbol_name — Gets name of a glyph
ps_symbol_width — Gets width of a glyph
ps_symbol — Output a glyph
ps_translate — Sets translation

Code Examples / Notes » ref.ps

billy dot diehl

OK, OK, the previous note helped get me started, but really, it took me most of the day to figure out how to get this "pear install ps" to work. At first, it seemed geared for PHP4. Hopefully, I can save someone the day I just spent. (Don't get me wrong, I learned something new).
If the above statement doesn't work try this because it worked for me using PHP5 and Apache.
1. Forget the "pear install ps", it doesn't work. Whoever wrote that should get punched.
2. Make sure you've got PHP5 and Apache working as you like.
3. Go to http://pecl.php.net/package/ps and download the latest release.
4. Decompress the contents into its own directory somewhere.
5. Read http://www.php.net/manual/en/install.pecl.phpize.php which tells you what to do with what you just decompressed.
6. Move the final result (a shared object file) into the directory specified by your php.ini file's "extension_dir".
7. Create an entry in you php.ini (along with other similar statements that should already be there) that says "extension=ps.so"
8. For giggles, restart apache
Worked for me, hope it works for you...


mattwheaton

I also was not able to install ps using PEAR. Here are the steps I took to getting it installed:
1. you may need to install the perl module XML::Parser (http://search.cpan.org/~msergeant/XML-Parser/Parser.pm) to get pslib to install
2. install pslib (http://pslib.sourceforge.net/)
3. install ps (http://pecl.php.net/package/ps) using the instructions from (http://www.php.net/manual/en/install.pecl.phpize.php)
4. copy the ps.so file created by to the php extensions directory (not automatically done)
5. edit php.ini to include the ps extension (not automatically done)
If you are running FreeBSD, this link may help you with problems installing pslib (http://www.freebsd.org/cgi/query-pr.cgi?pr=84406).
Note that pslib (the library) and ps (the php extension) are not the same.


norbert

For everybody who is frustrated by the not working of 'pear install ps' command under most likely SuSE, at www.hipersonik.com/php_ps_pslib.html is a possible way to get it working. It is also possible to use these instructions under other distributions.
If 'pear install ps' works fine from the start (pslib etc is installed), but ps does not work yet, use dl('ps.so'); This will save you a lot of time.


Change Language


Follow Navioo On Twitter
.NET Functions
Apache-specific Functions
Alternative PHP Cache
Advanced PHP debugger
Array Functions
Aspell functions [deprecated]
BBCode Functions
BCMath Arbitrary Precision Mathematics Functions
PHP bytecode Compiler
Bzip2 Compression Functions
Calendar Functions
CCVS API Functions [deprecated]
Class/Object Functions
Classkit Functions
ClibPDF Functions [deprecated]
COM and .Net (Windows)
Crack Functions
Character Type Functions
CURL
Cybercash Payment Functions
Credit Mutuel CyberMUT functions
Cyrus IMAP administration Functions
Date and Time Functions
DB++ Functions
Database (dbm-style) Abstraction Layer Functions
dBase Functions
DBM Functions [deprecated]
dbx Functions
Direct IO Functions
Directory Functions
DOM Functions
DOM XML Functions
enchant Functions
Error Handling and Logging Functions
Exif Functions
Expect Functions
File Alteration Monitor Functions
Forms Data Format Functions
Fileinfo Functions
filePro Functions
Filesystem Functions
Filter Functions
Firebird/InterBase Functions
Firebird/Interbase Functions (PDO_FIREBIRD)
FriBiDi Functions
FrontBase Functions
FTP Functions
Function Handling Functions
GeoIP Functions
Gettext Functions
GMP Functions
gnupg Functions
Net_Gopher
Haru PDF Functions
hash Functions
HTTP
Hyperwave Functions
Hyperwave API Functions
i18n Functions
IBM Functions (PDO_IBM)
IBM DB2
iconv Functions
ID3 Functions
IIS Administration Functions
Image Functions
Imagick Image Library
IMAP
Informix Functions
Informix Functions (PDO_INFORMIX)
Ingres II Functions
IRC Gateway Functions
PHP / Java Integration
JSON Functions
KADM5
LDAP Functions
libxml Functions
Lotus Notes Functions
LZF Functions
Mail Functions
Mailparse Functions
Mathematical Functions
MaxDB PHP Extension
MCAL Functions
Mcrypt Encryption Functions
MCVE (Monetra) Payment Functions
Memcache Functions
Mhash Functions
Mimetype Functions
Ming functions for Flash
Miscellaneous Functions
mnoGoSearch Functions
Microsoft SQL Server Functions
Microsoft SQL Server and Sybase Functions (PDO_DBLIB)
Mohawk Software Session Handler Functions
mSQL Functions
Multibyte String Functions
muscat Functions
MySQL Functions
MySQL Functions (PDO_MYSQL)
MySQL Improved Extension
Ncurses Terminal Screen Control Functions
Network Functions
Newt Functions
NSAPI-specific Functions
Object Aggregation/Composition Functions
Object property and method call overloading
Oracle Functions
ODBC Functions (Unified)
ODBC and DB2 Functions (PDO_ODBC)
oggvorbis
OpenAL Audio Bindings
OpenSSL Functions
Oracle Functions [deprecated]
Oracle Functions (PDO_OCI)
Output Control Functions
Ovrimos SQL Functions
Paradox File Access
Parsekit Functions
Process Control Functions
Regular Expression Functions (Perl-Compatible)
PDF Functions
PDO Functions
Phar archive stream and classes
PHP Options&Information
POSIX Functions
Regular Expression Functions (POSIX Extended)
PostgreSQL Functions
PostgreSQL Functions (PDO_PGSQL)
Printer Functions
Program Execution Functions
PostScript document creation
Pspell Functions
qtdom Functions
Radius
Rar Functions
GNU Readline
GNU Recode Functions
RPM Header Reading Functions
runkit Functions
SAM - Simple Asynchronous Messaging
Satellite CORBA client extension [deprecated]
SCA Functions
SDO Functions
SDO XML Data Access Service Functions
SDO Relational Data Access Service Functions
Semaphore
SESAM Database Functions
PostgreSQL Session Save Handler
Session Handling Functions
Shared Memory Functions
SimpleXML functions
SNMP Functions
SOAP Functions
Socket Functions
Standard PHP Library (SPL) Functions
SQLite Functions
SQLite Functions (PDO_SQLITE)
Secure Shell2 Functions
Statistics Functions
Stream Functions
String Functions
Subversion Functions
Shockwave Flash Functions
Swish Functions
Sybase Functions
TCP Wrappers Functions
Tidy Functions
Tokenizer Functions
Unicode Functions
URL Functions
Variable Handling Functions
Verisign Payflow Pro Functions
vpopmail Functions
W32api Functions
WDDX Functions
win32ps Functions
win32service Functions
xattr Functions
xdiff Functions
XML Parser Functions
XML-RPC Functions
XMLReader functions
XMLWriter Functions
XSL functions
XSLT Functions
YAZ Functions
YP/NIS Functions
Zip File Functions
Zlib Compression Functions
eXTReMe Tracker