PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




cpdf_set_text_matrix

Name

cpdf_set_text_matrix — Sets the text matrix

Synopsis

bool cpdf_set_text_matrix(pdfdoc, matrix);
resource pdfdoc: PDF document identifier
arry matrix: Matrix transformations

Returns

TRUE on success or FALSE on error

Description

This is a slightly more low-level version of other the transformation functions including cpdf_scale() , cpdf_rotate() , and cpdf_translate() . The exception however, is that the transformation matrix is reset each time rather than remainiing and affecting other objects.

When applying several transformations, it is always a good idea to specify them in the correct order so the results are more predictable. The best way to do multiple translations is to first translate, then rotate and finaly scale and skew.

In cpdf_set_text_matrix() , the transformation matrix is specified by an array of six elements, combinations of which affect the amount of translation that occurs. Different pairs of numbers cause each trnasformation. Translations are specified as

translate 1, 0, 0, 1, tx, ty tx and ty specify the translation in the x and y axes
scale sx, 0, 0, sy, 0, 0 sx and sy specify the scaling in the x and y directions
rotate cosa, sina, -sina, cosa, 0, 0 Rotate the coordinate system by an angle a counterclockwise
skew 1, tana, tanb, 1, 0, 0 Skews the x axis by an angle a and the y axis by angle b


Version

Since versions 3.0.8 and 4.0

Example

Example 160. Set different text transformations

// start a PDF document
$cpdf = cpdf_open(0, "test.pdf");

// create a 600x400 page
cpdf_page_init($cpdf, 1, 0, 600, 400, 1);

cpdf_begin_text($cpdf);
cpdf_set_font($cpdf, "Helvetica", 15, "WinAnsiEncoding");

// display as normal
cpdf_text($cpdf, "Norm", 10, 10);

// translate
cpdf_set_text_matrix($cpdf, array(1, 0, 0, 1, 100, 100));
cpdf_text($cpdf, "trans", 10, 10);

// rotate
cpdf_set_text_matrix($cpdf, array(0.7, 0.7, -0.7, 0.7, 0, 0));
cpdf_text($cpdf, "roatte", 10, 10);

// scale
cpdf_set_text_matrix($cpdf, array(2, 0, 0, 2, 0, 0));
cpdf_text($cpdf, "scale", 10, 10);

// skew
cpdf_set_text_matrix($cpdf, array(1, 0.58, 0.58, 1, 0, 0));
cpdf_text($cpdf, "skew", 10, 10);

cpdf_end_text($cpdf);

// close and write document
cpdf_finalize($cpdf);
cpdf_close($cpdf);



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.