/home/lnzliplg/public_html/pdflib-lite.tar
usr/share/doc/alt-pdflib-lite/examples/php/pdfclock.php 0000644 00000005053 15173135232 0017105 0 ustar 00 <?php
/* $Id: pdfclock.php,v 1.13 2006/10/01 20:33:35 rjs Exp $
*
* A little PDFlib application to draw an analog clock.
*/
$RADIUS = 200.0;
$MARGIN = 20.0;
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
/* This line is required to avoid problems on Japanese systems */
PDF_set_parameter($p, "hypertextencoding", "winansi");
/* open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "pdfclock.php");
PDF_set_info($p, "Author", "Rainer Schaaf");
PDF_set_info($p, "Title", "PDF clock (PHP)");
PDF_begin_page_ext($p, 2 * ($RADIUS + $MARGIN), 2 * ($RADIUS + $MARGIN), "");
PDF_translate($p, $RADIUS + $MARGIN, $RADIUS + $MARGIN);
PDF_setcolor($p, "fillstroke", "rgb", 0.0, 0.0, 1.0, 0.0);
PDF_save($p);
/* minute strokes */
PDF_setlinewidth($p, 2.0);
for ($alpha = 0; $alpha < 360; $alpha += 6) {
PDF_rotate($p, 6.0);
PDF_moveto($p, $RADIUS, 0.0);
PDF_lineto($p, $RADIUS-$MARGIN/3, 0.0);
PDF_stroke($p);
}
PDF_restore($p);
PDF_save($p);
/* 5 minute strokes */
PDF_setlinewidth($p, 3.0);
for ($alpha = 0; $alpha < 360; $alpha += 30) {
PDF_rotate($p, 30.0);
PDF_moveto($p, $RADIUS, 0.0);
PDF_lineto($p, $RADIUS-$MARGIN, 0.0);
PDF_stroke($p);
}
$ltime = getdate();
/* draw hour hand */
PDF_save($p);
PDF_rotate($p, -(($ltime['minutes']/60.0)+$ltime['hours']-3.0)*30.0);
PDF_moveto($p, -$RADIUS/10, -$RADIUS/20);
PDF_lineto($p, $RADIUS/2, 0.0);
PDF_lineto($p, -$RADIUS/10, $RADIUS/20);
PDF_closepath($p);
PDF_fill($p);
PDF_restore($p);
/* draw minute hand */
PDF_save($p);
PDF_rotate($p, -(($ltime['seconds']/60.0)+$ltime['minutes']-15.0)*6.0);
PDF_moveto($p, -$RADIUS/10, -$RADIUS/20);
PDF_lineto($p, $RADIUS * 0.8, 0.0);
PDF_lineto($p, -$RADIUS/10, $RADIUS/20);
PDF_closepath($p);
PDF_fill($p);
PDF_restore($p);
/* draw second hand */
PDF_setcolor($p, "fillstroke", "rgb", 1.0, 0.0, 0.0, 0.0);
PDF_setlinewidth($p, 2);
PDF_save($p);
PDF_rotate($p, -(($ltime['seconds'] - 15.0) * 6.0));
PDF_moveto($p, -$RADIUS/5, 0.0);
PDF_lineto($p, $RADIUS, 0.0);
PDF_stroke($p);
PDF_restore($p);
/* draw little circle at center */
PDF_circle($p, 0, 0, $RADIUS/30);
PDF_fill($p);
PDF_restore($p);
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=pdfclock.pdf");
print $buf;
PDF_delete($p);
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_pdfa.php 0000644 00000003505 15173135232 0017776 0 ustar 00 <?php
/* $Id: starter_pdfa.php,v 1.3 2006/10/01 20:33:35 rjs Exp $
*
* PDF/A starter:
* Create PDF/A-compliant output
*
* required software: PDFlib/PDFlib+PDI/PPS 7
* required data: font file, image file
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$imagefile = "nesrin.jpg";
$outfilename = "starter_pdfa.pdf";
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
/* we use "utf8" as textformat, this allows to use unicode encoding */
PDF_set_parameter($p, "textformat", "utf8");
/* PDF/A-1a requires Tagged PDF */
if (PDF_begin_document($p, $outfilename, "pdfa=PDF/A-1b:2005") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/*
* We use sRGB as output intent since it allows the color
* spaces CIELab, ICC-based, grayscale, and RGB.
*
* If you need CMYK color you must use a CMYK output profile.
*/
PDF_load_iccprofile($p, "sRGB", "usage=outputintent");
PDF_set_info($p, "Creator", "PDFlib starter sample");
PDF_set_info($p, "Title", "starter_pdfa");
PDF_begin_page_ext($p, 595, 842, "");
/* $font embedding is required for PDF/A */
$font = PDF_load_font($p, "LuciduxSans-Oblique", "unicode", "embedding");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_setfont($p, $font, 24);
PDF_fit_textline($p, "PDF/A-1b:2005 starter", 50, 700, "");
/* We can use an RGB $image since we already supplied an
* output intent profile.
*/
$image = PDF_load_image($p, "auto", $imagefile, "");
if ($image == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/* Place the $image at the bottom of the page */
PDF_fit_image($p, $image, 0.0, 0.0, "scale=0.5");
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
PDF_delete($p);
print "$outfilename generated";
?>
usr/share/doc/alt-pdflib-lite/examples/php/businesscard.php 0000644 00000004536 15173135232 0020012 0 ustar 00 <?php
/* $Id: businesscard.php,v 1.20 2006/10/01 20:33:35 rjs Exp $
*
* PDFlib client: businesscard example in PHP
*/
$infile = "boilerplate.pdf";
/* This is where font/image/PDF input files live. Adjust as necessary.
*
* Note that this directory must also contain the LuciduxSans font outline
* and metrics files.
*/
$searchpath = "../data";
$data = array( "name" => "Victor Kraxi",
"business.title" => "Chief Paper Officer",
"business.address.line1" => "17, Aviation Road",
"business.address.city" => "Paperfield",
"business.telephone.voice" => "phone +1 234 567-89",
"business.telephone.fax" => "fax +1 234 567-98",
"business.email" => "victor@kraxi.com",
"business.homepage" => "www.kraxi.com"
);
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
/* Set the search path for fonts and PDF files */
PDF_set_parameter($p, "SearchPath", $searchpath);
/* This line is required to avoid problems on Japanese systems */
PDF_set_parameter($p, "hypertextencoding", "winansi");
/* open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "businesscard.php");
PDF_set_info($p, "Author", "Thomas Merz");
PDF_set_info($p, "Title", "PDFlib block processing sample (PHP)");
$blockcontainer = PDF_open_pdi($p, $infile, "", 0);
if ($blockcontainer == 0) {
die ("Error: " . PDF_get_errmsg($p));
}
$page = PDF_open_pdi_page($p, $blockcontainer, 1, "");
if ($page == 0) {
die ("Error: " . PDF_get_errmsg($p));
}
PDF_begin_page_ext($p, 20, 20, ""); /* dummy page size */
/* This will adjust the page size to the block container's size. */
PDF_fit_pdi_page($p, $page, 0, 0, "adjustpage");
/* Fill all text blocks with dynamic data */
foreach ($data as $key => $value) {
if (PDF_fill_textblock($p, $page, $key, $value,
"embedding encoding=winansi") == 0) {
printf("Warning: %s\n ", PDF_get_errmsg($p));
}
}
PDF_end_page_ext($p, "");
PDF_close_pdi_page($p, $page);
PDF_end_document($p, "");
PDF_close_pdi($p, $blockcontainer);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=businesscard.pdf");
print $buf;
PDF_delete($p);
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_tagged.php 0000644 00000003350 15173135233 0020316 0 ustar 00 <?php
/* $Id: starter_tagged.php,v 1.4.2.1 2008/01/11 11:32:35 kurt Exp $
*
* Tagged PDF starter:
* Create document with structure information for reflow and accessibility
*
* required software: PDFlib/PDFlib+PDI/PPS 7
* required data: none (dummy text created in program)
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$outfilename = "starter_tagged.pdf";
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
if (PDF_begin_document($p, $outfilename, "tagged=true") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib starter sample");
PDF_set_info($p, "Title", "starter_tagged");
/* Automatically create spaces between chunks of text */
PDF_set_parameter($p, "autospace", "true");
/* open the first structure element as a child of the document
* structure root (=0)
*/
$id = PDF_begin_item($p, "P", "Title = {Simple Paragraph}");
PDF_begin_page_ext($p, 0, 0, "width=a4.width height=a4.height");
$font = PDF_load_font($p, "Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_setfont($p, $font, 24.0);
PDF_show_xy($p, "Hello, Tagged PDF!", 50, 700);
PDF_continue_text($p, "This PDF has a very simple");
PDF_continue_text($p, "document structure.");
PDF_end_item($p, $id);
/* The page number is created as an artifact; it will be
* ignored when reflowing the page in Acrobat.
*/
$id_artifact = PDF_begin_item($p, "Artifact", "");
PDF_show_xy($p, "Page 1", 250, 100);
PDF_end_item($p, $id_artifact);
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
PDF_delete($p);
print "$outfilename generated";
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_color.php 0000644 00000026241 15173135233 0020205 0 ustar 00 <?php
# $Id: starter_color.php,v 1.1.2.1 2007/12/29 23:26:05 rjs Exp $
# Starter color:
# Demonstrate the basic use of supported color spaces
#
# Apply the following color spaces to text and vector graphics:
# - gray
# - rgb
# - cmyk
# - iccbasedgray/rgb/cmyk
# - spot
# - lab
# - pattern
# - shadings
#
# Required software: PDFlib/PDFlib+PDI/PPS 7
# Required data: none
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$outfile = "starter_color.pdf";
$title = "Starter Color";
$y = 800;
$x = 50;
$xoffset1=80;
$xoffset2 = 100;
$yoffset = 70;
$r = 30;
# create a new PDFlib object
$p = PDF_new();
PDF_set_parameter($p, "SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.1 $';
PDF_set_info($p, "Title", $buf);
# Load the font
$font = PDF_load_font($p, "Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Start the page
PDF_begin_page_ext($p, 0, 0, "width=a4.width height=a4.height");
PDF_setfont($p, $font, 14);
# -------------------------------------------------------------------
# Use default colors
#
# If no special color is set the default values will be used. The
# default values are restored at the beginning of the page.
# 0=black in the Gray color space is the default fill and stroke
# color in many cases, as shown in our sample.
# -------------------------------------------------------------------
# Fill a circle with the default black fill color
PDF_circle($p, $x, $y-=$yoffset, $r);
PDF_fill($p);
# Output text with default black fill color
PDF_fit_textline($p,
"Circle and text filled with default color {gray 0}",
$x+$xoffset2, $y, "");
PDF_fit_textline($p, "1.", $x+$xoffset1, $y, "");
# -------------------------------------------------------------------
# Use the Gray color space
#
# Gray color is defined by Gray values between 0=black and 1=white.
# -------------------------------------------------------------------
# Using setcolor(), set the current fill color to a light gray
# represented by (0.5, 0, 0, 0) which defines 50% gray. Since gray
# colors are defined by only one value, the last three function
# parameters must be set to 0.
PDF_setcolor($p, "fill", "gray", 0.5, 0, 0, 0);
# Fill a circle with the current fill color defined above
PDF_circle($p, $x, $y-=$yoffset, $r);
PDF_fill($p);
# Output text with the current fill color
PDF_fit_textline($p, "Circle and text filled with {gray 0.5}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
PDF_fit_textline($p, "2.", $x+$xoffset1, $y, "fillcolor={gray 0.5}");
# --------------------------------------------------------------------
# Use the RGB color space
#
# RGB color is defined by RGB triples, i.e. three values between 0 and
# 1 specifying the percentage of red, green, and blue.
# (0, 0, 0) is black and (1, 1, 1) is white. The commonly used RGB
# color values in the range 0�255 must be divided by 255 in order to
# scale them to the range 0�1 as required by PDFlib.
# --------------------------------------------------------------------
# Use setcolor() to set the fill color to a grass-green
# represented by (0.1, 0.95, 0.3, 0) which defines 10% red, 95% green,
# 30% blue. Since RGB colors are defined by only three values, the last
# function parameter must be set to 0.
PDF_setcolor($p, "fill", "rgb", 0.1, 0.95, 0.3, 0);
# Draw a circle with the current fill color defined above
PDF_circle($p, $x, $y-=$yoffset, $r);
PDF_fill($p);
# Output a text line with the RGB fill color defined above
PDF_fit_textline($p, "Circle and text filled with {rgb 0.1 0.95 0.3}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
PDF_fit_textline($p, "3.", $x+$xoffset1, $y,
"fillcolor={rgb 0.1 0.95 0.3}");
# --------------------------------------------------------------------
# Use the CMYK color space
#
# CMYK color is defined by four CMYK values between 0 = no color and
# 1 = full color representing cyan, magenta, yellow, and black values;
# (0, 0, 0, 0) is white and (0, 0, 0, 1) is black.
# --------------------------------------------------------------------
# Use setcolor() to set the current fill color to a pale
# orange, represented by (0.1, 0.7, 0.7, 0.1) which defines 10% Cyan,
# 70% Magenta, 70% Yellow, and 10% Black.
PDF_setcolor($p, "fill", "cmyk", 0.1, 0.7, 0.7, 0.1);
# Fill a circle with the current fill color defined above
PDF_circle($p, $x, $y-=$yoffset, $r);
PDF_fill($p);
# Output a text line with the CMYK fill color defined above
PDF_fit_textline($p,
"Circle and text filled with {cmyk 0.1 0.7 0.7 0.1}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
PDF_fit_textline($p, "4.", $x+$xoffset1, $y,
"fillcolor={cmyk 0.1 0.7 0.7 0.1}");
# --------------------------------------------------------------------
# Use a Lab color
#
# Device-independent color in the CIE L*a*b* color space is specified
# by a luminance value in the range 0-100 and two color values in the
# range -127 to 128. The first value contains the green-red axis,
# while the second value contains the blue-yellow axis.
# --------------------------------------------------------------------
# Set the current fill color to a loud blue, represented by
# (100, -127, -127, 0). Since Lab colors are defined by only three
# values, the last function parameter must be set to 0.
PDF_setcolor($p, "fill", "lab", 100, -127, -127, 0);
# Fill a circle with the fill color defined above
PDF_circle($p, $x, $y-=$yoffset, $r);
PDF_fill($p);
# Output a text line with the Lab fill color defined above
PDF_fit_textline($p, "Circle and text filled with {lab 100 -127 -127}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
PDF_fit_textline($p, "5.", $x+$xoffset1, $y,
"fillcolor={lab 100 -127 -127}");
# ---------------------------------------------------------------
# Use an ICC based color
#
# ICC-based colors are specified with the help of an ICC profile.
# ---------------------------------------------------------------
# Load the sRGB profile. sRGB is guaranteed to be always available
$icchandle = PDF_load_iccprofile($p, "sRGB", "usage=iccbased");
# Set the sRGB profile. (Accordingly, you can use
# "setcolor:iccprofilergb" or "setcolor:iccprofilegray" with an
# appropriate profile)
PDF_set_value($p, "setcolor:iccprofilergb", $icchandle);
# Use setcolor() with the "iccbasedrgb" color space to set the current
# fill and stroke color to a grass-green, represented
# by the RGB color values (0.1 0.95 0.3 0) which define 10% Red,
# 95% Green, and 30% Blue. Since iccbasedrgb colors are defined by only
# three values, the last function parameter must be set to 0.
PDF_setcolor($p, "fill", "iccbasedrgb", 0.1, 0.95, 0.3, 0);
# Fill a circle with the ICC based RGB fill color defined above
PDF_circle($p, $x, $y-=$yoffset, $r);
PDF_fill($p);
# Output a text line with the ICC based RGB fill color defined above
PDF_fit_textline($p,
"Circle and text filled with {iccbasedrgb 0.1 0.95 0.3}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
PDF_fit_textline($p, "6.", $x+$xoffset1, $y,
"fillcolor={iccbasedrgb 0.1 0.95 0.3}");
# --------------------------------------------------------------------
# Use a spot color
#
# Spot color (separation color space) is a predefined or arbitrarily
# named custom color with an alternate representation in one of the
# other color spaces above; this is generally used for preparing
# documents which are intended to be printed on an offset printing
# machine with one or more custom colors. The tint value (percentage)
# ranges from 0 = no color to 1 = maximum intensity of the spot color.
# --------------------------------------------------------------------
# Define the spot color "PANTONE 281 U" from the builtin color
# library PANTONE
$spot = PDF_makespotcolor($p, "PANTONE 281 U");
# Set the spot color "PANTONE 281 U" with a tint value of 1 (=100%)
# and output some text. Since spot colors are defined by only two
# values, the last two function parameters must be set to 0.
PDF_setcolor($p, "fill", "spot", $spot, 1.0, 0, 0);
# Fill a circle with the ICC based RGB fill color defined above
PDF_circle($p, $x, $y-=$yoffset, $r);
PDF_fill($p);
PDF_fit_textline($p,
"Circle and text filled with {spotname {PANTONE 281 U} 1}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
PDF_fit_textline($p, "7.", $x+$xoffset1, $y,
"fillcolor={spotname {PANTONE 281 U} 1}");
# or
$buf = "fillcolor={spot " . $spot . " 1}";
PDF_fit_textline($p, "7.", $x+$xoffset1, $y, $buf);
# ----------------------------------------------------------
# For using the Pattern color space, see the Cookbook topics
# graphics/fill_pattern and images/background_pattern.
# ----------------------------------------------------------
# ---------------------------------------------------------
# For using the Shading color space, see the Cookbook topic
# color/color_gradient.
# ---------------------------------------------------------
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/pdfclock.php 0000644 00000005513 15173135234 0021601 0 ustar 00 <?php
/* $Id: pdfclock.php,v 1.5 2006/10/01 20:49:14 rjs Exp $
*
* A little PDFlib application to draw an analog clock.
*/
$RADIUS = 200.0;
$MARGIN = 20.0;
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
/* This line is required to avoid problems on Japanese systems */
$p->set_parameter("hypertextencoding", "winansi");
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "pdfclock.php");
$p->set_info("Author", "Rainer Schaaf");
$p->set_info("Title", "PDF clock (PHP)");
$p->begin_page_ext(2 * ($RADIUS + $MARGIN), 2 * ($RADIUS + $MARGIN), "");
$p->translate($RADIUS + $MARGIN, $RADIUS + $MARGIN);
$p->setcolor("fillstroke", "rgb", 0.0, 0.0, 1.0, 0.0);
$p->save();
/* minute strokes */
$p->setlinewidth(2.0);
for ($alpha = 0; $alpha < 360; $alpha += 6)
{
$p->rotate(6.0);
$p->moveto($RADIUS, 0.0);
$p->lineto($RADIUS-$MARGIN/3, 0.0);
$p->stroke();
}
$p->restore();
$p->save();
/* 5 minute strokes */
$p->setlinewidth(3.0);
for ($alpha = 0; $alpha < 360; $alpha += 30)
{
$p->rotate(30.0);
$p->moveto($RADIUS, 0.0);
$p->lineto($RADIUS-$MARGIN, 0.0);
$p->stroke();
}
$ltime = getdate();
/* draw hour hand */
$p->save();
$p->rotate(-(($ltime['minutes']/60.0)+$ltime['hours']-3.0)*30.0);
$p->moveto(-$RADIUS/10, -$RADIUS/20);
$p->lineto($RADIUS/2, 0.0);
$p->lineto(-$RADIUS/10, $RADIUS/20);
$p->closepath();
$p->fill();
$p->restore();
/* draw minute hand */
$p->save();
$p->rotate(-(($ltime['seconds']/60.0)+$ltime['minutes']-15.0)*6.0);
$p->moveto(-$RADIUS/10, -$RADIUS/20);
$p->lineto($RADIUS * 0.8, 0.0);
$p->lineto(-$RADIUS/10, $RADIUS/20);
$p->closepath();
$p->fill();
$p->restore();
/* draw second hand */
$p->setcolor("fillstroke", "rgb", 1.0, 0.0, 0.0, 0.0);
$p->setlinewidth(2);
$p->save();
$p->rotate(-(($ltime['seconds'] - 15.0) * 6.0));
$p->moveto(-$RADIUS/5, 0.0);
$p->lineto($RADIUS, 0.0);
$p->stroke();
$p->restore();
/* draw little circle at center */
$p->circle(0, 0, $RADIUS/30);
$p->fill();
$p->restore();
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=pdfclock.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in pdfclock sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_pdfa.php 0000644 00000004157 15173135234 0022475 0 ustar 00 <?php
/* $Id: starter_pdfa.php,v 1.1.2.2 2009/08/07 07:30:46 rjs Exp $
*
* PDF/A starter:
* Create PDF/A-compliant output
*
* required software: PDFlib/PDFlib+PDI/PPS 7
* required data: font file, image file
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$imagefile = "nesrin.jpg";
$outfilename = "starter_pdfa.pdf";
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
$p->set_parameter("SearchPath", $searchpath);
/* we use "utf8" as textformat, this allows to use unicode encoding */
$p->set_parameter("textformat", "utf8");
/* PDF/A-1a requires Tagged PDF */
if ($p->begin_document($outfilename, "pdfa=PDF/A-1b:2005") == 0) {
die("Error: " . $p->get_errmsg());
}
/*
* We use sRGB as output intent since it allows the color
* spaces CIELab, ICC-based, grayscale, and RGB.
*
* If you need CMYK color you must use a CMYK output profile.
*/
$p->load_iccprofile("sRGB", "usage=outputintent");
$p->set_info("Creator", "PDFlib starter sample");
$p->set_info("Title", "starter_pdfa");
$p->begin_page_ext(595, 842, "");
/* $font embedding is required for PDF/A */
$font = $p->load_font("LuciduxSans-Oblique", "unicode", "embedding");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$p->setfont($font, 24);
$p->fit_textline("PDF/A-1b:2005 starter", 50, 700, "");
/* We can use an RGB $image since we already supplied an
* output intent profile.
*/
$image = $p->load_image("auto", $imagefile, "");
if ($image == 0) {
die("Error: " . $p->get_errmsg());
}
/* Place the $image at the bottom of the page */
$p->fit_image($image, 0.0, 0.0, "scale=0.5");
$p->end_page_ext("");
$p->end_document("");
print "$outfilename generated";
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in starter_pdfa sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/businesscard.php 0000644 00000005161 15173135234 0022500 0 ustar 00 <?php
/* $Id: businesscard.php,v 1.5 2006/10/01 20:49:14 rjs Exp $
*
* PDFlib client: businesscard example in PHP
*/
$infile = "boilerplate.pdf";
/* This is where font/image/PDF input files live. Adjust as necessary.
*
* Note that this directory must also contain the LuciduxSans font outline
* and metrics files.
*/
$searchpath = "../data";
$data = array( "name" => "Victor Kraxi",
"business.title" => "Chief Paper Officer",
"business.address.line1" => "17, Aviation Road",
"business.address.city" => "Paperfield",
"business.telephone.voice" => "phone +1 234 567-89",
"business.telephone.fax" => "fax +1 234 567-98",
"business.email" => "victor@kraxi.com",
"business.homepage" => "www.kraxi.com"
);
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
/* Set the search path for fonts and PDF files */
$p->set_parameter("SearchPath", $searchpath);
/* This line is required to avoid problems on Japanese systems */
$p->set_parameter("hypertextencoding", "winansi");
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "businesscard.php");
$p->set_info("Author", "Thomas Merz");
$p->set_info("Title", "PDFlib block processing sample (PHP)");
$blockcontainer = $p->open_pdi($infile, "", 0);
if ($blockcontainer == 0){
die ("Error: " . $p->get_errmsg());
}
$page = $p->open_pdi_page($blockcontainer, 1, "");
if ($page == 0){
die ("Error: " . $p->get_errmsg());
}
$p->begin_page_ext(20, 20, ""); /* dummy page size */
/* This will adjust the page size to the block container's size. */
$p->fit_pdi_page($page, 0, 0, "adjustpage");
/* Fill all text blocks with dynamic data */
foreach ($data as $key => $value){
if ($p->fill_textblock($page, $key, $value,
"embedding encoding=winansi") == 0) {
printf("Warning: %s\n ", $p->get_errmsg());
}
}
$p->end_page_ext("");
$p->close_pdi_page($page);
$p->end_document("");
$p->close_pdi($blockcontainer);
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=businesscard.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in businesscard sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_tagged.php 0000644 00000004067 15173135234 0023016 0 ustar 00 <?php
/* $Id: starter_tagged.php,v 1.1.2.2 2009/08/07 07:30:46 rjs Exp $
*
* Tagged PDF starter:
* Create document with structure information for reflow and accessibility
*
* required software: PDFlib/PDFlib+PDI/PPS 7
* required data: none (dummy text created in program)
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$outfilename = "starter_tagged.pdf";
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
$p->set_parameter("SearchPath", $searchpath);
/* "lang" contains the predominant document language */
if ($p->begin_document($outfilename, "tagged=true lang=en") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib starter sample");
$p->set_info("Title", "starter_tagged");
/* Automatically create spaces between chunks of text */
$p->set_parameter("autospace", "true");
/* open the first structure element as a child of the document
* structure root (=0)
*/
$id = $p->begin_item("P", "Title = {Simple Paragraph}");
$p->begin_page_ext(0, 0, "width=a4.width height=a4.height");
$font = $p->load_font("Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$p->setfont($font, 24.0);
$p->show_xy("Hello, Tagged PDF!", 50, 700);
$p->continue_text("This PDF has a very simple");
$p->continue_text("document structure.");
$p->end_item($id);
/* The page number is created as an artifact; it will be
* ignored when reflowing the page in Acrobat.
*/
$id_artifact = $p->begin_item("Artifact", "");
$p->show_xy("Page 1", 250, 100);
$p->end_item($id_artifact);
$p->end_page_ext("");
$p->end_document("");
print "$outfilename generated";
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in starter_tagged sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_color.php 0000644 00000026405 15173135234 0022701 0 ustar 00 <?php
# $Id: starter_color.php,v 1.1.2.2 2008/07/30 13:13:34 rp Exp $
# Starter color:
# Demonstrate the basic use of supported color spaces
#
# Apply the following color spaces to text and vector graphics:
# - gray
# - rgb
# - cmyk
# - iccbasedgray/rgb/cmyk
# - spot
# - lab
# - pattern
# - shadings
#
# Required software: PDFlib/PDFlib+PDI/PPS 7
# Required data: none
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$outfile = "starter_color.pdf";
$title = "Starter Color";
$y = 800;
$x = 50;
$xoffset1=80;
$xoffset2 = 100;
$yoffset = 70;
$r = 30;
try {
# create a new PDFlib object
$p = new PDFlib();
$p->set_parameter("SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.2 $';
$p->set_info("Title", $buf);
# Load the font
$font = $p->load_font("Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
# Start the page
$p->begin_page_ext(0, 0, "width=a4.width height=a4.height");
$p->setfont($font, 14);
# -------------------------------------------------------------------
# Use default colors
#
# If no special color is set the default values will be used. The
# default values are restored at the beginning of the page.
# 0=black in the Gray color space is the default fill and stroke
# color in many cases, as shown in our sample.
# -------------------------------------------------------------------
# Fill a circle with the default black fill color
$p->circle($x, $y-=$yoffset, $r);
$p->fill();
# Output text with default black fill color
$p->fit_textline(
"Circle and text filled with default color {gray 0}",
$x+$xoffset2, $y, "");
$p->fit_textline("1.", $x+$xoffset1, $y, "");
# -------------------------------------------------------------------
# Use the Gray color space
#
# Gray color is defined by Gray values between 0=black and 1=white.
# -------------------------------------------------------------------
# Using setcolor(), set the current fill color to a light gray
# represented by (0.5, 0, 0, 0) which defines 50% gray. Since gray
# colors are defined by only one value, the last three function
# parameters must be set to 0.
$p->setcolor("fill", "gray", 0.5, 0, 0, 0);
# Fill a circle with the current fill color defined above
$p->circle($x, $y-=$yoffset, $r);
$p->fill();
# Output text with the current fill color
$p->fit_textline("Circle and text filled with {gray 0.5}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
$p->fit_textline("2.", $x+$xoffset1, $y, "fillcolor={gray 0.5}");
# --------------------------------------------------------------------
# Use the RGB color space
#
# RGB color is defined by RGB triples, i.e. three values between 0 and
# 1 specifying the percentage of red, green, and blue.
# (0, 0, 0) is black and (1, 1, 1) is white. The commonly used RGB
# color values in the range 0�255 must be divided by 255 in order to
# scale them to the range 0�1 as required by PDFlib.
# --------------------------------------------------------------------
# Use setcolor() to set the fill color to a grass-green
# represented by (0.1, 0.95, 0.3, 0) which defines 10% red, 95% green,
# 30% blue. Since RGB colors are defined by only three values, the last
# function parameter must be set to 0.
$p->setcolor("fill", "rgb", 0.1, 0.95, 0.3, 0);
# Draw a circle with the current fill color defined above
$p->circle($x, $y-=$yoffset, $r);
$p->fill();
# Output a text line with the RGB fill color defined above
$p->fit_textline("Circle and text filled with {rgb 0.1 0.95 0.3}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
$p->fit_textline("3.", $x+$xoffset1, $y,
"fillcolor={rgb 0.1 0.95 0.3}");
# --------------------------------------------------------------------
# Use the CMYK color space
#
# CMYK color is defined by four CMYK values between 0 = no color and
# 1 = full color representing cyan, magenta, yellow, and black values;
# (0, 0, 0, 0) is white and (0, 0, 0, 1) is black.
# --------------------------------------------------------------------
# Use setcolor() to set the current fill color to a pale
# orange, represented by (0.1, 0.7, 0.7, 0.1) which defines 10% Cyan,
# 70% Magenta, 70% Yellow, and 10% Black.
$p->setcolor("fill", "cmyk", 0.1, 0.7, 0.7, 0.1);
# Fill a circle with the current fill color defined above
$p->circle($x, $y-=$yoffset, $r);
$p->fill();
# Output a text line with the CMYK fill color defined above
$p->fit_textline(
"Circle and text filled with {cmyk 0.1 0.7 0.7 0.1}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
$p->fit_textline("4.", $x+$xoffset1, $y,
"fillcolor={cmyk 0.1 0.7 0.7 0.1}");
# --------------------------------------------------------------------
# Use a Lab color
#
# Device-independent color in the CIE L*a*b* color space is specified
# by a luminance value in the range 0-100 and two color values in the
# range -127 to 128. The first value contains the green-red axis,
# while the second value contains the blue-yellow axis.
# --------------------------------------------------------------------
# Set the current fill color to a loud blue, represented by
# (100, -127, -127, 0). Since Lab colors are defined by only three
# values, the last function parameter must be set to 0.
$p->setcolor("fill", "lab", 100, -127, -127, 0);
# Fill a circle with the fill color defined above
$p->circle($x, $y-=$yoffset, $r);
$p->fill();
# Output a text line with the Lab fill color defined above
$p->fit_textline("Circle and text filled with {lab 100 -127 -127}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
$p->fit_textline("5.", $x+$xoffset1, $y,
"fillcolor={lab 100 -127 -127}");
# ---------------------------------------------------------------
# Use an ICC based color
#
# ICC-based colors are specified with the help of an ICC profile.
# ---------------------------------------------------------------
# Load the sRGB profile. sRGB is guaranteed to be always available
$icchandle = $p->load_iccprofile("sRGB", "usage=iccbased");
# Set the sRGB profile. (Accordingly, you can use
# "setcolor:iccprofilergb" or "setcolor:iccprofilegray" with an
# appropriate profile)
$p->set_value("setcolor:iccprofilergb", $icchandle);
# Use setcolor() with the "iccbasedrgb" color space to set the current
# fill and stroke color to a grass-green, represented
# by the RGB color values (0.1 0.95 0.3 0) which define 10% Red,
# 95% Green, and 30% Blue. Since iccbasedrgb colors are defined by only
# three values, the last function parameter must be set to 0.
$p->setcolor("fill", "iccbasedrgb", 0.1, 0.95, 0.3, 0);
# Fill a circle with the ICC based RGB fill color defined above
$p->circle($x, $y-=$yoffset, $r);
$p->fill();
# Output a text line with the ICC based RGB fill color defined above
$p->fit_textline(
"Circle and text filled with {iccbasedrgb 0.1 0.95 0.3}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
$p->fit_textline("6.", $x+$xoffset1, $y,
"fillcolor={iccbasedrgb 0.1 0.95 0.3}");
# --------------------------------------------------------------------
# Use a spot color
#
# Spot color (separation color space) is a predefined or arbitrarily
# named custom color with an alternate representation in one of the
# other color spaces above; this is generally used for preparing
# documents which are intended to be printed on an offset printing
# machine with one or more custom colors. The tint value (percentage)
# ranges from 0 = no color to 1 = maximum intensity of the spot color.
# --------------------------------------------------------------------
# Define the spot color "PANTONE 281 U" from the builtin color
# library PANTONE
$spot = $p->makespotcolor("PANTONE 281 U");
# Set the spot color "PANTONE 281 U" with a tint value of 1 (=100%)
# and output some text. Since spot colors are defined by only two
# values, the last two function parameters must be set to 0.
$p->setcolor("fill", "spot", $spot, 1.0, 0, 0);
# Fill a circle with the ICC based RGB fill color defined above
$p->circle($x, $y-=$yoffset, $r);
$p->fill();
$p->fit_textline(
"Circle and text filled with {spotname {PANTONE 281 U} 1}",
$x+$xoffset2, $y, "");
# Alternatively, you can set the fill color in the call to
# fit_textline() using the "fillcolor" option. This case applies the
# fill color just the single function call. The current fill color
# won't be affected.
$p->fit_textline("7.", $x+$xoffset1, $y,
"fillcolor={spotname {PANTONE 281 U} 1}");
# or
$buf = "fillcolor={spot " . $spot . " 1}";
$p->fit_textline("7.", $x+$xoffset1, $y, $buf);
# ----------------------------------------------------------
# For using the Pattern color space, see the Cookbook topics
# graphics/fill_pattern and images/background_pattern.
# ----------------------------------------------------------
# ---------------------------------------------------------
# For using the Shading color space, see the Cookbook topic
# color/color_gradient.
# ---------------------------------------------------------
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_table.php 0000644 00000013453 15173135234 0022651 0 ustar 00 <?php
/* $Id: starter_table.php,v 1.1.2.2 2009/08/07 07:30:46 rjs Exp $
*
* Table starter:
* Create table which may span multiple pages
*
* required software: PDFlib/PDFlib+PDI/PPS 7
* required data: image file (dummy text created within the program)
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$imagefile = "nesrin.jpg";
$outfilename = "starter_table.pdf";
$tf=0; $tbl=0;
$rowmax = 50; $colmax = 5;
$llx= 50; $lly=50; $urx=550; $ury=800;
$headertext = "Table header (centered across all columns)";
/* Dummy text for filling a cell with multi-line Textflow */
$tf_text =
"Lorem ipsum dolor sit amet, consectetur adi­pi­sicing elit, sed do eius­mod tempor incidi­dunt ut labore et dolore magna ali­qua. Ut enim ad minim ve­niam, quis nostrud exer­citation ull­amco la­bo­ris nisi ut ali­quip ex ea commodo con­sequat. Duis aute irure dolor in repre­henderit in voluptate velit esse cillum dolore eu fugiat nulla pari­atur. Excep­teur sint occae­cat cupi­datat non proident, sunt in culpa qui officia dese­runt mollit anim id est laborum. ";
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
$p->set_parameter("SearchPath", $searchpath);
/* we use "utf8" as textformat, this allows to use unicode encoding */
$p->set_parameter("textformat", "utf8");
if ($p->begin_document($outfilename, "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib starter sample");
$p->set_info("Title", "starter_table");
/* -------------------- Add table cells -------------------- */
/* ---------- row 1: table header (spans all columns) */
$row = 1; $col = 1;
$font = $p->load_font("Times-Bold", "unicode", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$optlist = "fittextline={position=center font=" . $font . " fontsize=14} " .
"colspan=" . $colmax;
$tbl = $p->add_table_cell($tbl, $col, $row, $headertext, $optlist);
if ($tbl == 0) {
die("Error: " . $p->get_errmsg());
}
/* ---------- row 2: various kinds of content */
/* ----- Simple text cell */
$row++; $col=1;
$optlist = "fittextline={font=" . $font . " fontsize=10 orientate=west}";
$tbl = $p->add_table_cell($tbl, $col, $row, "vertical line", $optlist);
if ($tbl == 0) {
die("Error: " . $p->get_errmsg());
}
/* ----- Colorized background */
$col++;
$optlist = "fittextline={font=" . $font . " fontsize=10} " .
"matchbox={fillcolor={rgb 0.9 0.5 0}}";
$tbl = $p->add_table_cell($tbl, $col, $row, "some color", $optlist);
if ($tbl == 0) {
die("Error: " . $p->get_errmsg());
}
/* ----- Multi-line text with Textflow */
$col++;
$font = $p->load_font("Times-Roman", "unicode", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$optlist = "charref fontname=Times-Roman encoding=unicode fontsize=8 ";
$tf = $p->add_textflow($tf, $tf_text, $optlist);
if ($tf == 0) {
die("Error: " . $p->get_errmsg());
}
$optlist = "margin=2 textflow=" . $tf;
$tbl = $p->add_table_cell($tbl, $col, $row, "", $optlist);
if ($tbl == 0) {
die("Error: " . $p->get_errmsg());
}
/* ----- Rotated $image */
$col++;
$image = $p->load_image("auto", $imagefile, "");
if ($image == 0) {
die("Couldn't load $image: " . $p->get_errmsg());
}
$optlist = "image=" . $image . " fitimage={orientate=west}";
$tbl = $p->add_table_cell($tbl, $col, $row, "", $optlist);
if ($tbl == 0) {
die("Error: " . $p->get_errmsg());
}
/* ----- Diagonal stamp */
$col++;
$optlist = "fittextline={font=" . $font . " fontsize=10 stamp=ll2ur}";
$tbl = $p->add_table_cell($tbl, $col, $row, "entry void", $optlist);
if ($tbl == 0) {
die("Error: " . $p->get_errmsg());
}
/* ---------- Fill $row 3 and above with their numbers */
for ($row++; $row <= $rowmax; $row++) {
for ($col = 1; $col <= $colmax; $col++) {
$num = "Col " . $col . "/Row " . $row;
$optlist = "colwidth=20% fittextline={font=" . $font . " fontsize=10}";
$tbl = $p->add_table_cell($tbl, $col, $row, $num, $optlist);
if ($tbl == 0) {
die("Error: " . $p->get_errmsg());
}
}
}
/* ---------- Place the table on one or more pages ---------- */
/*
* Loop until all of the table is placed; create new pages
* as long as more table instances need to be placed.
*/
do {
$p->begin_page_ext(0, 0, "width=a4.width height=a4.height");
/* Shade every other $row; draw lines for all table cells.
* Add "showcells showborder" to visualize cell borders
*/
$optlist = "header=1 fill={{area=rowodd fillcolor={gray 0.9}}} " .
"stroke={{line=other}} ";
/* Place the table instance */
$result = $p->fit_table($tbl, $llx, $lly, $urx, $ury, $optlist);
if ($result == "_error") {
die("Couldn't place table: " . $p->get_errmsg());
}
$p->end_page_ext("");
} while ($result == "_boxfull");
/* Check the $result; "_stop" means all is ok. */
if ($result != "_stop") {
if ($result == "_error") {
die("Error when placing table: " . $p->get_errmsg());
} else {
/* Any other return value is a user exit caused by
* the "return" option; this requires dedicated code to
* deal with.
*/
die("User return found in Textflow");
}
}
/* This will also delete Textflow handles used in the table */
$p->delete_table($tbl, "");
$p->end_document("");
print "$outfilename generated";
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in starter_table sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_basic.php 0000644 00000005401 15173135234 0022635 0 ustar 00 <?php
/* $Id: starter_basic.php,v 1.1.2.2 2009/08/07 07:30:46 rjs Exp $
*
* Basic starter:
* Create some simple text, vector graphics and image output
*
* required software: PDFlib Lite/PDFlib/PDFlib+PDI/PPS 7
* required data: none
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data/";
$imagefile = "nesrin.jpg";
$outfilename = "starter_basic.pdf";
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
$p->set_parameter("SearchPath", $searchpath);
/* we use "utf8" as textformat, this allows to use unicode encoding */
$p->set_parameter("textformat", "utf8");
if ($p->begin_document($outfilename, "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib starter sample");
$p->set_info("Title", "starter_basic");
/* We load the $image before the first page, and use it
* on all pages
*/
$image = $p->load_image("auto", $imagefile, "");
if ($image == 0) {
die("Error: " . $p->get_errmsg());
}
/* Page 1 */
$p->begin_page_ext(595, 842, "");
/* For PDFlib Lite: change "unicode" to "winansi" */
$font = $p->load_font("Helvetica-Bold", "unicode", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$p->setfont($font, 24);
$p->set_text_pos(50, 700);
$p->show("Hello world!");
$p->fit_image($image, 0.0, 0.0, "scale=0.25");
$p->end_page_ext("");
/* Page 2 */
$p->begin_page_ext(595, 842, "");
/* red rectangle */
$p->setcolor("fill", "rgb", 1.0, 0.0, 0.0, 0.0);
$p->rect(200, 200, 250, 150);
$p->fill();
/* blue circle */
$p->setcolor("fill", "rgb", 0.0, 0.0, 1.0, 0.0);
$p->arc(400, 600, 100, 0, 360);
$p->fill();
/* thick gray line */
$p->setcolor("stroke", "gray", 0.5, 0.0, 0.0, 0.0);
$p->setlinewidth(10);
$p->moveto(100, 500);
$p->lineto(300, 700);
$p->stroke();
/* Using the same $image handle means the data will be copied
* to the PDF only once, which saves space.
*/
$p->fit_image($image, 150.0, 25.0, "scale=0.25");
$p->end_page_ext("");
/* Page 3 */
$p->begin_page_ext(595, 842, "");
/* Fit the image to a box of predefined size (without distortion) */
$optlist = "boxsize={400 400} position={center} fitmethod=meet";
$p->fit_image($image, 100, 200, $optlist);
$p->end_page_ext("");
$p->close_image($image);
$p->end_document("");
print "$outfilename generated";
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in starter_basic sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_pcos.php 0000644 00000007724 15173135235 0022533 0 ustar 00 <?php
/* $Id: starter_pcos.php,v 1.1.2.2 2009/08/07 07:30:46 rjs Exp $
*
* pCOS starter:
* Dump information from an existing PDF document
*
* required software: PDFlib+PDI/PPS 7
* required data: PDF input file
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$pdfinput = "TET-datasheet.pdf";
$docoptlist = "requiredmode=minimum";
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
$p->set_parameter("SearchPath", $searchpath);
/* We do not create any output document, so no call to
* begin_document() is required.
*/
/* Open the input document */
$doc = $p->open_pdi_document($pdfinput, $docoptlist);
if ($doc == 0) {
die("Error: " . $p->get_errmsg());
}
/* --------- general information (always available) */
$pcosmode = $p->pcos_get_number($doc, "pcosmode");
printf("<PRE>");
printf(" File name: %s\n",
$p->pcos_get_string($doc,"filename"));
printf(" PDF version: %s\n",
$p->pcos_get_number($doc, "pdfversion")/10);
printf(" Encryption: %s\n",
$p->pcos_get_string($doc, "encrypt/description"));
printf(" Master pw: %s\n",
(($p->pcos_get_number($doc, "encrypt/master") != 0) ? "yes":"no"));
printf(" User pw: %s\n",
(($p->pcos_get_number($doc, "encrypt/user") != 0) ? "yes" : "no"));
printf("Text copying: %s\n",
(($p->pcos_get_number($doc, "encrypt/nocopy") != 0) ? "no":"yes"));
printf(" Linearized: %s\n",
(($p->pcos_get_number($doc, "linearized") != 0) ? "yes" : "no"));
printf(" Tagged: %s\n\n",
(($p->pcos_get_number($doc, "tagged") != 0) ? "yes" : "no"));
if ($pcosmode == 0) {
printf("Minimum mode: no more information available\n\n");
$p->delete();
exit(0);
}
/* --------- more details (requires at least user password) */
printf("No. of pages: %s\n",
$p->pcos_get_number($doc, "length:pages"));
printf(" Page 1 size: width=%.3f, height=%.3f\n",
$p->pcos_get_number($doc, "pages[0]/width"),
$p->pcos_get_number($doc, "pages[0]/height"));
$count = $p->pcos_get_number($doc, "length:fonts");
printf("No. of fonts: %s\n", $count);
for ($i=0; $i < $count; $i++) {
$fonts = "fonts[" . $i . "]/embedded";
if ($p->pcos_get_number($doc, $fonts) != 0)
print("embedded ");
else
print("unembedded ");
$fonts = "fonts[" . $i . "]/type";
print($p->pcos_get_string($doc, $fonts) . " font ");
$fonts = "fonts[" . $i . "]/name";
printf("%s\n", $p->pcos_get_string($doc, $fonts));
}
printf("\n");
if ($pcosmode == 1) {
print(
"Restricted mode: no more information available");
$p->delete();
exit(0);
}
/* ----- document $info keys and XMP metadata (requires master pw) */
$count = $p->pcos_get_number($doc, "length:/Info");
for ($i=0; $i < $count; $i++) {
$info = "type:/Info[" . $i . "]";
$objtype = $p->pcos_get_string($doc, $info);
$info = "/Info[" . $i . "].key";
$key = $p->pcos_get_string($doc, $info);
$len = 12 - strlen($key);
while ($len-- > 0) print(" ");
print($key . ": ");
/* $info entries can be stored as string or name objects */
if ($objtype == "name" || $objtype == "string") {
$info = "/Info[" . $i . "]";
printf("'" . $p->pcos_get_string($doc, $info) . "'\n");
} else {
$info = "type:/Info[" . $i . "]";
printf("(" . $p->pcos_get_string($doc, $info) . " object)\n");
}
}
print("\n" . "XMP meta data: ");
$objtype = $p->pcos_get_string($doc, "type:/Root/Metadata");
if ($objtype == "stream") {
$contents = $p->pcos_get_stream($doc, "", "/Root/Metadata");
print(strlen($contents) . " bytes \n");
printf("");
} else {
printf("not present");
}
$p->close_pdi_document($doc);
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in starter_pcos sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_pdfmerge.php 0000644 00000004224 15173135235 0023350 0 ustar 00 <?php
/* $Id: starter_pdfmerge.php,v 1.1.2.2 2009/08/07 07:30:46 rjs Exp $
*
* PDF merge starter:
* Merge pages from multiple PDF documents; interactive elements (e.g.
* bookmarks) will be dropped.
*
* required software: PDFlib+PDI/PPS 7
* required data: PDF documents
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$outfilename = "starter_pdfmerge.pdf";
$pdffiles = array(
"PDFlib-real-world.pdf",
"PDFlib-datasheet.pdf",
"TET-datasheet.pdf",
"PLOP-datasheet.pdf",
"pCOS-datasheet.pdf"
);
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
$p->set_parameter("SearchPath", $searchpath);
if ($p->begin_document($outfilename, "") == 0)
die("Error: " . $p->get_errmsg());
$p->set_info("Creator", "PDFlib starter sample");
$p->set_info("Title", "starter_pdfmerge");
foreach ($pdffiles as $pdffile) {
/* Open the input PDF */
$indoc = $p->open_pdi_document($pdffile, "");
if ($indoc == 0) {
printf("Error: %s\n", $p->get_errmsg());
continue;
}
$endpage = $p->pcos_get_number($indoc, "/Root/Pages/Count");
/* Loop over all pages of the input document */
for ($pageno = 1; $pageno <= $endpage; $pageno++) {
$page = $p->open_pdi_page($indoc, $pageno, "");
if ($page == 0) {
printf("Error: %s\n", $p->get_errmsg());
continue;
}
/* Dummy $page size; will be adjusted later */
$p->begin_page_ext(10, 10, "");
/* Create a bookmark with the file name */
if ($pageno == 1) {
$p->create_bookmark($pdffile, "");
}
/* Place the imported $page on the output $page, and
* adjust the $page size
*/
$p->fit_pdi_page($page, 0, 0, "adjustpage");
$p->close_pdi_page($page);
$p->end_page_ext("");
}
$p->close_pdi_document($indoc);
}
$p->end_document("");
print "$outfilename generated";
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in starter_pdfmerge sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_pdfx.php 0000644 00000005020 15173135235 0022513 0 ustar 00 <?php
/* $Id: starter_pdfx.php,v 1.1.2.2 2009/08/07 07:30:46 rjs Exp $
*
* PDF/X starter:
* Create PDF/X-compliant output
*
* required software: PDFlib/PDFlib+PDI/PPS 7
* required data: font file, image file, icc profile
* (see www.pdflib.com for ICC profiles)
*/
/* This is where the data files are. Adjust as necessary.*/
$searchpath = "../data";
$imagefile = "nesrin.jpg";
$outfilename = "starter_pdfx.pdf";
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
$p->set_parameter("SearchPath", $searchpath);
/* we use "utf8" as textformat, this allows to use unicode encoding */
$p->set_parameter("textformat", "utf8");
if ($p->begin_document($outfilename, "pdfx=PDF/X-3:2002") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib starter sample");
$p->set_info("Title", "starter_pdfx");
/*
* You can use one of the Standard output intents (e.g. for SWOP
* printing) which do not require an ICC profile:
$p->load_iccprofile("CGATS TR 001", "usage=outputintent");
* However, if you use ICC or Lab color you must load an ICC
* profile as output intent:
*/
if ($p->load_iccprofile("ISOcoated.icc", "usage=outputintent") == -1) {
printf("Error: %s\n", $p->get_errmsg());
printf("Please install the ICC profile package from " .
"www.pdflib.com to run the PDF/X starter sample.\n");
$p->delete(p);
return(2);
}
$p->begin_page_ext(595, 842, "");
/* $font embedding is required for PDF/X */
$font = $p->load_font("LuciduxSans-Oblique", "unicode", "embedding");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$p->setfont($font, 24);
$spot = $p->makespotcolor("PANTONE 123 C");
$p->setcolor("fill", "spot", $spot, 1.0, 0.0, 0.0);
$p->fit_textline("PDF/X-3:2002 starter", 50, 700, "");
/* The RGB $image below needs an $icc profile; we use sRGB. */
$icc = $p->load_iccprofile("sRGB", "");
$image = $p->load_image("auto", $imagefile, "iccprofile=" . $icc);
if ($image == 0) {
die("Error: " . $p->get_errmsg());
}
$p->fit_image($image, 0.0, 0.0, "scale=0.5");
$p->end_page_ext("");
$p->end_document("");
print "$outfilename generated";
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in starter_pdfx sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_textflow.php 0000644 00000007406 15173135235 0023440 0 ustar 00 <?php
/* $Id: starter_textflow.php,v 1.1.2.1 2007/09/27 12:58:00 rjs Exp $
*
* Textflow starter:
* Create multi-column text output which may span multiple pages
*
* required software: PDFlib/PDFlib+PDI/PPS 7 or above
* required data: none
*/
$outfilename = "starter_textflow.pdf";
$tf = 0;
$llx1= 50; $lly1=50; $urx1=250; $ury1=800;
$llx2=300; $lly2=50; $urx2=500; $ury2=800;
/* Repeat the dummy text to produce more contents */
$count = 50;
$optlist1 = "fontname=Helvetica fontsize=10.5 encoding=unicode " .
"fillcolor={gray 0} alignment=justify";
$optlist2 = "fontname=Helvetica-Bold fontsize=14 encoding=unicode " .
"fillcolor={rgb 1 0 0} charref";
/* Dummy text for filling the columns. Soft hyphens are marked with
* the character reference "­" (character references are
* enabled by the charref option).
*/
$text=
"Lorem ipsum dolor sit amet, consectetur adi­pi­sicing elit, sed do eius­mod tempor incidi­dunt ut labore et dolore magna ali­qua. Ut enim ad minim ve­niam, quis nostrud exer­citation ull­amco la­bo­ris nisi ut ali­quip ex ea commodo con­sequat. Duis aute irure dolor in repre­henderit in voluptate velit esse cillum dolore eu fugiat nulla pari­atur. Excep­teur sint occae­cat cupi­datat non proident, sunt in culpa qui officia dese­runt mollit anim id est laborum. ";
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
/* we use "utf8" as textformat, this allows to use unicode encoding */
$p->set_parameter("textformat", "utf8");
if ($p->begin_document($outfilename, "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib starter sample");
$p->set_info("Title", "starter_textflow");
/* Create some amount of dummy text and feed it to a Textflow
* object with alternating options.
*/
for ($i=1; $i<=$count; $i++) {
$num = $i . " ";
$tf = $p->add_textflow($tf, $num, $optlist2);
if ($tf == 0)
die("Error: " . $p->get_errmsg());
$tf = $p->add_textflow($tf, $text, $optlist1);
if ($tf == 0)
die("Error: " . $p->get_errmsg());
}
/* Loop until all of the text is placed; create new pages
* as long as more text needs to be placed. Two columns will
* be created on all pages.
*/
do {
/* Add "showborder to visualize the fitbox borders */
$optlist = "verticalalign=justify linespreadlimit=120% ";
$p->begin_page_ext(0, 0, "width=a4.width height=a4.height");
/* Fill the first column */
$result = $p->fit_textflow($tf, $llx1, $lly1, $urx1, $ury1, $optlist);
/* Fill the second column if we have more text*/
if ($result != "_stop") {
$result = $p->fit_textflow($tf,
$llx2, $lly2, $urx2, $ury2, $optlist);
}
$p->end_page_ext("");
/* "_boxfull" means we must continue because there is more text;
* "_nextpage" is interpreted as "start new column"
*/
} while ($result == "_boxfull" || $result == "_nextpage");
/* Check for errors */
if (!$result == "_stop") {
/* "_boxempty" happens if the box is very small and doesn't
* hold any text at all.
*/
if ($result == "_boxempty") {
die("Error: Textflow box too small");
} else {
/* Any other return value is a user exit caused by
* the "return" option; this requires dedicated code to
* deal with.
*/
die("User return '" . $result . "' found in Textflow");
}
}
$p->delete_textflow($tf);
$p->end_document("");
print "$outfilename generated";
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in starter_textflow sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/chartab.php 0000644 00000005641 15173135235 0021423 0 ustar 00 <?php
/* $Id: chartab.php,v 1.6.2.1 2008/04/06 17:55:03 rp Exp $
*
* PDFlib client: chartab example in PHP
*/
/* change these as required */
$fontname = "LuciduxSans-Oblique";
/* This is where font/image/PDF input files live. Adjust as necessary. */
$searchpath = "../data";
/* list of encodings to use */
$encodings = array( "iso8859-1", "iso8859-2", "iso8859-15" );
/* whether or not to embed the font */
$embed = 1;
define("FONTSIZE", 16);
define("TOP", 700);
define("LEFT", 50);
define("YINCR", 2*FONTSIZE);
define("XINCR", 2*FONTSIZE);
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
$p->set_parameter("SearchPath", $searchpath);
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "destination {type fitwindow page 1}") == 0) {
die("Error: " . $p->get_errmsg());
}
/* This line is required to avoid problems on Japanese systems */
$p->set_parameter("hypertextencoding", "winansi");
$p->set_info("Creator", "chartab.php");
$p->set_info("Author", "Thomas Merz");
$p->set_info("Title", "Character table (PHP)");
/* loop over all encodings */
for ($page = 0; $page < count($encodings); $page++)
{
$p->begin_page_ext(595, 842, "");
/* print the heading and generate the bookmark */
$font = $p->load_font("Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$p->setfont($font, FONTSIZE);
$buf = sprintf("%s (%s) %sembedded",
$fontname, $encodings[$page], $embed ? "" : "not ");
$p->show_xy($buf, LEFT - XINCR, TOP + 3 * YINCR);
$p->create_bookmark($buf, "");
/* print the row and column captions */
$p->setfont($font, 2 * FONTSIZE/3);
for ($row = 0; $row < 16; $row++)
{
$buf = sprintf("x%X", $row);
$p->show_xy($buf, LEFT + $row*XINCR, TOP + YINCR);
$buf = sprintf("%Xx", $row);
$p->show_xy($buf, LEFT - XINCR, TOP - $row * YINCR);
}
/* print the character table */
$font = $p->load_font($fontname, $encodings[$page],
$embed ? "embedding": "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$p->setfont($font, FONTSIZE);
$y = TOP;
$x = LEFT;
for ($row = 0; $row < 16; $row++)
{
for ($col = 0; $col < 16; $col++) {
$buf = sprintf("%c", 16*$row + $col);
$p->show_xy($buf, $x, $y);
$x += XINCR;
}
$x = LEFT;
$y -= YINCR;
}
$p->end_page_ext("");
}
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=chartab.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in chartab sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_layer.php 0000644 00000007757 15173135235 0022711 0 ustar 00 <?php
# $Id: starter_layer.php,v 1.1.2.2 2008/02/11 20:10:28 rjs Exp $
# Starter layer:
# Define several layers, output images and text to them and define
# particular layers to be visible when opening the document
#
# Define two layers for RGB or Grayscale images and two layers for English or
# German image captions. Output images and text on the various layers and
# open the document with the RGB images and English captions visible.
#
# Required software: PDFlib/PDFlib+PDI/PPS 7
# Required data: grayscale and RGB images
#
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "Starter Layer";
$rgb = "nesrin.jpg";
$gray = "nesrin_gray.jpg";
try {
# create a new PDFlib object
$p = new PDFlib();
$p->set_parameter("SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
# Open the document with the "Layers" navigation tab visible
if ($p->begin_document("", "openmode=layers") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.2 $';
$p->set_info("Title", $buf);
# Load the font
$font = $p->load_font("Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
# Load the Grayscale image
$imageGray = $p->load_image("auto", $gray, "");
if ($imageGray == 0) {
die("Error: " . $p->get_errmsg());
}
# Load the RGB image
$imageRGB = $p->load_image("auto", $rgb, "");
if ($imageRGB == 0) {
die("Error: " . $p->get_errmsg());
}
# Define all layers which will be used, and their relationships.
# This should be done before the first page if the layers are
# used on more than one page.
# Define the layer "RGB"
$layerRGB = $p->define_layer("RGB", "");
# Define the layer "Grayscale" which is hidden when opening the
# document or printing it.
$layerGray = $p->define_layer("Grayscale",
"initialviewstate=false initialprintstate=false");
# At most one of the "Grayscale" and "RGB" layers should be visible
$buf = "group={" . $layerGray . " " . $layerRGB . "}";
$p->set_layer_dependency("Radiobtn", $buf);
# Define the layer "English"
$layerEN = $p->define_layer("English", "");
# Define the layer "German" which is hidden when opening the document
# or printing it.
$layerDE = $p->define_layer("German",
"initialviewstate=false initialprintstate=false");
# At most one of the "English" and "German" layers should be visible
$buf = "group={" . $layerEN . " " . $layerDE . "}";
$p->set_layer_dependency("Radiobtn", $buf);
# Start page
$p->begin_page_ext(0, 0, "width=a4.width height=a4.height");
# Place the RGB image on the layer "RGB"
$p->begin_layer($layerRGB);
$p->fit_image($imageRGB, 100, 400,
"boxsize={400 300} fitmethod=meet");
# Place the Grayscale image on the layer "Grayscale"
$p->begin_layer($layerGray);
$p->fit_image($imageGray, 100, 400,
"boxsize={400 300} fitmethod=meet");
# Place an English image caption on the layer "English"
$p->begin_layer($layerEN);
$buf = "font=" . $font . " fontsize=20";
$p->fit_textline("This is the Nesrin image.", 100, 370, $buf);
# Place a German image caption on the layer "German"
$p->begin_layer($layerDE);
$buf = "font=" . $font . " fontsize=20";
$p->fit_textline("Das ist das Nesrin-Bild.", 100, 370, $buf);
$p->end_layer();
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_graphics.php 0000644 00000016717 15173135236 0023372 0 ustar 00 <?php
#!/usr/bin/perl
# $Id: starter_graphics.php,v 1.1.2.1 2007/12/29 23:26:06 rjs Exp $
# Starter Graphics:
# Create some basic examples of vector graphics
#
# Stroke a line, curve, circle, arc, and rectangle using the current line width
# and stroke color. Stroke and fill a rectangle.
# Draw an arc segment by drawing a line and an arc, closing the path and
# filling and stroking it.
# Draw a rectangle and use it as the clipping a path. Draw and fill a circle
# using the clipping path defined.
#
# Required software: PDFlib Lite/PDFlib/PDFlib+PDI/PPS 7
# Required data: none
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "Starter Graphics";
$xt=20;
$x = 210;
$y=770;
$dy=90;
try {
# create a new PDFlib object
$p = new PDFlib();
$p->set_parameter("SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.1 $';
$p->set_info("Title", $buf);
# Load the font; for PDFlib Lite: change "unicode" to "winansi"
$font = $p->load_font("Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
# Start an A4 page
$p->begin_page_ext(0, 0, "width=a4.width height=a4.height");
# Set the font
$p->setfont($font, 14);
# Set the line width
$p->setlinewidth(2.0);
# Set the stroke color
$p->setcolor("stroke", "rgb", 0.0, 0.5, 0.5, 0.0);
# Set the fill color
$p->setcolor("fill", "rgb", 0.0, 0.85, 0.85, 0.0);
# -------------
# Stroke a line
# -------------
# Set the current point for graphics output
$p->moveto($x, $y);
# Draw a line from the current point to the supplied point
$p->lineto($x+300, $y+50);
# Stroke the path using the current line width and stroke color, and
# clear it
$p->stroke();
# Output some descriptive black text
$p->fit_textline("lineto() and stroke()", $xt, $y,
"fillcolor={gray 0}");
# --------------
# Stroke a curve
# --------------
# Set the current point for graphics output
$p->moveto($x, $y-=$dy);
# Draw a B�zier curve from the current point to (x3, y3), using three
# control points
$p->curveto($x+50, $y+40, $x+200, $y+80, $x+300, $y+30);
# Stroke the path using the current line width and stroke color, and
# clear it
$p->stroke();
# Output some descriptive black text
$p->fit_textline("curveto() and stroke()", $xt, $y,
"fillcolor={gray 0}");
# ---------------
# Stroke a circle
# ---------------
# Draw a circle at position (x, y) with a radius of 40
$p->circle($x, $y-=$dy, 40);
# Stroke the path using the current line width and stroke color, and
# clear it
$p->stroke();
# Output some descriptive black text
$p->fit_textline("circle() and stroke()", $xt, $y,
"fillcolor={gray 0}");
# ---------------------
# Stroke an arc segment
# ---------------------
# Draw an arc segment counterclockwise at position (x, y) with a radius
# of 40 starting at an angle of 90 degrees and ending at 180 degrees
$p->arc($x, $y-=$dy+20, 40, 90, 180);
# Stroke the path using the current line width and stroke color, and
# clear it
$p->stroke();
# Output some descriptive black text
$p->fit_textline("arc() and stroke()", $xt, $y,
"fillcolor={gray 0}");
# ------------------
# Stroke a rectangle
# ------------------
# Draw a rectangle at position (x, y) with a width of 200 and a height
# of 50
$p->rect($x, $y-=$dy, 200, 50);
# Stroke the path using the current line width and stroke color, and
# clear it
$p->stroke();
# Output some descriptive black text
$p->fit_textline("rect() and stroke()", $xt, $y,
"fillcolor={gray 0}");
# ----------------
# Fill a rectangle
# ----------------
# Draw a rectangle at position (x, y) with a width of 200 and a height
# of 50
$p->rect($x, $y-=$dy, 200, 50);
# Fill the path using current fill color, and clear it
$p->fill();
# Output some descriptive black text
$p->fit_textline("rect() and fill()", $xt, $y,
"fillcolor={gray 0}");
# ---------------------------
# Fill and stroke a rectangle
# ---------------------------
# Draw a rectangle at position (x, y) with a width of 200 and a height
# of 50
$p->rect($x, $y-=$dy, 200, 50);
# Fill and stroke the path using the current line width, fill color,
# and stroke color, and clear it
$p->fill_stroke();
# Output some descriptive black text
$p->fit_textline("rect() and fill_stroke()", $xt, $y,
"fillcolor={gray 0}");
# -------------------------------------------------------------
# Draw a line and an arc, close the path and fill and stroke it
# -------------------------------------------------------------
# Set the current point for graphics output
$p->moveto($x-40, $y-=$dy);
# Draw a line from the current point to the supplied point
$p->lineto($x, $y);
# Draw an arc segment counterclockwise at position (x, y) with a radius
# of 40 starting at an angle of 90 degrees and ending at 180 degrees
$p->arc($x, $y, 40, 90, 180);
# Close the path and stroke and fill it, i.e. close the current subpath
# (add a straight line segment from the current point to the starting
# point of the path), and stroke and fill the complete current path
$p->closepath_fill_stroke();
# Output some descriptive black text
$p->fit_textline("lineto(), arc(), and", $xt, $y+20,
"fillcolor={gray 0}");
$p->fit_textline("closepath_fill_stroke()", $xt, $y,
"fillcolor={gray 0}");
# -----------------------------------------------------------------
# Draw a rectangle and use it as the clipping a path. Draw and fill
# a circle and clip it according to the clipping path defined.
# -----------------------------------------------------------------
# Save the current graphics state including the current clipping
# path which is set to the entire page by default
$p->save();
# Draw a rectangle at position (x, y) with a width of 200 and a height
# of 50
$p->rect($x, $y-=$dy, 200, 50);
# Use the current path as the clipping path for subsequent operations
$p->clip();
# Draw a circle at position (x, y) with a radius of 100
$p->circle($x, $y, 80);
# Fill the path with the current fill color and clear it
$p->fill();
# Restore the graphics state which has been saved above
$p->restore();
# Output some descriptive black text
$p->fit_textline("rect(), clip(),", $xt, $y+20,
"fillcolor={gray 0}");
$p->fit_textline("circle(), and fill()", $xt, $y,
"fillcolor={gray 0}");
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_3d.php 0000644 00000005142 15173135236 0022066 0 ustar 00 <?php
/* $Id: starter_3d.php,v 1.1.2.2 2009/08/07 07:30:46 rjs Exp $
* 3D Starter:
* Create a 3D model and load it into a U3D annotation.
*
* Define a 3D view and load some 3D data with the view defined. Then create
* an annotation containing the loaded 3D data with the defined 3D view as the
* initial view.
*
* Acrobat 7.07 or above is required for viewing PDF documents containing a
* 3D model.
*
* Required software: PDFlib/PDFlib+PDI/PPS 7.0.1
* Required data: U3D data file
*/
# This is where the data files are. Adjust if necessary.
$searchpath = "../data";
$outfile = "starter_3d.pdf";
# Required minimum PDFlib version
$requiredversion = 701;
$requiredvstr = "7.0.1";
try {
$p = new PDFlib();
$p->set_parameter("SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
# Check whether the required minimum PDFlib version is available
$major = $p->get_value("major", 0);
$minor = $p->get_value("minor", 0);
$revision = $p->get_value("revision", 0);
if ($major*100 + $minor*10 + $revision < $requiredversion) {
die("Error: PDFlib " . $requiredvstr . " or above is required\n");
}
# Start the document
if ($p->begin_document($outfile, "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib Cookbook");
$p->set_info("Title", "starter_3d");
$font = $p->load_font("Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$p->begin_page_ext(0, 0, "width=a4.width height=a4.height");
# Define a U3D view
$optlist = "name=FirstView background={fillcolor={rgb 1 0.5 0.1}}";
if (($u3dview = $p->create_3dview("First view", $optlist)) == 0) {
die("Error: " . $p->get_errmsg());
}
# Load some U3D data with the view defined above
$buf = "views={$u3dview}";
if (($u3ddata = $p->load_3ddata("box.u3d", $buf)) == 0) {
die("Error: " . $p->get_errmsg());
}
# Create an annotation containing the loaded U3D data with the
# defined 3D view as the initial view
#
$buf = "name=annot usercoordinates contents=U3D 3ddata=$u3ddata 3dactivate={enable=open} 3Dinitialview=$u3dview";
$p->create_annotation(116, 400, 447, 580, "3D", $buf);
$p->end_page_ext("");
$p->end_document("");
$p->delete();
print "$outfile generated";
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in invoice sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/hello.php 0000644 00000002673 15173135236 0021125 0 ustar 00 <?php
/* $Id: hello.php,v 1.6.2.1 2008/04/06 17:55:03 rp Exp $
*
* PDFlib client: hello example in PHP
*/
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
/* This line is required to avoid problems on Japanese systems */
$p->set_parameter("hypertextencoding", "winansi");
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "hello.php");
$p->set_info("Author", "Rainer Schaaf");
$p->set_info("Title", "Hello world (PHP)!");
$p->begin_page_ext(595, 842, "");
$font = $p->load_font("Helvetica-Bold", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$p->setfont($font, 24.0);
$p->set_text_pos(50, 700);
$p->show("Hello world!");
$p->continue_text("(says PHP)");
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_pvf.php 0000644 00000005324 15173135236 0022355 0 ustar 00 <?php
#!/usr/bin/perl
# $Id: starter_pvf.php,v 1.1.2.1 2007/12/29 23:26:06 rjs Exp $
# PDFlib Virtual File system (PVF):
# Create a PVF file which holds an image or PDF, and import the data from the
# PVF file
#
# This avoids disk access and is especially useful when the same image or PDF
# is imported multiply. For examples, images which sit in a database don't
# have to be written and re-read from disk, but can be passed to PDFlib
# directly in memory. A similar technique can be used for loading other data
# such as fonts, ICC profiles, etc.
#
# Required software: PDFlib Lite/PDFlib/PDFlib+PDI/PPS 7
# Required data: image file
#
# Helper function to read the content of a file into a buffer
# avoids incompatible systemcalls
function read_file($fname)
{
$fp = fopen($fname, "r");
$data = fread ($fp, filesize($fname));
fclose($fp);
return $data;
} # read_file
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "PDFlib Virtual File System";
try {
# create a new PDFlib object
$p = new PDFlib();
$p->set_parameter("SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
# Set an output path according to the name of the topic
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.1 $';
$p->set_info("Title", $buf);
# We just read some image data from a file; to really benefit
# from using PVF read the data from a Web site or a database instead
$imagedata = read_file("../data/PDFlib-logo.tif");
$p->create_pvf("/pvf/image", $imagedata, "");
# Load the image from the PVF
$image = $p->load_image("auto", "/pvf/image", "");
if ($image == 0) {
die("Error: " . $p->get_errmsg());
}
# Fit the image on page 1
$p->begin_page_ext(595, 842, "");
$p->fit_image($image, 350, 750, "");
$p->end_page_ext("");
# Fit the image on page 2
$p->begin_page_ext(595, 842, "");
$p->fit_image($image, 350, 50, "");
$p->end_page_ext("");
# Delete the virtual file to free the allocated memory
$p->delete_pvf("/pvf/image");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_image.php 0000644 00000013635 15173135236 0022650 0 ustar 00 <?php
# $Id: starter_image.php,v 1.1.2.2 2008/07/30 13:13:34 rp Exp $
# Starter image:
# Load and place an image using various options for scaling and positioning
#
# Place the image it its original size.
# Place the image with scaling and orientation to the west.
# Fit the image into a box with clipping.
# Fit the image into a box with proportional resizing.
# Fit the image into a box entirely.
#
# Required software: PDFlib Lite/PDFlib/PDFlib+PDI/PPS 7
# Required data: image file
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "Starter Image";
$imagefile = "lionel.jpg";
$bw = 400;
$bh = 200;
$x = 20;
$y = 580;
$yoffset = 260;
try {
# create a new PDFlib object
$p = new PDFlib();
$p->set_parameter("SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.2 $';
$p->set_info("Title", $buf);
# For PDFlib Lite: change "unicode" to "winansi"
$font = $p->load_font("Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
# Load the image
$image = $p->load_image("auto", $imagefile, "");
if ($image == 0) {
die("Error: " . $p->get_errmsg());
}
# Start page 1
$p->begin_page_ext(0, 0, "width=a4.width height=a4.height");
$p->setfont($font, 12);
# ------------------------------------
# Place the image in its original size
# ------------------------------------
# Position the image in its original size with its lower left corner
# at the reference point (20, 380)
$p->fit_image($image, 20, 380, "");
# Output some descriptive text
$p->fit_textline(
"The image is placed with the lower left corner in its original " .
"size at reference point (20, 380):", 20, 820, "");
$p->fit_textline("fit_image(image, 20, 380, \"\");", 20, 800, "");
# --------------------------------------------------------
# Place the image with scaling and orientation to the west
# --------------------------------------------------------
# Position the image with its lower right corner at the reference
# point (580, 20).
# "scale=0.5" scales the image by 0.5.
# "orientate=west" orientates the image to the west.
$p->fit_image($image, 580, 20,
"scale=0.5 position={right bottom} orientate=west");
# Output some descriptive text
$p->fit_textline(
"The image is placed with a scaling of 0.5 and an orientation to " .
"the west with the lower right corner", 580, 320,
"position={right bottom}");
$p->fit_textline(
" at reference point (580, 20): fit_image(image, 580, 20, " .
"\"scale=0.5 orientate=west position={right bottom}\");",
580, 300, "position={right bottom}");
$p->end_page_ext("");
# Start page 2
$p->begin_page_ext(0, 0, "width=a4.width height=a4.height");
$p->setfont($font, 12);
# --------------------------------------
# Fit the image into a box with clipping
# --------------------------------------
# The "boxsize" option defines a box with a given width and height and
# its lower left corner located at the reference point.
# "position={right top}" positions the image on the top right of the
# box.
# "fitmethod=clip" clips the image to fit it into the box.
$buf = "boxsize={" . $bw . " " . $bh .
"} position={right top} fitmethod=clip";
$p->fit_image($image, $x, $y, $buf);
# Output some descriptive text
$p->fit_textline(
"fit_image(image, x, y, \"boxsize={400 200} position={right top} " .
"fitmethod=clip\");", 20, $y+$bh+10, "");
# ---------------------------------------------------
# Fit the image into a box with proportional resizing
# ---------------------------------------------------
# The "boxsize" option defines a box with a given width and height and
# its lower left corner located at the reference point.
# "position={center}" positions the image in the center of the
# box.
# "fitmethod=meet" resizes the image proportionally until its height
# or width completely fits into the box.
# The "showborder" option is used to illustrate the borders of the box.
$buf = "boxsize={" . $bw . " " . $bh .
"} position={center} fitmethod=meet showborder";
$p->fit_image($image, $x, $y-=$yoffset, $buf);
# Output some descriptive text
$p->fit_textline(
"fit_image(image, x, y, \"boxsize={400 200} position={center} " .
"fitmethod=meet showborder\");", 20, $y+$bh+10, "");
# ---------------------------------
# Fit the image into a box entirely
# ---------------------------------
# The "boxsize" option defines a box with a given width and height and
# its lower left corner located at the reference point.
# By default, the image is positioned in the lower left corner of the
# box.
# "fitmethod=entire" resizes the image proportionally until its height
# or width completely fits into the box.
$buf = "boxsize={" . $bw . " " . $bh . "} fitmethod=entire";
$p->fit_image($image, $x, $y-=$yoffset, $buf);
# Output some descriptive text
$p->fit_textline(
"fit_image(image, x, y, \"boxsize={400 200} fitmethod=entire\");",
20, $y+$bh+10, "");
$p->end_page_ext("");
$p->close_image($image);
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/image.php 0000644 00000003157 15173135236 0021102 0 ustar 00 <?php
/* $Id: image.php,v 1.5 2006/10/01 20:49:14 rjs Exp $
*
* PDFlib client: image example in PHP
*/
/* This is where font/image/PDF input files live. Adjust as necessary. */
$searchpath = "../data";
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
/* This line is required to avoid problems on Japanese systems */
$p->set_parameter("hypertextencoding", "winansi");
$p->set_parameter("SearchPath", $searchpath);
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "image.php");
$p->set_info("Author", "Rainer Schaaf");
$p->set_info("Title", "image sample (PHP)");
$imagefile = "nesrin.jpg";
$image = $p->load_image("auto", $imagefile, "");
if (!$image) {
die("Error: " . $p->get_errmsg());
}
/* dummy page size, will be adjusted by $p->fit_image() */
$p->begin_page_ext(10, 10, "");
$p->fit_image($image, 0, 0, "adjustpage");
$p->close_image($image);
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=image.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in image sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/quickreference.php 0000644 00000005076 15173135236 0023015 0 ustar 00 <?php
/* $Id: quickreference.php,v 1.6.2.1 2008/04/06 17:55:03 rp Exp $
*
* PDFlib+PDI client: mini imposition demo
*/
$infile = "reference.pdf";
/* This is where font/image/PDF input files live. Adjust as necessary. */
$searchpath = "../data";
$maxrow = 2;
$maxcol = 2;
$width = 500.0;
$height = 770.0;
$endpage = 0;
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
$p->set_parameter("SearchPath", $searchpath);
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
/* This line is required to avoid problems on Japanese systems */
$p->set_parameter("hypertextencoding", "winansi");
$p->set_info("Creator", "quickreference.php");
$p->set_info("Author", "Thomas Merz");
$p->set_info("Title", "mini imposition demo (php)");
$manual = $p->open_pdi($infile, "", 0);
if (!$manual) {
die("Error: " . $p->get_errmsg());
}
$row = 0;
$col = 0;
$p->set_parameter("topdown", "true");
$endpage = $p->pcos_get_number($manual, "length:pages");
for ($pageno = 1; $pageno <= $endpage; $pageno++) {
if ($row == 0 && $col == 0) {
$p->begin_page_ext($width, $height, "");
$font = $p->load_font("Helvetica-Bold", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$p->setfont($font, 18);
$p->set_text_pos(24, 24);
$p->show("PDFlib Quick Reference");
}
$page = $p->open_pdi_page($manual, $pageno, "");
if (!$page) {
die("Error: " . $p->get_errmsg());
}
$optlist = sprintf("scale %f", 1/$maxrow);
$p->fit_pdi_page($page,
$width/$maxcol*$col, ($row + 1) * $height/$maxrow, $optlist);
$p->close_pdi_page($page);
$col++;
if ($col == $maxcol) {
$col = 0;
$row++;
}
if ($row == $maxrow) {
$row = 0;
$p->end_page_ext("");
}
}
/* finish the last partial page */
if ($row != 0 || $col != 0) {
$p->end_page_ext("");
}
$p->end_document("");
$p->close_pdi($manual);
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=quickreference_php.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in quickreference sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_block.php 0000644 00000005752 15173135237 0022662 0 ustar 00 <?php
/* $Id: starter_block.php,v 1.1.2.3 2009/08/07 07:30:46 rjs Exp $
*
* Block starter:
* Import a PDF page containing, and process all blocks. The blocks are
* retrieved via pCOS, and the block filling functions are used to
* visualize the blocks on the output page. A real-world application would
* of course fill the blocks with data retrieved from some external data
* source.
*
* required software: PPS 7 or above
* required data: input PDF
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$infile = "boilerplate.pdf";
$outfilename = "starter_block.pdf";
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
$p->set_parameter("SearchPath", $searchpath);
/* we use "utf8" as textformat, this allows to use unicode encoding */
$p->set_parameter("textformat", "utf8");
if ($p->begin_document($outfilename, "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib starter sample");
$p->set_info("Title", "starter_block");
/* Open a PDF containing blocks */
$indoc = $p->open_pdi_document($infile, "");
if ($indoc == 0) {
die("Error: " . $p->get_errmsg());
}
/* Open the first $page */
$page = $p->open_pdi_page($indoc, 1, "");
if ($page == 0) {
die("Error: " . $p->get_errmsg());
}
$width = $p->pcos_get_number($indoc, "pages[0]/width");
$height = $p->pcos_get_number($indoc, "pages[0]/height");
$p->begin_page_ext($width, $height, "");
/* Place the imported $page on the output $page */
$p->fit_pdi_page($page, 0, 0, "");
/* Query the number of blocks on the first page */
$blockcount = $p->pcos_get_number($indoc, "length:pages[0]/blocks");
if ($blockcount == 0) {
die("Error: " . $infile . "does not contain any PDFlib blocks");
}
/* Loop over all blocks on the $page */
for ($i = 0; $i < $blockcount; $i++) {
/* Fetch the name and type of the $i-th block on the first page
* (one of Text/Image/PDF)
*/
$blockname = $p->pcos_get_string($indoc,
"pages[0]/blocks[" . $i . "]/Name");
$blocktype = $p->pcos_get_string($indoc,
"pages[0]/blocks[" . $i . "]/Subtype");
/* Visualize all text blocks */
if ($blocktype == "Text") {
$optlist = "fontname=Helvetica encoding=unicode " .
"fillcolor={rgb 1 0 0} " .
"bordercolor={gray 0} linewidth=0.25";
/* We simply use the $blockname as content */
if ($p->fill_textblock(
$page, $blockname, $blockname, $optlist) == 0) {
print("Warning: " . $p->get_errmsg());
}
}
}
$p->end_page_ext("");
$p->close_pdi_page($page);
$p->end_document("");
$p->close_pdi_document($indoc);
print "$outfilename generated";
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in starter_block sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_webform.php 0000644 00000004611 15173135237 0023222 0 ustar 00 <?php
/* $Id: starter_webform.php,v 1.1.2.1 2007/09/27 12:58:00 rjs Exp $
*
* Webform starter:
* create a linearized PDF (for fast delivery over the Web, also known
* as "fast Web view") which is encrypted and contains some form fields.
* A few lines of JavaScript are inserted as "page open" action to
* automatically populate the date field with the current date.
*
* required software: PDFlib/PDFlib+PDI/PPS 7
* required data: none
*/
$outfilename = "starter_webform.pdf";
$llx=150; $lly=550; $urx=350; $ury=575;
/* JavaScript for automatically filling the date into a form field */
$js = "var d = util.printd(\"mm/dd/yyyy\", new Date());" .
"var date = this.getField(\"date\");" .
"date.value = d;";
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
/* Prevent changes with a master password */
$optlist = "linearize masterpassword=pdflib permissions={nomodify}";
if ($p->begin_document($outfilename, $optlist) == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib starter sample");
$p->set_info("Title", "starter_webform");
$optlist = "script={" . $js . "}";
$action = $p->create_action("JavaScript", $optlist);
$optlist = "action={open=" . $action . "}";
$p->begin_page_ext(595, 842, $optlist);
$font = $p->load_font("Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
$p->setfont($font, 24);
$p->fit_textline("Date: ", 125, $lly+5, "position={right bottom}");
/* The tooltip will be used as rollover text for the field */
$optlist =
"tooltip={Date (will be filled automatically)} " .
"bordercolor={gray 0} font=" . $font;
$p->create_field($llx, $lly, $urx, $ury, "date", "textfield", $optlist);
$lly-=100; $ury-=100;
$p->fit_textline("Name: ", 125, $lly+5, "position={right bottom}");
$optlist = "tooltip={Enter your name here} " .
"bordercolor={gray 0} font=" . $font;
$p->create_field($llx, $lly, $urx, $ury, "name", "textfield", $optlist);
$p->end_page_ext("");
$p->end_document("");
print "$outfilename generated";
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in starter_webform sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_type3font.php 0000644 00000005206 15173135237 0023515 0 ustar 00 <?php
# $Id: starter_type3font.php,v 1.1.2.3 2008/07/30 13:16:29 rp Exp $
# Type 3 font starter:
# Create a simple Type 3 font from vector data
#
# Define a type 3 font with the glyphs "l" and "space" and output text with
# that font. In addition the glyph ".notdef" is defined which any undefined
# character will be mapped to.
#
# Required software: PDFlib/PDFlib+PDI/PPS 7
# Required data: none
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "Starter Type 3 Font";
try {
# create a new PDFlib object
$p = new PDFlib();
$p->set_parameter("SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.3 $';
$p->set_info("Title", $buf);
# Create the font "SimpleFont" containing the glyph "l",
# the glyph "space" for spaces and the glyph ".notdef" for any
# undefined character
$p->begin_font("SimpleFont",
0.001, 0.0, 0.0, 0.001, 0.0, 0.0, "");
$p->begin_glyph(".notdef", 266, 0, 0, 0, 0);
$p->end_glyph();
$p->begin_glyph("space", 266, 0, 0, 0, 0);
$p->end_glyph();
$p->begin_glyph("l", 266, 69, 0, 197, 530);
$p->setlinewidth(20);
$p->setdash(0, 0);
$x = 197;
$y = 0;
$p->moveto($x, $y);
$y += 530;
$p->lineto($x, $y);
$x -= 64;
$p->lineto($x, $y);
$y -= 530;
$p->moveto($x, $y);
$x += 128;
$p->lineto($x, $y);
$p->closepath();
$p->stroke();
$p->end_glyph();
$p->end_font();
# Start page
$p->begin_page_ext(0, 0, "width=300 height=200");
# Load the new "SimpleFont" font
$font = $p->load_font("SimpleFont", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
# Output the characters "l" and "space" of the "SimpleFont" font.
# The character "x" is undefined and will be mapped to ".notdef"
$buf = " font=" . $font . " fontsize=40";
$p->fit_textline("lll lllxlll", 100, 100, $buf);
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/starter_textline.php 0000644 00000016425 15173135237 0023423 0 ustar 00 <?php
# $Id: starter_textline.php,v 1.1.2.1 2007/12/29 23:26:06 rjs Exp $
# Starter text line:
# Demonstrate various options for placing a text line
#
# Place a text line with different font sizes.
# Output overlined, stroke out, and underlined text.
# Output text and define character spacing, work spacing, or horizontal
# scaling.
# Output text with a defined fill color. Output text including its outlines
# with a defined stroke color.
# Place text into a box at various positions. Place text completely into a box
# with automatic scaling if required.
#
# Required software: PDFlib Lite/PDFlib/PDFlib+PDI/PPS 7
# Required data: none
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "Starter Text Line";
$x = 10;
$xt = 280;
$y = 800;
$yoff = 50;
$textline = "Giant Wing Paper Plane";
try {
# create a new PDFlib object
$p = new PDFlib();
$p->set_parameter("SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
# Set an output path according to the name of the topic
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.1 $';
$p->set_info("Title", $buf);
# Start Page
$p->begin_page_ext(0, 0, "width=a4.width height=a4.height");
# For PDFlib Lite: change "unicode" to "winansi"
$font = $p->load_font("Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . $p->get_errmsg());
}
# Set the font with a font size of 14
$p->setfont($font, 14);
# Place the text line without any options applied
$p->fit_textline($textline, $x, $y, "");
# Output descriptive text
$p->fit_textline("fit_textline() without any options", $xt, $y,
"fontsize=12");
# Place the text with a different font size
$optlist = "fontsize=22";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y, "fontsize=12"); # description
# Place stroke out text
$optlist = "strikeout";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y, "fontsize=12"); # description
# Place underlined text
$optlist = "underline underlinewidth=7% underlineposition=-20%";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y, "fontsize=12"); # description
# Place overlined text
$optlist = "overline";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y, "fontsize=12"); # description
# Place the text with a horizontal scaling of 150%
$optlist = "horizscaling=150%";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y, "fontsize=12"); # description
# Place the text with a character spacing of 30% of the font size
$optlist = "charspacing=30%";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y, "fontsize=12"); # description
# Place the text with a word spacing of 50% of the font size
$optlist = "wordspacing=50%";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y, "fontsize=12"); # description
# Place the text with a different fill color
$optlist = "fillcolor={rgb 0.5 0.2 0.5}";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist);
$p->fit_textline($optlist, $xt, $y, "fontsize=12");
# Place the text including its outlines using a text rendering mode of
# 2 for "filling and stroking text" and different fill and stroke
# colors
$optlist =
"fontsize=22 fillcolor={rgb 0.6 0.3 0.6} strokecolor={gray 0} " .
"strokewidth=0.4 textrendering=2";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist);
# Output descriptive text
$p->fit_textline("fillcolor={rgb 0.6 0.3 0.6} strokecolor={gray 0} ",
$xt, $y+10, "fontsize=12");
$p->fit_textline("strokewidth=0.4 textrendering=2 fontsize=22",
$xt, $y-5, "fontsize=12");
# Place the text with its outlines using a text rendering mode of
# 1 for "stroking text" and a stroke color of black
$optlist =
"fontsize=22 strokecolor={gray 0} strokewidth=0.4 textrendering=1";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist);
# Output descriptive text
$p->fit_textline("strokecolor={gray 0} strokewidth=0.4", $xt, $y+10,
"fontsize=12");
$p->fit_textline("textrendering=1 fontsize=22", $xt, $y-=5,
"fontsize=12");
# Place the text in a box with default positioning and fitting
$optlist = "boxsize={200 20} showborder";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y+3, "fontsize=12"); # description
# Place the text in a box on the top right
$optlist = "boxsize={200 20} position={top right} showborder";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y+3, "fontsize=12"); # description
# Use "fitmethod=clip" to place the text in a box not large enough to
# show the complete text. The text will be clipped.
$optlist = "boxsize={130 20} fitmethod=clip showborder";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y+3, "fontsize=12"); # description
# Fit the text into the box automatically with "fitmethod=auto".
# In this case, if the text doesn't fit into the box a distortion
# factor is calculated which makes the text fit into the box. If this
# factor is larger than the "shrinklimit" option the text will
# be distorted by that factor. Otherwise, the font size will be
# be decreased until until the text fits into the box.
# Use "fitmethod=auto" to place the text in a box not large enough to
# show the complete text. The text will be distorted.
$optlist = "boxsize={130 20} fitmethod=auto showborder";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y+3, "fontsize=12"); # description
# Use "fitmethod=auto" to place the text in a box too small to show the
# complete text. The font size will be reduced until the text fits into
# the box.
$optlist = "boxsize={100 20} fitmethod=auto showborder";
$p->fit_textline($textline, $x, $y-=$yoff, $optlist); # sample text
$p->fit_textline($optlist, $xt, $y+3, "fontsize=12"); # description
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/examples.php5/invoice.php 0000644 00000013006 15173135237 0021447 0 ustar 00 <?php
/* $Id: invoice.php,v 1.9.2.1 2008/04/06 17:55:03 rp Exp $
*
* PDFlib client: invoice example in PHP
*/
$left = 55;
$right = 530;
$fontsize = 12;
$pagewidth = 595;
$pageheight = 842;
$fontsize = 12;
$infile = "stationery.pdf";
$baseopt = "ruler { 30 45 275 375 475} " .
"tabalignment { right left right right right} " .
"hortabmethod ruler fontsize 12 ";
/* This is where font/image/PDF input files live. Adjust as necessary. */
$searchpath = "../data";
$closingtext =
"Terms of payment: <fillcolor={rgb 1 0 0}>30 days net. " .
"<fillcolor={gray 0}>90 days warranty starting at the day of sale. " .
"This warranty covers defects in workmanship only. " .
"<fontname=Helvetica-BoldOblique encoding=host>Kraxi Systems, Inc. " .
"<resetfont>will, at its option, repair or replace the " .
"product under the warranty. This warranty is not transferable. " .
"No returns or exchanges will be accepted for wet products.";
$data = array( array("name"=>"Super Kite", "price"=>20, "quantity"=>2),
array("name"=>"Turbo Flyer", "price"=>40, "quantity"=>5),
array("name"=>"Giga Trasch", "price"=>180, "quantity"=>1),
array("name"=>"Bare Bone Kit", "price"=>50, "quantity"=>3),
array("name"=>"Nitty Gritty", "price"=>20, "quantity"=>10),
array("name"=>"Pretty Dark Flyer","price"=>75, "quantity"=>1),
array("name"=>"Free Gift", "price"=>0, "quantity"=>1)
);
$months = array( "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December");
try {
$p = new PDFlib();
# This means we must check return values of load_font() etc.
$p->set_parameter("errorpolicy", "return");
$p->set_parameter("SearchPath", $searchpath);
/* This line is required to avoid problems on Japanese systems */
$p->set_parameter("hypertextencoding", "winansi");
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "invoice.php");
$p->set_info("Author", "Thomas Merz");
$p->set_info("Title", "PDFlib invoice generation demo (PHP)");
$stationery = $p->open_pdi($infile, "", 0);
if ($stationery == 0){
die("Error: " . $p->get_errmsg());
}
$page = $p->open_pdi_page($stationery, 1, "");
if ($page == 0){
die("Error: " . $p->get_errmsg());
}
$boldfont = $p->load_font("Helvetica-Bold", "winansi", "");
if ($boldfont == 0) {
die("Error: " . $p->get_errmsg());
}
$regularfont = $p->load_font("Helvetica", "winansi", "");
if ($regularfont == 0) {
die("Error: " . $p->get_errmsg());
}
$leading = $fontsize + 2;
/* Establish coordinates with the origin in the upper left corner. */
$p->begin_page_ext($pagewidth, $pageheight, "topdown");
$p->fit_pdi_page($page, 0, $pageheight, "");
$p->close_pdi_page($page);
$p->setfont($regularfont, $fontsize);
/* print the address */
$y = 170;
$p->set_value("leading", $leading);
$p->show_xy("John Q. Doe", $left, $y);
$p->continue_text("255 Customer Lane");
$p->continue_text("Suite B");
$p->continue_text("12345 User Town");
$p->continue_text("Everland");
/* print the header and date */
$p->setfont($boldfont, $fontsize);
$y = 300;
$p->show_xy("INVOICE", $left, $y);
$time = localtime();
$buf = sprintf("%s %d, %d", $months[$time[4]], $time[3], $time[5]+1900);
$p->fit_textline($buf, $right, $y, "position {100 0}");
/* print the invoice header line */
$y = 370;
$buf = sprintf("\tITEM\tDESCRIPTION\tQUANTITY\tPRICE\tAMOUNT");
$optlist = sprintf("%s font %d ", $baseopt, $boldfont);
$textflow = $p->create_textflow($buf, $optlist);
if ($textflow == 0){
die("Error: " . $p->get_errmsg());
}
$p->fit_textflow($textflow, $left, $y-$leading, $right, $y, "");
$p->delete_textflow($textflow);
$y += 2*$leading;
$total = 0;
$optlist = sprintf("%s font %d ", $baseopt, $regularfont);
for ($i = 0; $i < count($data); $i++){
$sum = $data[$i]{"price"}*$data[$i]{"quantity"};
$buf = sprintf("\t%d\t%s\t%d\t%.2f\t%.2f", $i+1, $data[$i]{"name"},
$data[$i]{"quantity"}, $data[$i]{"price"}, $sum);
$textflow = $p->create_textflow($buf, $optlist);
if ($textflow == 0){
die("Error: " . $p->get_errmsg());
}
$p->fit_textflow($textflow, $left, $y-$leading, $right, $y, "");
$p->delete_textflow($textflow);
$y += $leading;
$total +=$sum;
}
$y += $leading;
$p->setfont($boldfont, $fontsize);
$p->fit_textline(sprintf("%.2f",$total), $right, $y, "position {100 0}");
/* Print the closing text */
$y +=5*$leading;
$optlist = "alignment=justify leading=120% ";
$optlist .= "fontname=Helvetica fontsize=12 encoding=winansi";
$textflow = $p->create_textflow($closingtext, $optlist);
if ($textflow == 0){
die("Error: " . $p->get_errmsg());
}
$p->fit_textflow($textflow, $left, $y+6*$leading, $right, $y, "");
$p->delete_textflow($textflow);
$p->end_page_ext("");
$p->end_document("");
$p->close_pdi($stationery);
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=invoice.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in invoice sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_table.php 0000644 00000012635 15173135237 0020164 0 ustar 00 <?php
/* $Id: starter_table.php,v 1.7 2006/10/02 21:11:38 tm Exp $
*
* Table starter:
* Create table which may span multiple pages
*
* required software: PDFlib/PDFlib+PDI/PPS 7
* required data: image file (dummy text created within the program)
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$imagefile = "nesrin.jpg";
$outfilename = "starter_table.pdf";
$tf=0; $tbl=0;
$rowmax = 50; $colmax = 5;
$llx= 50; $lly=50; $urx=550; $ury=800;
$headertext = "Table header (centered across all columns)";
/* Dummy text for filling a cell with multi-line Textflow */
$tf_text =
"Lorem ipsum dolor sit amet, consectetur adi­pi­sicing elit, sed do eius­mod tempor incidi­dunt ut labore et dolore magna ali­qua. Ut enim ad minim ve­niam, quis nostrud exer­citation ull­amco la­bo­ris nisi ut ali­quip ex ea commodo con­sequat. Duis aute irure dolor in repre­henderit in voluptate velit esse cillum dolore eu fugiat nulla pari­atur. Excep­teur sint occae­cat cupi­datat non proident, sunt in culpa qui officia dese­runt mollit anim id est laborum. ";
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
/* we use "utf8" as textformat, this allows to use unicode encoding */
PDF_set_parameter($p, "textformat", "utf8");
if (PDF_begin_document($p, $outfilename, "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib starter sample");
PDF_set_info($p, "Title", "starter_table");
/* -------------------- Add table cells -------------------- */
/* ---------- row 1: table header (spans all columns) */
$row = 1; $col = 1;
$font = PDF_load_font($p, "Times-Bold", "unicode", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
$optlist = "fittextline={position=center font=" . $font . " fontsize=14} " .
"colspan=" . $colmax;
$tbl = PDF_add_table_cell($p, $tbl, $col, $row, $headertext, $optlist);
if ($tbl == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/* ---------- row 2: various kinds of content */
/* ----- Simple text cell */
$row++; $col=1;
$optlist = "fittextline={font=" . $font . " fontsize=10 orientate=west}";
$tbl = PDF_add_table_cell($p, $tbl, $col, $row, "vertical line", $optlist);
if ($tbl == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/* ----- Colorized background */
$col++;
$optlist = "fittextline={font=" . $font . " fontsize=10} " .
"matchbox={fillcolor={rgb 0.9 0.5 0}}";
$tbl = PDF_add_table_cell($p, $tbl, $col, $row, "some color", $optlist);
if ($tbl == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/* ----- Multi-line text with Textflow */
$col++;
$font = PDF_load_font($p, "Times-Roman", "unicode", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
$optlist = "charref fontname=Times-Roman encoding=unicode fontsize=8 ";
$tf = PDF_add_textflow($p, $tf, $tf_text, $optlist);
if ($tf == 0) {
die("Error: " . PDF_get_errmsg($p));
}
$optlist = "margin=2 textflow=" . $tf;
$tbl = PDF_add_table_cell($p, $tbl, $col, $row, "", $optlist);
if ($tbl == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/* ----- Rotated $image */
$col++;
$image = PDF_load_image($p, "auto", $imagefile, "");
if ($image == 0) {
die("Couldn't load $image: " . PDF_get_errmsg($p));
}
$optlist = "image=" . $image . " fitimage={orientate=west}";
$tbl = PDF_add_table_cell($p, $tbl, $col, $row, "", $optlist);
if ($tbl == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/* ----- Diagonal stamp */
$col++;
$optlist = "fittextline={font=" . $font . " fontsize=10 stamp=ll2ur}";
$tbl = PDF_add_table_cell($p, $tbl, $col, $row, "entry void", $optlist);
if ($tbl == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/* ---------- Fill $row 3 and above with their numbers */
for ($row++; $row <= $rowmax; $row++) {
for ($col = 1; $col <= $colmax; $col++) {
$num = "Col " . $col . "/Row " . $row;
$optlist = "colwidth=20% fittextline={font=" . $font . " fontsize=10}";
$tbl = PDF_add_table_cell($p, $tbl, $col, $row, $num, $optlist);
if ($tbl == 0) {
die("Error: " . PDF_get_errmsg($p));
}
}
}
/* ---------- Place the table on one or more pages ---------- */
/*
* Loop until all of the table is placed; create new pages
* as long as more table instances need to be placed.
*/
do {
PDF_begin_page_ext($p, 0, 0, "width=a4.width height=a4.height");
/* Shade every other $row; draw lines for all table cells.
* Add "showcells showborder" to visualize cell borders
*/
$optlist = "header=1 fill={{area=rowodd fillcolor={gray 0.9}}} " .
"stroke={{line=other}} ";
/* Place the table instance */
$result = PDF_fit_table($p, $tbl, $llx, $lly, $urx, $ury, $optlist);
if ($result == "_error") {
die("Couldn't place table: " . PDF_get_errmsg($p));
}
PDF_end_page_ext($p, "");
} while ($result == "_boxfull");
/* Check the $result; "_stop" means all is ok. */
if ($result != "_stop") {
if ($result == "_error") {
die("Error when placing table: " . PDF_get_errmsg($p));
} else {
/* Any other return value is a user exit caused by
* the "return" option; this requires dedicated code to
* deal with.
*/
die("User return found in Textflow");
}
}
/* This will also delete Textflow handles used in the table */
PDF_delete_table($p, $tbl, "");
PDF_end_document($p, "");
PDF_delete($p);
print "$outfilename generated";
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_basic.php 0000644 00000004704 15173135237 0020154 0 ustar 00 <?php
/* $Id: starter_basic.php,v 1.5 2006/10/02 19:22:45 rjs Exp $
*
* Basic starter:
* Create some simple text, vector graphics and image output
*
* required software: PDFlib Lite/PDFlib/PDFlib+PDI/PPS 7
* required data: none
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data/";
$imagefile = "nesrin.jpg";
$outfilename = "starter_basic.pdf";
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
/* we use "utf8" as textformat, this allows to use unicode encoding */
PDF_set_parameter($p, "textformat", "utf8");
if (PDF_begin_document($p, $outfilename, "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib starter sample");
PDF_set_info($p, "Title", "starter_basic");
/* We load the $image before the first page, and use it
* on all pages
*/
$image = PDF_load_image($p, "auto", $imagefile, "");
if ($image == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/* Page 1 */
PDF_begin_page_ext($p, 595, 842, "");
/* For PDFlib Lite: change "unicode" to "winansi" */
$font = PDF_load_font($p, "Helvetica-Bold", "unicode", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_setfont($p, $font, 24);
PDF_set_text_pos($p, 50, 700);
PDF_show($p, "Hello world!");
PDF_fit_image($p, $image, 0.0, 0.0, "scale=0.25");
PDF_end_page_ext($p, "");
/* Page 2 */
PDF_begin_page_ext($p, 595, 842, "");
/* red rectangle */
PDF_setcolor($p, "fill", "rgb", 1.0, 0.0, 0.0, 0.0);
PDF_rect($p, 200, 200, 250, 150);
PDF_fill($p);
/* blue circle */
PDF_setcolor($p, "fill", "rgb", 0.0, 0.0, 1.0, 0.0);
PDF_arc($p, 400, 600, 100, 0, 360);
PDF_fill($p);
/* thick gray line */
PDF_setcolor($p, "stroke", "gray", 0.5, 0.0, 0.0, 0.0);
PDF_setlinewidth($p, 10);
PDF_moveto($p, 100, 500);
PDF_lineto($p, 300, 700);
PDF_stroke($p);
/* Using the same $image handle means the data will be copied
* to the PDF only once, which saves space.
*/
PDF_fit_image($p, $image, 150.0, 25.0, "scale=0.25");
PDF_end_page_ext($p, "");
/* Page 3 */
PDF_begin_page_ext($p, 595, 842, "");
/* Fit the image to a box of predefined size (without distortion) */
$optlist = "boxsize={400 400} position={center} fitmethod=meet";
PDF_fit_image($p, $image, 100, 200, $optlist);
PDF_end_page_ext($p, "");
PDF_close_image($p, $image);
PDF_end_document($p, "");
PDF_delete($p);
print "$outfilename generated";
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_pcos.php 0000644 00000007400 15173135240 0020025 0 ustar 00 <?php
/* $Id: starter_pcos.php,v 1.6.2.1 2007/02/16 12:15:51 stm Exp $
*
* pCOS starter:
* Dump information from an existing PDF document
*
* required software: PDFlib+PDI/PPS 7
* required data: PDF input file
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$pdfinput = "TET-datasheet.pdf";
$docoptlist = "requiredmode=minimum";
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
/* We do not create any output document, so no call to
* begin_document() is required.
*/
/* Open the input document */
$doc = PDF_open_pdi_document($p, $pdfinput, $docoptlist);
if ($doc == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/* --------- general information (always available) */
$pcosmode = PDF_pcos_get_number($p, $doc, "pcosmode");
printf(" File name: %s\n",
PDF_pcos_get_string($p, $doc,"filename"));
printf(" PDF version: %s\n",
PDF_pcos_get_number($p, $doc, "pdfversion")/10);
printf(" Encryption: %s\n",
PDF_pcos_get_string($p, $doc, "encrypt/description"));
printf(" Master pw: %s\n",
((PDF_pcos_get_number($p, $doc, "encrypt/master") != 0) ? "yes":"no"));
printf(" User pw: %s\n",
((PDF_pcos_get_number($p, $doc, "encrypt/user") != 0) ? "yes" : "no"));
printf("Text copying: %s\n",
((PDF_pcos_get_number($p, $doc, "encrypt/nocopy") != 0) ? "no":"yes"));
printf(" Linearized: %s\n",
((PDF_pcos_get_number($p, $doc, "linearized") != 0) ? "yes" : "no"));
printf(" Tagged: %s\n\n",
((PDF_pcos_get_number($p, $doc, "tagged") != 0) ? "yes" : "no"));
if ($pcosmode == 0) {
printf("Minimum mode: no more information available\n\n");
PDF_delete($p);
exit(0);
}
/* --------- more details (requires at least user password) */
printf("No. of pages: %s\n",
PDF_pcos_get_number($p, $doc, "length:pages"));
printf(" Page 1 size: width=%.3f, height=%.3f\n",
PDF_pcos_get_number($p, $doc, "pages[0]/width"),
PDF_pcos_get_number($p, $doc, "pages[0]/height"));
$count = PDF_pcos_get_number($p, $doc, "length:fonts");
printf("No. of fonts: %s\n", $count);
for ($i=0; $i < $count; $i++) {
$fonts = "fonts[" . $i . "]/embedded";
if (PDF_pcos_get_number($p, $doc, $fonts) != 0)
print("embedded ");
else
print("unembedded ");
$fonts = "fonts[" . $i . "]/type";
print(PDF_pcos_get_string($p, $doc, $fonts) . " font ");
$fonts = "fonts[" . $i . "]/name";
printf("%s\n", PDF_pcos_get_string($p, $doc, $fonts));
}
printf("\n");
if ($pcosmode == 1) {
print(
"Restricted mode: no more information available");
PDF_delete($p);
exit(0);
}
/* ----- document $info keys and XMP metadata (requires master pw) */
$count = PDF_pcos_get_number($p, $doc, "length:/Info");
for ($i=0; $i < $count; $i++) {
$info = "type:/Info[" . $i . "]";
$objtype = PDF_pcos_get_string($p, $doc, $info);
$info = "/Info[" . $i . "].key";
$key = PDF_pcos_get_string($p, $doc, $info);
$len = 12 - strlen($key);
while ($len-- > 0) print(" ");
print($key . ": ");
/* $info entries can be stored as string or name objects */
if ($objtype == "name" || $objtype == "string") {
$info = "/Info[" . $i . "]";
printf("'" . PDF_pcos_get_string($p, $doc, $info) . "'\n");
} else {
$info = "type:/Info[" . $i . "]";
printf("(" . PDF_pcos_get_string($p, $doc, $info) . " object)\n");
}
}
print("\n" . "XMP meta data: ");
$objtype = PDF_pcos_get_string($p, $doc, "type:/Root/Metadata");
if ($objtype == "stream") {
$contents = PDF_pcos_get_stream($p, $doc, "", "/Root/Metadata");
print(strlen($contents) . " bytes \n");
printf("");
} else {
printf("not present");
}
PDF_close_pdi_document($p, $doc);
PDF_delete($p);
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_pdfmerge.php 0000644 00000003653 15173135240 0020660 0 ustar 00 <?php
/* $Id: starter_pdfmerge.php,v 1.5.2.1 2007/08/08 15:09:41 rp Exp $
*
* PDF merge starter:
* Merge pages from multiple PDF documents; interactive elements (e.g.
* bookmarks) will be dropped.
*
* required software: PDFlib+PDI/PPS 7
* required data: PDF documents
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$outfilename = "starter_pdfmerge.pdf";
$pdffiles = array(
"PDFlib-real-world.pdf",
"PDFlib-datasheet.pdf",
"TET-datasheet.pdf",
"PLOP-datasheet.pdf",
"pCOS-datasheet.pdf"
);
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
if (PDF_begin_document($p, $outfilename, "") == 0)
die("Error: " . PDF_get_errmsg($p));
PDF_set_info($p, "Creator", "PDFlib starter sample");
PDF_set_info($p, "Title", "starter_pdfmerge");
foreach ($pdffiles as $pdffile) {
/* Open the input PDF */
$indoc = PDF_open_pdi_document($p, $pdffile, "");
if ($indoc == 0) {
printf("Error: %s\n", PDF_get_errmsg($p));
continue;
}
$endpage = PDF_pcos_get_number($p, $indoc, "/Root/Pages/Count");
/* Loop over all pages of the input document */
for ($pageno = 1; $pageno <= $endpage; $pageno++) {
$page = PDF_open_pdi_page($p, $indoc, $pageno, "");
if ($page == 0) {
printf("Error: %s\n", PDF_get_errmsg($p));
continue;
}
/* Dummy $page size; will be adjusted later */
PDF_begin_page_ext($p, 10, 10, "");
/* Create a bookmark with the file name */
if ($pageno == 1) {
PDF_create_bookmark($p, $pdffile, "");
}
/* Place the imported $page on the output $page, and
* adjust the $page size
*/
PDF_fit_pdi_page($p, $page, 0, 0, "adjustpage");
PDF_close_pdi_page($p, $page);
PDF_end_page_ext($p, "");
}
PDF_close_pdi_document($p, $indoc);
}
PDF_end_document($p, "");
PDF_delete($p);
print "$outfilename generated";
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_pdfx.php 0000644 00000004375 15173135240 0020032 0 ustar 00 <?php
/* $Id: starter_pdfx.php,v 1.7 2006/10/02 19:22:45 rjs Exp $
*
* PDF/X starter:
* Create PDF/X-compliant output
*
* required software: PDFlib/PDFlib+PDI/PPS 7
* required data: font file, image file, icc profile
* (see www.pdflib.com for ICC profiles)
*/
/* This is where the data files are. Adjust as necessary.*/
$searchpath = "../data";
$imagefile = "nesrin.jpg";
$outfilename = "starter_pdfx.pdf";
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
/* we use "utf8" as textformat, this allows to use unicode encoding */
PDF_set_parameter($p, "textformat", "utf8");
if (PDF_begin_document($p, $outfilename, "pdfx=PDF/X-3:2002") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib starter sample");
PDF_set_info($p, "Title", "starter_pdfx");
/*
* You can use one of the Standard output intents (e.g. for SWOP
* printing) which do not require an ICC profile:
PDF_load_iccprofile($p, "CGATS TR 001", "usage=outputintent");
* However, if you use ICC or Lab color you must load an ICC
* profile as output intent:
*/
if (PDF_load_iccprofile($p, "ISOcoated.icc", "usage=outputintent") == -1) {
printf("Error: %s\n", PDF_get_errmsg($p));
printf("Please install the ICC profile package from " .
"www.pdflib.com to run the PDF/X starter sample.\n");
PDF_delete(p);
return(2);
}
PDF_begin_page_ext($p, 595, 842, "");
/* $font embedding is required for PDF/X */
$font = PDF_load_font($p, "LuciduxSans-Oblique", "unicode", "embedding");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_setfont($p, $font, 24);
$spot = PDF_makespotcolor($p, "PANTONE 123 C");
PDF_setcolor($p, "fill", "spot", $spot, 1.0, 0.0, 0.0);
PDF_fit_textline($p, "PDF/X-3:2002 starter", 50, 700, "");
/* The RGB $image below needs an $icc profile; we use sRGB. */
$icc = PDF_load_iccprofile($p, "sRGB", "");
$image = PDF_load_image($p, "auto", $imagefile, "iccprofile=" . $icc);
if ($image == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_fit_image($p, $image, 0.0, 0.0, "scale=0.5");
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
PDF_delete($p);
print "$outfilename generated";
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_textflow.php 0000644 00000007026 15173135241 0020742 0 ustar 00 <?php
/* $Id: starter_textflow.php,v 1.6 2006/10/02 21:11:38 tm Exp $
*
* Textflow starter:
* Create multi-column text output which may span multiple pages
*
* required software: PDFlib/PDFlib+PDI/PPS 7 or above
* required data: none
*/
$outfilename = "starter_textflow.pdf";
$tf = 0;
$llx1= 50; $lly1=50; $urx1=250; $ury1=800;
$llx2=300; $lly2=50; $urx2=500; $ury2=800;
/* Repeat the dummy text to produce more contents */
$count = 50;
$optlist1 = "fontname=Helvetica fontsize=10.5 encoding=unicode " .
"fillcolor={gray 0} alignment=justify";
$optlist2 = "fontname=Helvetica-Bold fontsize=14 encoding=unicode " .
"fillcolor={rgb 1 0 0} charref";
/* Dummy text for filling the columns. Soft hyphens are marked with
* the character reference "­" (character references are
* enabled by the charref option).
*/
$text=
"Lorem ipsum dolor sit amet, consectetur adi­pi­sicing elit, sed do eius­mod tempor incidi­dunt ut labore et dolore magna ali­qua. Ut enim ad minim ve­niam, quis nostrud exer­citation ull­amco la­bo­ris nisi ut ali­quip ex ea commodo con­sequat. Duis aute irure dolor in repre­henderit in voluptate velit esse cillum dolore eu fugiat nulla pari­atur. Excep­teur sint occae­cat cupi­datat non proident, sunt in culpa qui officia dese­runt mollit anim id est laborum. ";
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
/* we use "utf8" as textformat, this allows to use unicode encoding */
PDF_set_parameter($p, "textformat", "utf8");
if (PDF_begin_document($p, $outfilename, "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib starter sample");
PDF_set_info($p, "Title", "starter_textflow");
/* Create some amount of dummy text and feed it to a Textflow
* object with alternating options.
*/
for ($i=1; $i<=$count; $i++) {
$num = $i . " ";
$tf = PDF_add_textflow($p, $tf, $num, $optlist2);
if ($tf == 0)
die("Error: " . PDF_get_errmsg($p));
$tf = PDF_add_textflow($p, $tf, $text, $optlist1);
if ($tf == 0)
die("Error: " . PDF_get_errmsg($p));
}
/* Loop until all of the text is placed; create new pages
* as long as more text needs to be placed. Two columns will
* be created on all pages.
*/
do {
/* Add "showborder to visualize the fitbox borders */
$optlist = "verticalalign=justify linespreadlimit=120% ";
PDF_begin_page_ext($p, 0, 0, "width=a4.width height=a4.height");
/* Fill the first column */
$result = PDF_fit_textflow($p, $tf, $llx1, $lly1, $urx1, $ury1, $optlist);
/* Fill the second column if we have more text*/
if ($result != "_stop") {
$result = PDF_fit_textflow($p, $tf,
$llx2, $lly2, $urx2, $ury2, $optlist);
}
PDF_end_page_ext($p, "");
/* "_boxfull" means we must continue because there is more text;
* "_nextpage" is interpreted as "start new column"
*/
} while ($result == "_boxfull" || $result == "_nextpage");
/* Check for errors */
if (!$result == "_stop") {
/* "_boxempty" happens if the box is very small and doesn't
* hold any text at all.
*/
if ($result == "_boxempty") {
die("Error: Textflow box too small");
} else {
/* Any other return value is a user exit caused by
* the "return" option; this requires dedicated code to
* deal with.
*/
die("User return '" . $result . "' found in Textflow");
}
}
PDF_delete_textflow($p, $tf);
PDF_end_document($p, "");
PDF_delete($p);
print "$outfilename generated";
?>
usr/share/doc/alt-pdflib-lite/examples/php/chartab.php 0000644 00000005333 15173135241 0016725 0 ustar 00 <?php
/* $Id: chartab.php,v 1.14 2006/10/01 20:33:35 rjs Exp $
*
* PDFlib client: chartab example in PHP
*/
/* change these as required */
$fontname = "LuciduxSans-Oblique";
/* This is where font/image/PDF input files live. Adjust as necessary. */
$searchpath = "../data";
/* list of encodings to use */
$encodings = array( "iso8859-1", "iso8859-2", "iso8859-15" );
/* whether or not to embed the font */
$embed = 1;
define("FONTSIZE", 16);
define("TOP", 700);
define("LEFT", 50);
define("YINCR", 2*FONTSIZE);
define("XINCR", 2*FONTSIZE);
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
/* This line is required to avoid problems on Japanese systems */
PDF_set_parameter($p, "hypertextencoding", "winansi");
/* open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "destination {type fitwindow page 1}") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "chartab.php");
PDF_set_info($p, "Author", "Thomas Merz");
PDF_set_info($p, "Title", "Character table (PHP)");
/* loop over all encodings */
for ($page = 0; $page < count($encodings); $page++) {
PDF_begin_page_ext($p, 595, 842, "");
/* print the heading and generate the bookmark */
$font = PDF_load_font($p, "Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_setfont($p, $font, FONTSIZE);
$buf = sprintf("%s (%s) %sembedded",
$fontname, $encodings[$page], $embed ? "" : "not ");
PDF_show_xy($p, $buf, LEFT - XINCR, TOP + 3 * YINCR);
PDF_create_bookmark($p, $buf, "");
/* print the row and column captions */
PDF_setfont($p, $font, 2 * FONTSIZE/3);
for ($row = 0; $row < 16; $row++) {
$buf = sprintf("x%X", $row);
PDF_show_xy($p, $buf, LEFT + $row*XINCR, TOP + YINCR);
$buf = sprintf("%Xx", $row);
PDF_show_xy($p, $buf, LEFT - XINCR, TOP - $row * YINCR);
}
/* print the character table */
$font = PDF_load_font($p, $fontname, $encodings[$page],
$embed ? "embedding": "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_setfont($p, $font, FONTSIZE);
$y = TOP;
$x = LEFT;
for ($row = 0; $row < 16; $row++) {
for ($col = 0; $col < 16; $col++) {
$buf = sprintf("%c", 16*$row + $col);
PDF_show_xy($p, $buf, $x, $y);
$x += XINCR;
}
$x = LEFT;
$y -= YINCR;
}
PDF_end_page_ext($p, "");
}
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
PDF_delete($p);
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_layer.php 0000644 00000007520 15173135241 0020201 0 ustar 00 <?php
# $Id: starter_layer.php,v 1.1.2.2 2008/02/11 20:10:28 rjs Exp $
# Starter layer:
# Define several layers, output images and text to them and define
# particular layers to be visible when opening the document
#
# Define two layers for RGB or Grayscale images and two layers for English or
# German image captions. Output images and text on the various layers and
# open the document with the RGB images and English captions visible.
#
# Required software: PDFlib/PDFlib+PDI/PPS 7
# Required data: grayscale and RGB images
#
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "Starter Layer";
# create a new PDFlib object
$p = PDF_new();
$rgb = "nesrin.jpg";
$gray = "nesrin_gray.jpg";
PDF_set_parameter($p, "SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
# Open the document with the "Layers" navigation tab visible
if (PDF_begin_document($p, "", "openmode=layers") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.2 $';
PDF_set_info($p, "Title", $buf);
# Load the font
$font = PDF_load_font($p, "Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Load the Grayscale image
$imageGray = PDF_load_image($p, "auto", $gray, "");
if ($imageGray == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Load the RGB image
$imageRGB = PDF_load_image($p, "auto", $rgb, "");
if ($imageRGB == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Define all layers which will be used, and their relationships.
# This should be done before the first page if the layers are
# used on more than one page.
#
# Define the layer "RGB"
$layerRGB = PDF_define_layer($p, "RGB", "");
# Define the layer "Grayscale" which is hidden when opening the
# document or printing it.
$layerGray = PDF_define_layer($p, "Grayscale",
"initialviewstate=false initialprintstate=false");
# At most one of the "Grayscale" and "RGB" layers should be visible
$buf = "group={" . $layerGray . " " . $layerRGB . "}";
PDF_set_layer_dependency($p, "Radiobtn", $buf);
# Define the layer "English"
$layerEN = PDF_define_layer($p, "English", "");
# Define the layer "German" which is hidden when opening the document
# or printing it.
$layerDE = PDF_define_layer($p, "German",
"initialviewstate=false initialprintstate=false");
# At most one of the "English" and "German" layers should be visible
$buf = "group={" . $layerEN . " " . $layerDE . "}";
PDF_set_layer_dependency($p, "Radiobtn", $buf);
# Start page
PDF_begin_page_ext($p, 0, 0, "width=a4.width height=a4.height");
# Place the RGB image on the layer "RGB"
PDF_begin_layer($p, $layerRGB);
PDF_fit_image($p, $imageRGB, 100, 400,
"boxsize={400 300} fitmethod=meet");
# Place the Grayscale image on the layer "Grayscale"
PDF_begin_layer($p, $layerGray);
PDF_fit_image($p, $imageGray, 100, 400,
"boxsize={400 300} fitmethod=meet");
# Place an English image caption on the layer "English"
PDF_begin_layer($p, $layerEN);
$buf = "font=" . $font . " fontsize=20";
PDF_fit_textline($p, "This is the Nesrin image.", 100, 370, $buf);
# Place a German image caption on the layer "German".
PDF_begin_layer($p, $layerDE);
$buf = "font=" . $font . " fontsize=20";
PDF_fit_textline($p, "Das ist das Nesrin-Bild.", 100, 370, $buf);
PDF_end_layer($p);
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_graphics.php 0000644 00000016555 15173135241 0020675 0 ustar 00 <?php
#!/usr/bin/perl
# $Id: starter_graphics.php,v 1.1.2.1 2007/12/29 23:26:05 rjs Exp $
# Starter Graphics:
# Create some basic examples of vector graphics
#
# Stroke a line, curve, circle, arc, and rectangle using the current line width
# and stroke color. Stroke and fill a rectangle.
# Draw an arc segment by drawing a line and an arc, closing the path and
# filling and stroking it.
# Draw a rectangle and use it as the clipping a path. Draw and fill a circle
# using the clipping path defined.
#
# Required software: PDFlib Lite/PDFlib/PDFlib+PDI/PPS 7
# Required data: none
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "Starter Graphics";
# create a new PDFlib object
$p = PDF_new();
$xt=20;
$x = 210;
$y=770;
$dy=90;
PDF_set_parameter($p, "SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.1 $';
PDF_set_info($p, "Title", $buf);
# Load the font; for PDFlib Lite: change "unicode" to "winansi"
$font = PDF_load_font($p, "Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Start an A4 page
PDF_begin_page_ext($p, 0, 0, "width=a4.width height=a4.height");
# Set the font
PDF_setfont($p, $font, 14);
# Set the line width
PDF_setlinewidth($p, 2.0);
# Set the stroke color
PDF_setcolor($p, "stroke", "rgb", 0.0, 0.5, 0.5, 0.0);
# Set the fill color
PDF_setcolor($p, "fill", "rgb", 0.0, 0.85, 0.85, 0.0);
# -------------
# Stroke a line
# -------------
# Set the current point for graphics output
PDF_moveto($p, $x, $y);
# Draw a line from the current point to the supplied point
PDF_lineto($p, $x+300, $y+50);
# Stroke the path using the current line width and stroke color, and
# clear it
PDF_stroke($p);
# Output some descriptive black text
PDF_fit_textline($p, "lineto() and stroke()", $xt, $y,
"fillcolor={gray 0}");
# --------------
# Stroke a curve
# --------------
# Set the current point for graphics output
PDF_moveto($p, $x, $y-=$dy);
# Draw a B�zier curve from the current point to (x3, y3), using three
# control points
PDF_curveto($p, $x+50, $y+40, $x+200, $y+80, $x+300, $y+30);
# Stroke the path using the current line width and stroke color, and
# clear it
PDF_stroke($p);
# Output some descriptive black text
PDF_fit_textline($p, "curveto() and stroke()", $xt, $y,
"fillcolor={gray 0}");
# ---------------
# Stroke a circle
# ---------------
# Draw a circle at position (x, y) with a radius of 40
PDF_circle($p, $x, $y-=$dy, 40);
# Stroke the path using the current line width and stroke color, and
# clear it
PDF_stroke($p);
# Output some descriptive black text
PDF_fit_textline($p, "circle() and stroke()", $xt, $y,
"fillcolor={gray 0}");
# ---------------------
# Stroke an arc segment
# ---------------------
# Draw an arc segment counterclockwise at position (x, y) with a radius
# of 40 starting at an angle of 90 degrees and ending at 180 degrees
PDF_arc($p, $x, $y-=$dy+20, 40, 90, 180);
# Stroke the path using the current line width and stroke color, and
# clear it
PDF_stroke($p);
# Output some descriptive black text
PDF_fit_textline($p, "arc() and stroke()", $xt, $y,
"fillcolor={gray 0}");
# ------------------
# Stroke a rectangle
# ------------------
# Draw a rectangle at position (x, y) with a width of 200 and a height
# of 50
PDF_rect($p, $x, $y-=$dy, 200, 50);
# Stroke the path using the current line width and stroke color, and
# clear it
PDF_stroke($p);
# Output some descriptive black text
PDF_fit_textline($p, "rect() and stroke()", $xt, $y,
"fillcolor={gray 0}");
# ----------------
# Fill a rectangle
# ----------------
# Draw a rectangle at position (x, y) with a width of 200 and a height
# of 50
PDF_rect($p, $x, $y-=$dy, 200, 50);
# Fill the path using current fill color, and clear it
PDF_fill($p);
# Output some descriptive black text
PDF_fit_textline($p, "rect() and fill()", $xt, $y,
"fillcolor={gray 0}");
# ---------------------------
# Fill and stroke a rectangle
# ---------------------------
# Draw a rectangle at position (x, y) with a width of 200 and a height
# of 50
PDF_rect($p, $x, $y-=$dy, 200, 50);
# Fill and stroke the path using the current line width, fill color,
# and stroke color, and clear it
PDF_fill_stroke($p);
# Output some descriptive black text
PDF_fit_textline($p, "rect() and fill_stroke()", $xt, $y,
"fillcolor={gray 0}");
# -------------------------------------------------------------
# Draw a line and an arc, close the path and fill and stroke it
# -------------------------------------------------------------
# Set the current point for graphics output
PDF_moveto($p, $x-40, $y-=$dy);
# Draw a line from the current point to the supplied point
PDF_lineto($p, $x, $y);
# Draw an arc segment counterclockwise at position (x, y) with a radius
# of 40 starting at an angle of 90 degrees and ending at 180 degrees
PDF_arc($p, $x, $y, 40, 90, 180);
# Close the path and stroke and fill it, i.e. close the current subpath
# (add a straight line segment from the current point to the starting
# point of the path), and stroke and fill the complete current path
PDF_closepath_fill_stroke($p);
# Output some descriptive black text
PDF_fit_textline($p, "lineto(), arc(), and", $xt, $y+20,
"fillcolor={gray 0}");
PDF_fit_textline($p, "closepath_fill_stroke()", $xt, $y,
"fillcolor={gray 0}");
# -----------------------------------------------------------------
# Draw a rectangle and use it as the clipping a path. Draw and fill
# a circle and clip it according to the clipping path defined.
# -----------------------------------------------------------------
# Save the current graphics state including the current clipping
# path which is set to the entire page by default
PDF_save($p);
# Draw a rectangle at position (x, y) with a width of 200 and a height
# of 50
PDF_rect($p, $x, $y-=$dy, 200, 50);
# Use the current path as the clipping path for subsequent operations
PDF_clip($p);
# Draw a circle at position (x, y) with a radius of 100
PDF_circle($p, $x, $y, 80);
# Fill the path with the current fill color and clear it
PDF_fill($p);
# Restore the graphics state which has been saved above
PDF_restore($p);
# Output some descriptive black text
PDF_fit_textline($p, "rect(), clip(),", $xt, $y+20,
"fillcolor={gray 0}");
PDF_fit_textline($p, "circle(), and fill()", $xt, $y,
"fillcolor={gray 0}");
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_3d.php 0000644 00000004421 15173135241 0017370 0 ustar 00 <?php
/* $Id: starter_3d.php,v 1.1.2.1 2008/02/22 15:50:40 rjs Exp $
* 3D Starter:
* Create a 3D model and load it into a U3D annotation.
*
* Define a 3D view and load some 3D data with the view defined. Then create
* an annotation containing the loaded 3D data with the defined 3D view as the
* initial view.
*
* Acrobat 7.07 or above is required for viewing PDF documents containing a
* 3D model.
*
* Required software: PDFlib/PDFlib+PDI/PPS 7.0.1
* Required data: U3D data file
*/
# This is where the data files are. Adjust if necessary.
$searchpath = "../data";
$outfile = "starter_3d.pdf";
# Required minimum PDFlib version
$requiredversion = 701;
$requiredvstr = "7.0.1";
$p = PDF_new();
PDF_set_parameter($p, "SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
# Check whether the required minimum PDFlib version is available
$major = PDF_get_value($p, "major", 0);
$minor = PDF_get_value($p, "minor", 0);
$revision = PDF_get_value($p, "revision", 0);
if ($major*100 + $minor*10 + $revision < $requiredversion) {
die("Error: PDFlib " . $requiredvstr . " or above is required\n");
}
# Start the document
if (PDF_begin_document($p, $outfile, "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib Cookbook");
PDF_set_info($p, "Title", "starter_3d");
$font = PDF_load_font($p, "Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_begin_page_ext($p, 0, 0, "width=a4.width height=a4.height");
# Define a U3D view
$optlist = "name=FirstView background={fillcolor={rgb 1 0.5 0.1}}";
if (($u3dview = PDF_create_3dview($p, "First view", $optlist)) == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Load some U3D data with the view defined above
$buf = "views={$u3dview}";
if (($u3ddata = PDF_load_3ddata($p, "box.u3d", $buf)) == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Create an annotation containing the loaded U3D data with the
# defined 3D view as the initial view
#
$buf = "name=annot usercoordinates contents=U3D 3ddata=$u3ddata 3dactivate={enable=open} 3Dinitialview=$u3dview";
PDF_create_annotation($p, 116, 400, 447, 580, "3D", $buf);
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
PDF_delete($p);
?>
usr/share/doc/alt-pdflib-lite/examples/php/hello.php 0000644 00000002270 15173135241 0016421 0 ustar 00 <?php
/* $Id: hello.php,v 1.15 2006/10/01 20:33:35 rjs Exp $
*
* PDFlib client: hello example in PHP
*/
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
/* This line is required to avoid problems on Japanese systems */
PDF_set_parameter($p, "hypertextencoding", "winansi");
/* open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "hello.php");
PDF_set_info($p, "Author", "Rainer Schaaf");
PDF_set_info($p, "Title", "Hello world (PHP)!");
PDF_begin_page_ext($p, 595, 842, "");
$font = PDF_load_font($p, "Helvetica-Bold", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_setfont($p, $font, 24.0);
PDF_set_text_pos($p, 50, 700);
PDF_show($p, "Hello world!");
PDF_continue_text($p, "(says PHP)");
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
PDF_delete($p);
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_pvf.php 0000644 00000004775 15173135241 0017671 0 ustar 00 <?php
#!/usr/bin/perl
# $Id: starter_pvf.php,v 1.1.2.1 2007/12/29 23:26:05 rjs Exp $
# PDFlib Virtual File system (PVF):
# Create a PVF file which holds an image or PDF, and import the data from the
# PVF file
#
# This avoids disk access and is especially useful when the same image or PDF
# is imported multiply. For examples, images which sit in a database don't
# have to be written and re-read from disk, but can be passed to PDFlib
# directly in memory. A similar technique can be used for loading other data
# such as fonts, ICC profiles, etc.
#
# Required software: PDFlib Lite/PDFlib/PDFlib+PDI/PPS 7
# Required data: image file
#
# Helper function to read the content of a file into a buffer
# avoids incompatible systemcalls
function read_file($fname)
{
$fp = fopen($fname, "r");
$data = fread ($fp, filesize($fname));
fclose($fp);
return $data;
} # read_file
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "PDFlib Virtual File System";
# create a new PDFlib object
$p = PDF_new();
PDF_set_parameter($p, "SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
# Set an output path according to the name of the topic
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.1 $';
PDF_set_info($p, "Title", $buf);
# We just read some image data from a file; to really benefit
# from using PVF read the data from a Web site or a database instead
$imagedata = read_file("../data/PDFlib-logo.tif");
PDF_create_pvf($p, "/pvf/image", $imagedata, "");
# Load the image from the PVF
$image = PDF_load_image($p, "auto", "/pvf/image", "");
if ($image == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Fit the image on page 1
PDF_begin_page_ext($p, 595, 842, "");
PDF_fit_image($p, $image, 350, 750, "");
PDF_end_page_ext($p, "");
# Fit the image on page 2
PDF_begin_page_ext($p, 595, 842, "");
PDF_fit_image($p, $image, 350, 50, "");
PDF_end_page_ext($p, "");
# Delete the virtual file to free the allocated memory
PDF_delete_pvf($p, "/pvf/image");
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_image.php 0000644 00000013363 15173135242 0020152 0 ustar 00 <?php
# $Id: starter_image.php,v 1.1.2.1 2007/12/29 23:26:05 rjs Exp $
# Starter image:
# Load and place an image using various options for scaling and positioning
#
# Place the image it its original size.
# Place the image with scaling and orientation to the west.
# Fit the image into a box with clipping.
# Fit the image into a box with proportional resizing.
# Fit the image into a box entirely.
#
# Required software: PDFlib Lite/PDFlib/PDFlib+PDI/PPS 7
# Required data: image file
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "Starter Image";
# create a new PDFlib object
$p = PDF_new();
$imagefile = "lionel.jpg";
$bw = 400;
$bh = 200;
$x = 20;
$y = 580;
$yoffset = 260;
PDF_set_parameter($p, "SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.1 $';
PDF_set_info($p, "Title", $buf);
# For PDFlib Lite: change "unicode" to "winansi"
$font = PDF_load_font($p, "Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Load the image
$image = PDF_load_image($p, "auto", $imagefile, "");
if ($image == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Start page 1
PDF_begin_page_ext($p, 0, 0, "width=a4.width height=a4.height");
PDF_setfont($p, $font, 12);
# ------------------------------------
# Place the image in its original size
# ------------------------------------
# Position the image in its original size with its lower left corner
# at the reference point (20, 380)
PDF_fit_image($p, $image, 20, 380, "");
# Output some descriptive text
PDF_fit_textline($p,
"The image is placed with the lower left corner in its original " .
"size at reference point (20, 380):", 20, 820, "");
PDF_fit_textline($p, "fit_image(image, 20, 380, \"\");", 20, 800, "");
# --------------------------------------------------------
# Place the image with scaling and orientation to the west
# --------------------------------------------------------
# Position the image with its lower right corner at the reference
# point (580, 20).
# "scale=0.5" scales the image by 0.5.
# "orientate=west" orientates the image to the west.
PDF_fit_image($p, $image, 580, 20,
"scale=0.5 position={right bottom} orientate=west");
# Output some descriptive text
PDF_fit_textline($p,
"The image is placed with a scaling of 0.5 and an orientation to " .
"the west with the lower right corner", 580, 320,
"position={right bottom}");
PDF_fit_textline($p,
" at reference point (580, 20): fit_image(image, 580, 20, " .
"\"scale=0.5 orientate=west position={right bottom}\");",
580, 300, "position={right bottom}");
PDF_end_page_ext($p, "");
# Start page 2
PDF_begin_page_ext($p, 0, 0, "width=a4.width height=a4.height");
PDF_setfont($p, $font, 12);
# --------------------------------------
# Fit the image into a box with clipping
# --------------------------------------
# The "boxsize" option defines a box with a given width and height and
# its lower left corner located at the reference point.
# "position={right top}" positions the image on the top right of the
# box.
# "fitmethod=clip" clips the image to fit it into the box.
$buf = "boxsize={" . $bw . " " . $bh .
"} position={right top} fitmethod=clip";
PDF_fit_image($p, $image, $x, $y, $buf);
# Output some descriptive text
PDF_fit_textline($p,
"fit_image(image, x, y, \"boxsize={400 200} position={right top} " .
"fitmethod=clip\");", 20, $y+$bh+10, "");
# ---------------------------------------------------
# Fit the image into a box with proportional resizing
# ---------------------------------------------------
# The "boxsize" option defines a box with a given width and height and
# its lower left corner located at the reference point.
# "position={center}" positions the image in the center of the
# box.
# "fitmethod=meet" resizes the image proportionally until its height
# or width completely fits into the box.
# The "showborder" option is used to illustrate the borders of the box.
$buf = "boxsize={" . $bw . " " . $bh .
"} position={center} fitmethod=meet showborder";
PDF_fit_image($p, $image, $x, $y-=$yoffset, $buf);
# Output some descriptive text
PDF_fit_textline($p,
"fit_image(image, x, y, \"boxsize={400 200} position={center} " .
"fitmethod=meet showborder\");", 20, $y+$bh+10, "");
# ---------------------------------
# Fit the image into a box entirely
# ---------------------------------
# The "boxsize" option defines a box with a given width and height and
# its lower left corner located at the reference point.
# By default, the image is positioned in the lower left corner of the
# box.
# "fitmethod=entire" resizes the image proportionally until its height
# or width completely fits into the box.
$buf = "boxsize={" . $bw . " " . $bh . "} fitmethod=entire";
PDF_fit_image($p, $image, $x, $y-=$yoffset, $buf);
# Output some descriptive text
PDF_fit_textline($p,
"fit_image(image, x, y, \"boxsize={400 200} fitmethod=entire\");",
20, $y+$bh+10, "");
PDF_end_page_ext($p, "");
PDF_close_image($p, $image);
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
?>
usr/share/doc/alt-pdflib-lite/examples/php/image.php 0000644 00000002547 15173135242 0016410 0 ustar 00 <?php
/* $Id: image.php,v 1.14 2006/10/01 20:33:35 rjs Exp $
*
* PDFlib client: image example in PHP
*/
/* This is where font/image/PDF input files live. Adjust as necessary. */
$searchpath = "../data";
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
/* This line is required to avoid problems on Japanese systems */
PDF_set_parameter($p, "hypertextencoding", "winansi");
/* open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "image.php");
PDF_set_info($p, "Author", "Rainer Schaaf");
PDF_set_info($p, "Title", "image sample (PHP)");
$imagefile = "nesrin.jpg";
$image = PDF_load_image($p, "auto", $imagefile, "");
if (!$image) {
die("Error: " . PDF_get_errmsg($p));
}
/* dummy page size, will be adjusted by PDF_fit_image() */
PDF_begin_page_ext($p, 10, 10, "");
PDF_fit_image($p, $image, 0, 0, "adjustpage");
PDF_close_image($p, $image);
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=image.pdf");
print $buf;
PDF_delete($p);
?>
usr/share/doc/alt-pdflib-lite/examples/php/quickreference.php 0000644 00000004473 15173135242 0020321 0 ustar 00 <?php
/* $Id: quickreference.php,v 1.19 2006/10/01 20:33:35 rjs Exp $
*
* PDFlib+PDI client: mini imposition demo
*/
$infile = "reference.pdf";
/* This is where font/image/PDF input files live. Adjust as necessary. */
$searchpath = "../data";
$maxrow = 2;
$maxcol = 2;
$width = 500.0;
$height = 770.0;
$endpage = 0;
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
/* This line is required to avoid problems on Japanese systems */
PDF_set_parameter($p, "hypertextencoding", "winansi");
/* open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "quickreference.php");
PDF_set_info($p, "Author", "Thomas Merz");
PDF_set_info($p, "Title", "mini imposition demo (php)");
$manual = PDF_open_pdi($p, $infile, "", 0);
if (!$manual) {
die("Error: " . PDF_get_errmsg($p));
}
$row = 0;
$col = 0;
PDF_set_parameter($p, "topdown", "true");
$endpage = PDF_pcos_get_number($p, $manual, "length:pages");
for ($pageno = 1; $pageno <= $endpage; $pageno++) {
if ($row == 0 && $col == 0) {
PDF_begin_page_ext($p, $width, $height, "");
$font = PDF_load_font($p, "Helvetica-Bold", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_setfont($p, $font, 18);
PDF_set_text_pos($p, 24, 24);
PDF_show($p, "PDFlib Quick Reference");
}
$page = PDF_open_pdi_page($p, $manual, $pageno, "");
if (!$page) {
die("Error: " . PDF_get_errmsg($p));
}
$optlist = sprintf("scale %f", 1/$maxrow);
PDF_fit_pdi_page($p, $page,
$width/$maxcol*$col, ($row + 1) * $height/$maxrow, $optlist);
PDF_close_pdi_page($p, $page);
$col++;
if ($col == $maxcol) {
$col = 0;
$row++;
}
if ($row == $maxrow) {
$row = 0;
PDF_end_page_ext($p, "");
}
}
/* finish the last partial page */
if ($row != 0 || $col != 0) {
PDF_end_page_ext($p, "");
}
PDF_end_document($p, "");
PDF_close_pdi($p, $manual);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=quickreference_php.pdf");
print $buf;
PDF_delete($p);
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_block.php 0000644 00000005351 15173135242 0020160 0 ustar 00 <?
/* $Id: starter_block.php,v 1.4.2.1 2008/05/09 10:11:54 rjs Exp $
*
* Block starter:
* Import a PDF page containing, and process all blocks. The blocks are
* retrieved via pCOS, and the block filling functions are used to
* visualize the blocks on the output page. A real-world application would
* of course fill the blocks with data retrieved from some external data
* source.
*
* required software: PPS 7 or above
* required data: input PDF
*/
/* This is where the data files are. Adjust as necessary. */
$searchpath = "../data";
$infile = "boilerplate.pdf";
$outfilename = "starter_block.pdf";
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
/* we use "utf8" as textformat, this allows to use unicode encoding */
PDF_set_parameter($p, "textformat", "utf8");
if (PDF_begin_document($p, $outfilename, "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib starter sample");
PDF_set_info($p, "Title", "starter_block");
/* Open a PDF containing blocks */
$indoc = PDF_open_pdi_document($p, $infile, "");
if ($indoc == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/* Open the first $page */
$page = PDF_open_pdi_page($p, $indoc, 1, "");
if ($page == 0) {
die("Error: " . PDF_get_errmsg($p));
}
$width = PDF_pcos_get_number($p, $indoc, "pages[0]/width");
$height = PDF_pcos_get_number($p, $indoc, "pages[0]/height");
PDF_begin_page_ext($p, $width, $height, "");
/* Place the imported $page on the output $page */
PDF_fit_pdi_page($p, $page, 0, 0, "");
/* Query the number of blocks on the first page */
$blockcount = PDF_pcos_get_number($p, $indoc, "length:pages[0]/blocks");
if ($blockcount == 0) {
die("Error: " . $infile . "does not contain any PDFlib blocks");
}
/* Loop over all blocks on the $page */
for ($i = 0; $i < $blockcount; $i++) {
/* Fetch the name and type of the $i-th block on the first page
* (one of Text/Image/PDF)
*/
$blockname = PDF_pcos_get_string($p, $indoc,
"pages[0]/blocks[" . $i . "]/Name");
$blocktype = PDF_pcos_get_string($p, $indoc,
"pages[0]/blocks[" . $i . "]/Subtype");
/* Visualize all text blocks */
if ($blocktype == "Text") {
$optlist = "fontname=Helvetica encoding=unicode " .
"fillcolor={rgb 1 0 0} " .
"bordercolor={gray 0} linewidth=0.25";
/* We simply use the $blockname as content */
if (PDF_fill_textblock($p,
$page, $blockname, $blockname, $optlist) == 0) {
print("Warning: " . PDF_get_errmsg($p));
}
}
}
PDF_end_page_ext($p, "");
PDF_close_pdi_page($p, $page);
PDF_end_document($p, "");
PDF_close_pdi_document($p, $indoc);
PDF_delete($p);
print "$outfilename generated";
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_webform.php 0000644 00000004175 15173135242 0020532 0 ustar 00 <?php
/* $Id: starter_webform.php,v 1.5 2006/10/02 19:22:45 rjs Exp $
*
* Webform starter:
* create a linearized PDF (for fast delivery over the Web, also known
* as "fast Web view") which is encrypted and contains some form fields.
* A few lines of JavaScript are inserted as "page open" action to
* automatically populate the date field with the current date.
*
* required software: PDFlib/PDFlib+PDI/PPS 7
* required data: none
*/
$outfilename = "starter_webform.pdf";
$llx=150; $lly=550; $urx=350; $ury=575;
/* JavaScript for automatically filling the date into a form field */
$js = "var d = util.printd(\"mm/dd/yyyy\", new Date());" .
"var date = this.getField(\"date\");" .
"date.value = d;";
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
/* Prevent changes with a master password */
$optlist = "linearize masterpassword=pdflib permissions={nomodify}";
if (PDF_begin_document($p, $outfilename, $optlist) == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib starter sample");
PDF_set_info($p, "Title", "starter_webform");
$optlist = "script={" . $js . "}";
$action = PDF_create_action($p, "JavaScript", $optlist);
$optlist = "action={open=" . $action . "}";
PDF_begin_page_ext($p, 595, 842, $optlist);
$font = PDF_load_font($p, "Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_setfont($p, $font, 24);
PDF_fit_textline($p, "Date: ", 125, $lly+5, "position={right bottom}");
/* The tooltip will be used as rollover text for the field */
$optlist =
"tooltip={Date (will be filled automatically)} " .
"bordercolor={gray 0} font=" . $font;
PDF_create_field($p, $llx, $lly, $urx, $ury, "date", "textfield", $optlist);
$lly-=100; $ury-=100;
PDF_fit_textline($p, "Name: ", 125, $lly+5, "position={right bottom}");
$optlist = "tooltip={Enter your name here} " .
"bordercolor={gray 0} font=" . $font;
PDF_create_field($p, $llx, $lly, $urx, $ury, "name", "textfield", $optlist);
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
PDF_delete($p);
print "$outfilename generated";
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_type3font.php 0000644 00000004676 15173135242 0021032 0 ustar 00 <?php
# $Id: starter_type3font.php,v 1.1.2.2 2009/11/18 00:16:12 rjs Exp $
# Type 3 font starter:
# Create a simple Type 3 font from vector data
#
# Define a type 3 font with the glyphs "l" and "space" and output text with
# that font. In addition the glyph ".notdef" is defined which any undefined
# character will be mapped to.
#
# Required software: PDFlib/PDFlib+PDI/PPS 7
# Required data: none
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "Starter Type 3 Font";
# create a new PDFlib object
$p = PDF_new();
PDF_set_parameter($p, "SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.2 $';
PDF_set_info($p, "Title", $buf);
# Create the font "SimpleFont" containing the glyph "l",
# the glyph "space" for spaces and the glyph ".notdef" for any
# undefined character
PDF_begin_font($p, "SimpleFont",
0.001, 0.0, 0.0, 0.001, 0.0, 0.0, "");
PDF_begin_glyph($p, ".notdef", 266, 0, 0, 0, 0);
PDF_end_glyph($p);
PDF_begin_glyph($p, "space", 266, 0, 0, 0, 0);
PDF_end_glyph($p);
PDF_begin_glyph($p, "l", 266, 0, 0, 266, 570);
PDF_setlinewidth($p, 20);
PDF_setdash($p, 0, 0);
$x = 197;
$y = 10;
PDF_moveto($p, $x, $y);
$y += 530;
PDF_lineto($p, $x, $y);
$x -= 64;
PDF_lineto($p, $x, $y);
$y -= 530;
PDF_moveto($p, $x, $y);
$x += 128;
PDF_lineto($p, $x, $y);
PDF_stroke($p);
PDF_end_glyph($p);
PDF_end_font($p);
# Start page
PDF_begin_page_ext($p, 0, 0, "width=300 height=200");
# Load the new "SimpleFont" font
$font = PDF_load_font($p, "SimpleFont", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Output the characters "l" and "space" of the "SimpleFont" font.
# The character "x" is undefined and will be mapped to ".notdef"
$buf = " font=" . $font . " fontsize=40";
PDF_fit_textline($p, "lll lllxlll", 100, 100, $buf);
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
?>
usr/share/doc/alt-pdflib-lite/examples/php/starter_textline.php 0000644 00000016264 15173135243 0020730 0 ustar 00 <?php
# $Id: starter_textline.php,v 1.1.2.1 2007/12/29 23:26:05 rjs Exp $
# Starter text line:
# Demonstrate various options for placing a text line
#
# Place a text line with different font sizes.
# Output overlined, stroke out, and underlined text.
# Output text and define character spacing, work spacing, or horizontal
# scaling.
# Output text with a defined fill color. Output text including its outlines
# with a defined stroke color.
# Place text into a box at various positions. Place text completely into a box
# with automatic scaling if required.
#
# Required software: PDFlib Lite/PDFlib/PDFlib+PDI/PPS 7
# Required data: none
# This is where the data files are. Adjust as necessary.
$searchpath = "../data";
$title = "Starter Text Line";
# create a new PDFlib object
$p = PDF_new();
$x = 10;
$xt = 280;
$y = 800;
$yoff = 50;
$textline = "Giant Wing Paper Plane";
PDF_set_parameter($p, "SearchPath", $searchpath);
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
# Set an output path according to the name of the topic
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "PDFlib Cookbook");
$buf = $title . ' $Revision: 1.1.2.1 $';
PDF_set_info($p, "Title", $buf);
# Start Page
PDF_begin_page_ext($p, 0, 0, "width=a4.width height=a4.height");
# For PDFlib Lite: change "unicode" to "winansi"
$font = PDF_load_font($p, "Helvetica", "winansi", "");
if ($font == 0) {
die("Error: " . PDF_get_errmsg($p));
}
# Set the font with a font size of 14
PDF_setfont($p, $font, 14);
# Place the text line without any options applied
PDF_fit_textline($p, $textline, $x, $y, "");
# Output descriptive text
PDF_fit_textline($p, "fit_textline() without any options", $xt, $y,
"fontsize=12");
# Place the text with a different font size
$optlist = "fontsize=22";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y, "fontsize=12"); # description
# Place stroke out text
$optlist = "strikeout";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y, "fontsize=12"); # description
# Place underlined text
$optlist = "underline underlinewidth=7% underlineposition=-20%";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y, "fontsize=12"); # description
# Place overlined text
$optlist = "overline";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y, "fontsize=12"); # description
# Place the text with a horizontal scaling of 150%
$optlist = "horizscaling=150%";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y, "fontsize=12"); # description
# Place the text with a character spacing of 30% of the font size
$optlist = "charspacing=30%";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y, "fontsize=12"); # description
# Place the text with a word spacing of 50% of the font size
$optlist = "wordspacing=50%";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y, "fontsize=12"); # description
# Place the text with a different fill color
$optlist = "fillcolor={rgb 0.5 0.2 0.5}";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist);
PDF_fit_textline($p, $optlist, $xt, $y, "fontsize=12");
# Place the text including its outlines using a text rendering mode of
# 2 for "filling and stroking text" and different fill and stroke
# colors
$optlist =
"fontsize=22 fillcolor={rgb 0.6 0.3 0.6} strokecolor={gray 0} " .
"strokewidth=0.4 textrendering=2";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist);
# Output descriptive text
PDF_fit_textline($p, "fillcolor={rgb 0.6 0.3 0.6} strokecolor={gray 0} ",
$xt, $y+10, "fontsize=12");
PDF_fit_textline($p, "strokewidth=0.4 textrendering=2 fontsize=22",
$xt, $y-5, "fontsize=12");
# Place the text with its outlines using a text rendering mode of
# 1 for "stroking text" and a stroke color of black
$optlist =
"fontsize=22 strokecolor={gray 0} strokewidth=0.4 textrendering=1";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist);
# Output descriptive text
PDF_fit_textline($p, "strokecolor={gray 0} strokewidth=0.4", $xt, $y+10,
"fontsize=12");
PDF_fit_textline($p, "textrendering=1 fontsize=22", $xt, $y-=5,
"fontsize=12");
# Place the text in a box with default positioning and fitting
$optlist = "boxsize={200 20} showborder";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y+3, "fontsize=12"); # description
# Place the text in a box on the top right
$optlist = "boxsize={200 20} position={top right} showborder";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y+3, "fontsize=12"); # description
# Use "fitmethod=clip" to place the text in a box not large enough to
# show the complete text. The text will be clipped.
$optlist = "boxsize={130 20} fitmethod=clip showborder";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y+3, "fontsize=12"); # description
# Fit the text into the box automatically with "fitmethod=auto".
# In this case, if the text doesn't fit into the box a distortion
# factor is calculated which makes the text fit into the box. If this
# factor is larger than the "shrinklimit" option the text will
# be distorted by that factor. Otherwise, the font size will be
# be decreased until until the text fits into the box.
# Use "fitmethod=auto" to place the text in a box not large enough to
# show the complete text. The text will be distorted.
$optlist = "boxsize={130 20} fitmethod=auto showborder";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y+3, "fontsize=12"); # description
# Use "fitmethod=auto" to place the text in a box too small to show the
# complete text. The font size will be reduced until the text fits into
# the box.
$optlist = "boxsize={100 20} fitmethod=auto showborder";
PDF_fit_textline($p, $textline, $x, $y-=$yoff, $optlist); # sample text
PDF_fit_textline($p, $optlist, $xt, $y+3, "fontsize=12"); # description
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
?>
usr/share/doc/alt-pdflib-lite/examples/php/readme.txt 0000644 00000000561 15173135243 0016606 0 ustar 00 ===================================
Notes on the PDFlib binding for PHP
===================================
This file has been superceded by the PDFlib-in-PHP-HowTo.pdf
document which is contained in all PDFlib for PHP distribution
packages as PDF (in the doc directory).
Or at http://www.pdflib.com/developer-center/technical-documentation/php-howto
on our website.
usr/share/doc/alt-pdflib-lite/examples/php/invoice.php 0000644 00000012305 15173135243 0016754 0 ustar 00 <?php
/* $Id: invoice.php,v 1.23 2006/10/01 20:33:35 rjs Exp $
*
* PDFlib client: invoice example in PHP
*/
$left = 55;
$right = 530;
$fontsize = 12;
$pagewidth = 595;
$pageheight = 842;
$fontsize = 12;
$infile = "stationery.pdf";
$baseopt = "ruler { 30 45 275 375 475} " .
"tabalignment { right left right right right} " .
"hortabmethod ruler fontsize 12 ";
/* This is where font/image/PDF input files live. Adjust as necessary. */
$searchpath = "../data";
$closingtext =
"Terms of payment: <fillcolor={rgb 1 0 0}>30 days net. " .
"<fillcolor={gray 0}>90 days warranty starting at the day of sale. " .
"This warranty covers defects in workmanship only. " .
"<fontname=Helvetica-BoldOblique encoding=host>Kraxi Systems, Inc. " .
"<resetfont>will, at its option, repair or replace the " .
"product under the warranty. This warranty is not transferable. " .
"No returns or exchanges will be accepted for wet products.";
$data = array( array("name"=>"Super Kite", "price"=>20, "quantity"=>2),
array("name"=>"Turbo Flyer", "price"=>40, "quantity"=>5),
array("name"=>"Giga Trasch", "price"=>180, "quantity"=>1),
array("name"=>"Bare Bone Kit", "price"=>50, "quantity"=>3),
array("name"=>"Nitty Gritty", "price"=>20, "quantity"=>10),
array("name"=>"Pretty Dark Flyer","price"=>75, "quantity"=>1),
array("name"=>"Free Gift", "price"=>0, "quantity"=>1)
);
$months = array( "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December");
$p = PDF_new();
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
PDF_set_parameter($p, "SearchPath", $searchpath);
/* open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
/* This line is required to avoid problems on Japanese systems */
PDF_set_parameter($p, "hypertextencoding", "winansi");
PDF_set_info($p, "Creator", "invoice.php");
PDF_set_info($p, "Author", "Thomas Merz");
PDF_set_info($p, "Title", "PDFlib invoice generation demo (PHP)");
$stationery = PDF_open_pdi($p, $infile, "", 0);
if ($stationery == 0) {
die("Error: " . PDF_get_errmsg($p));
}
$page = PDF_open_pdi_page($p, $stationery, 1, "");
if ($page == 0) {
die("Error: " . PDF_get_errmsg($p));
}
$boldfont = PDF_load_font($p, "Helvetica-Bold", "winansi", "");
if ($boldfont == 0) {
die("Error: " . PDF_get_errmsg($p));
}
$regularfont = PDF_load_font($p, "Helvetica", "winansi", "");
if ($regularfont == 0) {
die("Error: " . PDF_get_errmsg($p));
}
$leading = $fontsize + 2;
/* Establish coordinates with the origin in the upper left corner. */
PDF_begin_page_ext($p, $pagewidth, $pageheight, "topdown");
PDF_fit_pdi_page($p, $page, 0, $pageheight, "");
PDF_close_pdi_page($p, $page);
PDF_setfont($p, $regularfont, $fontsize);
/* print the address */
$y = 170;
PDF_set_value($p, "leading", $leading);
PDF_show_xy($p, "John Q. Doe", $left, $y);
PDF_continue_text($p, "255 Customer Lane");
PDF_continue_text($p, "Suite B");
PDF_continue_text($p, "12345 User Town");
PDF_continue_text($p, "Everland");
/* print the header and date */
PDF_setfont($p, $boldfont, $fontsize);
$y = 300;
PDF_show_xy($p, "INVOICE", $left, $y);
$time = localtime();
$buf = sprintf("%s %d, %d", $months[$time[4]], $time[3], $time[5]+1900);
PDF_fit_textline($p, $buf, $right, $y, "position {100 0}");
/* print the invoice header line */
$y = 370;
$buf = sprintf("\tITEM\tDESCRIPTION\tQUANTITY\tPRICE\tAMOUNT");
$optlist = sprintf("%s font %d ", $baseopt, $boldfont);
$textflow = PDF_create_textflow($p, $buf, $optlist);
if ($textflow == 0){
die("Error: " . PDF_get_errmsg($p));
}
PDF_fit_textflow($p, $textflow, $left, $y-$leading, $right, $y, "");
PDF_delete_textflow($p, $textflow);
$y += 2*$leading;
$total = 0;
$optlist = sprintf("%s font %d ", $baseopt, $regularfont);
for ($i = 0; $i < count($data); $i++) {
$sum = $data[$i]{"price"}*$data[$i]{"quantity"};
$buf = sprintf("\t%d\t%s\t%d\t%.2f\t%.2f", $i+1, $data[$i]{"name"},
$data[$i]{"quantity"}, $data[$i]{"price"}, $sum);
$textflow = PDF_create_textflow($p, $buf, $optlist);
if ($textflow == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_fit_textflow($p, $textflow, $left, $y-$leading, $right, $y, "");
PDF_delete_textflow($p, $textflow);
$y += $leading;
$total +=$sum;
}
$y += $leading;
PDF_setfont($p, $boldfont, $fontsize);
PDF_fit_textline($p,sprintf("%.2f",$total), $right, $y, "position {100 0}");
/* Print the closing text */
$y +=5*$leading;
$optlist = "alignment=justify leading=120% ";
$optlist .= "fontname=Helvetica fontsize=12 encoding=winansi";
$textflow = PDF_create_textflow($p, $closingtext, $optlist);
if ($textflow == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_fit_textflow($p, $textflow, $left, $y+6*$leading, $right, $y, "");
PDF_delete_textflow($p, $textflow);
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
PDF_close_pdi($p, $stationery);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
PDF_delete($p);
?>
usr/share/doc/alt-pdflib-lite/PDFlib-Lite-license.pdf 0000644 00000075104 15173135244 0016317 0 ustar 00 %PDF-1.4
%����
33 0 obj
<</Linearized 1/L 31300/O 36/E 20721/N 2/T 30520/H [ 1096 247]>>
endobj
xref
33 40
0000000016 00000 n
0000001343 00000 n
0000001540 00000 n
0000001573 00000 n
0000001771 00000 n
0000001872 00000 n
0000001966 00000 n
0000002754 00000 n
0000003282 00000 n
0000003384 00000 n
0000003731 00000 n
0000008226 00000 n
0000008702 00000 n
0000009081 00000 n
0000009291 00000 n
0000012583 00000 n
0000012926 00000 n
0000013312 00000 n
0000014117 00000 n
0000014869 00000 n
0000015660 00000 n
0000016419 00000 n
0000017177 00000 n
0000017978 00000 n
0000018803 00000 n
0000019334 00000 n
0000019389 00000 n
0000019507 00000 n
0000019587 00000 n
0000019663 00000 n
0000019752 00000 n
0000019854 00000 n
0000019982 00000 n
0000020066 00000 n
0000020158 00000 n
0000020289 00000 n
0000020391 00000 n
0000020496 00000 n
0000020612 00000 n
0000001096 00000 n
trailer
<</Size 73/Root 34 0 R/Info 32 0 R/ID[<34D66F953795F35DA07E09916984C9C8><7BE2BCE69390FC48929BEBCC660238BB>]/Prev 30509>>
startxref
0
%%EOF
72 0 obj
<</E 150/Filter/FlateDecode/I 182/L 166/Length 148/O 134/S 69>>stream
h�b```a``�e`e`�b�c@ >�r�`x���,�V1��S$U )$ �����+�p,��.�;��[,�冎2�X���5��
< v�V^�`[X��4�=�.�X��C� �Ķ@���P����<@� 5j
endstream
endobj
34 0 obj
<</Metadata 31 0 R/Names 35 0 R/OpenAction[36 0 R/Fit]/Outlines 58 0 R/PageLabels 28 0 R/PageMode/UseOutlines/Pages 30 0 R/Type/Catalog/ViewerPreferences<</DisplayDocTitle true>>>>
endobj
35 0 obj
<</Dests 5 0 R>>
endobj
36 0 obj
<</Annots[37 0 R]/Contents[50 0 R 51 0 R 52 0 R 53 0 R 54 0 R 55 0 R 56 0 R 57 0 R]/CropBox[0 0 595 842]/MediaBox[0 0 595.22 842]/Parent 30 0 R/Resources 38 0 R/Rotate 0/Type/Page>>
endobj
37 0 obj
<</Border[0 0 0]/Dest(G2000)/Rect[355.5 695.84 396 712.16]/Subtype/Link/Type/Annot>>
endobj
38 0 obj
<</ExtGState<</GS1 41 0 R>>/Font<</F1 39 0 R/F2 40 0 R>>/ProcSet[/PDF/Text]>>
endobj
39 0 obj
<</BaseFont/AHDLGC+TheSans-Plain/Encoding 42 0 R/FirstChar 32/FontDescriptor 44 0 R/LastChar 187/Subtype/Type1/ToUnicode 45 0 R/Type/Font/Widths[218 280 280 280 280 280 280 280 303 303 280 563 228 330 228 419 613 338 482 461 544 467 582 459 551 582 257 257 280 280 280 280 833 615 570 583 678 280 469 682 698 262 280 280 426 889 707 705 524 280 553 503 516 693 280 952 280 537 280 280 280 280 280 280 280 521 558 435 557 508 350 556 575 260 266 493 260 879 575 545 558 558 355 425 371 575 486 793 518 480 447 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 243 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 509 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 509]>>
endobj
40 0 obj
<</BaseFont/AHDLIC+TheSansBold-Plain/Encoding 46 0 R/FirstChar 32/FontDescriptor 48 0 R/LastChar 121/Subtype/Type1/ToUnicode 49 0 R/Type/Font/Widths[218 280 280 280 280 280 280 280 280 280 280 280 280 334 258 280 280 342 481 458 554 464 581 280 280 280 280 280 280 280 280 280 280 626 580 566 667 493 465 675 280 280 280 280 429 881 280 703 531 280 567 503 280 681 280 951 280 280 280 280 280 280 280 280 280 524 559 425 558 514 354 555 571 266 280 280 266 866 571 553 559 280 355 417 375 570 506 280 528 502]>>
endobj
41 0 obj
<</BG2/Default/OP false/OPM 1/SA false/SM 0.02/Type/ExtGState/UCR2/Default/op false>>
endobj
42 0 obj
<</Differences[32/space 40/parenleft/parenright 43/plus/comma/hyphen/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon 64/at/A/B/C/D 70/F/G/H/I 76/L/M/N/O/P 82/R/S/T/U 87/W 89/Y 97/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z 144/quoteright 171/guillemotleft 187/guillemotright]/Type/Encoding>>
endobj
43 0 obj
<</Filter/FlateDecode/Length 4409/Subtype/Type1C>>stream
h�TW{\Mi�?���f��9읒R�tQI.���TRI�$�\�N�NE)��\K�-��e�1�I��K�)a��ݬ|�)���g���z��]k}�k�M�tudE��3g�p�Z� @�~��ڀ0Uχᒒ��JC��t�
fZ���Cd�2����0�d� ��29E��^檎�l:{CЈ��#MW�zD��Ѧ6S�Nm�!pm���U��M�ժ���HSOUtp�* :L�
X�H�RǪ� DF�G��#30�
ՕY�ecte��)2��L�b"[#���d�$����Yʖɲd��6J�RP��6��(�:%�Ar'�E]s]?ݽ�t:�Fƕ�c.�,;�uc���z��b�}J����}����S�W��̾��~4g���������w��䂸���K�'�lhb��0Ѱu�ɀ�;\Ё����tg�������`���'zQH�xX����]��u/�P���q0�l�]U`�
f�fڇ�W��q�:��"G�,a�0�I�4�B;tP��?�ڠ��8'.-ܙ�B�k� �\*�H��@= ��!�"Y��]~��0��@g�o��^��{�.���%���i�b�+�%�!u
� ˇ��aa��'��O�T���iFa�y,%�]�� ��L�`�VM�d�D]}-���-8@�p ���i��L���Ӆq�<�;:� �������v�$���m�C���������Lw;���SI���;�������Yz������J?�_�]����G��.��/�q��RxIYw&p���ԙ"��&��e���6��UwʥQ���%5��
Z���+�7+�{ף�R?���.G��d��
���9��P)�� �m�T8̟��5;s� �tRQiJ�\�}�A"w �)
/�R��S4��Q����9{�i��_�Bf�S>f��A�i-�y�'ҹ���`�F.M�䡯m+N�
�z������(PB��9S�Ν����eeNJ�S��GҎ*�~A�nh���1�m�j~���Y l�a��O�O�_!�k�d�g��cM�`�<P��z@|�j�n��+1G�9�AϟL w��{���V~�R�)����_�mo�^h#p3%�S��4�o�9�}K32KEGtu��/�+�_���U=�?�Yz�QM�T[Oռ
������
�半k�N�p ~1������~���\�p�²���o����K�C��
��y���*nTT�ח�/�Y~��`G�ʻ�_��w�8x��
��,�{�MT�8��\�[xXa�M�|�0�|������Xږ�购z8$�� ͔q��;��)lJ�Ѵ}JXO�<N�êy�Es�L����웚'/.�["��iDC5=�%+�t�P��S=:�.
�n�g]��]�!�AC�-��x����0��>Soy�q��{�����!�֯�T�_ ˻���<آ.(0�<�8�p�VW���=/Ա�}}�|�8},�a,x��`LLJ(G}�]��keܱ{�Rp�s��\�Dcw3�t,�Ν�W.�3��"�%0-�0VIJ�|bm��L�>�`�ݲ�M��S���KҰ�zɛt�_�P�5��`0�4���
���smi;��c�
I{N��-3�drCw�� ��.�6��UO=o�Էri����Z�d�_��@�a�ma瞖�#|�̦�Ԥ�SB�0|*�\㝽�Q�~c�6N �-*Ӗ*�*]9O܋���>�Q'H���I�xV��������'��������=��xM4�+�8�N��5��^���������wq�%�Y�5�6 ��WEF�4KE�=��V�e@J
[���k����/>Mb�\O�U�:�&>7��H��B�T��\��%H�Y���H�i�F'��O�Z� �&�S.9Ko�&|�ir;܂�L5����R�c��Klں��ys���!j��!�lh�{���a.��B��G�!t� }�@�ᇭ�7HN����<�'�7�c�Q�dk,ǷPn�s�]x�wY������p�����w�d�Ǹ]��}
��l��bdA����ݮ�}5k4~&iL7U���`�43��4UҀܚ�o��5�2���_
C�G�c�Br�w9�"�!Ov�N�|Ǜ�
c<���]m�.�����v�S����-�4�~�&�A�T���P8����R��D�xhZ��O��w��;y�UO��/�Y8��n��w���6#�yt1�:h�:0߿]P>�3��H6��h/)�d �Kx0����.LK[&�d4�M;P��_ c@�ƢU?�k�e����$B�-(�8����o��eJ-
=�V�F{�@��C1�b��@����U ou M�}�S��^p#���x�����|FE�j�6������wW��D.:�t���7���]�<�4�[�w.W���L�/v�йA�ف�:��Q.b8�G+��\c�8�*a�xZS~9�Z 6���O�4nc3a�)R'�ܽ�ww�K����&�^�u�ɥ� ��&�tOcq�B샃�6v��nRH�
ԇ���
�Nr�\�?F�]e���+B�B�V��3I�5��S�K����e|PB@�ʞ/�o���4�x$�i��@�7�<��rµ���A����1���?���r�c�kc�c�7w[�n*�;g
q���AcJ;������C���&Qy�W�_�� ��{h�9os�o�q��}��-E����,z���i7�[Z�\�}�4��ꌐP�v��9,��[QTq��u �:��P�7@t/���v�QF{���Ӝ@�H!MK�<�U~\�6�د�W'�W�?��8&�G���G�Ff�`*�摒m���
m\R3|j�ο�K�|�#zS��&@�:��o��nx_~&a[�����]�3/�"�������{���\iB��� bb��F�_kԥ���lVDdf$i��f��m�{t�½b13�NV������OXnf�z�?`~�fgqIjb��mL���w��=�|l#��+<0ޝd�jG��Htm��1?|�_xYH���m[���&�d���ܯݻ[a}��-L}^U��ʺJ�42�grZՁ]=�:�+����V���Y8D\m�K��6i:u(�e_��{p�Xj�a�+������G�XK�x ed7��ʷͽ�2����_�u������*������O�+z��N�ޑl���<�|�"�5�6��*��+�JX���[1��R����Q@CI�}��V�k�w��qs���p�{?�{�����)+/rwg�R�c�NF��\5�n\#��I�o�|`_�<@f�\UMr�e�?��m6�Tm�Ȃέg-5�n6�_@<� }�69��ȗE]�&r]���ueeEE'�-��R�Mw21ރ9M]i��^��:���O|���j���usb�w�� ����¢�CJ0:_&"��HΧ�\Ra &;S,������%�Hw�0wѽ����}R���{o���VX�"�48eoY�]tu��bO��\���Li��M%�h�$��qń��6�0��y�T�g��_�����?~��.�C�Ϝ�����N��ܽ7�;�gV��+��g:�$Y#U�':�R&�;x���A8��p8��p %X�=%���� �/��Ԁ�a{�'�D�Hfʺ:I������כ6/�]�8�b�b§-m��l?~$�lB;?��_�S��
���{=�$�U�Y���wŰ�K��)#��X�s ����E�ҍH�V`>+e�#�
�,��%�S��xq:I�E+�*�V)����=�]/��=�UU�9O~���q��
O����SW:@ =�/���x��,+�);��)2���J4r�5YDW�\�r����A9yk�T{:��L�%?�m#*�Nl�?�`n,��Ф5�ob��F�D+l9�"B�u(�\�&�ƉD�XΚ��r�t��b��&?63���V#)�Yԙ7e���u4��v���<�]u��@��]��\��H���F%%������DU��S�)�?a�=�c^w2�pP�پ� ����-�B4d�$�M8��D�ol�L���+5�佦|�ŭU����7�gP��bwy�2�v��Z���g�2��p���n�3aL�4z8�8��<� tA-�G3i��P$��hn9�4wM"��T# ����1�BI����/��|c���c�V������ج�1юN-<�J~ju.]��߉ܴ�g���L�����^��"l���;����j��X����,� 4���8�,�]�;;�h�CyϳhHb�n���A����{���Y���m�kJ�e��� ���y����4a����vU�`��nnn�5�o��/�}!�'� ��!
endstream
endobj
44 0 obj
<</Ascent 735/CapHeight 679/CharSet(/space/P/a/g/e/one/o/f/two/D/F/l/i/b/L/t/c/n/s/A/r/m/parenleft/d/p/comma/zero/parenright/G/H/T/four/eight/three/M/u/h/y/plus/nine/slash/six/seven/x/at/period/w/N/colon/hyphen/v/five/guillemotright/guillemotleft/k/O/z/I/q/semicolon/W/B/U/S/R/j/quoteright/C\
/Y)/Descent -260/Flags 4/FontBBox[-62 -433 1757 1170]/FontFile3 43 0 R/FontName/AHDLGC+TheSans-Plain/ItalicAngle 0/StemH 77/StemV 91/Type/FontDescriptor/XHeight 500>>
endobj
45 0 obj
<</Filter/FlateDecode/Length 309>>stream
h�T�OO�0��|�9��P��" !q1&�Y��2 ����a��3�����ɫ���ڌ+�77�W�G�9\��i���@"��z����A�漬8զ��("�N���ΰ{Jn���C7�v��㓄f��'4+�P��a��Y�5!��i��E�~�\�.Vit���K(ڶ4���m������8�%*��gZ��9q�wd�0���G�6�\*f��C�B9T#&�]w�*�L����)ϑXb4�>L�V<�daF�$�Ly�8�&��]�i��9
�?�ϓ�
^����/�` ���
endstream
endobj
46 0 obj
<</Differences[32/space 45/hyphen/period 49/one/two/three/four/five/six 65/A/B/C/D/E/F/G 76/L/M 79/O/P 82/R/S 85/U 87/W 97/a/b/c/d/e/f/g/h/i 108/l/m/n/o/p 114/r/s/t/u/v 120/x/y]/Type/Encoding>>
endobj
47 0 obj
<</Filter/FlateDecode/Length 3206/Subtype/Type1C>>stream
h�lVyT��*)_�j��@�
\�)�(A\PDY�A�@�[@ihAW��+��¢w߸&o�yA�D4z��xf~-o��;3�O���������DAQ�����~>���c�Ei��%'���$)*Ac<'�lg*��
\n�<�3��G+�,�,a�H�䴝�OV
%E-X드���)!=�>`s̄�����b�nJNN��t�L��)�����c��Gg�&kҗ�'��i�c7i���5QI+44ə��FA����V�b��B)�Q
WJ�P�P(�)M�L��b*��0U�
;��b��eA�P�&f&&�Jke�r��Ô3�hZb�C{�et/���dAl%����,o��a���hΙ��6k�d�e�a10|������'@D?u��p"�~,rb9Lׂ�J�a2������ں�)\�о����0J �*�r�S�k��Ӄv,WT4|
��A)/Vͺy�X!���~�����7�ۨ�_���V<�
���C�k'�"�b�̑&xҎ,���@A�+zGA
����y���;���Ή֮���=B)d�n��ʞ>X�R�,�hHZ�x�$'���G3S��i|byE��ES:�D�z��� +�{X,7�J)7��u��Н�݃�ji�C�G �'M,�GJ0����"�h�z6� u��;�<�*�Oq��,l,���yP�Ք���Z�h�Uɩ�e�R.��#G�'��7�(q��`��xPP�� (���A��YHz�F,2�V��)�m����{0L����J$ц�TC���8�b�2�����58H(|�/\��w~µ�]MW�i��+r0����Ⱦ�� ��3���A�(�D*�v�YP���̭n�l�h�50�{��̸^�;��A�����`�ט��R%��#��A1���p�.?��=������N�F>h��2��
�"�g
��� ߟL�*���<2�}㦒r���)�#�\M����f�YpTʵ�|�����s����{��Q7�������`NWE��&`��$LD�o�S�Qu��A�P�1D�F�^9`�<���ΘY�?Lg�Wo� &�%�Hh������SSJJ�D9�-�=n %�zu::I\e1(���
���T�D���w����jP���� �8���Ѓ>�ML���� 4�Q�XV�`�MX7�qy�`, دj��[q,:c<F�5ZA�ӿ�;vO�'��\6/5y�G{�@T����usk��R�|-s�Z0�,_C���X\3�H��j�Q��a���X�J[=��#�-�i�Ɍ�Q66�Y�]�]~e�u��bŁ�.�wm�g��/�Tv�@���
��߁Ol8HՒ:F�0�H�D@�A�h
\�~8���qD�̍�D�H�ݧ,tE�e/�:���ݞI��]"�Ld��XMo����Dl�}�����
������_\%���70��$���<bv����P�U�ͬa߾�͑%���F�<r.�V�Q�;d~qx��-Gl���اѹ'z��p���%x�ΔS�����,�a�+ْ�C�C�-K\�h9�x�Dp2Z(byX�M�`��8[���|�Y��<&�,V@��3p�����yu���+*�c�<����;�w0��&��%?�X_h ^)���O���"5M�����T
��w�i<��?B��� C
��U�ˠ�.&/*�mSЮm�59�6(2c-s#����?�i/���lPb`�Q�L�lQ�Zq���4�����A3pc��^x�Gl�L#�5*����5İ���n��[�B�J{��}���#)+���<